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
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-04-24 10:22:11 +0300
committerJacques Lucke <mail@jlucke.com>2019-04-24 10:22:11 +0300
commit81b9187dda14bcca848945cad198c2d297ae0c18 (patch)
treedd96eb1bb9e017c29039aaa822a511c27913b4a6 /source/blender
parent844745da773b3c9924a18ab5dad8c9f453bf6598 (diff)
parentd7672ad0f7f4f4bcf3cb13c72ff19425f3be9709 (diff)
Merge branch 'master' into functions
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc9
-rw-r--r--source/blender/alembic/intern/abc_object.cc20
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc3
-rw-r--r--source/blender/avi/AVI_avi.h12
-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/blenfont/BLF_api.h4
-rw-r--r--source/blender/blenfont/CMakeLists.txt4
-rw-r--r--source/blender/blenfont/intern/blf.c48
-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_action.h6
-rw-r--r--source/blender/blenkernel/BKE_armature.h15
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_collection.h3
-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_main.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh.h23
-rw-r--r--source/blender/blenkernel/BKE_node.h6
-rw-r--r--source/blender/blenkernel/BKE_pbvh.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_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.c102
-rw-r--r--source/blender/blenkernel/intern/action.c212
-rw-r--r--source/blender/blenkernel/intern/anim.c96
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c236
-rw-r--r--source/blender/blenkernel/intern/appdir.c108
-rw-r--r--source/blender/blenkernel/intern/armature.c407
-rw-r--r--source/blender/blenkernel/intern/armature_update.c46
-rw-r--r--source/blender/blenkernel/intern/blender.c3
-rw-r--r--source/blender/blenkernel/intern/blendfile.c33
-rw-r--r--source/blender/blenkernel/intern/boids.c106
-rw-r--r--source/blender/blenkernel/intern/bpath.c15
-rw-r--r--source/blender/blenkernel/intern/brush.c54
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c21
-rw-r--r--source/blender/blenkernel/intern/camera.c54
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c88
-rw-r--r--source/blender/blenkernel/intern/cloth.c121
-rw-r--r--source/blender/blenkernel/intern/collection.c6
-rw-r--r--source/blender/blenkernel/intern/collision.c45
-rw-r--r--source/blender/blenkernel/intern/colorband.c72
-rw-r--r--source/blender/blenkernel/intern/colortools.c237
-rw-r--r--source/blender/blenkernel/intern/constraint.c419
-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.c594
-rw-r--r--source/blender/blenkernel/intern/customdata.c540
-rw-r--r--source/blender/blenkernel/intern/customdata_file.c78
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c3
-rw-r--r--source/blender/blenkernel/intern/deform.c45
-rw-r--r--source/blender/blenkernel/intern/displist.c216
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c607
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c6
-rw-r--r--source/blender/blenkernel/intern/editmesh.c15
-rw-r--r--source/blender/blenkernel/intern/editmesh_bvh.c12
-rw-r--r--source/blender/blenkernel/intern/editmesh_tangent.c12
-rw-r--r--source/blender/blenkernel/intern/effect.c57
-rw-r--r--source/blender/blenkernel/intern/fcurve.c321
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c210
-rw-r--r--source/blender/blenkernel/intern/font.c69
-rw-r--r--source/blender/blenkernel/intern/freestyle.c18
-rw-r--r--source/blender/blenkernel/intern/gpencil.c117
-rw-r--r--source/blender/blenkernel/intern/gpencil_modifier.c21
-rw-r--r--source/blender/blenkernel/intern/icons.c27
-rw-r--r--source/blender/blenkernel/intern/idcode.c6
-rw-r--r--source/blender/blenkernel/intern/idprop.c60
-rw-r--r--source/blender/blenkernel/intern/image.c759
-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.c297
-rw-r--r--source/blender/blenkernel/intern/key.c231
-rw-r--r--source/blender/blenkernel/intern/lattice.c165
-rw-r--r--source/blender/blenkernel/intern/layer.c3
-rw-r--r--source/blender/blenkernel/intern/library.c131
-rw-r--r--source/blender/blenkernel/intern/library_override.c18
-rw-r--r--source/blender/blenkernel/intern/library_query.c9
-rw-r--r--source/blender/blenkernel/intern/library_remap.c21
-rw-r--r--source/blender/blenkernel/intern/light.c3
-rw-r--r--source/blender/blenkernel/intern/linestyle.c54
-rw-r--r--source/blender/blenkernel/intern/main.c6
-rw-r--r--source/blender/blenkernel/intern/mask.c48
-rw-r--r--source/blender/blenkernel/intern/mask_evaluate.c54
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c15
-rw-r--r--source/blender/blenkernel/intern/material.c234
-rw-r--r--source/blender/blenkernel/intern/mball.c6
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c195
-rw-r--r--source/blender/blenkernel/intern/mesh.c165
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c60
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c57
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.c27
-rw-r--r--source/blender/blenkernel/intern/mesh_merge.c6
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c15
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c12
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c30
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c69
-rw-r--r--source/blender/blenkernel/intern/modifier.c111
-rw-r--r--source/blender/blenkernel/intern/movieclip.c159
-rw-r--r--source/blender/blenkernel/intern/multires.c279
-rw-r--r--source/blender/blenkernel/intern/nla.c351
-rw-r--r--source/blender/blenkernel/intern/node.c485
-rw-r--r--source/blender/blenkernel/intern/object.c236
-rw-r--r--source/blender/blenkernel/intern/object_deform.c24
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c117
-rw-r--r--source/blender/blenkernel/intern/object_facemap.c30
-rw-r--r--source/blender/blenkernel/intern/object_update.c9
-rw-r--r--source/blender/blenkernel/intern/ocean.c105
-rw-r--r--source/blender/blenkernel/intern/packedFile.c60
-rw-r--r--source/blender/blenkernel/intern/paint.c128
-rw-r--r--source/blender/blenkernel/intern/particle.c663
-rw-r--r--source/blender/blenkernel/intern/particle_child.c51
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c171
-rw-r--r--source/blender/blenkernel/intern/particle_system.c626
-rw-r--r--source/blender/blenkernel/intern/pbvh.c359
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c57
-rw-r--r--source/blender/blenkernel/intern/pbvh_intern.h1
-rw-r--r--source/blender/blenkernel/intern/pointcache.c599
-rw-r--r--source/blender/blenkernel/intern/report.c51
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c171
-rw-r--r--source/blender/blenkernel/intern/scene.c126
-rw-r--r--source/blender/blenkernel/intern/screen.c89
-rw-r--r--source/blender/blenkernel/intern/seqcache.c33
-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.c453
-rw-r--r--source/blender/blenkernel/intern/shader_fx.c21
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c39
-rw-r--r--source/blender/blenkernel/intern/smoke.c345
-rw-r--r--source/blender/blenkernel/intern/softbody.c231
-rw-r--r--source/blender/blenkernel/intern/sound.c119
-rw-r--r--source/blender/blenkernel/intern/studiolight.c55
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.c12
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c169
-rw-r--r--source/blender/blenkernel/intern/suggestions.c18
-rw-r--r--source/blender/blenkernel/intern/text.c429
-rw-r--r--source/blender/blenkernel/intern/texture.c58
-rw-r--r--source/blender/blenkernel/intern/tracking.c312
-rw-r--r--source/blender/blenkernel/intern/tracking_detect.c9
-rw-r--r--source/blender/blenkernel/intern/tracking_region_tracker.c21
-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/unit.c100
-rw-r--r--source/blender/blenkernel/intern/world.c3
-rw-r--r--source/blender/blenkernel/intern/writeavi.c15
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c90
-rw-r--r--source/blender/blenlib/BLI_astar.h6
-rw-r--r--source/blender/blenlib/BLI_dlrbTree.h17
-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_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_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.c9
-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.c15
-rw-r--r--source/blender/blenlib/intern/freetypefont.c35
-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.c31
-rw-r--r--source/blender/blenlib/intern/math_interp.c12
-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/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/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/intern/blend_validate.c14
-rw-r--r--source/blender/blenloader/intern/readblenentry.c39
-rw-r--r--source/blender/blenloader/intern/readfile.c1027
-rw-r--r--source/blender/blenloader/intern/readfile.h2
-rw-r--r--source/blender/blenloader/intern/undofile.c12
-rw-r--r--source/blender/blenloader/intern/versioning_250.c350
-rw-r--r--source/blender/blenloader/intern/versioning_260.c310
-rw-r--r--source/blender/blenloader/intern/versioning_270.c66
-rw-r--r--source/blender/blenloader/intern/versioning_280.c196
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c66
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c306
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c115
-rw-r--r--source/blender/blenloader/intern/writefile.c24
-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/intern/bmesh_core.c8
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_log.c8
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_query.c3
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c3
-rw-r--r--source/blender/bmesh/operators/bmo_fill_grid.c6
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c8
-rw-r--r--source/blender/bmesh/operators/bmo_planar_faces.c6
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c24
-rw-r--r--source/blender/bmesh/operators/bmo_rotate_edges.c6
-rw-r--r--source/blender/bmesh/operators/bmo_smooth_laplacian.c6
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c12
-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_bevel.c27
-rw-r--r--source/blender/bmesh/tools/bmesh_bisect_plane.c3
-rw-r--r--source/blender/bmesh/tools/bmesh_region_match.c3
-rw-r--r--source/blender/collada/CMakeLists.txt2
-rw-r--r--source/blender/compositor/CMakeLists.txt4
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp6
-rw-r--r--source/blender/compositor/intern/COM_Debug.cpp27
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp9
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h24
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp12
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.cpp30
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp9
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h3
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.cpp108
-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.cpp9
-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.h5
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.cpp6
-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_BlurBaseOperation.cpp3
-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.cpp3
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp30
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp63
-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.cpp6
-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.cpp9
-rw-r--r--source/blender/compositor/operations/COM_OpenCLKernels.cl16
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp30
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp35
-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.cpp27
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp6
-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.cpp105
-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.cpp12
-rw-r--r--source/blender/datatoc/datatoc.c3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cycle.cc14
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc62
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc12
-rw-r--r--source/blender/depsgraph/intern/depsgraph_debug.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc45
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.cc11
-rw-r--r--source/blender/draw/CMakeLists.txt2
-rw-r--r--source/blender/draw/DRW_engine.h6
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c97
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl6
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c75
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_utils.c112
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h4
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_render.c10
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl42
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl12
-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/workbench_deferred.c52
-rw-r--r--source/blender/draw/engines/workbench/workbench_forward.c50
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c45
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h34
-rw-r--r--source/blender/draw/intern/draw_armature.c15
-rw-r--r--source/blender/draw/intern/draw_cache.c75
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h5
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c68
-rw-r--r--source/blender/draw/intern/draw_manager.c171
-rw-r--r--source/blender/draw/intern/draw_manager.h21
-rw-r--r--source/blender/draw/intern/draw_manager_data.c40
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c21
-rw-r--r--source/blender/draw/modes/object_mode.c21
-rw-r--r--source/blender/draw/modes/sculpt_mode.c9
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl15
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl3
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl26
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl3
-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.c321
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c346
-rw-r--r--source/blender/editors/animation/anim_deps.c54
-rw-r--r--source/blender/editors/animation/anim_draw.c57
-rw-r--r--source/blender/editors/animation/anim_filter.c420
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c67
-rw-r--r--source/blender/editors/animation/anim_markers.c101
-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.c96
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c63
-rw-r--r--source/blender/editors/animation/keyframes_draw.c84
-rw-r--r--source/blender/editors/animation/keyframes_edit.c251
-rw-r--r--source/blender/editors/animation/keyframes_general.c129
-rw-r--r--source/blender/editors/animation/keyframing.c262
-rw-r--r--source/blender/editors/animation/keyingsets.c145
-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.h7
-rw-r--r--source/blender/editors/armature/armature_naming.c38
-rw-r--r--source/blender/editors/armature/armature_ops.c5
-rw-r--r--source/blender/editors/armature/armature_relations.c55
-rw-r--r--source/blender/editors/armature/armature_select.c84
-rw-r--r--source/blender/editors/armature/armature_skinning.c44
-rw-r--r--source/blender/editors/armature/armature_utils.c91
-rw-r--r--source/blender/editors/armature/meshlaplacian.c312
-rw-r--r--source/blender/editors/armature/pose_edit.c45
-rw-r--r--source/blender/editors/armature/pose_group.c60
-rw-r--r--source/blender/editors/armature/pose_lib.c183
-rw-r--r--source/blender/editors/armature/pose_select.c81
-rw-r--r--source/blender/editors/armature/pose_slide.c69
-rw-r--r--source/blender/editors/armature/pose_transform.c167
-rw-r--r--source/blender/editors/armature/pose_utils.c61
-rw-r--r--source/blender/editors/curve/CMakeLists.txt2
-rw-r--r--source/blender/editors/curve/editcurve.c17
-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.c6
-rw-r--r--source/blender/editors/gpencil/CMakeLists.txt4
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c93
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c164
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c39
-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.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c51
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c67
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c142
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c184
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c15
-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_paint.c158
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c48
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c36
-rw-r--r--source/blender/editors/gpencil/gpencil_undo.c3
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c138
-rw-r--r--source/blender/editors/include/BIF_glutil.h106
-rw-r--r--source/blender/editors/include/ED_armature.h7
-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_space_api.h1
-rw-r--r--source/blender/editors/include/ED_view3d.h2
-rw-r--r--source/blender/editors/include/UI_interface.h11
-rw-r--r--source/blender/editors/include/UI_resources.h6
-rw-r--r--source/blender/editors/include/UI_view2d.h10
-rw-r--r--source/blender/editors/interface/CMakeLists.txt2
-rw-r--r--source/blender/editors/interface/interface.c36
-rw-r--r--source/blender/editors/interface/interface_context_menu.c2
-rw-r--r--source/blender/editors/interface/interface_draw.c14
-rw-r--r--source/blender/editors/interface/interface_handlers.c19
-rw-r--r--source/blender/editors/interface/interface_intern.h9
-rw-r--r--source/blender/editors/interface/interface_layout.c133
-rw-r--r--source/blender/editors/interface/interface_panel.c2
-rw-r--r--source/blender/editors/interface/interface_query.c122
-rw-r--r--source/blender/editors/interface/interface_region_hud.c7
-rw-r--r--source/blender/editors/interface/interface_region_menu_popup.c2
-rw-r--r--source/blender/editors/interface/interface_region_popover.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c7
-rw-r--r--source/blender/editors/interface/view2d.c61
-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_collada.c12
-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/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.c3
-rw-r--r--source/blender/editors/mask/mask_editaction.c60
-rw-r--r--source/blender/editors/mask/mask_ops.c102
-rw-r--r--source/blender/editors/mask/mask_select.c24
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt4
-rw-r--r--source/blender/editors/mesh/editface.c33
-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.c27
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_screw.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.c145
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c12
-rw-r--r--source/blender/editors/mesh/editmesh_path.c42
-rw-r--r--source/blender/editors/mesh/editmesh_preselect_edgering.c3
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c38
-rw-r--r--source/blender/editors/mesh/editmesh_rip_edge.c3
-rw-r--r--source/blender/editors/mesh/editmesh_select.c66
-rw-r--r--source/blender/editors/mesh/editmesh_select_similar.c12
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c169
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c10
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c60
-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/meshtools.c105
-rw-r--r--source/blender/editors/object/CMakeLists.txt6
-rw-r--r--source/blender/editors/object/object_add.c129
-rw-r--r--source/blender/editors/object/object_bake.c36
-rw-r--r--source/blender/editors/object/object_bake_api.c93
-rw-r--r--source/blender/editors/object/object_collection.c66
-rw-r--r--source/blender/editors/object/object_constraint.c272
-rw-r--r--source/blender/editors/object/object_edit.c42
-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.c78
-rw-r--r--source/blender/editors/object/object_modes.c45
-rw-r--r--source/blender/editors/object/object_modifier.c255
-rw-r--r--source/blender/editors/object/object_relations.c189
-rw-r--r--source/blender/editors/object/object_select.c36
-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.c136
-rw-r--r--source/blender/editors/object/object_vgroup.c167
-rw-r--r--source/blender/editors/physics/CMakeLists.txt2
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c33
-rw-r--r--source/blender/editors/physics/particle_boids.c36
-rw-r--r--source/blender/editors/physics/particle_edit.c522
-rw-r--r--source/blender/editors/physics/particle_object.c154
-rw-r--r--source/blender/editors/physics/physics_fluid.c92
-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.c148
-rw-r--r--source/blender/editors/render/render_opengl.c54
-rw-r--r--source/blender/editors/render/render_preview.c129
-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.c261
-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.c156
-rw-r--r--source/blender/editors/screen/screen_draw.c6
-rw-r--r--source/blender/editors/screen/screen_edit.c159
-rw-r--r--source/blender/editors/screen/screen_geometry.c99
-rw-r--r--source/blender/editors/screen/screen_intern.h3
-rw-r--r--source/blender/editors/screen/screen_ops.c600
-rw-r--r--source/blender/editors/screen/screendump.c18
-rw-r--r--source/blender/editors/screen/workspace_edit.c6
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt2
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c106
-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.c96
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c225
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c318
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c52
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c51
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c102
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c42
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c107
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.c11
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c323
-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.c43
-rw-r--r--source/blender/editors/sound/sound_ops.c81
-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.c135
-rw-r--r--source/blender/editors/space_action/action_intern.h3
-rw-r--r--source/blender/editors/space_action/action_ops.c9
-rw-r--r--source/blender/editors/space_action/action_select.c146
-rw-r--r--source/blender/editors/space_action/space_action.c74
-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_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.c6
-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.c94
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c6
-rw-r--r--source/blender/editors/space_clip/tracking_ops_orient.c16
-rw-r--r--source/blender/editors/space_clip/tracking_ops_solve.c3
-rw-r--r--source/blender/editors/space_clip/tracking_select.c45
-rw-r--r--source/blender/editors/space_console/CMakeLists.txt2
-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.c107
-rw-r--r--source/blender/editors/space_file/filelist.c179
-rw-r--r--source/blender/editors/space_file/filesel.c88
-rw-r--r--source/blender/editors/space_file/fsmenu.c34
-rw-r--r--source/blender/editors/space_file/space_file.c12
-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.c65
-rw-r--r--source/blender/editors/space_graph/graph_edit.c321
-rw-r--r--source/blender/editors/space_graph/graph_intern.h5
-rw-r--r--source/blender/editors/space_graph/graph_ops.c45
-rw-r--r--source/blender/editors/space_graph/graph_select.c186
-rw-r--r--source/blender/editors/space_graph/graph_utils.c68
-rw-r--r--source/blender/editors/space_graph/space_graph.c67
-rw-r--r--source/blender/editors/space_image/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_image/image_buttons.c194
-rw-r--r--source/blender/editors/space_image/image_draw.c2
-rw-r--r--source/blender/editors/space_image/image_intern.h4
-rw-r--r--source/blender/editors/space_image/image_ops.c578
-rw-r--r--source/blender/editors/space_image/space_image.c84
-rw-r--r--source/blender/editors/space_info/CMakeLists.txt6
-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.c78
-rw-r--r--source/blender/editors/space_nla/nla_channels.c87
-rw-r--r--source/blender/editors/space_nla/nla_draw.c30
-rw-r--r--source/blender/editors/space_nla/nla_edit.c182
-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.c85
-rw-r--r--source/blender/editors/space_nla/space_nla.c52
-rw-r--r--source/blender/editors/space_node/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_node/drawnode.c13
-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_edit.c3
-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_toolbar.c34
-rw-r--r--source/blender/editors/space_node/space_node.c58
-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.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c5
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c12
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c12
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c9
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c14
-rw-r--r--source/blender/editors/space_script/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_script/space_script.c5
-rw-r--r--source/blender/editors/space_sequencer/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c27
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c11
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c8
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c3
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c28
-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.c14
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c70
-rw-r--r--source/blender/editors/space_text/text_draw.c186
-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.c32
-rw-r--r--source/blender/editors/space_text/text_intern.h2
-rw-r--r--source/blender/editors/space_text/text_ops.c307
-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.c123
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c33
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c44
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_armature.c16
-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.c8
-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.c4
-rw-r--r--source/blender/editors/transform/CMakeLists.txt4
-rw-r--r--source/blender/editors/transform/transform.c711
-rw-r--r--source/blender/editors/transform/transform_constraints.c69
-rw-r--r--source/blender/editors/transform/transform_conversions.c939
-rw-r--r--source/blender/editors/transform/transform_generics.c195
-rw-r--r--source/blender/editors/transform/transform_gizmo_2d.c6
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c36
-rw-r--r--source/blender/editors/transform/transform_input.c6
-rw-r--r--source/blender/editors/transform/transform_ops.c6
-rw-r--r--source/blender/editors/transform/transform_orientations.c30
-rw-r--r--source/blender/editors/transform/transform_snap.c90
-rw-r--r--source/blender/editors/transform/transform_snap_object.c3
-rw-r--r--source/blender/editors/undo/CMakeLists.txt2
-rw-r--r--source/blender/editors/undo/ed_undo.c6
-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.c18
-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.c9
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c18
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c293
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c450
-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/python/StrokeShader/BPy_IncreasingColorShader.cpp20
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp20
-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_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_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_buffers.h3
-rw-r--r--source/blender/gpu/GPU_immediate.h7
-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.c74
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c294
-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.c42
-rw-r--r--source/blender/gpu/intern/gpu_immediate.c7
-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_select.c9
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c3
-rw-r--r--source/blender/gpu/intern/gpu_shader.c122
-rw-r--r--source/blender/gpu/intern/gpu_texture.c106
-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.glsl3
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h3
-rw-r--r--source/blender/imbuf/IMB_imbuf.h6
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h2
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c119
-rw-r--r--source/blender/imbuf/intern/anim_movie.c75
-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.cpp3
-rw-r--r--source/blender/imbuf/intern/dds/Color.h17
-rw-r--r--source/blender/imbuf/intern/dds/ColorBlock.cpp18
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp171
-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.h2
-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.c99
-rw-r--r--source/blender/imbuf/intern/imageprocess.c39
-rw-r--r--source/blender/imbuf/intern/indexer.c16
-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.c24
-rw-r--r--source/blender/imbuf/intern/moviecache.c54
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.cpp38
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp299
-rw-r--r--source/blender/imbuf/intern/png.c56
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c48
-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.c12
-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.h29
-rw-r--r--source/blender/makesdna/DNA_anim_types.h4
-rw-r--r--source/blender/makesdna/DNA_armature_types.h7
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h7
-rw-r--r--source/blender/makesdna/DNA_material_types.h10
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h3
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h19
-rw-r--r--source/blender/makesdna/DNA_node_types.h21
-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.h9
-rw-r--r--source/blender/makesdna/DNA_screen_types.h16
-rw-r--r--source/blender/makesdna/DNA_space_types.h42
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h10
-rw-r--r--source/blender/makesdna/DNA_vec_types.h9
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h4
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h6
-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.c5
-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.h7
-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.c921
-rw-r--r--source/blender/makesrna/intern/rna_ID.c6
-rw-r--r--source/blender/makesrna/intern/rna_access.c1031
-rw-r--r--source/blender/makesrna/intern/rna_action.c18
-rw-r--r--source/blender/makesrna/intern/rna_animation.c38
-rw-r--r--source/blender/makesrna/intern/rna_animviz.c13
-rw-r--r--source/blender/makesrna/intern/rna_armature.c109
-rw-r--r--source/blender/makesrna/intern/rna_brush.c3
-rw-r--r--source/blender/makesrna/intern/rna_collection.c11
-rw-r--r--source/blender/makesrna/intern/rna_color.c8
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c3
-rw-r--r--source/blender/makesrna/intern/rna_curve.c3
-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.c5
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c19
-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.c3
-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_material.c21
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c17
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c4
-rw-r--r--source/blender/makesrna/intern/rna_nla.c33
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c51
-rw-r--r--source/blender/makesrna/intern/rna_object.c23
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c6
-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.c9
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c24
-rw-r--r--source/blender/makesrna/intern/rna_rna.c86
-rw-r--r--source/blender/makesrna/intern/rna_scene.c247
-rw-r--r--source/blender/makesrna/intern/rna_screen.c6
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c3
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c12
-rw-r--r--source/blender/makesrna/intern/rna_shader_fx.c3
-rw-r--r--source/blender/makesrna/intern/rna_space.c284
-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.c8
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c19
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c70
-rw-r--r--source/blender/makesrna/intern/rna_wm.c6
-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.txt8
-rw-r--r--source/blender/modifiers/intern/MOD_array.c18
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c18
-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_displace.c6
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c3
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c15
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c3
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c9
-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_mirror.c15
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c3
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c57
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c12
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c21
-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.c180
-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.c21
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c12
-rw-r--r--source/blender/modifiers/intern/MOD_util.c12
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c18
-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_weightvg_util.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c30
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c39
-rw-r--r--source/blender/nodes/CMakeLists.txt2
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c129
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bilateralblur.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_cryptomatte.c3
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c33
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_moviedistortion.c12
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_outputFile.c24
-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.c24
-rw-r--r--source/blender/nodes/intern/node_common.c90
-rw-r--r--source/blender/nodes/intern/node_exec.c63
-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.c36
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c27
-rw-r--r--source/blender/nodes/shader/node_shader_util.c63
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.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_principled.c6
-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.c21
-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.c121
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c15
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_script.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c9
-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.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectTransform.c18
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c58
-rw-r--r--source/blender/nodes/texture/node_texture_util.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_common.c9
-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.c9
-rw-r--r--source/blender/physics/CMakeLists.txt2
-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.c12
-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/gpu/CMakeLists.txt2
-rw-r--r--source/blender/python/intern/bpy.c38
-rw-r--r--source/blender/python/intern/bpy_interface.c32
-rw-r--r--source/blender/python/intern/bpy_operator.c4
-rw-r--r--source/blender/python/intern/bpy_rna.c11
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c1
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.c29
-rw-r--r--source/blender/python/intern/stubs.c1
-rw-r--r--source/blender/python/mathutils/CMakeLists.txt2
-rw-r--r--source/blender/python/mathutils/mathutils.h4
-rw-r--r--source/blender/render/CMakeLists.txt6
-rw-r--r--source/blender/render/extern/include/RE_pipeline.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.c345
-rw-r--r--source/blender/render/intern/source/initrender.c60
-rw-r--r--source/blender/render/intern/source/multires_bake.c78
-rw-r--r--source/blender/render/intern/source/pipeline.c218
-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.c203
-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.h3
-rw-r--r--source/blender/windowmanager/WM_types.h6
-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.c19
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c468
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c124
-rw-r--r--source/blender/windowmanager/intern/wm_files.c58
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c30
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c3
-rw-r--r--source/blender/windowmanager/intern/wm_gesture_ops.c14
-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.c51
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c8
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c47
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c3
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c6
-rw-r--r--source/blender/windowmanager/intern/wm_window.c15
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c5
-rw-r--r--source/blender/windowmanager/wm_event_types.h3
983 files changed, 38569 insertions, 22558 deletions
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..36daa50e095 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
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 0bc4eb2385b..aac7a7f2d82 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -787,8 +787,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);
}
diff --git a/source/blender/avi/AVI_avi.h b/source/blender/avi/AVI_avi.h
index 86f0189343e..7b7f58506da 100644
--- a/source/blender/avi/AVI_avi.h
+++ b/source/blender/avi/AVI_avi.h
@@ -153,10 +153,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/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index bf5ecd24269..60b27ead968 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -198,8 +198,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..d16a4d7ed4d 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;
}
@@ -378,26 +383,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 +565,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..2b34b1f8324 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_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_armature.h b/source/blender/blenkernel/BKE_armature.h
index 50457c5b3f0..267617e154f 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -207,8 +207,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 +335,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..2433b856697 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 58
/** Several breakages with 280, e.g. collections vs layers. */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0
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_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_main.h b/source/blender/blenkernel/BKE_main.h
index 84ff46aa5d0..b8721f61371 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -170,9 +170,8 @@ struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset);
#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..d4ad0e771d3 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -325,22 +325,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
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 48b58562dd7..682d0b981fa 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -491,7 +491,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,
@@ -1144,8 +1145,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 +1219,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_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 049fc585b56..6df6d36aceb 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);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 14a0071f9b3..7323457a6aa 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -24,32 +24,33 @@ set(INC
../blenlib
../blenloader
../blentranslation
+ ../bmesh
../depsgraph
../draw
../functions
+ ../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
@@ -121,6 +122,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
@@ -275,6 +277,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
@@ -520,9 +523,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_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..e70fcfe75c1 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;
}
@@ -756,24 +761,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 +822,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 +861,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 +904,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 +948,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 +967,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 +978,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 +988,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 +1012,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");
@@ -1184,8 +1201,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 +1245,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 +1316,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) {
@@ -1456,8 +1480,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 +1491,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 +1511,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) {
@@ -1687,11 +1714,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 */
@@ -2052,8 +2081,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 +2411,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,10 +2425,12 @@ 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. */
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index a3b7df6b020..8e9158b8433 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -177,8 +177,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 +192,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 +244,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 +271,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 +291,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
@@ -320,8 +327,9 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
* 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 +340,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 +354,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 +381,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 +395,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 +413,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 +436,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 +458,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 +510,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;
@@ -657,15 +678,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 +708,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 +766,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 +821,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 +861,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 +884,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 +996,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 +1029,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 +1065,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 +1112,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 +1156,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 +1218,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 +1241,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 +1265,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...
@@ -1229,12 +1288,14 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
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 ((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 +1318,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 +1330,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 +1342,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 +1355,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 +1370,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 +1393,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 +1408,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 +1434,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;
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 0e7caca9433..e74af25a4a1 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) {
@@ -221,10 +227,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 +261,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 +288,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 */
@@ -312,10 +322,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 +358,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 +394,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 +429,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 +443,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);
@@ -470,19 +489,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 +521,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 785c3eedcfc..e8bcb664c6e 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,8 +172,9 @@ AnimData *BKE_animdata_add_id(ID *id)
return iat->adt;
}
- else
+ else {
return NULL;
+ }
}
/* Action Setter --------------------------------------- */
@@ -198,8 +201,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 +251,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 */
@@ -288,8 +294,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... */
@@ -325,8 +332,9 @@ 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 +372,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 +510,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 +531,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 +553,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,8 +564,9 @@ 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;
}
@@ -868,8 +883,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 +908,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 +944,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 +1050,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 +1414,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 +1425,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 +1445,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 */
@@ -1490,8 +1515,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 +1526,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 +1558,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 +1582,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 +1596,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 +1613,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
@@ -1874,8 +1908,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,10 +1928,12 @@ 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) {
@@ -1927,14 +1964,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 +1995,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 +2053,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 +2063,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
*/
/* 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 +2100,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 +2115,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 +2127,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 +2142,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) {
@@ -2115,8 +2162,9 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
*/
/* 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 +2172,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 +2196,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;
}
@@ -2541,6 +2592,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 +2607,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;
}
@@ -2942,10 +2999,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;
@@ -2971,8 +3030,9 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
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);
@@ -3003,10 +3063,12 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
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
@@ -3150,8 +3212,9 @@ void nlastrip_evaluate(Depsgraph *depsgraph,
* 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)
+ 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 +3244,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 +3284,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 +3342,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);
@@ -3324,32 +3392,37 @@ 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))
+ 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
@@ -3436,12 +3509,14 @@ 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)
+ 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 +3547,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);
}
@@ -3710,8 +3786,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 +3807,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 +3851,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 +3869,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 +3899,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;
}
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 5383138956e..0986596f97c 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -73,8 +73,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 +84,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 +97,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;
@@ -165,8 +168,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);
@@ -324,11 +328,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 +381,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 +419,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 +532,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 +578,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..531c1795497 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;
}
@@ -215,12 +216,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 +235,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 +289,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 +305,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 +408,9 @@ int bone_autoside_name(
return 1;
}
- else
+ else {
return 0;
+ }
}
/* ************* B-Bone support ******************* */
@@ -420,8 +438,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 +451,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]);
@@ -660,15 +680,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 +735,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 +764,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);
@@ -792,11 +816,11 @@ void BKE_pchan_bbone_handles_compute(const BBoneSplineParameters *param,
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 +829,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 +846,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 +911,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 +939,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 +954,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 +968,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 +1043,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);
@@ -1071,8 +1094,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 +1178,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 +1200,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 +1217,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 +1231,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,39 +1240,21 @@ 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;
- bool use_quaternion;
-} ArmatureBBoneDefmatsData;
-
-static void armature_bbone_defmats_cb(void *userdata, Link *iter, int index)
-{
- ArmatureBBoneDefmatsData *data = userdata;
- bPoseChannel *pchan = (bPoseChannel *)iter;
-
- if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
- bPoseChanDeform *pdef_info = &data->pdef_info_array[index];
- const bool use_quaternion = data->use_quaternion;
-
- if (use_quaternion) {
- pdef_info->dual_quat = &data->dualquats[index];
- mat4_to_dquat(pdef_info->dual_quat, pchan->bone->arm_mat, pchan->chan_mat);
- }
- }
-}
-
void armature_deform_verts(Object *armOb,
Object *target,
const Mesh *mesh,
@@ -1258,10 +1266,8 @@ 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;
MDeformVert *dverts = NULL;
bDeformGroup *dg;
float obinv[4][4], premat[4][4], postmat[4][4];
@@ -1290,20 +1296,6 @@ void armature_deform_verts(Object *armOb,
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 +1305,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 +1337,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,12 +1348,8 @@ 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);
}
}
}
@@ -1401,19 +1383,23 @@ void armature_deform_verts(Object *armOb,
BLI_assert(i < mesh->totvert);
dvert = mesh->dvert + i;
}
- else if (dverts && i < target_totvert)
+ else if (dverts && i < target_totvert) {
dvert = dverts + i;
- else
+ }
+ else {
dvert = NULL;
+ }
}
- else
+ else {
dvert = NULL;
+ }
if (armature_def_nr != -1 && dvert) {
armature_weight = defvert_find_weight(dvert, armature_def_nr);
- if (invert_vgroup)
+ if (invert_vgroup) {
armature_weight = 1.0f - armature_weight;
+ }
/* hackish: the blending factor can be used for blending with prevCos too */
if (prevCos) {
@@ -1423,8 +1409,9 @@ void armature_deform_verts(Object *armOb,
}
/* check if there's any point in calculating for this vert */
- if (armature_weight == 0.0f)
+ if (armature_weight == 0.0f) {
continue;
+ }
/* get the coord we work on */
co = prevCos ? prevCos[i] : vertexCos[i];
@@ -1442,7 +1429,6 @@ void armature_deform_verts(Object *armOb,
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;
@@ -1459,7 +1445,7 @@ void armature_deform_verts(Object *armOb,
acum_weight += weight;
}
- pchan_bone_deform(pchan, pdef_info, weight, vec, dq, smat, co, &contrib);
+ pchan_bone_deform(pchan, weight, vec, dq, smat, co, &contrib);
/* if acumulated weight limit exceed, exit loop */
if ((target->type == OB_GPENCIL) && (acum_weight >= 1.0f)) {
@@ -1470,18 +1456,18 @@ void armature_deform_verts(Object *armOb,
/* 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);
+ for (pchan = 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) {
- 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);
+ for (pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
+ contrib += dist_bone_deform(pchan, vec, dq, smat, co);
+ }
}
}
@@ -1497,8 +1483,9 @@ void armature_deform_verts(Object *armOb,
mul_v3_fl(dco, armature_weight);
add_v3_v3(co, dco);
}
- else
+ else {
mul_v3m3_dq(co, (defMats) ? summat : NULL, dq);
+ }
smat = summat;
}
@@ -1514,8 +1501,9 @@ void armature_deform_verts(Object *armOb,
copy_m3_m4(post, postmat);
copy_m3_m3(tmpmat, defMats[i]);
- if (!use_quaternion) /* quaternion already is scale corrected */
+ if (!use_quaternion) { /* quaternion already is scale corrected */
mul_m3_fl(smat, armature_weight / contrib);
+ }
mul_m3_series(defMats[i], post, smat, pre, tmpmat);
}
@@ -1533,10 +1521,9 @@ void armature_deform_verts(Object *armOb,
}
}
- if (defnrToPC)
+ if (defnrToPC) {
MEM_freeN(defnrToPC);
- if (defnrToPCIndex)
- MEM_freeN(defnrToPCIndex);
+ }
}
/* ************ END Armature Deform ******************* */
@@ -1557,8 +1544,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);
@@ -1679,8 +1667,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. */
@@ -1707,8 +1696,9 @@ void BKE_bone_parent_transform_calc_from_matrices(int bone_flag,
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 {
copy_m4_m4(r_bpt->loc_mat, r_bpt->rotscale_mat);
+ }
}
/* Root bones. */
else {
@@ -1720,8 +1710,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,10 +1822,12 @@ 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;
}
}
@@ -2138,8 +2131,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 +2149,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);
@@ -2227,12 +2222,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 +2248,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,8 +2286,9 @@ 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;
@@ -2475,10 +2474,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 +2488,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,12 +2539,14 @@ 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. */
BKE_pose_rebuild(NULL, ob, arm, true);
@@ -2726,70 +2730,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 e6e9b561e78..5af818b9a91 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");
@@ -195,8 +201,9 @@ static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
/* 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 +300,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 +317,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);
@@ -412,8 +421,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);
@@ -549,8 +559,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 +624,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 +723,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 +735,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 +810,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)
@@ -838,8 +849,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)
@@ -877,5 +886,6 @@ void BKE_pose_eval_proxy_copy_bone(struct Depsgraph *depsgraph, Object *object,
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..789d7a6a05d 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -156,8 +156,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/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 723c8bb48bf..383d8e6bf61 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -278,8 +278,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 +305,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 +322,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 +402,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 +420,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 +445,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 +471,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 +643,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..fc3e12accea 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) {
@@ -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;
@@ -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);
@@ -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,14 +1056,16 @@ 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;
}
@@ -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);
@@ -1467,11 +1495,13 @@ 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: {
@@ -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..dcca6e2bf84 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -140,6 +140,9 @@ 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);
}
@@ -212,8 +215,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,8 +576,9 @@ 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;
}
@@ -869,8 +874,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 +1162,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 +1177,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 +1238,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 +1257,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 +1283,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 +1298,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 +1311,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 +1360,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..ab7baf6ce7a 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;
@@ -816,8 +822,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);
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index f4d09be2991..59811cfe373 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -129,8 +129,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 +144,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 +154,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 +185,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 +213,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 +289,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 +337,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 +345,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 +354,7 @@ void BKE_camera_params_compute_matrix(CameraParams *params)
viewplane.ymax,
params->clip_start,
params->clip_end);
+ }
}
/***************************** Camera View Frame *****************************/
@@ -723,8 +734,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 +877,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 +910,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 +967,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 debdedabadb..ea3834be68a 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);
+ }
}
}
@@ -423,8 +429,9 @@ static void cdDM_foreachMappedFaceCenter(
if (index) {
orig = *index++;
- if (orig == ORIGINDEX_NONE)
+ if (orig == ORIGINDEX_NONE) {
continue;
+ }
}
else {
orig = i;
@@ -489,10 +496,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)
@@ -829,11 +838,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 +869,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 +937,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 +1044,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 +1079,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 +1096,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;
}
@@ -1306,8 +1326,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;
}
@@ -1315,8 +1336,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;
}
@@ -1324,8 +1346,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;
}
@@ -1333,8 +1356,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;
}
@@ -1342,8 +1366,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;
}
@@ -1406,8 +1431,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;
}
@@ -1416,8 +1442,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;
}
@@ -1426,8 +1453,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;
}
@@ -1436,8 +1464,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;
}
@@ -1446,8 +1475,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 3062c4d52fa..6db5745dd42 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;
@@ -431,8 +441,10 @@ void clothModifier_do(ClothModifierData *clmd,
}
/* 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)) {
@@ -746,8 +775,9 @@ static int cloth_from_object(
}
// mesh input objects need Mesh
- if (!mesh)
+ if (!mesh) {
return 0;
+ }
cloth_from_mesh(clmd, mesh);
@@ -756,8 +786,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 +805,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 +847,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 +889,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 +996,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 +1054,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.
@@ -1358,8 +1396,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 +1473,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..16b330d9e7f 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -602,8 +602,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;
@@ -1217,8 +1218,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 41dc82cf05f..a8ca6d40b51 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -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];
@@ -637,16 +639,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];
+ }
}
}
}
@@ -816,16 +821,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 +982,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 +1288,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 +1510,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;
@@ -1642,8 +1654,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 +1679,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);
@@ -1686,8 +1700,9 @@ void cloth_find_point_contacts(Depsgraph *depsgraph,
// ret += cloth_points_objcollisions_resolve(clmd, collmd, collob->pd, collisions[i], collisions_index[i], dt);
}
- 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..3d13c16d595 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,8 +414,9 @@ 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;
@@ -480,14 +492,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 +577,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 +599,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 +648,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 01dc7c6b3ad..d6b68121c94 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -156,8 +156,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 +182,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,8 +204,9 @@ 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);
@@ -256,11 +259,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) {
@@ -513,10 +518,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 +541,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 +648,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);
@@ -689,7 +700,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 +708,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 +722,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 +730,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 +920,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 +966,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 +1074,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) {
@@ -1210,7 +1239,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 +1247,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 +1263,9 @@ static void kinematic_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
copy_v3_v3(ct->matrix[3], vec);
}
}
- else
+ else {
unit_m4(ct->matrix);
+ }
}
}
@@ -1379,8 +1410,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 +1436,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 +1477,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 +1541,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 +1597,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 +1704,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];
}
}
@@ -1750,34 +1811,43 @@ static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
/* we must get compatible eulers from the beginning because some of them can be modified below (see bug #21875) */
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 */
@@ -1979,8 +2049,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 +2137,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 +2175,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 +2194,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 +2289,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 +2554,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)) {
@@ -2944,8 +3021,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 +3036,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 +3046,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 +3057,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 +3490,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 +3531,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) {
@@ -3496,15 +3582,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 */
@@ -3630,20 +3720,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;
+ }
}
}
@@ -4100,8 +4194,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 +4263,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 +4340,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 +4443,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 +4580,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 +4602,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 +4694,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 +4755,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;
@@ -4858,10 +4969,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 +4992,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 +5009,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 +5035,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 +5096,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 +5142,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 +5181,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 +5205,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,8 +5220,9 @@ 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 */
@@ -5110,8 +5232,9 @@ static void con_fix_copied_refs_cb(bConstraint *UNUSED(con),
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 +5251,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 +5263,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 +5313,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 +5330,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;
+ }
}
}
}
@@ -5358,8 +5486,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 */
@@ -5437,14 +5566,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 +5606,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 +5636,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 +5646,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,9 +5688,10 @@ 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]),
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..293d2c34b07 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;
@@ -281,8 +284,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 +295,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 +306,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)) {
@@ -356,12 +364,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 +387,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 +434,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 +453,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 +470,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 +499,9 @@ void BKE_nurbList_free(ListBase *lb)
{
Nurb *nu, *next;
- if (lb == NULL)
+ if (lb == NULL) {
return;
+ }
nu = lb->first;
while (nu) {
@@ -494,8 +518,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 +558,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 +599,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 +1043,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 +1061,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 +1084,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 +1094,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 +1115,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 +1128,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 +1173,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 +1186,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 +1197,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 +1235,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 +1255,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 +1289,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 +1302,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 +1316,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 +1331,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 +1355,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 +1368,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 +1397,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 +1410,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 +1458,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 +1484,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 +1510,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 +1534,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 +1764,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 +1788,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 +1828,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 +1879,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 +1923,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 +1982,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 +2027,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 +2202,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 +2221,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 +2268,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 +2294,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 +2312,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 +2325,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 +2366,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 +2500,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 +2683,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 +2784,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);
}
@@ -2853,8 +2975,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 +2997,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 +3037,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 +3114,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 +3157,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 +3380,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 +3541,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 +3576,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 +3675,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 +3730,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 +3788,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 +3848,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 +3875,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;
@@ -3747,8 +3900,9 @@ static bool tridiagonal_solve_with_limits(
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);
@@ -3852,16 +4006,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 +4036,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 +4094,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 +4118,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 +4131,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 +4241,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 +4296,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 +4392,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 +4437,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 +4460,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 +4487,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 +4502,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 +4566,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 +4623,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 +4736,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 +4973,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 +5028,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 +5125,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 +5163,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..c2ef575d086 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -179,8 +179,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 +248,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 +262,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;
@@ -399,8 +402,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 +415,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 +461,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 +509,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 +522,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 +565,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 +593,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 +630,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 +649,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 +683,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 +714,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 +818,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 +865,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(
@@ -1093,8 +1117,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 +1164,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 +1197,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 +1228,9 @@ static void layerInterp_shapekey(const void **sources,
float **in = (float **)sources;
int i;
- if (count <= 0)
+ if (count <= 0) {
return;
+ }
zero_v3(co);
@@ -1720,16 +1748,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 +1871,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 +1946,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 +1960,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 +1988,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 +2012,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 +2041,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 +2075,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,36 +2157,44 @@ 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 */
@@ -2148,45 +2202,55 @@ 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 +2268,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 +2298,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 +2313,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 +2347,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 +2366,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 +2398,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 +2418,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 +2439,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 +2454,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 +2482,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 +2505,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 +2518,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 +2605,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 +2623,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 +2652,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 +2746,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 +2823,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 +2843,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,8 +2870,9 @@ void CustomData_interp(const CustomData *source,
}
}
- if (count > SOURCE_BUF_SIZE)
+ if (count > SOURCE_BUF_SIZE) {
MEM_freeN((void *)sources);
+ }
}
/**
@@ -2838,8 +2937,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 +2955,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 +2967,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 +2978,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 +2988,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 +2999,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 +3010,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 +3022,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 +3043,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 +3056,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 +3070,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 +3154,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 +3310,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 +3368,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 +3382,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 +3397,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 +3412,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 +3427,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 +3457,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 +3474,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 +3486,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
@@ -3377,8 +3509,9 @@ void *CustomData_bmesh_get(const CustomData *data, void *block, 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 NULL;
+ }
return POINTER_OFFSET(block, data->layers[layer_index].offset);
}
@@ -3389,8 +3522,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 +3532,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 +3624,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 +3643,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 +3660,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 +3709,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 +3726,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 +3743,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 +3787,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 +3804,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 +3828,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 +3851,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 +3870,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 +3883,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 +3925,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 +3937,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
@@ -3892,8 +4056,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 +4132,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
@@ -4013,8 +4179,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--;
}
@@ -4061,8 +4228,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 +4246,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 +4265,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 +4301,9 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
}
layer->flag |= CD_FLAG_IN_MEMORY;
}
- else
+ else {
break;
+ }
}
}
}
@@ -4152,8 +4323,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 +4340,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 +4406,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 +4426,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");
@@ -4277,17 +4453,20 @@ void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
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 +4478,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;
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..a57db5a7cbe 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -581,8 +581,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) {
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index c0effb1cb32..57ab0a9c94e 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));
@@ -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) {
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 2794a6e36e4..e3ee28ed022 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,8 +1023,9 @@ 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) {
@@ -1060,8 +1103,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 +1176,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 +1222,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 +1240,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 +1271,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 +1301,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 +1349,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 +1383,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 +1411,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 +1669,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 +1688,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 +1701,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 +1734,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 +1832,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 +1937,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 +2028,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 2d4f1607fe4..7fef07346c3 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -343,10 +343,12 @@ static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
{
DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
for (; surface; surface = surface->next) {
- if (surface == t_surface)
+ if (surface == t_surface) {
surface->flags |= MOD_DPAINT_PREVIEW;
- else
+ }
+ else {
surface->flags &= ~MOD_DPAINT_PREVIEW;
+ }
}
}
@@ -354,12 +356,15 @@ bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object
{
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 +424,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;
}
@@ -467,10 +473,12 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
surface_setUniqueOutputName(surface, surface->output_name, 0);
/* update preview */
- if (dynamicPaint_surfaceHasColorPreview(surface))
+ if (dynamicPaint_surfaceHasColorPreview(surface)) {
dynamicPaint_setPreview(surface);
- else
+ }
+ else {
dynamicPaint_resetPreview(surface->canvas);
+ }
}
static int surface_totalSamples(DynamicPaintSurface *surface)
@@ -565,8 +573,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 +588,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 +602,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 +616,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 +651,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 +757,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 +828,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 +866,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 +887,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 +902,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 +926,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 +962,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 +976,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 +1013,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 +1064,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;
@@ -1099,27 +1145,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 +1201,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 +1218,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 +1241,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) {
@@ -1287,10 +1343,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 +1385,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 +1411,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 +1423,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 +1444,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 +1642,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 +1668,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 +1722,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 +1734,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 +1759,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 +1787,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 +1811,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;
}
@@ -1789,8 +1868,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) {
@@ -1925,8 +2005,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) {
@@ -2121,8 +2202,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 +2216,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);
@@ -2426,8 +2510,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 +2577,18 @@ 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))
+ 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 +2648,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,16 +2663,18 @@ 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;
@@ -2602,8 +2692,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 +2724,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 +2744,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 +2766,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 +2777,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 +2799,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;
@@ -2808,10 +2905,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 +2942,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 +2960,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 +2976,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 +3005,9 @@ int dynamicPaint_createUVSurface(Scene *scene,
*/
if (!error) {
faceBB = MEM_mallocN(tottri * sizeof(*faceBB), "MPCanvasFaceBB");
- if (!faceBB)
+ if (!faceBB) {
error = true;
+ }
}
*progress = 0.01f;
@@ -3097,8 +3206,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;
@@ -3107,10 +3217,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;
@@ -3130,17 +3242,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) {
@@ -3219,8 +3336,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);
@@ -3245,8 +3363,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);
@@ -3288,8 +3407,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);
@@ -3562,10 +3682,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) {
@@ -3581,8 +3703,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);
@@ -3624,10 +3747,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];
+ }
}
}
@@ -3643,8 +3768,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);
@@ -3691,10 +3817,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;
}
@@ -3794,12 +3922,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 = {
@@ -3930,8 +4060,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++) {
@@ -3955,10 +4086,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);
@@ -4028,8 +4161,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)) {
@@ -4072,8 +4206,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;
@@ -4090,8 +4225,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 */
@@ -4229,9 +4365,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) {
@@ -4328,8 +4465,9 @@ static int dynamicPaint_paintMesh(Depsgraph *depsgraph,
}
/* free brush velocity data */
- if (brushVelocity)
+ if (brushVelocity) {
MEM_freeN(brushVelocity);
+ }
return 1;
}
@@ -4378,8 +4516,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 */
@@ -4394,8 +4533,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;
@@ -4424,14 +4564,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;
@@ -4445,8 +4587,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;
@@ -4457,13 +4600,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) {
@@ -4529,8 +4674,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
@@ -4554,8 +4700,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);
@@ -4564,8 +4711,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) {
@@ -4641,8 +4789,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 ||
@@ -4721,8 +4870,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;
@@ -4790,15 +4940,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);
@@ -4844,15 +4997,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);
@@ -4910,8 +5065,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++) {
@@ -4927,8 +5083,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];
@@ -4937,8 +5094,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(
@@ -4954,8 +5112,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);
@@ -5033,18 +5192,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) {
@@ -5106,10 +5267,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);
@@ -5132,8 +5295,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;
@@ -5155,16 +5319,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);
@@ -5188,8 +5354,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;
@@ -5213,8 +5380,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 *
@@ -5247,8 +5415,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];
@@ -5266,8 +5435,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;
@@ -5282,8 +5452,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;
@@ -5296,8 +5467,9 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
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;
@@ -5342,8 +5514,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);
@@ -5370,8 +5543,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
@@ -5511,8 +5685,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 = {
@@ -5550,8 +5725,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;
@@ -5563,8 +5739,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;
@@ -5590,8 +5767,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;
@@ -5604,10 +5782,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;
+ }
}
}
@@ -5637,8 +5817,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++) {
@@ -5805,12 +5986,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++) {
@@ -5966,30 +6149,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;
}
@@ -6007,16 +6195,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"));
}
@@ -6032,8 +6225,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));
+ }
}
/*
@@ -6095,8 +6289,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 = {
@@ -6138,10 +6333,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 */
@@ -6188,8 +6385,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;
}
@@ -6216,8 +6415,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);
@@ -6226,10 +6426,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 */
@@ -6267,8 +6469,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..794b1d669d2 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,
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c
index 9c412c3c1b0..12f70eed2c6 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;
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..6a644b2ed4b 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -322,15 +322,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;
@@ -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..1105d210e13 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);
@@ -737,8 +751,9 @@ int get_effector_data(EffectorCache *eff,
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)
+ 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 +825,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 +838,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 +972,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 32c92ec5b55..c2d68e34693 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -83,8 +83,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);
@@ -107,8 +108,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
@@ -131,8 +133,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);
@@ -163,8 +166,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);
@@ -191,12 +195,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);
@@ -206,14 +212,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;
}
@@ -230,16 +238,18 @@ FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_
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;
+ }
}
}
@@ -253,8 +263,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) {
@@ -286,10 +297,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) {
@@ -345,10 +358,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)) {
@@ -392,8 +407,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 */
@@ -401,15 +417,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;
}
@@ -465,8 +483,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];
@@ -474,8 +493,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
@@ -494,10 +514,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 */
@@ -541,8 +563,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) {
@@ -658,10 +681,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;
}
@@ -670,29 +695,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;
@@ -755,12 +789,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) {
@@ -770,8 +806,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) {
@@ -785,15 +822,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 */
@@ -818,12 +857,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;
@@ -839,21 +880,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;
@@ -903,10 +948,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;
@@ -966,16 +1013,18 @@ bool BKE_fcurve_is_cyclic(FCurve *fcu)
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;
}
@@ -993,8 +1042,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];
@@ -1010,10 +1060,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);
@@ -1068,8 +1120,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++) {
@@ -1128,8 +1181,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) {
@@ -1137,8 +1191,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) {
@@ -1146,8 +1201,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;
+ }
}
}
@@ -1180,8 +1236,9 @@ 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;
}
@@ -1195,8 +1252,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);
@@ -1303,8 +1361,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);
@@ -1746,10 +1805,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 --------------------------------- */
@@ -1758,8 +1819,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
@@ -1768,8 +1830,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;
@@ -1797,8 +1860,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;
}
@@ -1810,8 +1874,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;
@@ -1827,8 +1892,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;
+ }
if (type == DVAR_TYPE_FUNCTION) {
dtar->idtype = ID_NT;
@@ -1847,8 +1913,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;
@@ -1880,10 +1947,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
@@ -1897,8 +1966,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 */
@@ -1907,8 +1977,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");
@@ -1940,8 +2011,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 */
@@ -1952,8 +2024,9 @@ 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);
@@ -1969,8 +2042,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);
@@ -2121,8 +2195,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
@@ -2130,10 +2205,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;
}
@@ -2151,8 +2228,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 */
@@ -2176,10 +2254,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;
}
@@ -2198,13 +2278,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 {
@@ -2279,8 +2361,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
@@ -2321,23 +2404,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)));
@@ -2346,18 +2434,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 {
@@ -2373,30 +2465,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;
@@ -2556,9 +2655,10 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
* This lower bound was established in b888a32eee8147b028464336ad2404d8155c64dd
*/
a = binarysearch_bezt_index_ex(bezts, evaltime, fcu->totvert, 0.0001, &exact);
- if (G.debug & G_DEBUG)
+ 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
@@ -2633,13 +2733,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;
@@ -2842,12 +2943,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));
+ }
}
}
@@ -2881,10 +2983,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 */
@@ -2912,10 +3016,12 @@ static float evaluate_fcurve_ex(FCurve *fcu, float evaltime, float cvalue)
* - '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);
@@ -2923,8 +3029,9 @@ static float evaluate_fcurve_ex(FCurve *fcu, float evaltime, float cvalue)
/* 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;
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 3cb941e1f93..79808d20193 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -104,8 +104,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)
@@ -114,8 +115,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)
@@ -181,27 +183,33 @@ static void fcm_generator_evaluate(
*/
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 */
@@ -211,15 +219,18 @@ static void fcm_generator_evaluate(
/* 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++)
+ 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;
}
@@ -269,10 +280,12 @@ 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(
@@ -302,11 +315,13 @@ static void fcm_fn_generator_evaluate(
{
/* 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 */
@@ -316,8 +331,9 @@ static void fcm_fn_generator_evaluate(
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;
}
@@ -328,8 +344,9 @@ static void fcm_fn_generator_evaluate(
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;
}
@@ -342,10 +359,12 @@ static void fcm_fn_generator_evaluate(
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;
+ }
}
}
@@ -372,8 +391,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)
@@ -382,8 +402,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)
@@ -414,8 +435,9 @@ static void fcm_envelope_evaluate(
int a;
/* get pointers */
- if (env->data == NULL)
+ if (env->data == NULL) {
return;
+ }
prevfed = env->data;
fed = prevfed + 1;
lastfed = prevfed + (env->totvert - 1);
@@ -636,8 +658,9 @@ static float fcm_cycles_time(
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
@@ -659,8 +682,9 @@ static float fcm_cycles_time(
ofs = lastkey[0];
}
}
- if ((ELEM(0, side, mode)))
+ if ((ELEM(0, side, mode))) {
return evaltime;
+ }
/* find relative place within a cycle */
{
@@ -672,8 +696,9 @@ static float fcm_cycles_time(
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);
@@ -696,10 +721,12 @@ static float fcm_cycles_time(
/* 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;
}
@@ -707,8 +734,9 @@ static float fcm_cycles_time(
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)) {
@@ -716,17 +744,20 @@ static float fcm_cycles_time(
* - 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)
*/
- 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 */
@@ -895,10 +926,12 @@ static float fcm_limits_time(FCurve *UNUSED(fcu),
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;
@@ -913,10 +946,12 @@ static void fcm_limits_evaluate(FCurve *UNUSED(fcu),
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 = {
@@ -958,12 +993,14 @@ static float fcm_stepped_time(FCurve *UNUSED(fcu),
/* 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
@@ -1048,10 +1085,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 --------------------------- */
@@ -1063,8 +1102,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)) {
@@ -1085,19 +1125,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;
@@ -1110,8 +1153,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);
@@ -1122,8 +1166,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;
@@ -1134,8 +1179,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);
@@ -1149,8 +1195,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);
+ }
}
}
@@ -1160,16 +1207,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);
@@ -1180,8 +1229,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;
}
@@ -1199,8 +1249,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) {
@@ -1215,13 +1266,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 */
@@ -1234,16 +1287,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
@@ -1255,12 +1311,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) {
@@ -1268,14 +1326,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 */
@@ -1312,16 +1373,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) {
@@ -1365,11 +1429,13 @@ float evaluate_time_fmodifiers(FModifiersStackStorage *storage,
float evaltime)
{
/* 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.
@@ -1385,8 +1451,9 @@ float evaluate_time_fmodifiers(FModifiersStackStorage *storage,
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
@@ -1424,19 +1491,22 @@ void evaluate_value_fmodifiers(FModifiersStackStorage *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 */
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 */
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index ffb3bad12e6..9ee8ecd1b64 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);
@@ -726,16 +734,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 +776,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 +834,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 +890,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 +1029,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 +1102,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 +1216,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 */
@@ -1387,8 +1409,9 @@ static bool vfont_to_curve(Object *ob,
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;
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..e45a4f4d649 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 */
@@ -693,8 +700,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 +727,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 +756,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 +801,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 +812,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 +835,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 +862,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 +906,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 +924,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 +943,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 +967,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 +988,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 +1011,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);
@@ -1142,8 +1175,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 +1203,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 +1223,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 +1290,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 +1309,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.
@@ -1610,8 +1648,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..08162276a64 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);
@@ -519,8 +523,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));
@@ -582,8 +587,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 +632,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 +651,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);
@@ -720,8 +728,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..aebed7e0e91 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);
+ }
}
/** \} */
@@ -778,8 +790,9 @@ IDProperty *IDP_CopyProperty(const IDProperty *prop)
/* 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 +849,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 +897,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 +916,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..eaf90bd4ebb 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,8 +374,9 @@ 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);
}
@@ -494,10 +497,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 +534,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 +572,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 +695,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 +731,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 +875,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 +921,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 +951,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 +1000,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 +1191,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 +1254,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 +1340,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 +1362,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 +1392,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 +1495,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 +1701,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 +1728,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 +1782,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 +1958,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 +1973,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 +2299,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 +2310,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 +2323,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 +2544,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 +2583,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 +2635,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 +2654,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 +2725,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 +2742,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 +2804,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 +2849,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 +2877,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 +2893,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 +3117,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 +3157,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 +3225,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 +3243,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 +3253,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 +3326,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 +3418,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 +3441,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 +3461,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 +3557,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 +3593,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 +3700,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 +3775,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 +3802,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 +3814,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 +3876,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 +3903,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 +3946,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 +4032,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 +4063,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 +4099,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 +4126,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 +4142,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 +4154,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 +4173,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 +4225,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 +4281,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 +4396,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 +4407,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 +4423,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 +4461,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 +4491,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 +4607,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 +4687,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 +4699,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 +4757,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 +4783,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 +4818,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 +4910,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 +4943,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 +4998,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 +5021,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 +5050,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;
}
@@ -5146,16 +5315,20 @@ bool BKE_image_remove_renderslot(Image *ima, ImageUser *iuser, int index)
if (remove_slot == current_last_slot) {
/* 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 +5352,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 46315e1bc9a..d641229d5e0 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);
+ }
}
/* *************************************************** */
@@ -378,42 +382,60 @@ 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));
@@ -469,8 +491,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 */
@@ -913,8 +936,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) {
@@ -1002,16 +1026,18 @@ static char *get_rna_access(ID *id,
*/
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 */
@@ -1050,8 +1076,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);
@@ -1116,8 +1143,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;
@@ -1137,16 +1165,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' */
@@ -1157,8 +1187,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 */
}
@@ -1210,8 +1241,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));
@@ -1228,8 +1260,9 @@ static void fcurve_add_to_list(
/* 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;
@@ -1266,20 +1299,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) {
@@ -1300,10 +1339,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;
}
}
@@ -1316,8 +1357,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);
@@ -1332,10 +1374,12 @@ 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);
@@ -1366,17 +1410,21 @@ 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) {
@@ -1397,8 +1445,9 @@ 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
@@ -1418,18 +1467,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
@@ -1524,11 +1576,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')
@@ -1537,10 +1591,12 @@ 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 */
@@ -1558,8 +1614,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... */
@@ -1571,14 +1628,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);
@@ -1598,13 +1658,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) {
@@ -1654,8 +1716,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;
@@ -1679,8 +1742,9 @@ static void ipo_to_animdata(
/* 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];
@@ -1688,8 +1752,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 */
@@ -1698,8 +1763,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);
}
@@ -1713,14 +1779,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;
}
@@ -1769,31 +1837,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) */
@@ -1811,8 +1886,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);
@@ -1848,8 +1924,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 -------------- */
@@ -1860,8 +1937,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) {
@@ -1976,8 +2054,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;
+ }
}
}
@@ -1985,8 +2064,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
@@ -1999,8 +2079,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;
@@ -2011,8 +2092,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) {
@@ -2022,8 +2104,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;
@@ -2034,8 +2117,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) {
@@ -2045,8 +2129,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;
@@ -2066,8 +2151,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;
@@ -2095,8 +2181,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;
@@ -2109,8 +2196,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) {
@@ -2120,8 +2208,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;
@@ -2132,8 +2221,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) {
@@ -2143,8 +2233,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;
@@ -2155,8 +2246,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) {
@@ -2166,8 +2258,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;
@@ -2178,8 +2271,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) {
@@ -2189,8 +2283,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;
@@ -2212,12 +2307,14 @@ void do_versions_ipos_to_animato(Main *bmain)
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);
@@ -2227,8 +2324,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) {
@@ -2248,6 +2346,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..e0246f874f3 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);
}
}
@@ -198,10 +200,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 +225,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 +378,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 +417,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 +456,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 +612,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 +663,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 +675,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 +693,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 +723,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 +750,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 +761,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 +788,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 +822,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 +839,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 +871,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 +890,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 +926,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 +1050,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 +1088,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 +1159,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 +1182,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 +1192,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 +1202,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 +1414,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 +1427,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 +1452,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 +1472,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 +1486,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 +1571,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 +1596,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 +1609,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 +1622,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 +1690,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 +1709,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 +1747,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 +1772,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 +1788,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 +1826,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 +1850,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 +1883,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 +1941,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 +1956,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 +2089,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 +2147,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 +2177,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__);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index d301405bdb4..5570d39f43f 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -147,12 +147,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");
@@ -311,10 +314,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 +354,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 +421,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 +479,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 +495,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 +511,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 +524,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 +534,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 +579,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 +604,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 +654,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;
@@ -695,8 +720,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 +731,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 +753,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,8 +867,9 @@ 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);
}
@@ -858,8 +887,9 @@ void lattice_deform_verts(Object *laOb,
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);
@@ -929,12 +959,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 +1018,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 +1034,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");
@@ -1042,19 +1079,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 +1109,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 +1127,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 +1155,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 +1208,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 +1223,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 +1271,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..f0c2c1e5477 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -450,8 +450,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);
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 4230ab313d0..ca73415b962 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -393,124 +393,154 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
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:
@@ -1004,13 +1034,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;
+ }
}
}
@@ -1452,8 +1484,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 +1534,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 +1571,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 +1602,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 +1615,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 +1648,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 +1683,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));
@@ -1723,8 +1764,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;
}
@@ -2091,8 +2131,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);
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 7a29575dffe..30307eb1266 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -79,8 +79,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! */
@@ -207,8 +208,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 +217,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;
@@ -620,8 +619,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);
@@ -705,8 +703,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);
}
@@ -804,8 +801,7 @@ void BKE_override_static_operations_store_finalize(OverrideStaticStorage *overri
* 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 a87f8a4969a..92ed6ea4e04 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: {
@@ -1412,8 +1413,7 @@ 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;
}
@@ -1426,8 +1426,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(
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 9b6de945db8..7657b47bcf5 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 */
@@ -448,8 +452,7 @@ static void libblock_remap_data(
* 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...
@@ -717,8 +720,9 @@ static int id_relink_to_newid_looper(void *UNUSED(user_data),
*/
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);
}
@@ -823,8 +827,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);
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index f0943bc2749..0a7cb2a30a0 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -144,8 +144,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/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index a0cfe7dfe41..4d159adbb57 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -136,14 +136,18 @@ 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);
+ }
}
/**
@@ -426,8 +430,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 +606,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 +669,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 +842,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 +958,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 +1299,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 +1374,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..8ae5ed7fbdd 100644
--- a/source/blender/blenkernel/intern/main.c
+++ b/source/blender/blenkernel/intern/main.c
@@ -260,8 +260,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);
}
@@ -295,8 +294,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;
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index e307ad6cac8..c925ebe26cf 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)
@@ -399,8 +402,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 +428,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 +733,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 +823,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);
@@ -889,8 +898,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 +950,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;
@@ -1214,11 +1225,13 @@ static void mask_calc_point_handle(MaskSplinePoint *point,
BezTriple *bezt_prev = NULL, *bezt_next = NULL;
//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 +1712,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)
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index d3e43a60565..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;
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 0f5fd89d833..31cb0e54785 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -488,14 +488,18 @@ 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;
@@ -979,8 +983,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);
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index a4da6663de8..599dc1e15d5 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -424,10 +424,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 +459,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 +513,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 +540,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 +586,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 +629,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 +676,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 +706,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 +724,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 +795,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 +910,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 +926,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 +1001,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 +1025,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 +1138,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 +1227,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 +1252,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 +1274,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 +1431,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 +1480,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 +1500,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..0980089a1f7 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)
@@ -206,8 +207,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. */
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index 3ca46b7be61..b008eca2258 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);
@@ -1278,8 +1335,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 +1366,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 +1384,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;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 5df06e61744..117567621c9 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;
}
@@ -573,17 +592,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 +855,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 +869,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 +907,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);
@@ -922,12 +953,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 +973,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)
@@ -1053,8 +1091,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 +1103,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 +1115,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 +1132,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 +1251,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 +1269,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 +1304,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 +1348,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;
@@ -1436,8 +1488,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 +1614,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 +1630,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;
}
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 6f96267ff55..93017e77d36 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;
@@ -974,8 +985,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);
@@ -1182,8 +1194,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) {
@@ -1253,8 +1266,9 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
BKE_id_copy_ex(NULL, &me->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
BKE_mesh_apply_vert_coords(result, deformedVerts);
- if (build_shapekey_layers)
+ if (build_shapekey_layers) {
add_shapekey_layers(result, me);
+ }
MEM_freeN(deformedVerts);
}
@@ -1262,8 +1276,9 @@ 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);
ASSERT_IS_VALID_MESH(result);
@@ -1282,8 +1297,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 +1308,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 +1318,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 +1342,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__);
@@ -1504,8 +1523,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 3982339d501..800d61a6a66 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -165,8 +165,9 @@ 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 */
if (only_face_normals == false) {
@@ -199,8 +200,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;
@@ -462,11 +464,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 +498,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 +555,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,
@@ -2590,8 +2596,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 +2613,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 +2641,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 +2687,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);
+ }
}
}
@@ -2877,17 +2890,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++) {
@@ -3398,8 +3415,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) {
@@ -3727,8 +3745,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_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 811b78411a3..69ed804a75c 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -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 */
diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c
index 1d534f72842..31988c7b566 100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@ -664,10 +664,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..6799c6f5c43 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -445,13 +445,16 @@ 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:
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index 8d482a961b6..c82126c39d0 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -190,14 +190,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;
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index e6c4e9ff4be..d6d39ca0f1d 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -530,10 +530,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 +554,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 +609,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;
@@ -681,8 +690,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..e2515665728 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) {
@@ -595,8 +598,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 +609,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.
@@ -679,8 +685,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 +707,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 +728,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 +761,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 +1322,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 +1365,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 +1403,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 +1416,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 +1439,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 +1527,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 +1538,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..b244a69ec09 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -129,11 +129,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 +164,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 +226,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 +262,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 +275,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 +293,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 +400,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 +436,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;
@@ -490,16 +507,20 @@ bool modifier_isEnabled(const struct Scene *scene, ModifierData *md, int require
{
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 +543,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 +582,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 +629,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 +656,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->flag & SELECT)) {
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 +679,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->flag & SELECT)) {
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 +705,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->flag & SELECT)) {
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 +731,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->flag & SELECT)) {
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 +752,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 +794,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 +822,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) {
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 51f7fd2208c..1a61fa2c537 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);
+ }
}
}
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 5e404f7e264..6af92422b30 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) {
@@ -1716,13 +1786,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 +1806,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 +2014,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 +2072,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 +2142,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 +2160,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 +2191,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 +2239,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 +2256,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 +2370,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 +2415,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 +2458,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..6953339f287 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) {
@@ -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) {
@@ -169,8 +176,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);
@@ -219,8 +227,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);
@@ -247,8 +256,9 @@ void BKE_nla_tracks_copy(Main *bmain, ListBase *dst, ListBase *src, const int fl
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 +282,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 +294,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 +317,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");
@@ -347,13 +361,15 @@ NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act)
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 +438,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) {
@@ -499,16 +518,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;
+ }
}
}
@@ -546,17 +569,20 @@ 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);
@@ -568,8 +594,9 @@ float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
* - 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 +614,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 +627,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 +652,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 +679,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 +698,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 +737,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 +757,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 +790,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 +816,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 +842,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 +865,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 +880,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 +904,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 +923,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) {
@@ -934,13 +980,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 +1005,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 +1039,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 +1056,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 +1076,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 +1099,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 +1118,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 +1132,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 +1153,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 +1185,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 +1207,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 +1231,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
@@ -1294,19 +1364,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 +1393,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 +1408,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 +1426,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 +1447,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 +1468,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 +1528,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 +1576,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,8 +1609,9 @@ 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 */
BLI_ghash_insert(gh, tstrip->name, tstrip);
@@ -1575,21 +1659,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 +1689,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 +1714,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,8 +1746,9 @@ 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 */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
@@ -1657,8 +1757,9 @@ void BKE_nla_validate_state(AnimData *adt)
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 +1779,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 +1809,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 +1835,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) {
@@ -1797,8 +1902,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
@@ -1853,8 +1959,9 @@ void BKE_nla_action_pushdown(AnimData *adt)
* 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 +1978,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
@@ -1935,26 +2044,31 @@ 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)
@@ -1980,12 +2094,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 +2149,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 45bade78207..8a3f973ae5f 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;
@@ -133,14 +135,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 +184,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 +235,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,30 +245,40 @@ 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;
}
@@ -283,16 +300,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 +327,9 @@ bNodeTreeType *ntreeTypeFind(const char *idname)
if (idname[0]) {
nt = BLI_ghash_lookup(nodetreetypes_hash, idname);
- if (nt)
+ if (nt) {
return nt;
+ }
}
return NULL;
@@ -354,8 +376,9 @@ bNodeType *nodeTypeFind(const char *idname)
if (idname[0]) {
nt = BLI_ghash_lookup(nodetypes_hash, idname);
- if (nt)
+ if (nt) {
return nt;
+ }
}
return NULL;
@@ -383,11 +406,13 @@ static void node_free_type(void *nodetype_v)
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)
@@ -424,8 +449,9 @@ bNodeSocketType *nodeSocketTypeFind(const char *idname)
if (idname[0]) {
st = BLI_ghash_lookup(nodesockettypes_hash, idname);
- if (st)
+ if (st) {
return st;
+ }
}
return NULL;
@@ -471,8 +497,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 +510,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 +789,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 +861,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;
}
@@ -1071,8 +1103,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 +1114,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 +1133,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 +1171,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 +1192,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 +1212,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);
+ }
}
}
@@ -1389,8 +1432,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 +1505,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 +1536,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 +1568,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 +1596,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 +1622,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 +1634,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 +1672,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 +1691,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 +1706,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);
@@ -1706,18 +1761,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 +1789,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 +1811,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 +1849,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 +1906,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 +1920,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 +1989,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 +2017,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 +2037,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 +2053,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 +2064,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 +2086,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 +2130,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 +2200,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 +2219,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 +2230,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,12 +2263,14 @@ 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:
+ /* 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.
@@ -2218,9 +2301,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 +2354,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 +2369,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 +2445,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 +2533,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 +2553,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 +2569,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 +2580,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 +2599,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 +2616,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 +2630,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 +2644,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 +2665,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 +2678,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 +2700,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 +2713,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 +2732,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 +2927,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 +2943,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 +3021,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 +3042,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 +3060,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 +3090,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 +3179,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,11 +3214,13 @@ 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;
+ }
}
}
}
@@ -3103,9 +3230,11 @@ void ntreeVerifyNodes(struct Main *main, struct ID *id)
FOREACH_NODETREE_BEGIN (main, ntree, owner_id) {
bNode *node;
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->typeinfo->verifyfunc)
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->typeinfo->verifyfunc) {
node->typeinfo->verifyfunc(ntree, node, id);
+ }
+ }
}
FOREACH_NODETREE_END;
}
@@ -3114,12 +3243,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 +3262,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)
+ if (bmain) {
ntreeVerifyNodes(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 +3309,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 +3331,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 +3365,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 +3513,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 +3524,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 +3545,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 +3582,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;
}
@@ -3796,10 +3943,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..a623baf7b71 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -300,8 +300,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 +445,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 +580,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 +729,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 +881,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 +975,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 +1021,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 +1043,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 +1118,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 +1135,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;
+ }
}
}
}
@@ -1160,12 +1170,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 +1202,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;
}
@@ -1350,11 +1365,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);
@@ -1588,8 +1605,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
@@ -1779,8 +1797,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 +1809,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 +1825,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);
+ }
}
}
}
@@ -1879,10 +1901,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)) {
@@ -2012,10 +2036,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 +2081,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;
}
}
@@ -2375,8 +2403,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 +2460,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:
@@ -2525,10 +2556,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)
@@ -2633,12 +2666,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 +2771,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 +3146,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);
}
@@ -3244,8 +3284,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 +3297,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 +3311,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 +3413,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 +3431,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 +3448,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 +3722,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 +3867,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 +3887,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 +3915,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 +3925,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 +3949,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 +4016,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 +4239,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 +4252,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 +4317,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 +4343,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 +4373,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 +4413,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..751110affaf 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)) {
@@ -401,10 +403,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 +428,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;
@@ -615,8 +621,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 +634,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) {
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 2544bb6a8f0..00ef5d9c469 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);
@@ -120,12 +123,14 @@ 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)
+ 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 +163,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 +224,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 +265,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 +284,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 +348,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 +378,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 +495,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);
@@ -584,8 +598,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 +626,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 +742,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 +779,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 +801,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 +875,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 +909,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];
}
@@ -971,8 +1002,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 +1022,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 +1036,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 +1073,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 +1095,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..66a3b418f3a 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);
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index f84048b502f..606df3a7a96 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -295,10 +295,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 +367,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);
@@ -813,8 +817,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 +837,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 +948,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 +1066,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 +1112,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 +1131,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 +1194,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 +1225,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 +1241,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 +1269,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,8 +1338,9 @@ 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 */
@@ -1352,13 +1376,16 @@ void BKE_ocean_bake(struct Ocean *o,
char string[FILE_MAX];
//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);
@@ -1413,8 +1440,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 +1464,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 +1491,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);
return;
}
}
//BLI_rng_free(rng);
- if (prev_foam)
+ if (prev_foam) {
MEM_freeN(prev_foam);
+ }
och->baked = 1;
}
@@ -1563,8 +1596,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 +1606,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..29e9295df1d 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,8 +177,9 @@ 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);
@@ -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,
@@ -650,18 +660,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 +684,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..7e8e724cfcc 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);
@@ -222,8 +229,9 @@ 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)
+ if (ts->use_uv_sculpt) {
return &ts->uvsculpt->paint;
+ }
return &ts->imapaint.paint;
default:
break;
@@ -247,15 +255,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 (ts->use_uv_sculpt) {
return &ts->uvsculpt->paint;
+ }
}
else {
return &ts->imapaint.paint;
@@ -279,15 +290,18 @@ ePaintMode BKE_paintmode_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 PAINT_MODE_TEXTURE_2D;
- else if (ts->use_uv_sculpt)
+ }
+ else if (ts->use_uv_sculpt) {
return PAINT_MODE_SCULPT_UV;
+ }
}
else {
return PAINT_MODE_TEXTURE_2D;
@@ -304,8 +318,9 @@ 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)
+ if (ts->use_uv_sculpt) {
return PAINT_MODE_SCULPT_UV;
+ }
return PAINT_MODE_TEXTURE_2D;
default:
return PAINT_MODE_TEXTURE_2D;
@@ -599,8 +614,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 +728,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 +822,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 +920,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,
@@ -958,28 +980,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 +1041,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 +1065,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;
@@ -1340,8 +1379,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/particle.c b/source/blender/blenkernel/intern/particle.c
index 9e121d279ba..986e47894ca 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,8 +472,9 @@ 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). */
@@ -465,12 +488,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 +515,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 +537,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);
@@ -578,16 +608,19 @@ void psys_free_particles(ParticleSystem *psys)
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 +630,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 +682,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 +702,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 +718,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 +789,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);
@@ -821,13 +862,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 +881,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 +932,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 +1025,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 +1046,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 +1133,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]);
+ }
}
}
@@ -1134,8 +1205,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 +1218,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 +1234,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 +1279,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 +1316,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 +1423,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:
@@ -1523,21 +1605,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 +1633,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 +1647,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 +1658,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 +1742,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 +1769,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 +1831,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 +1879,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 +1911,9 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
GuideEffectorData *data;
PARTICLE_P;
- if (!effectors)
+ if (!effectors) {
return;
+ }
LOOP_PARTICLES
{
@@ -1835,12 +1935,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 +1977,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 +2033,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;
@@ -1986,13 +2095,16 @@ int do_guides(Depsgraph *depsgraph,
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);
interp_v3_v3v3(state->co, state->co, effect, totstrength);
@@ -2022,8 +2134,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 +2158,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 +2186,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 +2205,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 +2230,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) {
@@ -2175,8 +2294,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 +2304,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 +2349,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 +2410,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 +2435,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 */
@@ -2350,20 +2479,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 +2513,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 +2523,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 +2548,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 +2592,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);
@@ -2547,8 +2684,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 +2708,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 +2749,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 +2886,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 +2906,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 +2931,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 +2982,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 +3006,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 +3030,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 +3045,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 +3075,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 +3176,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 +3304,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 +3358,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 +3401,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 +3437,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 +3476,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 +3510,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 +3553,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 +3588,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 +3672,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;
@@ -3631,11 +3809,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 +3919,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 +3929,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 +3958,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 +4007,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 +4017,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 +4050,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 +4084,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 +4140,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 +4171,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 +4201,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,8 +4316,9 @@ 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);
+ }
}
}
}
@@ -4135,8 +4339,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 */
@@ -4181,10 +4386,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;
}
@@ -4257,8 +4464,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 +4520,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,14 +4598,17 @@ 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 */
@@ -4447,8 +4660,9 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
}
}
- 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 +4732,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 +4769,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 +4785,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 +4798,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 +4825,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..45aa55a401b 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,13 +895,15 @@ 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)) {
@@ -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++;
@@ -1171,8 +1214,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 +1233,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 +1255,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 +1268,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 +1321,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 +1334,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 +1347,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 +1370,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..38183f97b72 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,16 +552,21 @@ 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);
BLI_kdtree_3d_free(ctx->tree);
@@ -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);
@@ -842,12 +883,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 +910,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 +1035,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 +1049,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 +1068,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 +1132,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 +1145,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 +1162,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 +1173,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 +1205,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 +1273,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 +1310,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 +1350,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 +1384,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 +1434,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 +1468,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);
@@ -1522,8 +1591,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 +1618,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 +1634,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 +1663,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 +1730,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 +1740,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 +1751,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 +1857,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 +1871,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 +1911,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 +1939,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 +1949,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 +1967,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 +1977,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 +2052,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 +2065,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 +2086,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 +2125,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
@@ -2134,16 +2229,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 +2249,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,8 +2285,9 @@ 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);
@@ -2292,10 +2391,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) {
@@ -2343,8 +2444,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 +2469,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 +2527,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 +2593,9 @@ static float collision_newton_rhapson(ParticleCollision *col,
d1 = 0.f;
continue;
}
- else
+ else {
return -1.f;
+ }
}
dd = (t1 - t0) / (d1 - d0);
@@ -2510,20 +2615,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 +2711,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 +2812,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 +2823,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 +2838,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;
@@ -2874,8 +2987,9 @@ static int collision_response(ParticleSimulationData *sim,
/* 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 +2999,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 +3030,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 +3138,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 +3167,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 +3227,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 +3257,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 +3327,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 +3404,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 +3471,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 +3503,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 +3547,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
@@ -3471,34 +3622,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 +3698,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 +3764,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 +3801,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 +3815,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 +3848,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 +3863,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 +3897,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 +3911,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 +3931,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 +4027,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 +4039,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 +4072,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 +4083,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;
+ }
}
}
@@ -4057,8 +4237,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 +4265,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 +4317,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 +4334,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 +4348,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 +4362,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 +4387,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 +4399,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 +4421,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 +4459,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 +4566,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 +4586,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 +4602,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 +4641,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 +4659,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 +4681,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 +4698,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);
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 445205a513a..0a82d086862 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 */
@@ -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;
}
@@ -1035,8 +1089,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 +1134,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 +1164,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 +1203,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 +1220,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 +1261,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 +1274,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 +1310,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 +1337,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 +1357,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 +1449,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 +1478,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 +1515,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 +1567,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 +1791,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 +1833,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 +1843,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 +1869,9 @@ static bool pbvh_grids_node_raycast(PBVH *bvh,
}
}
- if (origco)
+ if (origco) {
origco += gridsize * gridsize;
+ }
}
return hit;
@@ -1792,8 +1887,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,10 +1917,12 @@ 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. */
@@ -1838,15 +1936,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 +2016,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 +2061,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 +2071,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 +2099,9 @@ static bool pbvh_grids_node_nearest_to_ray(PBVH *bvh,
}
}
- if (origco)
+ if (origco) {
origco += gridsize * gridsize;
+ }
}
return hit;
@@ -2014,8 +2118,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 +2170,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 +2233,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 +2254,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 +2283,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]);
+ }
}
}
@@ -2252,8 +2362,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 +2385,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 +2463,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 +2480,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 40172a4778c..bc84b3737aa 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];
@@ -708,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;
@@ -1156,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
@@ -1249,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
@@ -1396,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
@@ -1472,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
@@ -1541,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;
@@ -1819,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);
}
@@ -1860,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");
@@ -2002,8 +2015,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);
@@ -2033,8 +2047,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;
@@ -2116,8 +2131,9 @@ static void pbvh_bmesh_print(PBVH *bvh)
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);
@@ -2267,8 +2283,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 1d0764d1f94..c07ae89e250 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;
@@ -297,14 +304,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 +324,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 +372,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 +417,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 +452,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 +492,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 +544,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 +555,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 +596,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)
@@ -609,8 +632,9 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
"pointcache_lzo_buffer");
//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,
@@ -681,8 +705,9 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
res_big = res_big_array[0] * res_big_array[1] * res_big_array[2];
//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 +856,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 +1351,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 +1423,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 +1454,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 +1479,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 +1505,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 +1605,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 +1633,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 +1736,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;
@@ -2030,8 +2068,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,
@@ -2056,8 +2095,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) {
@@ -2081,21 +2121,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,
@@ -2120,11 +2163,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);
@@ -2141,8 +2186,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;
@@ -2183,8 +2229,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) {
@@ -2224,10 +2271,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
@@ -2247,10 +2296,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
@@ -2260,8 +2311,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;
@@ -2286,8 +2338,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;
@@ -2298,8 +2352,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;
@@ -2312,21 +2367,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;
}
@@ -2335,11 +2394,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;
}
@@ -2372,22 +2433,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;
@@ -2402,8 +2468,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)
@@ -2411,8 +2478,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)
@@ -2429,8 +2497,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;
}
@@ -2441,8 +2510,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)
@@ -2451,8 +2521,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[])
@@ -2461,8 +2532,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]);
+ }
}
}
@@ -2472,8 +2544,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);
@@ -2481,12 +2554,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;
}
@@ -2496,17 +2572,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;
@@ -2521,8 +2601,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;
@@ -2550,14 +2631,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");
@@ -2571,8 +2655,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 {
@@ -2603,12 +2688,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);
}
@@ -2623,8 +2710,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;
}
@@ -2638,8 +2726,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;
}
@@ -2648,14 +2737,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) {
@@ -2689,8 +2781,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));
@@ -2711,8 +2804,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;
}
@@ -2722,12 +2816,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;
}
@@ -2769,8 +2865,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);
@@ -2805,8 +2902,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 */
@@ -2825,16 +2923,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) {
@@ -2859,8 +2959,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 */
@@ -2879,16 +2980,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) {
@@ -2908,8 +3011,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;
@@ -2917,27 +3021,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) {
@@ -2947,11 +3057,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) {
@@ -2961,19 +3073,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;
@@ -2985,8 +3101,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));
}
@@ -3003,8 +3120,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;
}
@@ -3013,16 +3131,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;
}
@@ -3067,13 +3188,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) {
@@ -3083,14 +3206,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;
@@ -3130,26 +3255,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);
@@ -3173,11 +3303,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);
@@ -3195,12 +3327,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);
@@ -3224,19 +3358,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 */
@@ -3252,8 +3389,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
@@ -3283,8 +3421,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;
+ }
}
}
}
@@ -3293,8 +3432,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;
@@ -3309,23 +3449,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;
+ }
}
}
}
@@ -3350,8 +3493,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;
}
@@ -3359,14 +3503,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];
@@ -3379,8 +3526,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;
}
@@ -3451,8 +3599,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);
@@ -3476,8 +3625,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;
}
}
@@ -3488,8 +3638,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;
@@ -3520,19 +3671,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);
}
@@ -3553,17 +3710,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) {
@@ -3598,15 +3758,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;
}
@@ -3627,8 +3789,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)) {
@@ -3687,10 +3850,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)
@@ -3726,8 +3891,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);
@@ -3735,8 +3901,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? */
@@ -3784,14 +3951,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 */
@@ -3823,9 +3993,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 */
@@ -3835,8 +4006,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;
@@ -3847,8 +4019,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);
@@ -3874,8 +4047,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);
@@ -3898,8 +4072,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;
@@ -3979,8 +4154,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 {
@@ -3990,22 +4166,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);
@@ -4041,8 +4221,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)
@@ -4068,8 +4249,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)
{
@@ -4078,8 +4260,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;
}
@@ -4089,10 +4272,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);
@@ -4182,23 +4367,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?*/
@@ -4211,8 +4400,9 @@ void BKE_ptcache_load_external(PTCacheID *pid)
start = MIN2(start, frame);
end = MAX2(end, frame);
}
- else
+ else {
info = 1;
+ }
}
}
}
@@ -4253,8 +4443,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);
}
@@ -4283,17 +4474,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;
}
@@ -4301,18 +4496,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);
@@ -4326,8 +4524,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..b5960962e17 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -109,8 +109,9 @@ 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 */
@@ -135,8 +136,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 +149,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 +164,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 +202,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 +337,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 +421,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 +480,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 +571,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 +595,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 +645,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 +680,15 @@ 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)
+ 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 +712,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 +730,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 +770,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 +880,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 +966,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) {
@@ -959,13 +995,15 @@ static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, b
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 +1024,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 +1107,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 +1136,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 +1167,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 +1283,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 +1407,9 @@ 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;
+ }
if (rbo->shape == RB_SHAPE_TRIMESH && rbo->flag & RBO_FLAG_USE_DEFORM) {
Mesh *mesh = ob->runtime.mesh_deform_eval;
@@ -1387,9 +1432,10 @@ 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) {
@@ -1427,19 +1473,22 @@ static void rigidbody_update_sim_ob(
* - 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 +1513,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.
@@ -1538,8 +1588,9 @@ 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... */
@@ -1587,8 +1638,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,8 +1657,9 @@ 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) &&
@@ -1690,8 +1743,9 @@ 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)
@@ -1765,10 +1819,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
@@ -1836,8 +1892,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..81b1375f0f6 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -355,8 +355,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);
@@ -455,8 +456,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)
@@ -1016,8 +1018,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;
@@ -1204,8 +1207,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 +1253,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 +1302,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 +1317,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++) {
@@ -1590,8 +1600,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 +1642,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 +1657,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;
@@ -1793,14 +1808,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);
}
@@ -1851,8 +1869,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 +1898,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 +1914,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 +1943,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 +1965,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 +1987,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 +2005,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 +2018,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 +2061,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 +2076,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 +2114,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 +2153,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;
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 9fa70d38574..a3ec3364436 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,10 +297,12 @@ 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;
+ }
}
}
}
@@ -398,14 +406,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 +458,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 +489,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 +556,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 +625,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 +709,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 +821,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 +897,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..b022819ca8c 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -111,8 +111,9 @@ static bool seqcache_hashcmp(const void *a_, const void *b_)
void BKE_sequencer_cache_destruct(void)
{
- if (moviecache)
+ if (moviecache) {
IMB_moviecache_free(moviecache);
+ }
preprocessed_cache_destruct();
}
@@ -138,8 +139,9 @@ static bool seqcache_key_check_seq(ImBuf *UNUSED(ibuf), void *userkey, void *use
void BKE_sequencer_cache_cleanup_sequence(Sequence *seq)
{
- if (moviecache)
+ if (moviecache) {
IMB_moviecache_cleanup(moviecache, seqcache_key_check_seq, seq);
+ }
}
struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
@@ -187,8 +189,9 @@ void BKE_sequencer_preprocessed_cache_cleanup(void)
{
SeqPreprocessCacheElem *elem;
- if (!preprocess_cache)
+ if (!preprocess_cache) {
return;
+ }
for (elem = preprocess_cache->elems.first; elem; elem = elem->next) {
IMB_freeImBuf(elem->ibuf);
@@ -200,8 +203,9 @@ void BKE_sequencer_preprocessed_cache_cleanup(void)
static void preprocessed_cache_destruct(void)
{
- if (!preprocess_cache)
+ if (!preprocess_cache) {
return;
+ }
BKE_sequencer_preprocessed_cache_cleanup();
@@ -216,21 +220,26 @@ ImBuf *BKE_sequencer_preprocessed_cache_get(const SeqRenderData *context,
{
SeqPreprocessCacheElem *elem;
- if (!preprocess_cache)
+ if (!preprocess_cache) {
return NULL;
+ }
- if (preprocess_cache->cfra != cfra)
+ if (preprocess_cache->cfra != cfra) {
return NULL;
+ }
for (elem = preprocess_cache->elems.first; elem; elem = elem->next) {
- if (elem->seq != seq)
+ if (elem->seq != seq) {
continue;
+ }
- if (elem->type != type)
+ if (elem->type != type) {
continue;
+ }
- if (seq_cmp_render_data(&elem->context, context) != 0)
+ if (seq_cmp_render_data(&elem->context, context) != 0) {
continue;
+ }
IMB_refImBuf(elem->ibuf);
return elem->ibuf;
@@ -248,8 +257,9 @@ void BKE_sequencer_preprocessed_cache_put(
preprocess_cache = MEM_callocN(sizeof(SeqPreprocessCache), "sequencer preprocessed cache");
}
else {
- if (preprocess_cache->cfra != cfra)
+ if (preprocess_cache->cfra != cfra) {
BKE_sequencer_preprocessed_cache_cleanup();
+ }
}
elem = MEM_callocN(sizeof(SeqPreprocessCacheElem), "sequencer preprocessed cache element");
@@ -270,8 +280,9 @@ void BKE_sequencer_preprocessed_cache_cleanup_sequence(Sequence *seq)
{
SeqPreprocessCacheElem *elem, *elem_next;
- if (!preprocess_cache)
+ if (!preprocess_cache) {
return;
+ }
for (elem = preprocess_cache->elems.first; elem; elem = elem_next) {
elem_next = elem->next;
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 4f50dde4bdb..b2d5609ad07 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -153,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;
}
@@ -163,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;
}
@@ -187,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;
@@ -221,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);
@@ -245,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);
}
@@ -466,8 +473,9 @@ 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();
@@ -572,8 +580,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(
@@ -640,8 +649,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);
+ }
}
}
@@ -652,8 +662,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)++;
@@ -667,22 +678,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)
@@ -699,16 +716,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;
}
@@ -741,11 +761,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,
@@ -765,10 +787,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;
@@ -797,8 +821,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;
}
@@ -806,10 +831,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 */
@@ -851,10 +878,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;
@@ -993,8 +1022,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);
@@ -1005,8 +1035,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;
@@ -1016,8 +1047,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;
@@ -1057,8 +1089,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);
@@ -1074,8 +1107,9 @@ void BKE_sequencer_sort(Scene *scene)
}
seqt = seqt->next;
}
- if (seqt == NULL)
+ if (seqt == NULL) {
BLI_addtail(&effbase, seq);
+ }
}
else {
seqt = seqbase.first;
@@ -1086,8 +1120,9 @@ void BKE_sequencer_sort(Scene *scene)
}
seqt = seqt->next;
}
- if (seqt == NULL)
+ if (seqt == NULL) {
BLI_addtail(&seqbase, seq);
+ }
}
}
@@ -1106,8 +1141,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;
}
@@ -1151,8 +1187,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;
}
@@ -1172,8 +1209,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) {
@@ -1360,24 +1398,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);
@@ -1397,8 +1442,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;
}
@@ -1465,8 +1511,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);
}
@@ -1620,10 +1667,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));
@@ -1744,10 +1793,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);
@@ -1777,17 +1828,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) {
@@ -1887,8 +1941,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;
}
@@ -1941,8 +1996,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);
@@ -1960,8 +2016,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];
@@ -1978,15 +2035,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;
}
@@ -1998,8 +2058,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: {
@@ -2051,8 +2112,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");
@@ -2157,8 +2219,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;
+ }
}
}
@@ -2167,11 +2230,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);
}
@@ -2212,8 +2277,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];
}
@@ -2251,8 +2317,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;
}
@@ -2296,15 +2363,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;
+ }
}
}
@@ -2376,15 +2445,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;
+ }
}
}
@@ -2428,18 +2500,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;
@@ -2490,12 +2566,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);
+ }
}
}
}
@@ -2511,8 +2589,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;
@@ -2530,8 +2609,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);
+ }
}
/*
@@ -2923,16 +3003,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:
@@ -2994,8 +3077,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 */
@@ -3034,13 +3118,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]) {
@@ -3077,8 +3163,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);
@@ -3110,8 +3197,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");
@@ -3137,8 +3225,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]);
+ }
}
}
}
@@ -3485,8 +3574,9 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
/* 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);
@@ -3527,8 +3617,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);
@@ -3745,8 +3836,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);
}
@@ -3763,8 +3855,9 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
}
}
- if (ibuf)
+ if (ibuf) {
sequencer_imbuf_assign_spaces(context->scene, ibuf);
+ }
return ibuf;
}
@@ -3799,8 +3892,9 @@ static ImBuf *seq_render_strip(const SeqRenderData *context,
is_proxy_image = (ibuf != NULL);
}
- if (ibuf == NULL)
+ if (ibuf == NULL) {
ibuf = do_render_strip_uncached(context, state, seq, cfra);
+ }
if (ibuf) {
if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) {
@@ -3811,8 +3905,9 @@ static ImBuf *seq_render_strip(const SeqRenderData *context,
}
}
- 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,
@@ -3831,8 +3926,9 @@ static ImBuf *seq_render_strip(const SeqRenderData *context,
use_preprocess = true;
}
- if (use_preprocess)
+ if (use_preprocess) {
ibuf = input_preprocess(context, seq, cfra, ibuf, is_proxy_image, is_preprocessed);
+ }
BKE_sequencer_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf);
@@ -3885,18 +3981,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;
@@ -4058,8 +4158,9 @@ ImBuf *BKE_sequencer_give_ibuf(const SeqRenderData *context, float cfra, int cha
Editing *ed = BKE_sequencer_editing_get(context->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);
@@ -4238,16 +4339,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
@@ -4266,16 +4370,18 @@ static void sequence_do_invalidate_dependent(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);
}
- if (cur->seqbase.first)
+ if (cur->seqbase.first) {
sequence_do_invalidate_dependent(seq, &cur->seqbase);
+ }
}
}
@@ -4297,11 +4403,13 @@ static void sequence_invalidate_cache(Scene *scene,
}
/* 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)
+ if (invalidate_preprocess) {
BKE_sequencer_preprocessed_cache_cleanup_sequence(seq);
+ }
/* invalidate cache for all dependent sequences */
@@ -4363,25 +4471,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) {
@@ -4393,8 +4511,9 @@ static bool update_changed_seq_recurs(
}
}
- if (len_change)
+ if (len_change) {
BKE_sequence_calc(scene, seq);
+ }
}
return free_imbuf;
@@ -4408,11 +4527,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
@@ -4500,13 +4621,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) ||
@@ -4576,8 +4699,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 */
@@ -4619,8 +4743,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;
}
@@ -4666,12 +4791,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,
@@ -4720,8 +4847,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;
@@ -4781,8 +4909,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;
@@ -4902,8 +5031,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);
}
@@ -4921,10 +5051,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);
+ }
}
}
@@ -5062,8 +5194,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);
@@ -5097,8 +5230,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);
@@ -5126,8 +5260,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);
@@ -5156,8 +5291,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;
@@ -5194,8 +5330,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;
}
@@ -5204,8 +5341,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;
}
@@ -5275,8 +5413,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++;
@@ -5338,8 +5477,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);
}
@@ -5399,8 +5539,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;
@@ -5592,8 +5733,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;
@@ -5660,8 +5802,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 */
@@ -5675,8 +5818,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);
@@ -5688,8 +5832,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;
}
@@ -5726,12 +5871,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;
@@ -5741,8 +5889,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;
+ }
}
}
@@ -5855,8 +6004,9 @@ int BKE_sequencer_find_next_prev_edit(Scene *scene,
best_dist = MAXFRAME * 2;
- if (ed == NULL)
+ if (ed == NULL) {
return cfra;
+ }
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
int i;
@@ -5865,8 +6015,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;
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..3cd2131c22b 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -378,10 +378,12 @@ static void shrinkwrap_calc_nearest_vertex_cb_ex(void *__restrict userdata,
* 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);
@@ -647,23 +649,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 +682,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);
}
@@ -1036,8 +1044,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);
@@ -1146,8 +1155,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 +1385,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 +1473,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 50c72f5a57f..a815aaefb29 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"
@@ -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;
@@ -901,8 +920,9 @@ static void obstacles_from_mesh(Object *coll_ob,
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 +983,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 +1105,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 +1150,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 +1180,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 +1215,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 +1262,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 +1301,8 @@ static void em_combineMaps(
}
}
} // high res loop
+ }
+ }
}
/* free original data */
@@ -1394,12 +1426,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 +1465,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 +1522,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 +1577,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 +1660,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;
@@ -1777,7 +1819,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 +1892,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 +2023,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 +2034,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 +2053,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 +2063,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 +2125,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 +2159,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 +2175,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 +2264,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 +2279,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 +2321,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 +2341,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 +2408,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 */
@@ -2604,8 +2685,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 +2701,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(
@@ -2687,8 +2769,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 +2852,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 +2867,9 @@ static void update_flowsfluids(
}
BKE_collision_objects_free(flowobjs);
- if (emaps)
+ if (emaps) {
MEM_freeN(emaps);
+ }
}
typedef struct UpdateEffectorsData {
@@ -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 37b6211916c..6903021e0cf 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -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(
@@ -636,8 +646,9 @@ 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;
@@ -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);
@@ -1532,8 +1554,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 +1567,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 +1741,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 +1753,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 +1777,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 +1795,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);
}
@@ -1874,15 +1904,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;
@@ -1978,8 +2012,9 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
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 */
@@ -2115,8 +2150,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);
@@ -2186,8 +2222,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;
@@ -2199,13 +2236,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);
}
@@ -2235,8 +2274,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);
@@ -2258,8 +2298,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);
@@ -2294,15 +2335,18 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
/* 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 */
@@ -2332,8 +2376,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 */
@@ -2381,22 +2426,26 @@ 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);
if (fuzzy) {
*err /= sb->fuzzyness;
@@ -2607,10 +2656,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);
@@ -2913,8 +2964,9 @@ 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) {
@@ -2995,8 +3047,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 */
+ }
}
}
}
@@ -3004,8 +3057,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;
@@ -3063,8 +3117,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;
@@ -3087,8 +3142,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;
@@ -3134,8 +3190,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 */
@@ -3175,11 +3232,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 */
@@ -3190,13 +3249,16 @@ 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)
+ 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);
@@ -3250,8 +3312,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;
@@ -3275,8 +3338,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);
@@ -3300,13 +3364,16 @@ static void softbody_step(
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)) {
@@ -3352,20 +3419,24 @@ static void softbody_step(
timedone += forcetime;
newtime = min_ff(forcetimemax, max_ff(newtime, forcetimemin));
//if (newtime > forcetime) printf("up, ");
- if (forcetime > 0.0f)
+ 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);
@@ -3373,8 +3444,9 @@ 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) {
@@ -3398,8 +3470,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);
+ }
}
}
@@ -3507,15 +3580,16 @@ 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 &
@@ -3527,12 +3601,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 118d307eb7c..857d59d9e5c 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -97,14 +97,16 @@ 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);
}
@@ -190,8 +192,9 @@ 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;
@@ -199,12 +202,15 @@ static void sound_sync_callback(void *data, int mode, float time)
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;
}
@@ -256,23 +262,29 @@ 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);
}
@@ -280,8 +292,9 @@ void BKE_sound_init(struct Main *bmain)
void BKE_sound_init_main(struct Main *bmain)
{
# ifdef WITH_JACK
- if (sound_device)
+ if (sound_device) {
AUD_setSynchronizerCallback(sound_sync_callback, bmain);
+ }
# else
(void)bmain; /* unused */
# endif
@@ -353,14 +366,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)
@@ -405,23 +421,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
@@ -435,10 +455,12 @@ 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);
}
@@ -452,8 +474,9 @@ AUD_Device *BKE_sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int st
void BKE_sound_create_scene(struct 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);
@@ -466,14 +489,18 @@ void BKE_sound_create_scene(struct Scene *scene)
void BKE_sound_destroy_scene(struct 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)
@@ -488,14 +515,16 @@ void BKE_sound_reset_scene_specs(struct Scene *scene)
void BKE_sound_mute_scene(struct 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)
{
- if (scene->sound_scene)
+ if (scene->sound_scene) {
AUD_Sequence_setFPS(scene->sound_scene, FPS);
+ }
BKE_sequencer_refresh_sound_length(scene);
}
@@ -633,13 +662,15 @@ void BKE_sound_update_sequencer(struct Main *main, bSound *sound)
static void sound_start_play_scene(struct 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)
@@ -666,8 +697,9 @@ 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);
}
@@ -677,8 +709,9 @@ void BKE_sound_stop_scene(struct 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();
+ }
}
}
@@ -749,14 +782,17 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
float BKE_sound_sync_scene(struct 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;
}
@@ -764,13 +800,16 @@ float BKE_sound_sync_scene(struct Scene *scene)
int BKE_sound_scene_playing(struct 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)
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index df48e505f6f..315bd0cabc9 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);
@@ -543,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);
@@ -659,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];
@@ -834,12 +834,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;
@@ -1026,12 +1025,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
@@ -1165,8 +1163,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);
@@ -1200,8 +1197,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) {
@@ -1223,8 +1219,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);
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..a58d1eaff3e 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);
@@ -303,19 +309,23 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
* 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,
@@ -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);
@@ -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;
@@ -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,8 +2248,9 @@ 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) {
@@ -2313,6 +2361,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
me->mvert,
me->totvert,
&me->vdata,
+ &me->ldata,
looptri,
looptris_num);
@@ -2692,8 +2741,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 +2782,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 +2962,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 +3031,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 +3043,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 +3096,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..42e1ef6fa0a 100644
--- a/source/blender/blenkernel/intern/suggestions.c
+++ b/source/blender/blenkernel/intern/suggestions.c
@@ -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 930f9ac5ee8..9047aa51dea 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");
@@ -545,25 +551,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 +585,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 +611,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 +627,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 +664,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 +707,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 +728,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 +746,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 +817,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 +831,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 +851,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 +861,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 +881,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 +892,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 +934,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 +967,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 +977,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 +1011,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 +1021,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 +1045,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 +1069,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 +1091,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 +1113,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 +1136,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 +1166,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 +1241,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 +1273,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 +1303,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 +1338,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 +1358,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 +1425,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 +1468,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 +1480,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 +1565,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);
@@ -2267,8 +2363,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;
}
@@ -2559,27 +2656,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 */
@@ -2604,15 +2705,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);
@@ -2624,8 +2728,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");
@@ -2646,8 +2751,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);
@@ -2656,8 +2762,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);
+ }
}
}
@@ -2665,8 +2772,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);
@@ -2678,8 +2786,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;
@@ -2697,8 +2806,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)
@@ -2712,8 +2822,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);
@@ -2721,8 +2832,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;
@@ -2749,8 +2861,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)
@@ -2780,8 +2893,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);
@@ -2796,8 +2910,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);
@@ -2842,8 +2957,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') {
@@ -2913,13 +3029,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);
@@ -2939,10 +3057,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;
@@ -2983,8 +3103,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;
@@ -3004,8 +3125,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 {
@@ -3014,8 +3136,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;
@@ -3099,15 +3222,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);
@@ -3136,8 +3261,9 @@ 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;
@@ -3195,10 +3321,12 @@ 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;
}
@@ -3210,50 +3338,64 @@ bool text_check_delim(const char ch)
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;
}
@@ -3271,8 +3413,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..dd307880eb6 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);
@@ -254,9 +260,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;
}
@@ -466,8 +470,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 +499,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 +511,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 +535,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 +558,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 +584,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 +599,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 +615,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..73f50be612e 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);
}
@@ -406,16 +409,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 +449,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 +665,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 +677,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 +699,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 +765,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 +788,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 +852,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 +873,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 +931,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 +978,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 +996,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 +1016,9 @@ static bGPDlayer *track_mask_gpencil_layer_get(MovieTrackingTrack *track)
frame = frame->next;
}
- if (ok)
+ if (ok) {
return layer;
+ }
}
layer = layer->next;
@@ -1084,10 +1113,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 +1194,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 +1209,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 +1288,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 +1329,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 +1377,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 +1676,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 +1753,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 +1894,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 +1905,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 +1917,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 +1944,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 +1964,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 +2012,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 +2049,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) {
@@ -2064,8 +2126,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 +2254,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 +2411,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 +2433,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 +2461,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 +2494,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 +2521,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 +2636,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 +2664,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 +2715,9 @@ void BKE_tracking_disable_channels(
}
}
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
ibuf->userflags |= IB_RECT_INVALID;
+ }
}
/*********************** Dopesheet functions *************************/
@@ -2655,10 +2729,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 +2742,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 +2755,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 +2768,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 +2811,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 +2845,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 +2863,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 +2884,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 +2924,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 +2991,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 +3031,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 +3042,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 +3097,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_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..0d2113aebe8 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.
@@ -256,8 +258,9 @@ static bool configure_and_run_tracker(ImBuf *destination_ibuf,
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 +292,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 +362,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 +387,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/unit.c b/source/blender/blenkernel/intern/unit.c
index ac8e35cd781..aa08370e139 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);
@@ -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;
}
@@ -789,15 +808,17 @@ static const bUnitDef *unit_detect_from_str(const bUnitCollection *usys,
/* 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 +833,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 +850,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 +877,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;
@@ -880,8 +905,9 @@ 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;
@@ -901,8 +927,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 +992,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 +1015,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 +1030,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/world.c b/source/blender/blenkernel/intern/world.c
index 8dcd31a13c9..741d67296df 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -144,8 +144,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..8456a2cddfc 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 */
@@ -630,8 +640,9 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
//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;
@@ -786,8 +798,9 @@ static AVStream *alloc_audio_stream(FFMpegContext *context,
*/
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 */
@@ -833,16 +846,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 +871,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 +1057,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 +1071,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 +1200,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;
@@ -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) {
/*
@@ -1643,8 +1667,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 +1677,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 +1819,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/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_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_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_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 b303794276e..150aea7da5f 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_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 4860fa6c669..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.
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 f8a34404cc7..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)
+ 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..92553ae89a9 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -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..32b6e1a5465 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/which-hashing-algorithm-is-best-for-uniqueness-and-speed
*
- * \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 668308581e7..fa018cca642 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],
@@ -2868,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],
@@ -3131,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])
@@ -3408,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)) {
@@ -3469,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])
@@ -3524,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) : \
@@ -4338,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.
*/
@@ -4814,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
*
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index 380603913f1..14fde18aa52 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -512,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,
@@ -621,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/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/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/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..5e4fe4ce269 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);
@@ -438,7 +446,9 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
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 +461,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 6acf0a76fa9..16e8c040fda 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -344,8 +344,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 +354,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 +370,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 +416,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 +439,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 +554,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 +578,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 +600,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 +667,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 +689,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 +704,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 +718,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 +1058,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 +1081,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 +1196,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 +1237,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 +1395,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 +1443,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 +1472,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 +1526,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 +1534,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 +1611,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 +1674,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 +1730,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 +1817,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 +1834,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 +1886,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 +1925,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 +1944,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 +1962,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 +1973,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 +1997,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 +2030,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 +2043,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 +2059,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 +2075,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 +2085,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 +2106,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 +2149,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 +2159,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 +2187,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 +2292,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 +2324,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 +2366,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 +2419,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 +2437,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 +2546,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 +2657,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 +2745,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 +2761,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 +2852,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 +2885,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 +2898,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 +2940,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 +2954,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 +3040,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 +3055,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 +3139,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 +3228,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 +3256,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);
@@ -3415,8 +3502,9 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
/* verify static socket templates */
FOREACH_NODETREE_BEGIN (main, ntree, id) {
bNode *node;
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
node_verify_socket_templates(ntree, node);
+ }
}
FOREACH_NODETREE_END;
@@ -3440,8 +3528,9 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
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))
+ if (ngroup && (ngroup->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2)) {
lib_node_do_versions_group_indices(node);
+ }
}
}
}
@@ -3485,11 +3574,13 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
/*static const float offsety = 0.0f;*/
if (create_io_nodes) {
- if (ntree->inputs.first)
+ if (ntree->inputs.first) {
input_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_INPUT);
+ }
- if (ntree->outputs.first)
+ if (ntree->outputs.first) {
output_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_OUTPUT);
+ }
}
/* Redirect links from/to the node tree interface to input/output node.
@@ -3508,8 +3599,9 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
++num_inputs;
if (link->tonode) {
- if (input_locx > link->tonode->locx - offsetx)
+ if (input_locx > link->tonode->locx - offsetx) {
input_locx = link->tonode->locx - offsetx;
+ }
input_locy += link->tonode->locy;
}
}
@@ -3525,8 +3617,9 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
++num_outputs;
if (link->fromnode) {
- if (output_locx < link->fromnode->locx + offsetx)
+ if (output_locx < link->fromnode->locx + offsetx) {
output_locx = link->fromnode->locx + offsetx;
+ }
output_locy += link->fromnode->locy;
}
}
@@ -3535,8 +3628,9 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open))
}
}
- if (free_link)
+ if (free_link) {
nodeRemLink(ntree, link);
+ }
}
if (num_inputs > 0) {
@@ -3698,19 +3792,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);
@@ -3724,8 +3822,7 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
bNodeInstanceHash *new_previews = BKE_node_instance_hash_new("node previews");
bNodeInstanceHashIterator iter;
- NODE_INSTANCE_HASH_ITER(iter, ntree->previews)
- {
+ NODE_INSTANCE_HASH_ITER(iter, ntree->previews) {
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
if (preview) {
bNodePreview *new_preview = newimaadr(fd, preview);
@@ -3847,8 +3944,9 @@ 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: {
@@ -3863,8 +3961,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;
@@ -3880,8 +3979,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]) {
@@ -3959,8 +4059,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)
@@ -4052,8 +4153,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) {
@@ -4140,8 +4242,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);
+ }
}
}
@@ -4327,10 +4430,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) {
@@ -4458,8 +4563,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;
@@ -4471,8 +4577,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);
@@ -4619,8 +4726,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)
@@ -4628,8 +4736,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;
@@ -4672,10 +4781,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)
@@ -4751,8 +4862,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)
@@ -4768,18 +4880,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);
@@ -4815,8 +4931,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);
@@ -4851,8 +4968,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) {
@@ -4875,8 +4993,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);
@@ -4904,8 +5023,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;
@@ -5044,8 +5164,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;
+ }
}
}
}
@@ -5057,8 +5178,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);
+ }
}
}
}
@@ -5082,17 +5204,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++;
}
}
@@ -5165,8 +5290,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);
}
@@ -5319,10 +5445,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 */
@@ -5335,10 +5463,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;
@@ -5358,8 +5488,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] */
@@ -5396,9 +5527,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
+ }
}
{
@@ -5412,8 +5544,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);
@@ -5437,8 +5570,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;
+ }
}
}
}
@@ -5453,8 +5587,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);
@@ -5468,8 +5603,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);
@@ -5492,8 +5628,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);
@@ -5502,7 +5639,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) {
@@ -5521,8 +5658,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;
@@ -5546,8 +5684,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;
@@ -5595,8 +5734,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);
@@ -5664,8 +5804,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);
+ }
}
}
}
@@ -5753,16 +5894,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) {
@@ -5774,15 +5920,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;
@@ -5827,9 +5975,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 ||
@@ -5860,8 +6009,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;
@@ -5898,8 +6048,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;
+ }
}
}
@@ -5907,7 +6058,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
@@ -5930,8 +6082,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);
@@ -6021,8 +6174,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) {
@@ -6046,8 +6200,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);
@@ -6115,8 +6270,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);
+ }
}
/** \} */
@@ -6334,8 +6490,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;
+ }
}
}
@@ -6360,8 +6517,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);
+ }
}
}
@@ -6414,8 +6572,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) {
@@ -6460,21 +6619,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);
@@ -6494,8 +6657,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);
}
}
@@ -6504,9 +6668,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);
@@ -6558,12 +6723,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) {
@@ -6649,21 +6817,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);
@@ -6687,8 +6859,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;
@@ -6785,14 +6958,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;
@@ -6854,7 +7029,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;
@@ -6870,10 +7046,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));
@@ -6881,15 +7059,18 @@ 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;
+ }
}
}
}
@@ -6962,8 +7143,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);
@@ -6993,10 +7175,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. */
@@ -7051,8 +7235,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);
@@ -7237,11 +7422,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;
@@ -7261,10 +7448,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);
}
@@ -7569,11 +7758,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 */
@@ -7654,7 +7845,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);
@@ -7884,7 +8076,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;
@@ -7950,9 +8143,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)
@@ -7983,9 +8177,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]
@@ -8032,17 +8227,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;
@@ -8098,11 +8295,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 */
@@ -8119,8 +8318,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;
@@ -8207,8 +8407,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)
@@ -8255,8 +8456,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. */
@@ -8293,7 +8495,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;
@@ -8313,7 +8516,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);
@@ -8481,15 +8685,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);
@@ -8592,8 +8800,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 */
@@ -8894,17 +9103,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]);
}
@@ -9038,11 +9251,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);
@@ -9056,9 +9272,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);
@@ -9078,12 +9296,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... */
}
@@ -9113,10 +9333,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);
@@ -9290,19 +9512,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;
@@ -9324,8 +9551,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;
+ }
}
}
@@ -9342,13 +9570,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);
@@ -9433,7 +9663,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);
@@ -9528,14 +9759,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) {
@@ -9733,10 +9967,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;
}
@@ -9746,12 +9982,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");
@@ -9766,12 +10004,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;
@@ -9784,17 +10024,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)) {
@@ -9923,8 +10166,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);
@@ -9941,8 +10188,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);
@@ -9957,8 +10205,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);
+ }
}
}
@@ -9981,8 +10230,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:
@@ -10110,8 +10360,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)
@@ -10124,8 +10375,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]) {
@@ -10191,8 +10443,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)
@@ -10200,11 +10453,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) {
@@ -10213,16 +10468,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)
@@ -10230,11 +10489,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)
@@ -10252,11 +10513,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;
@@ -10269,11 +10532,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)
@@ -10281,19 +10546,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)
@@ -10304,8 +10572,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)
@@ -10326,16 +10595,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]);
@@ -10373,8 +10644,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
+ }
}
}
@@ -10382,8 +10654,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);
@@ -10403,8 +10676,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);
@@ -10491,27 +10765,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);
@@ -10564,25 +10844,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);
}
}
@@ -10604,8 +10889,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;
@@ -10613,16 +10899,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;
@@ -10664,8 +10955,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)
@@ -10679,8 +10971,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)
@@ -10690,14 +10983,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)
@@ -10711,8 +11006,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;
@@ -10742,22 +11038,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);
+ }
}
}
@@ -10951,7 +11252,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)) {
@@ -10960,7 +11262,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;
}
@@ -10990,7 +11293,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);
@@ -11053,14 +11357,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) {
@@ -11143,8 +11449,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;
@@ -11179,8 +11486,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 ||
@@ -11252,8 +11560,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(
@@ -11294,10 +11604,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)
{
@@ -11375,7 +11686,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);
@@ -11394,7 +11706,8 @@ static void library_link_end(Main *mainl,
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);
@@ -11424,9 +11737,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,
@@ -11610,8 +11926,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();
@@ -11663,7 +11980,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);
@@ -11694,21 +12015,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..1122950771c 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
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..d7c26564576 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);
@@ -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: {
@@ -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:
@@ -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++;
+ }
+ }
}
}
@@ -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);
@@ -1954,14 +2049,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 +2077,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 +2182,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 +2193,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 +2221,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 +2252,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 +2279,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;
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 785e6b4016e..6c9ec7607a2 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -106,7 +106,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 +119,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 +205,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 +239,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 +300,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 +312,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 +466,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 +549,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 +571,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 +643,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 +665,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 +683,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 +721,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 +754,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 +779,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;
}
@@ -824,8 +857,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 +873,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 +916,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 +939,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 +977,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 +1015,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 +1033,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 +1047,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 +1074,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 +1130,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 +1242,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 +1425,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 +1516,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 +1566,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 +1788,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 +1806,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 +1820,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 +1835,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,7 +1949,8 @@ 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 ... */
+ /* 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!
@@ -1891,8 +1964,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* 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))
+ if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE;
+ }
}
FOREACH_NODETREE_END;
}
@@ -1907,11 +1981,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,8 +2010,9 @@ 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
}
@@ -1979,8 +2056,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 +2098,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 +2121,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 +2180,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 +2202,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 +2263,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 +2392,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 +2494,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;
+ }
}
}
}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 69416f08205..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,7 +1164,8 @@ 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)
@@ -1191,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) {
@@ -1324,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...
@@ -1435,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 a68da431d57..73109cd9a6b 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;
}
@@ -591,17 +598,25 @@ static void do_versions_remove_region(ListBase *regionbase, int regiontype)
}
}
-static ARegion *do_versions_find_region(ListBase *regionbase, int regiontype)
+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;
}
}
- BLI_assert(!"Did not find expected region in versioning");
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);
@@ -609,6 +624,74 @@ static ARegion *do_versions_add_region(int regiontype, const char *name)
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;
@@ -657,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);
@@ -750,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) {
@@ -838,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]);
@@ -850,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__);
@@ -975,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) {
@@ -1803,7 +1893,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;
}
@@ -3116,6 +3207,39 @@ 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. */
+ if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_IMAGE) &&
+ (do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER) == NULL)) {
+ /* Add tool header. */
+ ARegion *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);
+ }
+ }
+ }
+ }
}
{
@@ -3136,6 +3260,46 @@ 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);
+ }
+
/* Versioning code until next subversion bump goes here. */
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 25bd738ce45..b5b86224644 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;
@@ -328,8 +328,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 +353,8 @@ 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);
}
+
+ 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..6329a3959b9 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--;
+ }
}
}
}
@@ -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..91f605460c9 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -157,14 +157,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 +179,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 +200,21 @@ 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)
+ 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 +227,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 +250,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 +336,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 +360,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 +376,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 +524,26 @@ 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;
+ }
+ }
+
/**
* 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..4abe873403d 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2175,10 +2175,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 +2776,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");
@@ -3740,9 +3741,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. */
@@ -3893,7 +3895,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 +3910,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);
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/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 5dcf6acad57..36abb1dc5c4 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
@@ -162,7 +162,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 +237,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 +373,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
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index a802515a3b2..f97ae0ace1e 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -750,8 +750,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_log.c b/source/blender/bmesh/intern/bmesh_log.c
index fd9439eb158..e6696236fac 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);
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 606051ebefa..8728186ef33 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -749,8 +749,7 @@ bool BM_face_validate(BMFace *face, FILE *err)
}
BLI_array_grow_items(verts, face->len);
- BM_ITER_ELEM_INDEX(l, &iter, face, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &iter, face, BM_LOOPS_OF_FACE, i) {
verts[i] = l->v;
if (l->e->v1 == l->e->v2) {
fprintf(err, "Found bmesh edge with identical verts!\n");
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 3f2c93f570e..1a0e167b93d 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -1432,8 +1432,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;
@@ -1451,8 +1450,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;
}
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index 1986a1c782d..d7266121874 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -1841,8 +1841,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);
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..c97a5c0f38e 100644
--- a/source/blender/bmesh/operators/bmo_fill_grid.c
+++ b/source/blender/bmesh/operators/bmo_fill_grid.c
@@ -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_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..3ed74d68317 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) {
@@ -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;
}
@@ -1582,8 +1576,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) {
@@ -1720,8 +1713,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_rotate_edges.c b/source/blender/bmesh/operators/bmo_rotate_edges.c
index e017806df0d..b999e942d10 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);
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..66021624025 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -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_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 2c304d790df..3cb4cbfdf41 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -2990,11 +2990,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 +3070,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);
+ }
}
}
}
@@ -6357,11 +6360,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 +6392,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 +6507,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 +6542,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_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/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/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/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_Debug.cpp b/source/blender/compositor/intern/COM_Debug.cpp
index b977154db1a..8632b7ad0f0 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=\"{",
@@ -368,8 +375,9 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
/* 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(""));
@@ -407,8 +415,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..367362c2c66 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -96,8 +96,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();
@@ -342,8 +343,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 +403,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_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 12cd55c95a3..01a8a86bb15 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -158,10 +158,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 +174,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 +201,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 +217,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_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp
index 89f4542d42f..39dc946f3bc 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) {
@@ -305,11 +313,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..968dc171bd3 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -365,8 +365,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..853e0e768d3 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) {
@@ -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..c3d1e0cf511 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -239,8 +239,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 +252,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 +263,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/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.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_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_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_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..c48c39f7726 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -28,8 +28,9 @@ inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float g
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 6caaf227ef2..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;
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index 7b63d3ef3cb..c47e4d560a5 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()) :
@@ -95,8 +96,9 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
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)
+ 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_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index 34f0d2cb760..cd1dae2c9b5 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -1340,8 +1340,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..8d11328b63b 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,34 @@ 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)
+ 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..ff75fb7090f 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;
}
//------------------------------------------------------------------------------
@@ -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];
}
}
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..46bd015163b 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
@@ -73,10 +73,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..da594be2268 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();
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..f6cbb8f69c1 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
@@ -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);
@@ -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..90bc859a1bb 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,
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 e7f33cd2c79..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;
}
@@ -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_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_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index f23057bbe8e..4cc9d7a748c 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -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..fb86b04cff7 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -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;
@@ -409,8 +424,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 +440,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 +472,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 +501,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 +586,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 +625,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 +722,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 +747,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 +821,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 +892,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..cb119fb4f1d 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());
}
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/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..c4a2fc71d1b 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -335,7 +335,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. */
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..c1f904150f3 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,
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_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/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 01b712fcd87..49975407c0b 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.
*
@@ -841,6 +840,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 +855,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 +889,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 +912,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 +961,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 +988,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/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..bdf450fab9c 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
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/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/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index fdaec58977f..9ed0ab9a5d4 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -870,8 +870,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;
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..ea33c004191 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,
@@ -433,12 +467,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 +493,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++;
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 320b621f903..8c2dee66d92 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 */
@@ -1621,6 +1648,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 +1717,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 +1746,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 +1772,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;
@@ -1887,9 +1926,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);
@@ -1980,10 +2016,10 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data,
/* 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.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 40937f317ad..e6a3f45d60d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_render.c
+++ b/source/blender/draw/engines/gpencil/gpencil_render.c
@@ -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/shaders/gpencil_point_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
index c8af822bc9e..b7206ac2e80 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,9 @@ uniform sampler2D myTexture;
uniform float gradient_f;
uniform vec2 gradient_s;
+uniform vec4 colormix;
+uniform float mix_stroke_factor;
+
in vec4 mColor;
in vec2 mTexCoord;
out vec4 fragColor;
@@ -21,23 +24,40 @@ out vec4 fragColor;
#define GPENCIL_COLOR_PATTERN 2
/* 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);
@@ -47,7 +67,15 @@ void main()
}
/* texture */
if (color_type == GPENCIL_COLOR_TEXTURE) {
- fragColor = texture2D(myTexture, mTexCoord);
+ 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);
}
@@ -59,11 +87,13 @@ void main()
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_stroke_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
index 35d07306361..8964bee69ff 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,9 @@ uniform sampler2D myTexture;
uniform float gradient_f;
+uniform vec4 colormix;
+uniform float mix_stroke_factor;
+
in vec4 mColor;
in vec2 mTexCoord;
in vec2 uvfac;
@@ -46,7 +49,14 @@ void main()
/* texture */
if (color_type == GPENCIL_COLOR_TEXTURE) {
- fragColor = text_color;
+ 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);
}
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/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index 91f4f351c7b..efbe33b45da 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,
@@ -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_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c
index 782e85597d7..1117ee0126b 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);
@@ -579,9 +580,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 +595,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 +641,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..6151c1f54dd 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"
@@ -67,7 +68,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 +91,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 +132,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 +169,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 +194,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 +208,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 +291,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/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 12d4ca95a39..7d1f0568e63 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -1110,14 +1110,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.curveInX = ebone->curveInX;
- param.curveInY = ebone->curveInY;
+ param.scale_out_x = ebone->scale_out_x;
+ param.scale_out_y = ebone->scale_out_y;
- param.curveOutX = ebone->curveOutX;
- param.curveOutY = ebone->curveOutY;
+ param.curve_in_x = ebone->curve_in_x;
+ param.curve_in_y = ebone->curve_in_y;
+
+ 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);
}
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 7099f6ca573..8a13d8be622 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -482,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};
@@ -659,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};
@@ -1746,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;
@@ -1783,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;
@@ -4023,4 +4031,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_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 94d8a82f2e4..e4ce3ed9d49 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);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 630cbd20319..dcc249e90cf 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -364,6 +364,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);
@@ -1997,7 +2002,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 +2128,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;
}
@@ -4198,16 +4207,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;
@@ -4420,8 +4429,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);
@@ -4520,8 +4528,7 @@ static void uvedit_fill_buffer_data(MeshRenderData *rdata,
}
}
- 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);
@@ -4717,6 +4724,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)
@@ -4733,6 +4762,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);
@@ -4757,6 +4798,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 */
@@ -4929,15 +4971,7 @@ 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);
}
}
}
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 9e078fd2774..31dd5828649 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)
* \{ */
@@ -2294,42 +2347,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).
*/
@@ -2446,21 +2463,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 +2508,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)
{
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..de3505b4ccd 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -634,6 +634,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 +665,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 +698,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 +981,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 */
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 79c1d77bbf1..c5e3ecd0752 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -617,9 +617,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 */
@@ -1231,12 +1231,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;
@@ -1260,11 +1261,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);
}
}
}
@@ -1273,11 +1273,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/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 786146dc2ff..7d42f59fea0 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -511,6 +511,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 +560,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 */
@@ -1853,8 +1854,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 +1880,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];
diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c
index b25a8af795b..e5d10a5d6e1 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);
}
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 50e9c3677f9..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
@@ -17,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 = (doEdges && ((edge_flag & EDGE_SELECTED) != 0)) ? colorEdgeSelect : 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;
}
@@ -46,10 +51,10 @@ vec4 EDIT_MESH_vertex_color(int vertex_flag)
vec4 EDIT_MESH_face_color(int face_flag)
{
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) ? mix(colorFaceSelect, colorEditMeshActive, 0.5) :
- 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;
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 5f1008b2f72..2c2cd1f0610 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
@@ -29,7 +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);
- FragColor.a *= (selectEdges) ? 1.0 : 0.4;
}
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 f25724d2e91..047bd1dccc6 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
@@ -13,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();
@@ -70,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_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
index 6b93193c9ae..d700e69fb57 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
@@ -82,8 +82,7 @@ void main()
float facing = dot(view_vec, view_normal);
facing = 1.0 - abs(facing) * 0.2;
- finalColor = mix(colorEditMeshMiddle, finalColor, facing);
- finalColor.a = 1.0;
+ finalColor.rgb = mix(colorEditMeshMiddle.rgb, finalColor.rgb, facing);
#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 225bad1b35b..bab76911449 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -298,8 +298,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 +312,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 +356,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 +384,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 */
@@ -476,8 +483,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
@@ -635,8 +643,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 */
@@ -710,8 +719,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 */
@@ -803,8 +813,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 */
@@ -843,20 +854,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);
+ }
}
}
@@ -884,8 +899,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 */
@@ -1038,10 +1054,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);
@@ -1491,8 +1509,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 */
@@ -1571,8 +1590,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 */
@@ -1656,8 +1676,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 */
@@ -1821,8 +1842,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 */
@@ -1909,8 +1931,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 */
@@ -1987,8 +2010,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 */
@@ -2065,8 +2089,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 */
@@ -2143,8 +2168,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 */
@@ -2223,8 +2249,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 */
@@ -2301,8 +2328,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 */
@@ -2392,8 +2420,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 */
@@ -2472,8 +2501,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 */
@@ -2550,8 +2580,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 */
@@ -2629,8 +2660,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 */
@@ -2708,8 +2740,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 */
@@ -2788,8 +2821,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 */
@@ -2907,10 +2941,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);
+ }
}
}
@@ -3097,8 +3133,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 */
@@ -3275,8 +3312,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 */
@@ -3386,8 +3424,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 */
@@ -3558,10 +3597,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
@@ -3754,17 +3795,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;
+ }
}
/* --------------------------- */
@@ -3775,26 +3819,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");
+ }
}
/* --------------------------- */
@@ -3824,28 +3873,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;
+ }
}
}
}
@@ -3855,7 +3910,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) { \
@@ -3960,14 +4016,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;
@@ -3976,10 +4035,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(
@@ -3987,8 +4048,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)) {
@@ -4022,8 +4084,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);
@@ -4061,10 +4123,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);
@@ -4130,39 +4194,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,
@@ -4221,8 +4293,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);
@@ -4299,8 +4372,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(
@@ -4358,20 +4432,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);
}
@@ -4402,20 +4479,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);
+ }
}
}
@@ -4448,12 +4528,15 @@ static void draw_setting_widget(bAnimContext *ac,
//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:
@@ -4487,10 +4570,12 @@ static void draw_setting_widget(bAnimContext *ac,
//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 */
@@ -4533,16 +4618,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) {
@@ -4656,8 +4745,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;
@@ -4853,7 +4943,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);
}
@@ -4900,17 +4991,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... */
@@ -4931,7 +5025,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,
@@ -4977,7 +5072,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,
@@ -4990,15 +5086,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 67ec5a95913..d0eb2d187fd 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;
@@ -501,14 +513,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 +531,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 +546,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
+ /* 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
+ }
+ else {
continue;
+ }
}
}
}
@@ -551,8 +567,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 +579,16 @@ 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,
+ /* 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
+ }
+ else {
break;
+ }
/* store this level as the 'old' level now */
// prevLevel = level; // XXX: prevLevel is unused
@@ -586,8 +605,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
@@ -649,11 +669,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 +688,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 +749,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 +933,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 +942,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 +1015,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 +1028,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 +1073,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 +1101,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 +1129,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 +1223,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);
@@ -1240,12 +1279,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 +1314,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 +1328,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 +1355,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 +1400,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 +1470,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 +1483,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 +1493,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 +1560,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 +1629,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 +1715,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 +1740,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 +1758,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 +1920,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 +1943,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 +1970,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 +2107,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 +2152,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 +2210,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 +2304,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 +2325,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 +2341,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 +2380,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 +2394,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 +2411,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 +2455,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 +2536,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 +2588,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,9 +2657,10 @@ 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;
@@ -2632,10 +2712,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);
@@ -2672,17 +2753,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)
@@ -2716,15 +2800,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 */
@@ -2743,13 +2829,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);
@@ -2772,8 +2860,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
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;
@@ -2783,24 +2872,28 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
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);
}
@@ -2842,8 +2935,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);
@@ -2891,19 +2985,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;
}
@@ -2911,13 +3008,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);
@@ -2939,8 +3038,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;
@@ -2965,9 +3065,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;
@@ -2977,8 +3078,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;
@@ -3015,8 +3117,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;
@@ -3041,8 +3144,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;
}
@@ -3067,8 +3171,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;
@@ -3158,9 +3263,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;
@@ -3210,8 +3316,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);
@@ -3220,9 +3327,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 df73c78aa18..d7fe326f2ee 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);
@@ -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) {
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 11c768a8efd..d5116858970 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -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 b5891a03f0a..674f530894d 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -114,8 +114,9 @@ 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);
}
@@ -130,8 +131,9 @@ 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;
@@ -140,8 +142,9 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
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;
@@ -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 */
@@ -467,20 +482,24 @@ 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.
*
- * For this to work correctly, a standard set of data needs to be available within the scope that this
- * gets called in:
+ * For this to work correctly,
+ * a standard set of data needs to be available within the scope that this
+ *
+ * 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
@@ -986,27 +1005,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 +1048,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 +1072,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 +1172,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,8 +1203,10 @@ 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:
@@ -1189,8 +1221,9 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
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 +1232,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 +1276,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)));
@@ -1290,28 +1329,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
@@ -1372,15 +1413,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 +1441,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 +1468,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 +1487,26 @@ 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
* - 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 +1560,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 +1615,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 +1661,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 +1716,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 +1751,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;
@@ -1759,12 +1812,14 @@ 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)
+ 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 +1834,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 +1852,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 +1874,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 +1914,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 +1982,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 +2011,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 +2025,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 +2116,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 +2156,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 +2203,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,9 +2215,10 @@ 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;
}
}
@@ -2172,8 +2228,9 @@ static size_t animdata_filter_ds_textures(
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 +2248,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 +2286,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 +2302,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 +2355,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)) {
@@ -2366,19 +2426,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 +2480,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 +2492,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 +2506,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 +2518,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 +2530,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 +2542,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 +2554,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 +2573,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 +2585,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 +2624,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);
}
@@ -2613,8 +2680,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 +2716,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 +2761,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 +2789,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;
@@ -2785,8 +2851,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 +2885,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;
@@ -2883,8 +2947,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 +2993,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 +3008,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 +3057,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 +3100,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 +3115,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,7 +3142,8 @@ 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,
@@ -3152,11 +3224,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 +3291,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;
@@ -3300,9 +3375,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 +3396,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 +3408,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 +3424,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 */
@@ -3360,8 +3442,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
/* 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 +3469,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..e90599b05c8 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]``
@@ -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)
{
@@ -569,8 +581,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 +594,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 +613,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 +649,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 +689,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 +1102,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 +1213,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 +1234,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 +1251,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 +1342,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 +1438,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 +1504,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 +1534,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 +1628,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..34d7fac041f 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);
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 de8e6bb1362..22350f997f3 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);
@@ -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..815d4c5f3af 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;
@@ -258,8 +270,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;
@@ -301,8 +314,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 +341,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 +364,9 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
}
}
- if (ret_code)
+ if (ret_code) {
break;
+ }
}
ANIM_animdata_freelist(&anim_data);
@@ -368,8 +385,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 +425,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 +486,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 +540,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 +591,9 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
/**
@@ -603,8 +628,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 +654,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 +692,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 +718,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 +827,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 +839,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 +849,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 +870,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 +883,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 +1035,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 +1053,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 +1071,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 +1086,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 +1100,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 +1159,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 +1303,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 +1367,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 +1422,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 +1443,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 +1549,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 +1562,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..4851665c9f3 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:
@@ -1146,8 +1192,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 +1555,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 +1642,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 +1652,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 +1744,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 +1754,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 +1799,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 +1833,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 +1853,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 +2058,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 +2069,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 +2182,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;
+ }
}
}
}
@@ -2205,8 +2266,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 +2277,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 +2287,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 +2311,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 +2423,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 +2595,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 +2663,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 +2708,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 +2741,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 +2755,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;
+ }
}
}
@@ -2721,12 +2795,14 @@ 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 +2810,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 +2824,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 +2836,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 +2850,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 +2865,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 +2876,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 +2893,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 +2911,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..7362a7e04a1 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(
@@ -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 */
@@ -1002,16 +1040,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 +1077,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 +1112,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 +1134,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..4aed4217b6d 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;
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index b1f0297bb29..6d25fac79f6 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,8 +326,9 @@ 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]
+ /* 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...
{
@@ -376,8 +385,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 +406,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..3401c6ed157 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -172,8 +172,9 @@ void ED_operatormacros_armature(void)
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
- /* 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",
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 6226059e794..037703c50bf 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) {
@@ -591,12 +595,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 */
@@ -672,7 +677,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 +699,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;
@@ -765,8 +771,9 @@ static int armature_parent_set_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,
@@ -779,8 +786,9 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
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 {
@@ -795,10 +803,12 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
/* 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)
+ if (ebone->flag & BONE_SELECTED) {
bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
- else
+ }
+ else {
bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val);
+ }
}
}
CTX_DATA_END;
@@ -822,8 +832,9 @@ static int armature_parent_set_invoke(bContext *C,
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
if (ebone != actbone) {
- if (ebone->parent != actbone)
+ if (ebone->parent != actbone) {
allchildbones = 1;
+ }
}
}
CTX_DATA_END;
@@ -831,8 +842,9 @@ static int armature_parent_set_invoke(bContext *C,
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT);
/* ob becomes parent, make the associated menus */
- if (allchildbones)
+ if (allchildbones) {
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET);
+ }
UI_popup_menu_end(C, pup);
@@ -871,8 +883,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..95c10b79678 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);
@@ -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 1afcfaca8aa..fb3fb310b9d 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;
}
@@ -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];
@@ -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 a9f8925febc..b194650060a 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);
@@ -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];
}
@@ -1499,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;
@@ -1513,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);
@@ -1534,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;
@@ -1557,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 */
@@ -1566,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);
@@ -1589,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");
@@ -1612,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;
@@ -1666,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);
@@ -1681,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 599823a6401..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);
}
@@ -262,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 */
{
@@ -290,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 */
{
@@ -390,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? */
@@ -426,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) {
@@ -443,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);
@@ -457,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);
@@ -601,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])) {
@@ -659,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) {
@@ -736,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
@@ -745,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);
@@ -789,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);
@@ -887,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);
@@ -964,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 ce809bee71e..010f1c0e654 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -105,8 +105,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 +136,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 +162,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 +198,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 +216,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 +236,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 +271,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 +353,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 +440,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 +490,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 +696,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 +974,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 +996,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 +1046,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 +1082,9 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
}
}
- if (ok)
+ if (ok) {
animsys_evaluate_action_group(ptr, act, agrp, (float)frame);
+ }
}
}
}
@@ -1090,13 +1115,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 +1148,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 +1234,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 +1274,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 +1343,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 +1362,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 +1381,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 +1405,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;
}
@@ -1471,8 +1521,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 +1537,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 {
@@ -1592,12 +1644,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 +1669,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 +1726,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 */
@@ -1690,8 +1748,9 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
if (IS_AUTOKEY_MODE(scene, NORMAL)) {
//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 +1774,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 +1795,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;
}
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..79182a89096 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -397,7 +397,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 +459,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
@@ -583,7 +585,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) {
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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) {
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..45c51897cbf 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);
@@ -224,10 +229,12 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
* - note: code copied from transform_generics.c -> recalcData()
*/
/* FIXME: shouldn't this use the builtin stuff? */
- 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(depsgraph, scene, ob);
+ }
/* otherwise animation doesn't get updated */
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
@@ -254,18 +261,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);
+ }
}
}
@@ -355,8 +365,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/editcurve.c b/source/blender/editors/curve/editcurve.c
index 17582da2256..a787b45c13c 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -733,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) {
@@ -1275,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;
@@ -2288,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++) {
@@ -3726,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 441ebac6017..e2a86469da1 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
@@ -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..84dc29afab3 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -101,12 +101,14 @@ static void gp_draw_stroke_buffer(const tGPspoint *points,
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 */
@@ -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) {
@@ -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;
@@ -377,7 +382,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). */
gp_calc_2d_stroke_fxy(&pt2->x, sflag, offsx, offsy, winx, winy, s1);
/* calculate gradient and normal - 'angle'=(ny/nx) */
@@ -511,26 +517,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;
@@ -625,8 +638,9 @@ static void gp_draw_strokes_edit(bGPdata *gpd,
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 (gp_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
@@ -783,8 +799,9 @@ static void gp_draw_onionskins(bGPdata *gpd,
color[3] = alpha * fac * 0.66f;
gp_draw_strokes(gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
- else
+ else {
break;
+ }
}
}
else if (gpl->gstep == 0) {
@@ -814,8 +831,9 @@ static void gp_draw_onionskins(bGPdata *gpd,
color[3] = alpha * fac * 0.66f;
gp_draw_strokes(gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
- else
+ else {
break;
+ }
}
}
else if (gpl->gstep_next == 0) {
@@ -846,13 +864,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);
@@ -913,8 +933,9 @@ static void 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);
@@ -1032,8 +1053,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 +1063,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;
@@ -1098,22 +1121,27 @@ 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))
+ 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);
@@ -1136,8 +1164,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. */
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index aedfc88e43f..0363fd6c754 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)
+ /* 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
+ /* 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)
+ }
+ 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;
}
@@ -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;
+ }
}
/* ------------------------------- */
@@ -1634,10 +1670,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 +1756,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 +1786,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 +1879,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 +1927,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 +2027,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 +2115,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;
@@ -2286,8 +2334,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 +2351,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 +2432,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 +2455,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);
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 2caaf7f7797..c54598fd549 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -274,7 +274,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 +325,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;
}
@@ -447,7 +449,7 @@ 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 */
@@ -643,8 +645,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 +677,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);
@@ -816,26 +819,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;
@@ -1141,8 +1151,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..c433b374d4c 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);
@@ -564,8 +567,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 627e05393ff..f9a5ff3a0cf 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -302,7 +302,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])
{
@@ -351,7 +352,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;
@@ -366,8 +368,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;
}
@@ -801,7 +804,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) {
@@ -926,8 +938,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;
}
@@ -1106,7 +1119,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;
@@ -1382,8 +1396,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) {
@@ -1453,7 +1468,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;
@@ -1501,9 +1517,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;
@@ -1721,10 +1738,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) {
@@ -1824,8 +1843,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);
@@ -1854,8 +1874,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;
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index c1c797b15be..ded663276a4 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -501,8 +501,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 +694,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 +777,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 +911,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);
}
@@ -962,8 +967,11 @@ static void gp_stroke_to_bezier(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.
*/
else {
float p1[3], p2[3];
@@ -1133,7 +1141,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 +1215,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 +1288,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)) {
@@ -1405,8 +1418,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 +1586,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 +1603,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..5ac8cc1761f 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) {
@@ -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);
@@ -1123,14 +1130,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) {
@@ -1212,8 +1221,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 +1283,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 +1455,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 +1556,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 +1692,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 +1769,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 +1836,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 +1847,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) {
@@ -2239,13 +2261,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 +2332,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 +2521,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 +2598,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 +2696,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 +2761,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 +2816,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 +2913,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 +3084,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 +3151,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 +3165,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 +3238,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 +3290,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 +3614,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 +3777,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 +3826,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 +3876,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 +3893,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 +4256,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 +4479,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..616db4b73f7 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 */
@@ -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_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index aba01a6935f..f985ade9c7e 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
+ /* 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)
+ }
+ 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;
}
@@ -1223,8 +1239,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 +1250,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 +1379,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 +1476,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 +1529,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 +1901,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 +1934,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 +1963,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 +1974,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 +2058,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 +2102,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 +2119,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 +2162,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 +2282,9 @@ static void gp_paint_cleanup(tGPsdata *p)
}
/* "unlock" frame */
- if (p->gpf)
+ if (p->gpf) {
p->gpf->flag &= ~GP_FRAME_PAINT;
+ }
}
/* ------------------------------- */
@@ -2544,7 +2576,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 +2617,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;
}
@@ -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);
@@ -3587,8 +3631,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 +3648,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 +3707,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 +3741,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 +3764,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);
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..365fb319b3b 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,7 +292,8 @@ 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 prefix -
+ * Useful for isolating all layers for a particular character for instance. */
/* TODO: All with same appearance - colour/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,
@@ -1382,17 +1390,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..bf077d528dd 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -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 1dffa901c32..0d920641c5d 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];
@@ -2471,15 +2522,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..c88277c2ea5 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 retrived
+ * 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_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_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_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_view3d.h b/source/blender/editors/include/ED_view3d.h
index fe7ccb7170c..caa202c46a8 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -524,8 +524,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],
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index dd086461801..d6cfe7aea1f 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
@@ -1614,7 +1622,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);
@@ -2302,6 +2310,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..18962f9d9da 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -341,7 +341,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]);
@@ -361,7 +362,8 @@ void UI_GetThemeColorShadeAlpha4ubv(int colorid,
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..a16c1efd6cf 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -117,6 +117,9 @@ 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: */
@@ -275,6 +278,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..55a44b4d314 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
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e6148ba8c93..a5abbb2b86f 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;
@@ -1375,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};
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index c8800f495ce..b6d9863f9b5 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -1064,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 efc748d39a1..671a004f9fe 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1333,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,
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index e9914ce6f24..608ef69c4cc 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1778,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;
@@ -7688,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.
@@ -8738,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.
@@ -8780,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)) {
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 344b3ec3526..4af7fdd779f 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -460,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);
@@ -898,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;
@@ -913,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;
@@ -931,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 a89d161b708..cfedd40bfd1 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -722,14 +722,67 @@ 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)
+ 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:
@@ -743,16 +796,13 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
* - 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);
}
@@ -773,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++) {
@@ -789,7 +840,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
/* Separate items, potentially with a label. */
if (next_item->identifier) {
/* Item without identifier but with name:
- * Add group label for the following items. */
+ * Add group label for the following items. */
if (item->name) {
if (!is_first) {
uiItemS(block->curlayout);
@@ -806,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) {
@@ -865,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);
}
@@ -876,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;
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 7117115a0a1..ae28c09b7e2 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1757,7 +1757,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;
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index be09e44fa9d..e1f91be1631 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;
}
@@ -455,11 +481,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 +508,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 +526,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 +538,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_hud.c b/source/blender/editors/interface/interface_region_hud.c
index a69f3d89c41..362a1c8a22c 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -286,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_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..110c8827849 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);
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 76d82b93ad1..bbff2c16636 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));
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 4e53e59d7c0..952778cfc6d 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -2626,27 +2626,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;
}
@@ -2656,6 +2683,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/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_collada.c b/source/blender/editors/io/io_collada.c
index 6ccdf8628a8..bfbd3722142 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);
@@ -221,10 +223,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);
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/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..454e7e2a731 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) {
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..ab774fa13df 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;
}
@@ -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_select.c b/source/blender/editors/mask/mask_select.c
index 076f8d067b9..00699c8ffe0 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) {
@@ -265,8 +270,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 +339,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;
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..28b697531ab 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 */
@@ -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_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..9314b96afee 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) {
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_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..cd5281e1273 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -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..062008cd656 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);
+ }
}
}
@@ -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 b1a62ffde3d..a39944fc145 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -170,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.
*/
@@ -539,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;
+ }
}
}
@@ -809,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;
}
}
@@ -939,8 +944,9 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
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 69066adba41..d81de37add3 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;
}
@@ -1423,10 +1427,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);
}
@@ -2204,8 +2210,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;
}
}
@@ -2213,8 +2220,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;
}
}
@@ -2222,8 +2230,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;
}
}
@@ -2575,8 +2584,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);
@@ -2587,10 +2597,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 */
@@ -2602,22 +2614,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));
}
}
@@ -2674,8 +2689,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) {
@@ -4601,8 +4617,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);
+ }
}
}
@@ -4670,8 +4687,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
@@ -4701,10 +4719,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;
}
@@ -4747,12 +4767,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 fcad933e3c4..349acf754ce 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);
@@ -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)) {
@@ -2835,31 +2841,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 +2898,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 +2915,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 +3011,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 +3110,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);
@@ -3330,8 +3351,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 +3403,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 +3448,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;
@@ -3616,11 +3640,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,10 +3707,12 @@ 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 */
break;
@@ -3717,8 +3745,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 +3823,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 +4297,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},
};
@@ -5962,15 +5992,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];
@@ -6182,8 +6216,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);
@@ -6324,12 +6359,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;
}
@@ -6359,10 +6397,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]);
@@ -6370,8 +6410,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]);
+ }
}
}
@@ -6403,12 +6444,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);
}
@@ -6450,18 +6494,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;
@@ -7598,8 +7646,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);
@@ -7730,7 +7779,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];
@@ -8810,12 +8860,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;
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 7d318fb16e1..d7ed14184fa 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -573,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;
@@ -627,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;
}
@@ -723,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;
@@ -778,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;
}
@@ -835,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.
@@ -850,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;
@@ -873,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,
@@ -882,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++;
@@ -909,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);
}
}
@@ -920,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);
}
}
@@ -1019,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,
@@ -1244,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/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 8cc23edad16..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;
}
@@ -974,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;
@@ -1024,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];
@@ -1050,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);
@@ -1076,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);
@@ -1257,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);
@@ -1332,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;
}
@@ -1348,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/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..87782e895b5 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) {
@@ -1535,8 +1554,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 +1571,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 +1850,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 +1956,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 +2118,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 +2185,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 +2296,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 +2338,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 +2401,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);
@@ -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..6e2f0dba969 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) {
@@ -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;
}
@@ -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..85801dbdd0a 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,8 +377,9 @@ 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))) {
@@ -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..54c50db99a5 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
@@ -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..8ae736d42c0 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);
@@ -1763,10 +1831,12 @@ static bool get_new_constraint_target(
/* 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)
+ 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]);
@@ -1818,11 +1888,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 +1906,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 +1949,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 +1959,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 +1993,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 +2015,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 +2128,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 +2146,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 +2175,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,8 +2212,7 @@ 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? */
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 4e532b0ab41..95737453777 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;
}
@@ -718,8 +719,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 +859,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 +940,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 +1038,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 +1211,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 +1227,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 +1281,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 +1331,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 +1367,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 */
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..c1205635a96 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,12 +480,15 @@ 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;
}
@@ -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..bc95360eab9 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);
@@ -659,8 +673,9 @@ static int modifier_apply_obdata(
}
/* Multires: ensure that recent sculpting is applied */
- if (md->type == eModifierType_Multires)
+ if (md->type == eModifierType_Multires) {
multires_force_update(ob);
+ }
if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) {
if (!multiresModifier_reshapeFromDeformModifier(depsgraph, mmd, ob, md)) {
@@ -677,8 +692,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->type == eModifierType_Multires) {
multires_customdata_delete(me);
+ }
}
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
@@ -719,8 +735,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 +772,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 +828,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 +848,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 +858,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 +911,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 +975,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 +992,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 +1011,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 +1041,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 +1053,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 +1083,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 +1095,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 +1141,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 +1192,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 +1205,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 +1235,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 +1247,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 +1284,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 +1302,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 +1334,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 +1356,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 +1388,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 +1423,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 +1456,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 +1483,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 +1542,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 +1573,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 +1587,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 +1617,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 +1823,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 +1961,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 +2036,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 +2093,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 +2109,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 +2147,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 +2161,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)
@@ -2148,8 +2225,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 +2280,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 +2360,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 +2435,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 +2500,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_relations.c b/source/blender/editors/object/object_relations.c
index 63cacc21d1c..bf74c17c361 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);
@@ -1049,10 +1081,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 +1215,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;
@@ -1541,20 +1577,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);
@@ -1682,9 +1722,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) {
@@ -1713,9 +1754,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;
@@ -1755,7 +1797,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);
}
@@ -1823,8 +1866,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));
@@ -1835,13 +1879,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);
@@ -1938,25 +1984,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 */
@@ -2148,7 +2204,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... */
}
}
@@ -2367,7 +2424,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) {
@@ -2584,8 +2642,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..f0508b5f35c 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -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", ""},
@@ -657,8 +660,9 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
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..9e1ef96ab93 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];
@@ -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_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 7ba57801ebe..d422ee565a3 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -245,7 +245,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 +349,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 +375,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 +393,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 +418,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 +538,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 +711,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 +790,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 +817,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 +876,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
*/
@@ -1001,10 +1018,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 +1038,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 +1065,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 +1089,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 +1228,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 +1255,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])
{
@@ -1480,8 +1509,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 +1983,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 +2007,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 +2443,9 @@ cleanup:
*r_totmirr = totmirr;
*r_totfail = totfail;
- if (flip_map)
+ if (flip_map) {
MEM_freeN(flip_map);
+ }
#undef VGROUP_MIRR_OP
}
@@ -2416,8 +2453,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 +2465,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 +2479,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 +2527,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 +2587,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 +2602,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 +2662,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 +2684,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));
}
@@ -2681,12 +2727,15 @@ 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);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
@@ -2834,8 +2883,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);
@@ -3571,8 +3621,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 +3734,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 +3829,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 +3882,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..7178a485a6e 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -72,14 +72,16 @@ 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;
@@ -117,8 +119,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;
@@ -165,8 +168,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 +181,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 +228,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,17 +238,21 @@ 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) {
@@ -251,8 +261,9 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
}
else {
bDeformGroup *defgroup = defgroup_find_name(ob, name);
- if (defgroup)
+ if (defgroup) {
BKE_object_defgroup_remove(ob, defgroup);
+ }
}
}
}
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 d592bbd82b1..9921ca02af9 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,8 +366,9 @@ 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;
@@ -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,10 +514,11 @@ 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,
@@ -525,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)
@@ -552,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;
}
@@ -584,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
{
@@ -641,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;
@@ -704,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
{
@@ -878,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++;
+ }
}
}
}
@@ -906,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);
@@ -924,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
{
@@ -938,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 */
@@ -949,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;
+ }
}
}
@@ -972,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;
@@ -1025,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)
@@ -1043,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 */
@@ -1065,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;
+ }
+ }
}
}
@@ -1225,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;
@@ -1321,8 +1365,9 @@ void recalc_lengths(PTCacheEdit *edit)
POINT_P;
KEY_K;
- if (edit == 0)
+ if (edit == 0) {
return;
+ }
LOOP_EDITED_POINTS
{
@@ -1341,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);
@@ -1402,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 */
@@ -1441,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);
+ }
}
}
}
@@ -1466,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;
@@ -1478,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);
@@ -1493,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);
@@ -1508,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);
}
@@ -1526,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 */
@@ -1557,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;
+ }
}
/************************************************/
@@ -1573,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;
@@ -1607,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;
@@ -1712,8 +1777,9 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
break;
}
- if (action == SEL_DESELECT)
+ if (action == SEL_DESELECT) {
break;
+ }
}
}
@@ -1806,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);
@@ -1874,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);
@@ -2190,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);
@@ -2202,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
@@ -2375,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;
+ }
}
}
@@ -2436,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;
+ }
}
}
@@ -2534,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;
@@ -2605,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;
@@ -2629,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 */
@@ -2678,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;
}
}
@@ -2690,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));
@@ -2703,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) {
@@ -2728,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;
@@ -2736,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
{
@@ -2761,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));
@@ -2807,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;
@@ -2848,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;
@@ -2885,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++;
@@ -2899,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;
@@ -2958,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;
@@ -3010,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);
@@ -3146,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 **************************/
@@ -3187,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) {
@@ -3242,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);
@@ -3255,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;
@@ -3276,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) {
@@ -3319,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];
@@ -3349,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) {
@@ -3426,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);
@@ -3458,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;
@@ -3614,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]);
@@ -3630,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.
@@ -3727,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,
@@ -3875,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) {
@@ -3891,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) {
@@ -3931,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;
}
@@ -4088,8 +4210,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");
@@ -4171,12 +4294,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) {
@@ -4223,16 +4348,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);
@@ -4268,12 +4395,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;
@@ -4303,8 +4432,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);
@@ -4325,8 +4455,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);
@@ -4406,8 +4537,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];
@@ -4426,8 +4558,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) :
@@ -4456,10 +4589,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);
@@ -4475,17 +4610,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;
}
@@ -4495,15 +4634,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: {
@@ -4514,10 +4656,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);
@@ -4532,11 +4676,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: {
@@ -4573,12 +4719,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);
@@ -4617,8 +4765,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);
@@ -4649,8 +4798,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);
@@ -4736,8 +4886,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 */
@@ -4769,8 +4920,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;
@@ -4831,12 +4983,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;
@@ -4848,10 +5002,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);
@@ -4911,19 +5067,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
{
@@ -4963,14 +5123,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;
@@ -5031,21 +5194,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];
@@ -5069,8 +5235,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);
}
@@ -5080,12 +5247,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 b05dac83716..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,18 +1094,22 @@ 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 ...
+ *
+ * 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)
@@ -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 65fb58efe6d..1ec0aeffa17 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;
}
@@ -257,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);
@@ -281,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);
@@ -457,8 +460,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 */
@@ -526,8 +530,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);
@@ -554,12 +559,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;
@@ -593,16 +601,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);
+ }
}
}
@@ -619,8 +630,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 */
@@ -635,16 +647,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");
@@ -701,7 +716,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,
@@ -767,8 +783,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 */
@@ -817,7 +834,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)) {
@@ -940,7 +963,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) {
@@ -1017,9 +1041,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;
@@ -1091,19 +1115,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);
@@ -1182,19 +1211,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..8403f178284 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;
@@ -349,7 +363,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
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);
@@ -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);
@@ -1107,8 +1156,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..41ef5d81901 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) {
@@ -431,10 +440,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 +562,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 +963,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 +1048,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 +1082,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 +1109,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 +1123,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 9b31b63edae..c9a4f1948ce 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;
}
@@ -397,10 +402,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 +468,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 +518,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 +571,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 +592,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 +621,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 +675,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 +727,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);
+ }
}
}
}
@@ -809,10 +828,12 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* 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;
@@ -828,18 +849,22 @@ 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)
+ 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 +875,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 +896,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 +915,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 +943,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 +1016,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 +1045,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 +1066,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 +1104,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 +1134,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 +1171,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 +1266,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;
@@ -1319,8 +1358,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);
@@ -1332,7 +1372,8 @@ void ED_preview_icon_job(
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 +1404,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;
@@ -1431,6 +1473,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 ce952b50f9d..5cd5153b060 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);
@@ -618,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)
@@ -662,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)
@@ -691,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;
+ }
}
/* *************************************************************** */
@@ -703,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);
}
@@ -729,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) {
@@ -776,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 */
@@ -825,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);
@@ -871,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);
}
@@ -887,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) {
@@ -929,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;
}
@@ -1009,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);
@@ -1144,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;
@@ -1154,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;
@@ -1181,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();
}
@@ -1254,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;
@@ -1278,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;
@@ -1333,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;
@@ -1369,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)) {
@@ -1466,8 +1543,9 @@ 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;
}
@@ -1640,8 +1718,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);
@@ -1655,8 +1734,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);
@@ -1735,12 +1815,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);
@@ -1755,10 +1834,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);
}
}
@@ -1794,8 +1873,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);
@@ -1892,9 +1972,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)) {
@@ -1925,8 +2007,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);
}
@@ -1937,7 +2020,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) {
@@ -1950,7 +2033,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;
}
@@ -2035,6 +2118,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;
}
@@ -2220,8 +2304,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) {
@@ -2342,7 +2427,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) {
@@ -2477,7 +2563,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;
}
@@ -2509,15 +2596,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;
@@ -2858,8 +2947,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]);
@@ -2991,8 +3081,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();
@@ -3094,8 +3185,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) {
@@ -3171,8 +3263,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..6dcb9f8a82c 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -65,53 +65,55 @@
#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",
+ "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,
+};
int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
{
@@ -274,8 +276,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 +287,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 +333,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 +344,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,57 +457,66 @@ 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;
}
@@ -564,9 +581,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 +594,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 +745,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..6fea27a9cff 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -540,7 +540,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 +589,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..50f0ab9b96b 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,19 +404,22 @@ 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;
}
}
@@ -425,12 +433,19 @@ static void screen_refresh_headersizes(void)
for (st = lb->first; st; st = st->next) {
ARegionType *art;
art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER);
- if (art)
+ if (art) {
art->prefsizey = ED_area_headersize();
+ }
+
+ art = BKE_regiontype_from_id(st, RGN_TYPE_TOOL_HEADER);
+ if (art) {
+ art->prefsizey = ED_area_headersize();
+ }
art = BKE_regiontype_from_id(st, RGN_TYPE_FOOTER);
- if (art)
+ if (art) {
art->prefsizey = ED_area_headersize();
+ }
}
}
@@ -458,8 +473,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 +526,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 +558,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 +581,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 +622,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 +683,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 +708,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 +732,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 +749,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 +846,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 +876,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 +1023,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 +1225,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 +1309,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 +1342,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 +1353,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 +1389,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 +1411,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 +1457,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 +1485,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 +1500,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 +1533,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 +1546,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..a0d9c232195 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,10 +155,6 @@ 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);
@@ -181,33 +180,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);
@@ -222,56 +194,6 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
}
}
-#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;
- }
- }
- }
- }
- }
- }
-
-# 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... */
@@ -280,10 +202,12 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
int headery = headery_init;
/* adjust headery if verts are along the edge of window */
- if (sa->v1->vec.y > window_rect.ymin)
+ if (sa->v1->vec.y > window_rect.ymin) {
headery += U.pixelsize;
- if (sa->v2->vec.y < (window_rect.ymax - 1))
+ }
+ if (sa->v2->vec.y < (window_rect.ymax - 1)) {
headery += U.pixelsize;
+ }
if (screen_geom_area_height(sa) < headery) {
/* lower edge */
@@ -306,7 +230,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 f059659806e..8e7475ec511 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,54 @@ 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)) {
+ /* 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 +947,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 +964,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;
@@ -905,8 +989,9 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
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))
+ 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 +1035,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 +1067,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 +1172,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 +1187,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 +1201,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 +1291,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 +1330,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 +1422,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 +1463,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 +1520,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 +1732,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 +1746,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 +1762,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 +1942,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 +2029,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 +2053,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 +2106,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 +2228,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 +2450,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 +2462,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 +2503,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 +2534,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 +2559,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 +2586,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 +2605,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 +2618,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 +2640,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 +2812,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 +2873,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 +2909,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 +3084,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 +3235,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 +3256,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 +3272,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 +3294,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 +3310,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 +3384,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 +3468,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 +3607,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 +3668,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;
}
@@ -3699,17 +3867,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);
@@ -3747,40 +3920,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
* \{ */
@@ -3828,9 +3967,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. */
@@ -3840,11 +3995,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)) {
@@ -4013,8 +4163,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;
}
@@ -4030,40 +4181,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;
}
}
@@ -4072,8 +4231,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;
}
}
@@ -4087,18 +4247,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;
@@ -4131,22 +4294,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;
@@ -4168,17 +4336,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++;
+ }
}
}
@@ -4271,8 +4443,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);
+ }
}
}
@@ -4285,7 +4458,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;
@@ -4358,8 +4532,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);
@@ -4379,8 +4554,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);
}
@@ -4529,8 +4705,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");
@@ -4631,7 +4808,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);
}
}
@@ -4721,12 +4899,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 */
@@ -4749,8 +4928,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;
@@ -4765,13 +4945,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) {
@@ -4785,7 +4967,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);
@@ -4804,10 +4986,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) {
@@ -4827,15 +5011,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) {
@@ -5109,7 +5295,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);
@@ -5179,8 +5364,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 ce64bdc27c8..6294a64af0f 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -109,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;
@@ -158,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..697622aae96 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();
+ }
}
}
@@ -814,18 +835,23 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
/* coloured 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 4c978f560b3..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;
@@ -695,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);
@@ -765,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.
@@ -1092,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;
}
@@ -1120,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);
@@ -1142,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;
@@ -1174,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);
@@ -1233,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);
@@ -1281,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..78832bbbd8f 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 */
@@ -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 7f8887814a1..5436c5912bc 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;
@@ -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);
@@ -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;
@@ -1870,8 +1894,9 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
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)) {
@@ -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))
@@ -2424,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]));
@@ -2498,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);
@@ -2509,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) {
@@ -2521,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) {
@@ -2533,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) {
@@ -2737,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) {
@@ -2789,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],
@@ -2880,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;
@@ -2896,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;
@@ -3027,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);
@@ -3060,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) {
@@ -3132,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) {
@@ -3476,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;
}
@@ -3822,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);
@@ -3859,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) {
@@ -4036,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 */
@@ -4059,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) {
@@ -4230,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;
}
@@ -4386,17 +4450,19 @@ static void project_paint_begin(const bContext *C,
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(&((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 */
@@ -4501,11 +4567,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);
@@ -4538,8 +4606,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]);
@@ -4579,8 +4648,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++;
@@ -4666,8 +4736,9 @@ 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);
@@ -4682,8 +4753,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;
}
@@ -4691,8 +4763,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;
}
@@ -4770,8 +4843,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);
@@ -4787,8 +4861,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);
@@ -4843,8 +4918,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);
@@ -4910,8 +4986,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);
@@ -4971,8 +5048,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;
@@ -5318,10 +5396,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;
@@ -5360,37 +5440,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;
}
@@ -5464,8 +5554,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();
@@ -5498,14 +5589,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);
@@ -5570,8 +5664,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)) {
@@ -5711,8 +5806,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 :) */
@@ -5815,8 +5911,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 */
@@ -6075,10 +6172,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,
@@ -6243,14 +6342,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;
@@ -6374,8 +6477,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_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..e15912efdd4 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,
@@ -628,12 +633,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 +702,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 +718,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 +755,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 +793,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 +921,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;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 8c1ba213ba0..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);
@@ -506,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);
@@ -589,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. */
@@ -614,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;
@@ -630,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;
@@ -639,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(
@@ -774,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);
@@ -797,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) {
@@ -819,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);
@@ -845,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 */
@@ -876,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;
@@ -895,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;
@@ -942,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)
@@ -991,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;
@@ -1043,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);
@@ -1175,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;
@@ -1204,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),
@@ -1247,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);
@@ -1274,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];
@@ -1303,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..91a2ebd0603 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)
@@ -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 291320a520f..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.
@@ -845,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.
*
@@ -1289,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) {
@@ -1324,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;
}
@@ -1397,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 */
@@ -1667,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 = {
@@ -1874,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);
@@ -2158,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,
@@ -2308,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;
@@ -2328,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);
}
@@ -2570,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");
@@ -3280,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/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 6882b249f0d..5ae004fde5f 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 *******************/
@@ -725,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,
@@ -840,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;
}
}
@@ -887,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;
}
}
@@ -1211,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);
@@ -1262,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);
@@ -1287,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(
@@ -1305,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];
+ }
}
}
@@ -1536,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 */
@@ -1770,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;
@@ -1824,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;
@@ -1880,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;
@@ -1923,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;
@@ -1993,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);
@@ -2009,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;
@@ -2104,8 +2142,9 @@ static void smooth(Sculpt *sd,
break;
}
- if (ss->multires)
+ if (ss->multires) {
multires_stitch_grids(ob);
+ }
}
}
@@ -2169,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;
}
@@ -2242,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;
@@ -2333,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;
@@ -2357,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);
@@ -2428,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;
@@ -2490,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;
@@ -2556,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;
@@ -2663,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;
@@ -2681,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);
@@ -2746,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;
@@ -2822,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;
@@ -2899,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);
@@ -2916,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;
@@ -2979,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;
@@ -3051,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);
@@ -3093,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;
}
@@ -3161,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;
+ }
}
}
}
@@ -3254,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;
+ }
}
}
}
@@ -3350,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;
+ }
}
}
}
@@ -3380,14 +3443,17 @@ 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;
+ }
mul_v3_v3v3(temp, area_no_sp, ss->cache->scale);
mul_v3_fl(temp, displace);
@@ -3470,8 +3536,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;
+ }
}
}
}
@@ -3561,8 +3628,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;
+ }
}
}
}
@@ -3640,8 +3708,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;
@@ -3707,8 +3776,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);
}
@@ -3822,11 +3892,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) {
@@ -3901,8 +3973,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);
@@ -3932,8 +4005,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,
@@ -3954,8 +4028,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);
@@ -3976,13 +4051,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;
@@ -4013,8 +4090,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 */
@@ -4025,16 +4103,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);
+ }
}
}
@@ -4194,8 +4275,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 */
@@ -4207,8 +4289,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;
@@ -4251,8 +4334,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,
@@ -4271,7 +4355,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;
@@ -4386,8 +4471,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);
}
@@ -4459,10 +4545,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;
@@ -4479,10 +4567,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) {
@@ -4553,8 +4643,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);
@@ -4588,8 +4679,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
}
@@ -4616,8 +4708,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);
@@ -4663,10 +4756,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 */
@@ -5182,8 +5277,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,
@@ -5252,8 +5348,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))
@@ -5294,20 +5391,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);
}
@@ -5381,8 +5481,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);
}
@@ -5432,8 +5532,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;
}
@@ -5761,8 +5862,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;
@@ -5941,8 +6043,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) {
@@ -6169,8 +6272,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]);
@@ -6191,8 +6295,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..3cda90ea3f9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -144,8 +144,9 @@ static Brush *uv_sculpt_brush(bContext *C)
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
- if (!settings->uvsculpt)
+ if (!settings->uvsculpt) {
return NULL;
+ }
return BKE_paint_brush(&settings->uvsculpt->paint);
}
@@ -306,8 +307,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 +336,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 +378,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 +387,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 +410,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 +468,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 +490,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 +536,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);
@@ -705,8 +713,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 +743,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 +912,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;
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 31dfe0bd30a..c2165e8ec70 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;
}
@@ -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 3444d71baff..93beb3e851e 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) {
@@ -219,7 +224,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 +265,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 +372,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 +403,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 +568,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 +618,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;
@@ -743,8 +757,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);
@@ -773,16 +788,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) {
@@ -802,8 +820,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");
@@ -867,14 +886,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;
}
@@ -890,8 +913,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);
@@ -981,12 +1005,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);
@@ -1043,8 +1069,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");
@@ -1117,8 +1144,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");
@@ -1222,8 +1250,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);
+ }
}
}
}
@@ -1243,8 +1272,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");
@@ -1297,8 +1327,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);
@@ -1318,8 +1349,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");
@@ -1376,8 +1408,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;
@@ -1403,8 +1436,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");
@@ -1457,8 +1491,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);
@@ -1502,8 +1537,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");
@@ -1554,8 +1590,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);
}
@@ -1570,8 +1607,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 */
@@ -1586,8 +1624,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);
@@ -1711,8 +1750,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");
@@ -1787,10 +1827,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 */
@@ -1838,8 +1880,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..b91ac3c39a3 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);
@@ -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 6b37cd8fe27..fb35afb6770 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));
@@ -342,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);
@@ -409,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 */
@@ -529,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;
@@ -594,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));
@@ -741,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;
@@ -777,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) {
@@ -791,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) {
@@ -825,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);
@@ -874,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*/ |
@@ -940,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");
@@ -966,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);
@@ -1000,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);
@@ -1138,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);
@@ -1167,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) {
@@ -1179,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 */
@@ -1314,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) {
@@ -1405,16 +1442,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) */
@@ -1503,13 +1541,16 @@ 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;
@@ -1616,17 +1657,20 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
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"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* column selection */
column = RNA_boolean_get(op->ptr, "column");
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index eda8ad4a787..d6d46904db3 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)
@@ -243,8 +215,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 +225,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 */
@@ -364,22 +338,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 +449,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 +459,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;
}
}
@@ -689,8 +669,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 +696,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) {
@@ -782,8 +764,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 +775,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 +792,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_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..8a5f48d11d2 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);
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..f176763abf5 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;
}
@@ -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;
}
}
@@ -1008,8 +1020,9 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
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,8 +1034,9 @@ 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 */
@@ -1037,8 +1051,9 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
UI_view2d_scrollers_free(scrollers);
/* 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);
}
@@ -1053,8 +1068,9 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
View2DScrollers *scrollers;
short unit = 0, cfra_flag = 0;
- if (clip)
+ if (clip) {
BKE_tracking_dopesheet_update(&clip->tracking);
+ }
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -1073,8 +1089,9 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
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 */
@@ -1095,10 +1112,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),
@@ -1130,8 +1149,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 +1239,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 +1292,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_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_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_select.c b/source/blender/editors/space_clip/tracking_select.c
index 24282ce0e96..207a0f1aff6 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);
@@ -305,8 +312,9 @@ static int mouse_select(bContext *C, float co[2], int extend)
if (track) {
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 +326,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;
@@ -584,10 +593,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 +831,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 +900,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 +911,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_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..7d3a042d75a 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;
}
@@ -1459,8 +1473,9 @@ int file_exec(bContext *C, wmOperator *exec_op)
break;
}
}
- if (active == 0)
+ if (active == 0) {
return OPERATOR_CANCELLED;
+ }
}
sfile->op = NULL;
@@ -1575,8 +1590,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 +1621,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 +1650,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 +1676,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 +1701,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 +1723,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. */
+ /* Postscroll (after rename has been validated by user) is done,
+ * rename process is totally finisehd, cleanup. */
if ((params->rename_flag & FILE_PARAMS_RENAME_POSTSCROLL_ACTIVE) != 0) {
params->renamefile[0] = '\0';
params->rename_flag = 0;
@@ -1791,8 +1813,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 +2050,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 +2071,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 +2175,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 +2205,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 +2249,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 +2300,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 +2366,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 +2378,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 3c3656c97c0..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 {
@@ -2519,10 +2570,14 @@ 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
@@ -2533,10 +2588,20 @@ static void filelist_readjob_main_rec(Main *bmain, FileList *filelist)
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)
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 a896968dadf..982c663cd18 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -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;
@@ -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,11 @@ 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 +536,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 +568,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 +683,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..e0d370cdde2 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);
@@ -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);
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 9f5536ae174..b06066136aa 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);
}
@@ -879,7 +895,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 */
@@ -925,7 +942,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);
@@ -975,8 +993,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
@@ -1203,14 +1222,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);
@@ -1225,8 +1246,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);
@@ -1236,7 +1258,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;
@@ -1268,7 +1291,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 */
@@ -1313,8 +1336,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);
@@ -1418,27 +1442,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 36c3ec21d2a..eb392538d23 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);
@@ -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,14 +482,16 @@ 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)
{
@@ -496,11 +503,12 @@ static void draw_fcurve_curve(
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 */
+ /* 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)
+ if (dx <= 0.0f) {
return;
+ }
/* disable any drivers */
FCurve fcurve_for_draw = *fcu_;
@@ -523,7 +531,8 @@ static void draw_fcurve_curve(
*/
/* 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? */
+ /* 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);
if (sipo->flag & SIPO_BEAUTYDRAW_OFF) {
@@ -536,13 +545,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 +620,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 +655,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 +725,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 +793,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 +845,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]);
}
@@ -1193,8 +1211,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..1bb14bc3ce2 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;
@@ -914,8 +962,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 +982,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 +1020,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 +1106,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 +1187,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 +1251,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");
@@ -1278,8 +1333,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 +1397,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 +1420,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);
@@ -1442,8 +1500,9 @@ static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, const wmEven
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 +1642,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 +1745,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 +1767,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 +1817,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 +1839,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 +1890,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 +1910,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 +1964,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 +1991,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 +2061,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 +2084,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 +2151,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 +2241,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 +2258,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 +2284,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 +2434,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 +2453,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 +2545,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 +2593,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 +2612,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 +2657,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 +2725,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 +2750,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 +2830,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 +2856,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 +2876,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 +2899,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 +2910,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 +2986,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 +3007,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 +3044,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 +3112,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 +3166,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..606f4bc3fe3 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -36,10 +36,6 @@ 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);
@@ -164,7 +160,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..79df4760939 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);
@@ -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..a5376cd0c0e 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -122,10 +122,12 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
/* 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 +147,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 +219,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 +247,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 +280,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 +297,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;
@@ -320,14 +327,16 @@ static void box_select_graphkeys(bAnimContext *ac,
/* 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 +353,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 +372,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 +443,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 +521,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 +672,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 +733,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 +785,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 +851,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 +878,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 +913,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 +1000,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 +1018,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 +1051,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 +1064,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 +1147,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;
}
@@ -1155,12 +1191,14 @@ static void nearest_fcurve_vert_store(ListBase *matches,
/* 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 +1213,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 +1240,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 +1254,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 +1313,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 +1329,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)) {
@@ -1308,8 +1351,9 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
}
else {
/* if vert is selected, we've got what we want... */
- if (nvi->sel)
+ if (nvi->sel) {
found = 1;
+ }
}
}
@@ -1319,8 +1363,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])
{
@@ -1355,8 +1402,9 @@ static void mouse_graph_keys(bAnimContext *ac,
nvi = find_nearest_fcurve_vert(ac, mval);
/* check if anything to select */
- if (nvi == NULL)
+ if (nvi == NULL) {
return;
+ }
/* deselect all other curves? */
if (select_mode == SELECT_REPLACE) {
@@ -1370,8 +1418,9 @@ 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 points can be selected on this F-Curve */
@@ -1408,10 +1457,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 +1490,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 +1541,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 +1577,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);
@@ -1544,14 +1603,17 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve
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;
+ }
/* figure out action to take */
if (RNA_boolean_get(op->ptr, "column")) {
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index 1c3b4f1377b..b823ddec696 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -66,7 +66,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 +91,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 +139,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 +165,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 +192,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 +219,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 +243,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 +288,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 8751fe5199d..e45a27a08fb 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)
@@ -325,8 +297,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);
}
@@ -462,8 +435,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 +449,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 +464,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 +474,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,10 +569,12 @@ 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) {
@@ -635,8 +614,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 &
@@ -664,8 +644,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 +664,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 +776,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 66e5607b06d..f5dd0c4ad53 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -154,150 +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)
@@ -1521,53 +1377,3 @@ void image_buttons_register(ARegionType *art)
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..3baee1d723b 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 {
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 086f3103523..2c99997bbad 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"
@@ -355,15 +356,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 +512,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;
}
@@ -1005,15 +988,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 +1117,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 +1175,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 +1654,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 +1693,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;
- }
- }
+ ImageUser *iuser = &sima->iuser;
- /* 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;
- }
+ 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"));
- /* 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;
-
- /* we need to get the specific per-view buffers */
- ED_space_image_release_buffer(sima, ibuf, lock);
-
- 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 +1853,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 +1884,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 +1893,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 +1908,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 +1917,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 +2025,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 +2544,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 +2561,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 +2575,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 +2587,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 *********************/
@@ -3649,7 +3244,6 @@ 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,
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 9c834f09fd4..1e1d1e570b3 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,19 @@ 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;
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for image");
@@ -291,9 +237,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);
@@ -1097,6 +1040,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/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..d6353a9b0d4 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -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..638ad62592e 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);
@@ -134,8 +138,9 @@ static int mouse_nla_channels(
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 */
@@ -143,22 +148,25 @@ static int mouse_nla_channels(
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 +206,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 +222,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 +270,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 +331,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 +341,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 +370,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 +380,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 +448,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 +576,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 +721,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 +783,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 +801,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 +856,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 58db49d09af..76930d3117b 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;
@@ -735,8 +744,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 +759,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 +770,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 +871,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 +893,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 +957,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 +977,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 +1023,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 +1084,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 +1148,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 +1202,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 +1221,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 +1292,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 +1352,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 +1431,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 +1495,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 +1513,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 +1665,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 +1682,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 +1742,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 +1759,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 +1820,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 +1839,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 +1914,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 +1933,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 +2017,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 +2036,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 +2111,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);
@@ -2144,8 +2190,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);
@@ -2293,10 +2340,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... */
@@ -2323,8 +2372,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);
@@ -2339,18 +2389,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);
@@ -2417,8 +2470,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();
@@ -2434,8 +2488,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);
@@ -2471,7 +2526,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 *********************** */
@@ -2487,8 +2548,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 |
@@ -2504,13 +2566,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..cb54129a820 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 */
@@ -557,8 +577,9 @@ 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;
+ }
}
}
@@ -573,8 +594,9 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* 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) {
@@ -631,8 +653,9 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
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 */
@@ -640,10 +663,12 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
// 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;
+ }
/* select strips based upon mouse position */
mouse_nla_strips(C, &ac, event->mval, selectmode);
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index ccf2e552644..527a4f6e5f6 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)
@@ -300,15 +272,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 */
@@ -392,8 +366,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 +413,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 +423,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 +500,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 +577,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 327aa94ca3e..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"
@@ -3414,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;
}
@@ -3481,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_edit.c b/source/blender/editors/space_node/node_edit.c
index 09af141b026..3e73cc52c52 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -2032,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_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_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..94380814fe8 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))
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..4cb80bd1394 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)) {
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 9081bee685d..f4efde09a5b 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -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);
}
@@ -1563,7 +1563,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;
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 6cfb5ce8202..d939f84e186 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1478,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;
@@ -1682,7 +1683,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? */
@@ -2101,8 +2103,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;
@@ -2149,8 +2150,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_select.c b/source/blender/editors/space_outliner/outliner_select.c
index bab5ee02916..459736a730d 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. */
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index ad4661102bc..650827a17c7 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -650,7 +650,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 +739,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 +1770,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 "
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 6b24e83e8ee..69449f46677 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -958,7 +958,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;
@@ -1470,10 +1470,7 @@ 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;
@@ -1785,10 +1782,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,
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..3ffa54727e6 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -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_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 5842d3b9c0d..550aa9d7f8d 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;
}
@@ -1226,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) {
@@ -1601,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);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index c94da4afa52..4a6cfaae42f 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);
@@ -1548,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);
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index a051071ab61..9244bbb3034 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,
@@ -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/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 35c031e8bc8..30aca84f4e0 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;
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..49d5ae06413 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);
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 b2c5f42adb4..cdd691fe879 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -204,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;
@@ -219,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) {
@@ -250,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 {
@@ -281,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;
}
}
@@ -302,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);
@@ -322,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) {
@@ -352,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;
}
@@ -365,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;
}
@@ -379,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;
}
@@ -414,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;
@@ -444,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++;
@@ -458,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;
@@ -471,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);
@@ -506,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++;
}
@@ -530,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);
}
@@ -577,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);
@@ -618,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;
@@ -630,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 */
@@ -664,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;
@@ -692,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;
@@ -721,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;
@@ -740,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);
}
@@ -804,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;
}
@@ -876,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);
@@ -1098,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();
@@ -1129,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);
@@ -1147,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;
@@ -1173,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;
+ }
}
}
@@ -1307,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);
}
@@ -1332,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;
@@ -1353,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 */
@@ -1380,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;
@@ -1390,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 &&
@@ -1410,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;
@@ -1480,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;
@@ -1498,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 */
@@ -1509,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);
@@ -1563,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 */
@@ -1654,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;
@@ -1704,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;
@@ -1718,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 cbb3be0f1c8..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 */
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 f2fdffb15c8..4d904822360 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -78,8 +78,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 +95,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 +113,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 +133,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 +148,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 +232,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 +274,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);
@@ -323,8 +332,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 +456,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 +543,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 +569,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);
@@ -689,8 +706,9 @@ 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)
+ if (data->text == text) {
BPY_pyconstraint_update(ob, con);
+ }
update = 1;
}
}
@@ -699,8 +717,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)
+ if (data->text == text) {
BPY_pyconstraint_update(ob, con);
+ }
update = 1;
}
}
@@ -738,8 +757,9 @@ 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);
@@ -753,8 +773,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;
}
@@ -822,8 +843,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);
@@ -871,8 +893,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;
}
@@ -995,8 +1018,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);
}
@@ -1128,8 +1152,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;
@@ -1157,8 +1182,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... */
@@ -1201,8 +1227,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. */
@@ -1342,8 +1369,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;
}
@@ -1432,14 +1460,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;
@@ -1453,8 +1483,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;
}
@@ -1552,8 +1583,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;
@@ -1617,14 +1649,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;
@@ -1645,8 +1679,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)
@@ -1695,14 +1730,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;
}
@@ -1725,8 +1763,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)
@@ -1765,8 +1804,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)
@@ -1803,8 +1843,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.
@@ -1831,8 +1872,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) {
@@ -1845,11 +1887,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)
@@ -1859,28 +1903,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:
@@ -1926,31 +1975,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;
}
@@ -2019,12 +2076,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);
@@ -2077,10 +2137,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);
@@ -2136,8 +2198,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;
}
@@ -2247,8 +2310,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);
@@ -2305,8 +2369,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));
@@ -2332,8 +2397,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:
@@ -2363,8 +2429,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;
@@ -2426,11 +2493,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;
}
@@ -2443,8 +2512,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) {
@@ -2453,10 +2523,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;
+ }
}
}
@@ -2540,13 +2612,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);
@@ -2633,18 +2708,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) {
@@ -2705,13 +2783,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) {
@@ -2735,25 +2816,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)
@@ -2840,8 +2926,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;
@@ -2920,8 +3007,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]);
@@ -2960,18 +3048,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');
@@ -3029,8 +3122,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);
@@ -3073,8 +3167,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;
}
@@ -3117,21 +3212,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) {
@@ -3156,17 +3255,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;
@@ -3223,8 +3325,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..456a012020f 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,13 @@ 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;
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for view3d");
@@ -1189,6 +1131,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 +1528,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 +1547,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..52feff4b65a 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)
{
@@ -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 2c831c0877c..12ce793e3ef 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);
@@ -1450,6 +1451,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();
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 85bc0fba36b..f029fd9bfc7 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;
@@ -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.
*/
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 84ebacc0a2f..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;
@@ -1844,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])
@@ -1892,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_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 f50f6f81087..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],
@@ -556,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_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 1b81ccec3ba..7ac8291a385 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -865,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.
*/
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 d4837084a5f..c80a0eaa597 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -586,15 +586,18 @@ 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) {
@@ -664,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) &&
@@ -1046,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);
@@ -1381,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);
@@ -1487,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;
@@ -1770,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;
}
@@ -2117,16 +2125,21 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if (!(t->options & CTX_NO_PET)) {
if ((prop = RNA_struct_find_property(op->ptr, "proportional")) &&
!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)
+ }
+ else if (t->obedit_type != -1) {
ts->proportional = proportional;
- else if (t->options & CTX_MASK)
+ }
+ else if (t->options & CTX_MASK) {
ts->proportional_mask = (proportional != PROP_EDIT_OFF);
- else
+ }
+ else {
ts->proportional_objects = (proportional != PROP_EDIT_OFF);
+ }
}
if ((prop = RNA_struct_find_property(op->ptr, "proportional_size"))) {
@@ -2586,10 +2599,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:
@@ -2598,10 +2613,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);
@@ -2686,8 +2703,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;
@@ -2780,8 +2796,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);
}
@@ -2810,32 +2825,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 */
@@ -2844,19 +2868,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... */
@@ -2865,12 +2894,15 @@ 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);
@@ -2887,19 +2919,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 +2949,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 +2998,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 +3095,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 +3176,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 +3192,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 +3236,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);
@@ -3364,8 +3417,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 +3443,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 +3633,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 +3647,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 +3831,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 +3904,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 +3918,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 +4012,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 +4035,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 +4123,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 +4190,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 +4230,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 +4294,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 +4587,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);
@@ -4621,15 +4690,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);
@@ -4763,8 +4833,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;
@@ -4786,8 +4855,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;
@@ -4965,13 +5033,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) {
@@ -5074,8 +5145,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) {
@@ -5088,11 +5158,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;
@@ -5105,10 +5177,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);
}
@@ -5155,8 +5229,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);
}
@@ -5295,16 +5370,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;
@@ -5378,15 +5454,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;
@@ -5456,22 +5533,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;
+ }
}
}
}
@@ -5543,43 +5622,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;
+ }
}
}
}
@@ -5646,22 +5731,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;
+ }
}
}
}
@@ -5726,15 +5813,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;
@@ -5806,15 +5894,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) {
@@ -5892,32 +5981,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;
+ }
}
}
}
@@ -5976,35 +6071,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;
+ }
}
}
}
@@ -6059,10 +6161,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"),
@@ -6071,6 +6174,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,
@@ -6131,15 +6235,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);
}
@@ -6202,22 +6307,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;
+ }
}
}
}
@@ -6500,13 +6608,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;
@@ -6515,8 +6621,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,
@@ -6866,8 +6971,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 &&
@@ -7109,15 +7215,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;
@@ -7132,8 +7241,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);
@@ -7287,10 +7397,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
@@ -7563,8 +7675,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;
@@ -7592,8 +7703,9 @@ void freeEdgeSlideVerts(TransInfo *UNUSED(t),
{
EdgeSlideData *sld = custom_data->data;
- if (!sld)
+ if (!sld) {
return;
+ }
freeEdgeSlideTempFaces(sld);
@@ -7634,14 +7746,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);
}
}
@@ -7651,8 +7761,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;
@@ -7787,12 +7896,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();
@@ -7864,8 +7975,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++) {
@@ -7878,8 +7988,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++) {
@@ -7915,8 +8024,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++) {
@@ -8220,8 +8328,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) {
@@ -8246,8 +8353,9 @@ void freeVertSlideVerts(TransInfo *UNUSED(t),
{
VertSlideData *sld = custom_data->data;
- if (!sld)
+ if (!sld) {
return;
+ }
freeVertSlideTempFaces(sld);
@@ -8289,8 +8397,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) {
@@ -8509,8 +8616,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;
@@ -8658,15 +8764,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;
}
@@ -8732,35 +8839,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;
+ }
}
}
}
@@ -8812,15 +8926,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);
}
@@ -8835,15 +8950,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);
}
@@ -8851,10 +8967,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)"));
+ }
}
}
/** \} */
@@ -8879,19 +8997,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)) {
@@ -8978,15 +9097,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);
}
@@ -9042,20 +9162,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;
@@ -9065,10 +9188,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;
@@ -9087,10 +9212,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) {
@@ -9101,30 +9228,36 @@ 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
@@ -9203,14 +9336,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]);
@@ -9231,8 +9368,7 @@ 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
@@ -9341,21 +9477,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;
+ }
}
}
@@ -9424,8 +9562,7 @@ static void applyTimeSlideValue(TransInfo *t, float sval)
/* 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)
- {
+ 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,
@@ -9556,10 +9693,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]);
}
@@ -9572,8 +9711,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++) {
@@ -9596,8 +9734,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_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 3e58cecd42b..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)) {
@@ -221,10 +224,12 @@ static void axisProjection(const TransInfo *t,
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)
+ if (factor < 0.0f) {
factor *= -factor;
- else
+ }
+ else {
factor *= factor;
+ }
/* -factor makes move down going backwards */
normalize_v3_v3_length(out, axis, -factor);
@@ -267,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;
+ }
}
}
}
@@ -741,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);
@@ -764,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);
@@ -788,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) {
@@ -841,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);
@@ -855,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();
}
@@ -874,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];
@@ -991,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;
@@ -1151,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;
}
@@ -1175,14 +1193,17 @@ 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;
/*
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 3f16d2bcfee..e4f2adff77d 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++;
+ }
}
}
@@ -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;
@@ -609,22 +620,28 @@ static short apply_targetless_ik(Object *ob)
* the values here, or else there are huge discrepancies between IK-solver (interactive)
* and applied poses.
*/
- if (parchan->rotmode > 0)
+ if (parchan->rotmode > 0) {
mat3_to_eulO(parchan->eul, parchan->rotmode, rmat3);
- else if (parchan->rotmode == ROT_MODE_AXISANGLE)
+ }
+ else if (parchan->rotmode == ROT_MODE_AXISANGLE) {
mat3_to_axis_angle(parchan->rotAxis, &parchan->rotAngle, rmat3);
- else
+ }
+ else {
mat3_to_quat(parchan->quat, rmat3);
+ }
/* for size, remove rotation */
/* causes problems with some constraints (so apply only if needed) */
if (data->flag & CONSTRAINT_IK_STRETCH) {
- if (parchan->rotmode > 0)
+ if (parchan->rotmode > 0) {
eulO_to_mat3(qrmat, parchan->eul, parchan->rotmode);
- else if (parchan->rotmode == ROT_MODE_AXISANGLE)
+ }
+ else if (parchan->rotmode == ROT_MODE_AXISANGLE) {
axis_angle_to_mat3(qrmat, parchan->rotAxis, parchan->rotAngle);
- else
+ }
+ else {
quat_to_mat3(qrmat, parchan->quat);
+ }
invert_m3_m3(imat3, qrmat);
mul_m3_m3m3(smat, rmat3, imat3);
@@ -711,10 +728,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 +850,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 +870,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 +970,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 +1019,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 +1040,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 +1064,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 +1080,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 +1096,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 +1110,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 +1153,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 +1169,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 +1186,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 +1232,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 +1278,7 @@ static void createTransPose(TransInfo *t)
}
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->data_len == 0) {
continue;
}
@@ -1331,8 +1368,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 +1381,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 +1426,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 +1547,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 +1572,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 +1621,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 +1632,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 +1645,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 +1667,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 +1813,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 +1842,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 +1867,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 +1881,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 +1940,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 +1975,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 +2002,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 +2022,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,8 +2062,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);
+ }
/* TODO - in the case of tilt and radius we can also avoid allocating the
* initTransDataCurveHandles but for now just don't change handle types */
@@ -2041,10 +2103,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 +2137,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 +2152,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 +2166,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 +2224,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 +2239,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 +2256,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 +2270,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 +2293,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 +2309,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 +2338,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 +2385,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 +2406,9 @@ void flushTransParticles(TransInfo *t)
}
}
}
- else
+ else {
point->flag |= PEP_EDIT_RECALC;
+ }
}
PE_update_object(t->depsgraph, scene, OBACT(view_layer), 1);
@@ -2739,8 +2824,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);
@@ -2876,8 +2960,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) {
@@ -2916,12 +3001,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) {
@@ -2934,20 +3021,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);
@@ -2987,14 +3078,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);
@@ -3007,8 +3102,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;
@@ -3065,8 +3159,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)
@@ -3256,8 +3351,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;
@@ -3352,8 +3446,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;
@@ -3361,16 +3456,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);
@@ -3422,8 +3519,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];
@@ -3474,8 +3570,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;
@@ -3485,34 +3580,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;
+ }
}
}
@@ -3521,15 +3630,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]);
@@ -3543,14 +3653,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 ************************* */
@@ -3572,8 +3685,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 */
@@ -3607,10 +3721,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++;
+ }
}
}
}
@@ -3753,10 +3869,12 @@ static void createTransNlaData(bContext *C, TransInfo *t)
* 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++;
+ }
}
}
}
@@ -3774,10 +3892,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)) {
@@ -3791,10 +3911,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)) {
@@ -3887,8 +4009,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
@@ -4021,8 +4144,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 */
@@ -4037,25 +4161,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 */
@@ -4064,22 +4192,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 */
@@ -4088,23 +4220,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 */
@@ -4143,8 +4279,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) */
@@ -4154,8 +4291,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;
@@ -4301,14 +4439,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 */
@@ -4331,19 +4472,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;
@@ -4376,8 +4523,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;
@@ -4421,14 +4569,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;
@@ -4504,8 +4655,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;
+ }
}
}
}
@@ -4605,13 +4757,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);
@@ -4680,8 +4835,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);
@@ -4713,16 +4869,19 @@ 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. */
@@ -4734,8 +4893,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)) {
@@ -4802,10 +4962,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 */
@@ -4817,16 +4979,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);
@@ -4914,8 +5079,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++,
@@ -4939,16 +5105,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++,
@@ -4998,16 +5167,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) */
@@ -5071,8 +5243,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 */
@@ -5163,34 +5336,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;
}
@@ -5297,10 +5477,12 @@ 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,
* as these use the generic transform modes which don't account for this sort of thing.
@@ -5329,10 +5511,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];
@@ -5377,12 +5561,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);
@@ -5399,8 +5586,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) {
@@ -5408,8 +5596,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;
+ }
}
}
}
@@ -5684,8 +5873,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) {
@@ -5779,12 +5969,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);
+ }
}
}
@@ -5795,8 +5988,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);
}
@@ -5890,8 +6084,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
}
@@ -5932,23 +6127,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) ? */
}
}
@@ -6008,8 +6206,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
@@ -6198,8 +6397,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)) {
@@ -6225,7 +6425,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) {
@@ -6238,7 +6438,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);
}
}
@@ -6247,10 +6448,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;
}
@@ -6349,8 +6551,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;
@@ -6362,8 +6565,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;
@@ -6452,8 +6656,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) {
@@ -6496,8 +6701,9 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
flag);
}
- if (pchanName)
+ if (pchanName) {
MEM_freeN(pchanName);
+ }
}
}
}
@@ -6509,10 +6715,12 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
/* 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,
@@ -6670,8 +6878,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);
+ }
}
}
}
@@ -6681,8 +6890,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;
@@ -6754,8 +6962,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
@@ -6766,8 +6973,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);
}
@@ -6808,9 +7014,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(
@@ -6848,8 +7055,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;
@@ -6879,8 +7087,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 */
+ }
}
}
@@ -6891,11 +7100,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:
@@ -6924,8 +7135,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 (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- if (ID_REAL_USERS(gpd))
+ if (ID_REAL_USERS(gpd)) {
posttrans_gpd_clean(gpd);
+ }
}
}
}
@@ -6945,8 +7157,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);
+ }
}
}
}
@@ -6976,8 +7189,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;
@@ -6988,8 +7202,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};
@@ -7016,8 +7231,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);
+ }
}
}
@@ -7030,15 +7246,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};
@@ -7067,8 +7285,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');
@@ -7081,8 +7298,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);
}
@@ -7090,8 +7306,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;
@@ -7114,19 +7329,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) */
@@ -7182,11 +7400,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);
@@ -7199,8 +7419,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 */
@@ -7218,13 +7439,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);
+ }
}
}
@@ -7316,9 +7538,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;
@@ -7509,8 +7732,9 @@ 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;
@@ -7662,8 +7886,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;
@@ -7693,14 +7918,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;
@@ -7712,8 +7940,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),
@@ -7841,22 +8070,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),
@@ -7873,8 +8106,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(
@@ -7910,13 +8144,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 */
@@ -7944,14 +8180,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;
@@ -7962,8 +8201,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;
@@ -7989,8 +8229,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);
@@ -8009,8 +8250,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) {
@@ -8019,8 +8261,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);
@@ -8028,8 +8271,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);
}
@@ -8040,8 +8284,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) {
@@ -8288,8 +8533,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;
@@ -8333,8 +8579,9 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
}
}
- if (is_prop_edit)
+ if (is_prop_edit) {
count += 3;
+ }
}
}
}
@@ -8546,8 +8793,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;
@@ -8559,16 +8807,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");
@@ -8666,8 +8917,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) {
@@ -8703,8 +8955,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 */
@@ -8719,8 +8972,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++;
+ }
}
}
}
@@ -9001,8 +9255,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;
@@ -9157,8 +9410,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) {
@@ -9209,8 +9461,7 @@ 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;
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index eebb6382ccd..e816f4b31ff 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;
@@ -432,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);
@@ -478,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) {
@@ -496,14 +510,16 @@ 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);
@@ -559,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
@@ -651,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 {
@@ -669,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;
+ }
}
}
}
@@ -699,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);
}
@@ -730,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);
+ }
}
}
@@ -770,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;
@@ -801,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) {
@@ -828,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);
@@ -842,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;
@@ -858,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;
+ }
}
}
@@ -876,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) {
@@ -938,8 +961,7 @@ 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 */
}
@@ -949,8 +971,7 @@ static void recalcData_objects(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) {
Object *ob = tc->poseobj;
bArmature *arm = ob->data;
@@ -1008,18 +1029,19 @@ 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'
@@ -1039,8 +1061,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);
+ }
}
}
@@ -1523,10 +1546,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) {
@@ -1726,8 +1751,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);
}
}
@@ -1735,14 +1759,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));
@@ -1750,15 +1778,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;
@@ -1786,8 +1812,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) {
@@ -1864,8 +1891,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;
@@ -1901,8 +1927,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);
}
@@ -1994,8 +2019,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)) {
@@ -2023,8 +2047,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)) {
@@ -2102,12 +2125,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 */
@@ -2213,8 +2239,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) {
@@ -2240,18 +2265,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:
@@ -2325,8 +2353,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 58762a933c9..50610f1b3da 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -485,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 */
@@ -1055,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) {
@@ -1067,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 {
@@ -1076,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..b4c539fba8e 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 */
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 8b4c1c30959..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);
@@ -780,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])) {
@@ -866,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 d8e80265bec..e8bd8e905c9 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) {
@@ -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;
}
@@ -853,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) {
@@ -923,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];
@@ -1064,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
}
}
@@ -1124,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];
@@ -1161,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);
@@ -1207,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++) {
@@ -1507,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);
@@ -1516,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;
}
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 5d4867f5ef9..9174f6950ae 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -956,8 +956,9 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree
//printf("real edge found\n");
v_index[j] = mloop[lt->tri[j]].e;
}
- else
+ else {
v_index[j] = -1;
+ }
}
}
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 a574b353c16..49b5cada04a 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -483,8 +483,9 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
(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..867271229e2 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);
+ }
}
}
@@ -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..3983cce6769 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);
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 5ff90097840..4fb2c6441a3 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);
@@ -505,7 +510,8 @@ void ED_uvedit_draw_main(SpaceImage *sima,
draw_uvs_texpaint(scene, obact, depsgraph);
}
- if (show_uvedit && !(toolsettings->use_uv_sculpt))
+ 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 d1e63ad2986..16a4b647cfe 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);
@@ -142,8 +144,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 +175,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 +189,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 +273,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 +313,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 +445,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 +480,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 +505,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 +543,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 +565,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 +646,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 +703,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 +781,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 +925,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 +1047,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 +1065,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 +1087,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 +1109,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 +1192,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 +1291,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 +1343,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 +1351,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 +1449,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 +1663,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 +1697,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 +1717,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 +1744,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 +1822,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 +1851,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;
}
}
@@ -2294,8 +2346,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,17 +2437,20 @@ 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;
+ }
}
}
@@ -2439,12 +2495,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;
}
@@ -2513,8 +2572,7 @@ static int uv_mouse_select_multi(
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)
- {
+ 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);
@@ -2589,14 +2647,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 +2685,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;
}
@@ -2977,8 +3040,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)
{
@@ -3131,11 +3194,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;
}
@@ -3143,8 +3208,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;
@@ -3163,10 +3229,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,
@@ -3247,10 +3315,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,
@@ -3415,8 +3485,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);
@@ -3826,8 +3897,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);
@@ -3875,8 +3947,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)) {
@@ -3902,8 +3975,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)) {
@@ -3991,8 +4065,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)) {
@@ -4329,8 +4404,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) {
@@ -4345,8 +4421,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;
+ }
}
}
}
@@ -4354,8 +4431,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);
@@ -4539,8 +4617,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);
@@ -4650,20 +4729,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) {
@@ -4674,11 +4756,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 */
@@ -4687,8 +4771,9 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
commonFaces = 1;
}
}
- else
+ else {
separated1 = 1;
+ }
if (separated1 || separated2) {
faces_separated = 1;
@@ -4699,10 +4784,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);
+ }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 913aacec4c8..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);
+ }
}
}
@@ -2350,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;
@@ -2404,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));
@@ -2504,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];
@@ -2615,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]);
+ }
}
}
}
@@ -2693,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);
}
@@ -2728,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) {
@@ -2755,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;
@@ -2808,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");
@@ -2906,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) {
@@ -2944,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;
@@ -3054,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)) {
@@ -3072,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) {
@@ -3091,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);
@@ -3113,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);
@@ -3152,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;
+ }
}
}
@@ -3176,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);
@@ -3240,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);
@@ -3261,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)
@@ -3278,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);
@@ -3315,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;
}
@@ -3343,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];
@@ -3394,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);
+ }
}
}
@@ -3406,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)
@@ -3431,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 {
@@ -3455,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++;
@@ -3467,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;
@@ -3494,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);
}
@@ -3517,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");
@@ -3577,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;
@@ -3618,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);
@@ -3712,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");
@@ -3761,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])
@@ -3774,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);
+ }
}
}
@@ -3795,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)
@@ -3811,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);
@@ -3845,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;
@@ -3905,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;
@@ -3922,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;
@@ -4062,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);
@@ -4084,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;
@@ -4149,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);
@@ -4197,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);
@@ -4323,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)
@@ -4361,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;
@@ -4383,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);
}
}
@@ -4404,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);
+ }
}
}
}
@@ -4447,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);
@@ -4503,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);
}
@@ -4557,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");
@@ -4592,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) {
@@ -4622,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;
@@ -4638,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)
@@ -4651,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;
@@ -4729,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);
+ }
}
}
@@ -4749,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/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_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/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_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_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_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_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 2b678876cde..a2f63882860 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};
/** \} */
@@ -131,7 +131,10 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len)
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);
}
@@ -159,7 +162,6 @@ static void gpu_pbvh_batch_init(GPU_PBVH_Buffers *buffers, GPUPrimType prim)
}
if (buffers->lines == NULL) {
- BLI_assert(buffers->index_lines_buf != NULL);
buffers->lines = GPU_batch_create(GPU_PRIM_LINES,
buffers->vert_buf,
/* can be NULL if buffer is empty */
@@ -183,10 +185,12 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
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;
{
@@ -216,6 +220,18 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
}
}
}
+
+ if (vcol && show_vcol) {
+ for (uint i = 0; i < buffers->face_indices_len; i++) {
+ const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
+ 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 */
@@ -231,8 +247,9 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
buffers->mloop[lt->tri[2]].v,
};
- if (paint_is_face_hidden(lt, mvert, buffers->mloop))
+ if (paint_is_face_hidden(lt, mvert, buffers->mloop)) {
continue;
+ }
/* Face normal and mask */
if (lt->poly != mpoly_prev) {
@@ -255,6 +272,12 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
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);
+ }
+
vbo_index++;
}
@@ -291,8 +314,9 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
/* 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))
+ if (!paint_is_face_hidden(lt, mvert, mloop)) {
tottri++;
+ }
}
if (tottri == 0) {
@@ -325,8 +349,9 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
const MLoopTri *lt = &looptri[face_indices[i]];
/* Skip hidden faces */
- if (paint_is_face_hidden(lt, mvert, mloop))
+ if (paint_is_face_hidden(lt, mvert, mloop)) {
continue;
+ }
GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i]));
@@ -347,8 +372,9 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
const MLoopTri *lt = &looptri[face_indices[i]];
/* Skip hidden faces */
- if (paint_is_face_hidden(lt, mvert, mloop))
+ if (paint_is_face_hidden(lt, mvert, mloop)) {
continue;
+ }
/* TODO skip "non-real" edges. */
GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 0, i * 3 + 1);
@@ -507,10 +533,12 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
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;
+ static char vcol[4] = {255, 255, 255, 255};
/* Build VBO */
const int has_mask = key->has_mask;
@@ -573,6 +601,11 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index, &fmask);
empty_mask = empty_mask && (fmask == 0.0f);
}
+
+ if (show_vcol) {
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, &vcol);
+ }
+
vbo_index += 1;
}
}
@@ -619,6 +652,10 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
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;
}
}
@@ -673,6 +710,7 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn(BMVert *v,
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)) {
@@ -690,6 +728,11 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn(BMVert *v,
*empty_mask = *empty_mask && (effective_mask == 0.0f);
}
+ 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! */
@@ -706,13 +749,15 @@ static int gpu_bmesh_vert_visible_count(GSet *bm_unique_verts, GSet *bm_other_ve
GSET_ITER (gs_iter, bm_unique_verts) {
BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
- if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN))
+ 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))
+ if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
totvert++;
+ }
}
return totvert;
@@ -727,8 +772,9 @@ static int gpu_bmesh_face_visible_count(GSet *bm_faces)
GSET_ITER (gh_iter, bm_faces) {
BMFace *f = BLI_gsetIterator_getKey(&gh_iter);
- if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN))
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
totface++;
+ }
}
return totface;
@@ -744,6 +790,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
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;
@@ -792,6 +839,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
NULL,
cd_vert_mask_offset,
show_mask,
+ show_vcol,
&empty_mask);
}
@@ -803,6 +851,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
NULL,
cd_vert_mask_offset,
show_mask,
+ show_vcol,
&empty_mask);
}
@@ -844,6 +893,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
&fmask,
cd_vert_mask_offset,
show_mask,
+ show_vcol,
&empty_mask);
}
}
@@ -966,10 +1016,12 @@ void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers)
/* debug function, draws the pbvh BB */
void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, uint pos)
{
- if (leaf)
+ if (leaf) {
immUniformColor4f(0.0, 1.0, 0.0, 0.5);
- else
+ }
+ else {
immUniformColor4f(1.0, 0.0, 0.0, 0.5);
+ }
/* TODO(merwin): revisit this after we have mutable VertexBuffers
* could keep a static batch & index buffer, change the VBO contents per draw
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 242544ec07f..aef68333b6f 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,44 @@ 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, "\tvec3 facingnormal = gl_FrontFacing? viewNormal: -viewNormal;\n");
- if (builtins & GPU_VIEW_POSITION)
+ }
+ 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");
@@ -1266,8 +1346,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();
@@ -1292,8 +1373,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;
@@ -1307,8 +1389,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);
}
@@ -1339,12 +1422,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);
}
}
@@ -1373,8 +1458,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;
}
@@ -1539,8 +1625,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);
@@ -1552,11 +1639,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);
@@ -1754,19 +1842,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);
@@ -1791,25 +1883,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);
@@ -2068,8 +2165,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_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 77ecac35835..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)
@@ -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 3c8b76dd36c..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);
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_select.c b/source/blender/gpu/intern/gpu_select.c
index 4cfedc0708b..17d3321560d 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: {
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 253c8703234..6c3e05912b0 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 {
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index dd8035e2618..b0b0fe01192 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
*/
@@ -637,17 +654,22 @@ void GPU_shader_free(GPUShader *shader)
#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..13164c86ffb 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 */
@@ -1029,10 +1048,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 +1071,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 +1546,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 +1580,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 +1626,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 +1645,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 +1694,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 +1734,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 +1745,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_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..6ad93e88130 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;
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 8445c0f8f3a..bdc1abf3132 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -472,7 +472,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);
@@ -660,7 +661,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 eaf3d58270a..76304b33a6f 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 */
@@ -602,8 +638,9 @@ 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..4ef4e15d1c9 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -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;
}
@@ -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 f960faee1ab..b1ca6221753 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.cpp
+++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp
@@ -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/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 c392ef351ff..581d740c97c 100644
--- a/source/blender/imbuf/intern/dds/ColorBlock.cpp
+++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp
@@ -130,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;
}
@@ -238,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;
}
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index 89fe3bf5f25..abe8a0c1883 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -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;
@@ -747,26 +749,32 @@ void DDSHeader::setDX10Format(uint 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)
@@ -868,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()
@@ -975,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
@@ -988,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
@@ -1196,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);
@@ -1209,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) {
@@ -1307,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;
@@ -1341,7 +1364,7 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
else {
printf("DDS: mipmap format not supported\n");
return (0);
- };
+ }
}
uint DirectDrawSurface::faceSize() const
@@ -1378,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.
@@ -1458,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 ba487afdfc1..e63b17c89e5 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 {
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 32b1c6b280e..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)
{
@@ -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 ccab0164df7..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
@@ -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,
@@ -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 a09f83e9b92..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;
}
@@ -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,8 +572,9 @@ 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 */
@@ -606,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..4424e5548ca 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);
+ }
}
}
@@ -205,18 +206,21 @@ static size_t IMB_get_size_in_memory(ImBuf *ibuf)
size += sizeof(ImBuf);
- if (ibuf->rect)
+ if (ibuf->rect) {
channel_size += sizeof(char);
+ }
- if (ibuf->rect_float)
+ 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])
+ if (ibuf->mipmap[a]) {
size += IMB_get_size_in_memory(ibuf->mipmap[a]);
+ }
}
}
@@ -232,8 +236,9 @@ static size_t get_item_size(void *p)
size_t size = sizeof(MovieCacheItem);
MovieCacheItem *item = (MovieCacheItem *)p;
- if (item->ibuf)
+ if (item->ibuf) {
size += IMB_get_size_in_memory(item->ibuf);
+ }
return size;
}
@@ -285,8 +290,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 +344,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 +374,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 +384,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);
@@ -460,11 +469,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 +511,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 +542,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 +552,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 +568,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 4e801c8e3aa..31649330e11 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);
}
@@ -1095,8 +1176,9 @@ void IMB_exrtile_write_channels(
/* eventually we can make the parts' channels to include
* only the current view TODO */
- if (strcmp(viewname, echan->m->view.c_str()) != 0)
+ 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,18 +1894,19 @@ 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();
@@ -1813,8 +1916,9 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
//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 bff2ac62fdf..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;
}
@@ -457,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);
}
@@ -489,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);
@@ -538,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);
@@ -567,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;
}
@@ -618,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;
@@ -791,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..d44ce1ac269 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 */
+ /* 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, "#?"))
+ 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);
@@ -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 6341192c40c..06b8019a24d 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -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 fd3409b266c..5af7f9d0bbf 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;
@@ -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. */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 210e0901d26..c21a4191bf7 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -458,8 +458,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). */
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_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_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 882653ab73e..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 {
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..1c7712dbb17 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,
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 6befb9da522..4bdb348c74f 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -264,13 +264,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;
@@ -466,10 +467,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.
*/
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..781a2216029 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 {
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_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..6923619ef91 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -643,9 +643,9 @@ 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. */
@@ -949,7 +949,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 {
@@ -1103,10 +1104,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..0667ab3aee0 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 {
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 44526c93815..49c709b972c 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -77,8 +77,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 {
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 5564912335e..0ea1ca9c018 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -465,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");
@@ -587,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..463d612094e 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -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 168df3285b2..94fa06452be 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");
@@ -1429,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");
@@ -1530,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");
@@ -1560,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;
@@ -1576,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;
@@ -1621,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);
@@ -1641,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);
@@ -1650,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);
@@ -1664,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);
@@ -1673,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);
@@ -1731,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(
@@ -1856,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");
}
@@ -1897,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;
}
}
@@ -2020,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");
}
@@ -2049,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: {
@@ -2065,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,
@@ -2075,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,
@@ -2085,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;
}
}
@@ -2122,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");
@@ -2137,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",
@@ -2179,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)
@@ -2208,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: {
@@ -2271,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: {
@@ -2336,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;
@@ -2359,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));
@@ -2384,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");
@@ -2403,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);
@@ -2422,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 = ");
@@ -2471,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);
@@ -2481,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;
@@ -2509,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");
@@ -2538,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");
@@ -2556,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");
@@ -2575,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,
+ /* 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))
+ }
+ 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",
@@ -2606,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");
}
@@ -2618,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");
@@ -2641,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)) {
@@ -2666,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",
@@ -2680,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",
@@ -2691,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;
@@ -2710,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");
@@ -2789,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) {
@@ -2812,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);
+ }
}
}
}
@@ -2840,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)
@@ -2976,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");
}
@@ -2989,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"
@@ -3014,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");
}
@@ -3043,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 ",
@@ -3051,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)
@@ -3073,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;
}
@@ -3085,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,
@@ -3108,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;
@@ -3138,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");
}
@@ -3184,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),
@@ -3401,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");
@@ -3426,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");
@@ -3451,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");
@@ -3466,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;
@@ -3476,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;
@@ -3494,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,
@@ -3542,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");
@@ -3569,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: {
@@ -3601,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: {
@@ -3635,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: {
@@ -3665,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;
}
@@ -3680,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: {
@@ -3698,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;
}
}
@@ -3723,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);
@@ -3776,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");
@@ -3796,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 */
@@ -3832,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);
}
@@ -3843,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));
@@ -3871,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");
@@ -4003,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
@@ -4022,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);
@@ -4041,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
@@ -4096,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");
@@ -4459,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");
}
@@ -4515,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) {
@@ -4553,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");
@@ -4573,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");
}
@@ -4619,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..c893fb86851 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;
}
@@ -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..27a9333cd9e 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;
}
@@ -688,8 +693,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 +703,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 +714,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 +724,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 +742,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 +1021,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");
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..6c31d256cb7 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); */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index e2ff6935e43..d5c9dfb8d02 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1246,7 +1246,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 */
@@ -1840,6 +1840,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");
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..934847fed50 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -594,9 +594,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;
@@ -617,9 +615,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
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;
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 89dd6a308ce..44445181402 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -2961,7 +2961,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_curve.c b/source/blender/makesrna/intern/rna_curve.c
index e73f5841da9..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)
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..215c513c003 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -185,7 +185,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);
}
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 3bed1955b2e..7ad6b5d4cf1 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;
}
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..f87bb69a94f 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);
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_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 c76e243e100..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);
}
@@ -2076,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) \
@@ -2116,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) \
@@ -2163,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
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 2d7fe1a6e09..cbafddb11a3 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5261,7 +5261,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"},
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 8a064bd065d..1ce7b776126 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);
@@ -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
@@ -8142,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.
*/
@@ -8219,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);
@@ -8304,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.
*/
@@ -9124,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);
@@ -9139,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);
@@ -9163,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 047887644c8..aed7b83e34f 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -346,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);
@@ -357,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);
}
@@ -1369,8 +1371,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__);
@@ -1458,7 +1460,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);
@@ -1860,7 +1863,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(
@@ -2640,7 +2644,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 63ccc10afb2..02b700a03c1 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -534,7 +534,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 +592,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 4cafa42c9fc..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 5f652777481..1b4a7efbdd8 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -614,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);
@@ -743,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);
}
@@ -978,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 16897a2b4d6..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,
@@ -1725,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);
@@ -1733,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;
@@ -1742,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,
@@ -1765,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) {
@@ -1878,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. */
@@ -2810,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");
@@ -2981,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");
}
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 848944262e8..53cfc0bc3c0 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -713,8 +713,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;
@@ -1009,7 +1009,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 +1144,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 +1840,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");
@@ -2528,6 +2536,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);
@@ -3603,16 +3612,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);
@@ -3644,10 +3657,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);
@@ -3655,270 +3670,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)
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 5913376606b..89996cf3241 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},
};
@@ -550,11 +551,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..be76a8136c0 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -504,7 +504,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 01ea7471b29..6f524be7473 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(
@@ -2701,8 +2704,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..ca00ce993d3 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",
@@ -191,7 +197,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 +362,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 +378,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 +559,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 +910,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 +923,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 +1081,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 +1221,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 +1810,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 +1887,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 +2441,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 +2493,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 +2503,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 +3004,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 +3137,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 +3484,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 +3594,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 +3999,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 +4102,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 +4334,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 +4478,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 +4602,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 +4782,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 +4935,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 +5728,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 +5906,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 dd378c60c72..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;
@@ -1405,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 c41e1623961..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);
@@ -1473,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..0236820e4d9 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -2949,10 +2949,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);
@@ -4474,7 +4472,8 @@ 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 */
+ /* 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 +4533,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 +4579,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 +4594,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 +4765,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 +5085,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);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index e3c2f9d5233..34faf13fa7e 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -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_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 b7408355bc2..2a1e46d6505 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -21,18 +21,18 @@
set(INC
.
intern
+ ../blenfont
../blenkernel
../blenlib
- ../blenfont
+ ../bmesh
../depsgraph
+ ../functions
../makesdna
../makesrna
- ../bmesh
- ../functions
../render/extern/include
../../../intern/elbeem/extern
- ../../../intern/guardedalloc
../../../intern/eigen
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index c909f9dc076..3443d275c81 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,
@@ -441,10 +444,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 +487,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;
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 32a020a35ff..02d3bd305be 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -124,24 +124,28 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
.pmask = CD_MASK_ORIGINDEX},
});
- if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0])
+ 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_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index e801b69ad3f..b5454497152 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -330,10 +330,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_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 6109db3651c..7d87ba240d5 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -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);
@@ -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_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 02682b23490..71636463f70 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -730,8 +730,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_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_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_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index ce1554b7e33..1ca25cbb068 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -481,8 +481,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 8573ef14e09..5d7b380a751 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -62,8 +62,9 @@ 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)
@@ -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);
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 8fadfbaff07..bfd1858df09 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:
@@ -350,8 +351,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
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 */
@@ -362,8 +364,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 */
@@ -690,8 +693,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++) {
@@ -704,8 +708,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);*/
@@ -812,8 +817,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);
@@ -849,8 +855,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);
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 e114483759e..7ddde7236c0 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;
@@ -992,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]);
+ }
}
}
@@ -1046,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;
@@ -1077,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) {
@@ -1174,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) {
@@ -1208,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;
@@ -1286,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);
@@ -1314,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 */
@@ -1407,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 */
@@ -1504,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);
+ }
}
}
}
@@ -1523,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) {
@@ -1575,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 {
@@ -1601,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);
@@ -1610,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);
+ }
}
}
@@ -1631,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) {
@@ -1668,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);
}
@@ -1701,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 */
@@ -1710,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 */
@@ -1805,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);
@@ -1823,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);
@@ -1851,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 0cf864fbf89..78006147ab5 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -534,10 +534,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;
}
@@ -568,10 +570,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;
}
@@ -735,8 +739,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) {
@@ -948,11 +953,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_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_util.c b/source/blender/modifiers/intern/MOD_util.c
index 953848a22a0..fc2e3dd587d 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 */
}
@@ -235,10 +237,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 2ee0b36edc9..f9eb92cd132 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -68,8 +68,9 @@ 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)
@@ -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_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 3e1c2f9bc02..871da8dfba9 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -135,8 +135,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_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 f41689b741c..e509d1464f2 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -78,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;
+ }
}
/**************************************
@@ -140,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..9699b5f15dd 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -194,12 +194,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 +248,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 +327,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 +384,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 +531,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/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 53fdde5baf2..fd6435312b9 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);
}
@@ -253,12 +257,14 @@ 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 +273,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);
+ }
}
}
@@ -290,119 +298,30 @@ void ntreeCompositTagRender(Scene *curscene)
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/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_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index 729252f0937..e4c9b8dd0cd 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -276,8 +276,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_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index d4278b3b540..a1649d9f8f0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -90,8 +90,9 @@ static void cmp_node_image_add_pass_output(bNodeTree *ntree,
* 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 +159,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,
@@ -345,10 +348,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
@@ -368,8 +373,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 +393,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 +418,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 +434,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)
@@ -518,9 +527,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);
}
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..806a05757d0 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);
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..f61c6bdd83b 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;
+ }
}
}
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index d9ea6425b01..ed4cdde67f0 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 */
@@ -216,8 +228,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 +283,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 +344,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 +360,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 +386,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);
}
@@ -390,9 +414,11 @@ static void node_group_input_init(bNodeTree *ntree, bNode *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;
}
@@ -422,8 +448,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");
@@ -487,9 +514,11 @@ static void node_group_output_init(bNodeTree *ntree, bNode *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;
}
@@ -519,8 +548,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");
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index ed3dbf4515b..7fcba8cb472 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;
@@ -179,16 +188,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 +212,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 +224,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 +243,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 +260,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 +324,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..4141ccccafa 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -131,8 +131,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 +146,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 +169,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 +185,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 +352,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 +391,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..ed531a092ca 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -408,8 +408,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 +440,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. */
@@ -574,8 +577,9 @@ static void ntree_shader_link_builtin_group_normal(bNodeTree *ntree,
/* 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)
+ if (group_input_node) {
node_group_input_verify(group_ntree, group_input_node, &group_ntree->id);
+ }
ntreeUpdateTree(G.main, group_ntree);
/* Assumes sockets are always added at the end. */
bNodeSocket *group_node_normal_socket = group_node->inputs.last;
@@ -849,8 +853,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 +868,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 +891,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 +929,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..e75cb8a6642 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) {
@@ -98,18 +100,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 +141,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 +153,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 +164,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 +193,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 +236,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 +249,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 +281,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_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_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
index e0fda117648..b45249e11b2 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;
+ }
}
}
}
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..64dd2f28208 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);
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..f8d1617887e 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: {
@@ -150,53 +172,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 +247,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_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..d590f229c1a 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;
+ }
}
}
}
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..d4dcb6857d2 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;
}
@@ -117,8 +115,9 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
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,8 +127,9 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
}
BKE_image_release_ibuf(ima, ibuf, NULL);
- if (!in[0].link)
+ if (!in[0].link) {
in[0].link = GPU_attribute(CD_MTFACE, "");
+ }
node_shader_gpu_tex_mapping(mat, node, in, out);
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_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..60630da586d 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,8 +321,9 @@ 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) */
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..929bf92dec3 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);
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..bf7cdf18d44 100644
--- a/source/blender/nodes/texture/nodes/node_texture_proc.c
+++ b/source/blender/nodes/texture/nodes/node_texture_proc.c
@@ -59,14 +59,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 +278,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/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 279208993a0..f540b2e102c 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -2593,8 +2593,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 +2743,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 +3166,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 +3340,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;
}
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/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/intern/bpy.c b/source/blender/python/intern/bpy.c
index ed576c553e4..08f4df543a8 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -274,19 +274,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_interface.c b/source/blender/python/intern/bpy_interface.c
index 774ce2b9422..90dfdcd33b7 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 */
@@ -105,7 +104,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 +148,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
@@ -329,8 +326,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 +422,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 +448,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 +697,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 +708,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 +716,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 +768,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;
}
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 2c31fcda12d..0f66a9cbeb9 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"
@@ -320,9 +319,6 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
* 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_rna.c b/source/blender/python/intern/bpy_rna.c
index ed8bbe939af..0ca96071ee0 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -8827,16 +8827,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_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index 7d690cb7d47..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},
};
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index bb7604aea97..78dae50efe6 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -54,20 +54,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)
@@ -225,10 +226,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)) {
@@ -378,10 +377,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/stubs.c b/source/blender/python/intern/stubs.c
index bf068f99722..448751b1155 100644
--- a/source/blender/python/intern/stubs.c
+++ b/source/blender/python/intern/stubs.c
@@ -33,7 +33,6 @@
/* python, will come back */
//void BPY_script_exec(void) {}
//void BPY_python_start(void) {}
-//void BPY_text_free_code(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.h b/source/blender/python/mathutils/mathutils.h
index a69d00d10e7..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 {
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 145508b514e..46d2df0acb5 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -91,7 +91,8 @@ 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;
@@ -125,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/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 df114ed9c1d..c62322a2af4 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];
@@ -945,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 */
@@ -991,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)) {
@@ -1002,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;
}
@@ -1043,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;
@@ -1063,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;
@@ -1080,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);
@@ -1100,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 {
@@ -1121,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;
@@ -1147,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;
}
}
@@ -1181,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) {
@@ -1213,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;
@@ -1222,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);
@@ -1234,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++;
}
@@ -1247,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;
@@ -1320,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;
@@ -1348,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
@@ -1368,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 */
@@ -1381,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;
@@ -1404,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;
@@ -1419,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;
}
@@ -1471,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;
@@ -1489,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);
@@ -1524,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 {
@@ -1542,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;
}
}
@@ -1559,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;
+ }
}
}
}
@@ -1595,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);
+ }
}
}
@@ -1643,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);
@@ -1667,10 +1771,12 @@ 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) {
@@ -1792,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) {
@@ -1824,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) {
@@ -1835,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
@@ -1857,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;
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 52792718108..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);
}
@@ -1310,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 */
@@ -1421,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,
@@ -1436,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;
@@ -1445,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 bab806f6231..cfe7f4923a0 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
@@ -1248,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;
}
@@ -1287,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 */
@@ -1354,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;
@@ -1445,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;
@@ -1526,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;
@@ -1613,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]);
}
@@ -1638,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);
+ }
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
@@ -1669,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)) {
@@ -1697,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)) {
@@ -1739,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)) {
@@ -1776,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) {
@@ -1801,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;
@@ -1968,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;
@@ -2012,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);
@@ -2042,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;
@@ -2097,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;
}
@@ -2124,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) &&
@@ -2158,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);
@@ -2218,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;
@@ -2250,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;
@@ -2339,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),
@@ -2350,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);
@@ -2366,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);
@@ -2433,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;
@@ -2470,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;
@@ -2526,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),
@@ -2540,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) {
@@ -2555,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);
@@ -2585,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);
@@ -2608,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 */
@@ -2630,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);
@@ -2660,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;
@@ -2725,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;
@@ -2759,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);
}
@@ -2781,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) {
@@ -2852,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;
@@ -2865,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..de3cff62537 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;
}
@@ -274,8 +281,9 @@ static float wood_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 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..5cc70aecd8d 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -635,7 +635,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_types.h b/source/blender/windowmanager/WM_types.h
index 425853c7a96..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;
@@ -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..f21baa21006 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);
}
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 1cc45653087..76a59944832 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;
}
}
@@ -1992,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;
@@ -2274,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,
@@ -2942,15 +2952,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])
@@ -3176,7 +3194,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);
@@ -3209,7 +3228,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);
@@ -3235,12 +3255,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 */
@@ -3276,7 +3297,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. */
}
}
@@ -3367,8 +3389,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) {
@@ -3466,7 +3487,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;
}
@@ -3485,7 +3507,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;
@@ -3685,8 +3708,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)) {
@@ -3723,8 +3745,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) {
@@ -4151,8 +4172,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;
@@ -4230,11 +4252,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;
@@ -4346,7 +4372,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;
@@ -4505,14 +4532,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)) {
@@ -4926,7 +4955,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 e55afeb6f4c..f9e420a987f 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
@@ -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;
@@ -1322,12 +1335,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);
@@ -2409,8 +2424,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 1b2ecf4c1ab..b12bb89ea9f 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -255,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 00f9f078f91..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);
}
@@ -476,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) {
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..d67fb064dbe 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -104,7 +104,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)
{
@@ -665,16 +666,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;
@@ -890,7 +896,8 @@ wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const bContext *C,
/* ****************** modal keymaps ************ */
-/* modal maps get linked to a running operator, and filter the keys before sending to modal() callback */
+/* Modal key-maps get linked to a running operator,
+ * and filter the keys before sending to modal() callback. */
wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf,
const char *idname,
@@ -1051,7 +1058,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);
@@ -1121,7 +1129,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... */
@@ -1409,10 +1418,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 +1447,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 +1548,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,
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 701aae20cd3..9680f82fe8b 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;
@@ -777,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 :
@@ -1161,7 +1164,8 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
/* 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);
@@ -3343,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");
@@ -3361,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;
@@ -3636,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");
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 47f860e7667..41e63cc0aca 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -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..0abb5678800 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -246,7 +246,8 @@ 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). */
+ * 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) {
@@ -602,7 +603,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.
*/
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 89696082e7a..2dbe738dd86 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);
}
}
@@ -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_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,