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:
authorYiming Wu <xp8110@outlook.com>2019-04-04 14:14:41 +0300
committerYiming Wu <xp8110@outlook.com>2019-04-04 14:14:41 +0300
commit525c9034cd77e22d9307f3813c47a314269dda73 (patch)
treeb1663d8d04afc7615a82a456810384446977a522 /source/blender
parenta08bf336f5425d81bacbc8fbfa77bca209de8a93 (diff)
parentc384b5ddbdcb4c0b26e55a824681db1f9753e496 (diff)
Merge remote-tracking branch 'origin/master' into soc-2018-npr
# Conflicts: # release/datafiles/locale # release/scripts/addons # release/scripts/addons_contrib # release/scripts/startup/bl_ui/properties_scene.py # source/blender/draw/intern/draw_manager_texture.c # source/blender/makesdna/DNA_scene_types.h # source/blender/makesrna/intern/rna_scene.c # source/tools
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/alembic/intern/abc_curves.cc8
-rw-r--r--source/blender/alembic/intern/abc_customdata.cc12
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc26
-rw-r--r--source/blender/alembic/intern/abc_nurbs.cc8
-rw-r--r--source/blender/alembic/intern/abc_points.cc8
-rw-r--r--source/blender/avi/intern/avi_mjpeg.c22
-rw-r--r--source/blender/blenfont/intern/blf_font.c2
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c37
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h73
-rw-r--r--source/blender/blenkernel/BKE_blender_copybuffer.h6
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_brush.h1
-rw-r--r--source/blender/blenkernel/BKE_cloth.h12
-rw-r--r--source/blender/blenkernel/BKE_collection.h29
-rw-r--r--source/blender/blenkernel/BKE_context.h4
-rw-r--r--source/blender/blenkernel/BKE_dynamicpaint.h2
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h25
-rw-r--r--source/blender/blenkernel/BKE_gpencil_modifier.h2
-rw-r--r--source/blender/blenkernel/BKE_image.h2
-rw-r--r--source/blender/blenkernel/BKE_layer.h12
-rw-r--r--source/blender/blenkernel/BKE_main.h28
-rw-r--r--source/blender/blenkernel/BKE_mball.h17
-rw-r--r--source/blender/blenkernel/BKE_mesh_remap.h5
-rw-r--r--source/blender/blenkernel/BKE_mesh_runtime.h33
-rw-r--r--source/blender/blenkernel/BKE_modifier.h34
-rw-r--r--source/blender/blenkernel/BKE_node.h9
-rw-r--r--source/blender/blenkernel/BKE_object.h6
-rw-r--r--source/blender/blenkernel/BKE_paint.h2
-rw-r--r--source/blender/blenkernel/BKE_particle.h18
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h2
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h4
-rw-r--r--source/blender/blenkernel/BKE_scene.h9
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.h10
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c1320
-rw-r--r--source/blender/blenkernel/intern/anim.c3
-rw-r--r--source/blender/blenkernel/intern/appdir.c41
-rw-r--r--source/blender/blenkernel/intern/armature.c33
-rw-r--r--source/blender/blenkernel/intern/armature_update.c12
-rw-r--r--source/blender/blenkernel/intern/blender.c2
-rw-r--r--source/blender/blenkernel/intern/blender_copybuffer.c15
-rw-r--r--source/blender/blenkernel/intern/blendfile.c15
-rw-r--r--source/blender/blenkernel/intern/boids.c49
-rw-r--r--source/blender/blenkernel/intern/bpath.c6
-rw-r--r--source/blender/blenkernel/intern/brush.c53
-rw-r--r--source/blender/blenkernel/intern/cachefile.c2
-rw-r--r--source/blender/blenkernel/intern/camera.c46
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c2
-rw-r--r--source/blender/blenkernel/intern/cloth.c12
-rw-r--r--source/blender/blenkernel/intern/collection.c46
-rw-r--r--source/blender/blenkernel/intern/colorband.c47
-rw-r--r--source/blender/blenkernel/intern/context.c4
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c42
-rw-r--r--source/blender/blenkernel/intern/curve.c6
-rw-r--r--source/blender/blenkernel/intern/customdata.c35
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c13
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c148
-rw-r--r--source/blender/blenkernel/intern/effect.c1
-rw-r--r--source/blender/blenkernel/intern/gpencil.c174
-rw-r--r--source/blender/blenkernel/intern/gpencil_modifier.c21
-rw-r--r--source/blender/blenkernel/intern/image.c88
-rw-r--r--source/blender/blenkernel/intern/lattice.c2
-rw-r--r--source/blender/blenkernel/intern/layer.c28
-rw-r--r--source/blender/blenkernel/intern/library.c9
-rw-r--r--source/blender/blenkernel/intern/library_query.c29
-rw-r--r--source/blender/blenkernel/intern/library_remap.c8
-rw-r--r--source/blender/blenkernel/intern/light.c2
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c2
-rw-r--r--source/blender/blenkernel/intern/linestyle.c2
-rw-r--r--source/blender/blenkernel/intern/material.c8
-rw-r--r--source/blender/blenkernel/intern/mball.c69
-rw-r--r--source/blender/blenkernel/intern/mesh.c16
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c114
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c27
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c25
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c24
-rw-r--r--source/blender/blenkernel/intern/modifier.c38
-rw-r--r--source/blender/blenkernel/intern/movieclip.c51
-rw-r--r--source/blender/blenkernel/intern/multires.c4
-rw-r--r--source/blender/blenkernel/intern/node.c108
-rw-r--r--source/blender/blenkernel/intern/object.c101
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c35
-rw-r--r--source/blender/blenkernel/intern/object_update.c31
-rw-r--r--source/blender/blenkernel/intern/particle.c100
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c43
-rw-r--r--source/blender/blenkernel/intern/particle_system.c18
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c2
-rw-r--r--source/blender/blenkernel/intern/pointcache.c15
-rw-r--r--source/blender/blenkernel/intern/scene.c39
-rw-r--r--source/blender/blenkernel/intern/sequencer.c7
-rw-r--r--source/blender/blenkernel/intern/smoke.c20
-rw-r--r--source/blender/blenkernel/intern/softbody.c32
-rw-r--r--source/blender/blenkernel/intern/speaker.c2
-rw-r--r--source/blender/blenkernel/intern/studiolight.c6
-rw-r--r--source/blender/blenkernel/intern/subdiv_ccg.c174
-rw-r--r--source/blender/blenkernel/intern/subdiv_converter_mesh.c4
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c3
-rw-r--r--source/blender/blenkernel/intern/text.c2
-rw-r--r--source/blender/blenkernel/intern/texture.c2
-rw-r--r--source/blender/blenkernel/intern/tracking.c4
-rw-r--r--source/blender/blenkernel/intern/tracking_auto.c2
-rw-r--r--source/blender/blenkernel/intern/undo_system.c2
-rw-r--r--source/blender/blenkernel/intern/workspace.c5
-rw-r--r--source/blender/blenkernel/intern/world.c2
-rw-r--r--source/blender/blenlib/BLI_assert.h32
-rw-r--r--source/blender/blenlib/BLI_kdtree.h86
-rw-r--r--source/blender/blenlib/BLI_kdtree_impl.h89
-rw-r--r--source/blender/blenlib/BLI_listbase.h4
-rw-r--r--source/blender/blenlib/BLI_math_geom.h5
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h3
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h2
-rw-r--r--source/blender/blenlib/BLI_math_vector.h3
-rw-r--r--source/blender/blenlib/BLI_mempool.h2
-rw-r--r--source/blender/blenlib/BLI_path_util.h2
-rw-r--r--source/blender/blenlib/BLI_rand.h14
-rw-r--r--source/blender/blenlib/BLI_utildefines.h253
-rw-r--r--source/blender/blenlib/CMakeLists.txt11
-rw-r--r--source/blender/blenlib/intern/BLI_args.c24
-rw-r--r--source/blender/blenlib/intern/BLI_dial_2d.c6
-rw-r--r--source/blender/blenlib/intern/BLI_dynstr.c48
-rw-r--r--source/blender/blenlib/intern/BLI_filelist.c59
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c16
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c144
-rw-r--r--source/blender/blenlib/intern/BLI_kdtree.c809
-rw-r--r--source/blender/blenlib/intern/BLI_linklist.c24
-rw-r--r--source/blender/blenlib/intern/BLI_timer.c8
-rw-r--r--source/blender/blenlib/intern/DLRB_tree.c137
-rw-r--r--source/blender/blenlib/intern/boxpack_2d.c17
-rw-r--r--source/blender/blenlib/intern/convexhull_2d.c14
-rw-r--r--source/blender/blenlib/intern/dynlib.c9
-rw-r--r--source/blender/blenlib/intern/easing.c88
-rw-r--r--source/blender/blenlib/intern/edgehash.c12
-rw-r--r--source/blender/blenlib/intern/expr_pylike_eval.c19
-rw-r--r--source/blender/blenlib/intern/fileops.c112
-rw-r--r--source/blender/blenlib/intern/freetypefont.c25
-rw-r--r--source/blender/blenlib/intern/gsqueue.c6
-rw-r--r--source/blender/blenlib/intern/hash_md5.c9
-rw-r--r--source/blender/blenlib/intern/jitter_2d.c12
-rw-r--r--source/blender/blenlib/intern/kdtree_1d.c25
-rw-r--r--source/blender/blenlib/intern/kdtree_2d.c25
-rw-r--r--source/blender/blenlib/intern/kdtree_3d.c25
-rw-r--r--source/blender/blenlib/intern/kdtree_4d.c25
-rw-r--r--source/blender/blenlib/intern/kdtree_impl.h967
-rw-r--r--source/blender/blenlib/intern/lasso_2d.c24
-rw-r--r--source/blender/blenlib/intern/listbase.c116
-rw-r--r--source/blender/blenlib/intern/math_base.c12
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c62
-rw-r--r--source/blender/blenlib/intern/math_color.c89
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c3
-rw-r--r--source/blender/blenlib/intern/math_geom.c287
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c9
-rw-r--r--source/blender/blenlib/intern/math_interp.c104
-rw-r--r--source/blender/blenlib/intern/math_matrix.c120
-rw-r--r--source/blender/blenlib/intern/math_rotation.c114
-rw-r--r--source/blender/blenlib/intern/math_solvers.c12
-rw-r--r--source/blender/blenlib/intern/math_statistics.c3
-rw-r--r--source/blender/blenlib/intern/math_vector.c20
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c22
-rw-r--r--source/blender/blenlib/intern/noise.c50
-rw-r--r--source/blender/blenlib/intern/path_util.c173
-rw-r--r--source/blender/blenlib/intern/polyfill_2d.c13
-rw-r--r--source/blender/blenlib/intern/rand.c15
-rw-r--r--source/blender/blenlib/intern/rct.c168
-rw-r--r--source/blender/blenlib/intern/scanfill.c91
-rw-r--r--source/blender/blenlib/intern/smallhash.c3
-rw-r--r--source/blender/blenlib/intern/sort.c6
-rw-r--r--source/blender/blenlib/intern/sort_utils.c36
-rw-r--r--source/blender/blenlib/intern/storage.c54
-rw-r--r--source/blender/blenlib/intern/string.c76
-rw-r--r--source/blender/blenlib/intern/string_utf8.c74
-rw-r--r--source/blender/blenlib/intern/string_utils.c6
-rw-r--r--source/blender/blenlib/intern/task.c27
-rw-r--r--source/blender/blenlib/intern/threads.c44
-rw-r--r--source/blender/blenlib/intern/uvproject.c6
-rw-r--r--source/blender/blenlib/intern/voronoi_2d.c96
-rw-r--r--source/blender/blenlib/intern/winstuff.c31
-rw-r--r--source/blender/blenlib/intern/winstuff_dir.c19
-rw-r--r--source/blender/blenloader/BLO_readfile.h2
-rw-r--r--source/blender/blenloader/intern/blend_validate.c37
-rw-r--r--source/blender/blenloader/intern/readblenentry.c16
-rw-r--r--source/blender/blenloader/intern/readfile.c95
-rw-r--r--source/blender/blenloader/intern/readfile.h11
-rw-r--r--source/blender/blenloader/intern/versioning_270.c4
-rw-r--r--source/blender/blenloader/intern/versioning_280.c326
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c7
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c42
-rw-r--r--source/blender/blenloader/intern/writefile.c9
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c74
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_inline.h4
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c54
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_log.c31
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c46
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c180
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c128
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c11
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c7
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api_inline.h12
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c126
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_query.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_structure.c18
-rw-r--r--source/blender/bmesh/intern/bmesh_structure_inline.h12
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c16
-rw-r--r--source/blender/bmesh/operators/bmo_bridge.c8
-rw-r--r--source/blender/bmesh/operators/bmo_connect_concave.c10
-rw-r--r--source/blender/bmesh/operators/bmo_create.c10
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c7
-rw-r--r--source/blender/bmesh/operators/bmo_dupe.c19
-rw-r--r--source/blender/bmesh/operators/bmo_edgenet.c3
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c13
-rw-r--r--source/blender/bmesh/operators/bmo_fill_grid.c4
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c30
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c3
-rw-r--r--source/blender/bmesh/operators/bmo_join_triangles.c3
-rw-r--r--source/blender/bmesh/operators/bmo_mirror.c9
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c43
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c28
-rw-r--r--source/blender/bmesh/operators/bmo_smooth_laplacian.c16
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c41
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide_edgering.c7
-rw-r--r--source/blender/bmesh/operators/bmo_triangulate.c2
-rw-r--r--source/blender/bmesh/operators/bmo_utils.c18
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c850
-rw-r--r--source/blender/bmesh/tools/bmesh_bisect_plane.c12
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c24
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_dissolve.c8
-rw-r--r--source/blender/bmesh/tools/bmesh_intersect.c6
-rw-r--r--source/blender/bmesh/tools/bmesh_path.c9
-rw-r--r--source/blender/bmesh/tools/bmesh_region_match.c6
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.c9
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.h3
-rw-r--r--source/blender/bmesh/tools/bmesh_wireframe.c16
-rw-r--r--source/blender/collada/AnimationExporter.cpp10
-rw-r--r--source/blender/collada/AnimationExporter.h89
-rw-r--r--source/blender/collada/AnimationImporter.h11
-rw-r--r--source/blender/collada/ArmatureExporter.h16
-rw-r--r--source/blender/collada/ArmatureImporter.cpp18
-rw-r--r--source/blender/collada/ArmatureImporter.h5
-rw-r--r--source/blender/collada/BCAnimationSampler.h10
-rw-r--r--source/blender/collada/BCSampleData.cpp6
-rw-r--r--source/blender/collada/DocumentImporter.cpp16
-rw-r--r--source/blender/collada/EffectExporter.cpp14
-rw-r--r--source/blender/collada/EffectExporter.h11
-rw-r--r--source/blender/collada/ExtraHandler.h14
-rw-r--r--source/blender/collada/GeometryExporter.cpp8
-rw-r--r--source/blender/collada/MeshImporter.cpp10
-rw-r--r--source/blender/collada/MeshImporter.h37
-rw-r--r--source/blender/collada/SceneExporter.cpp15
-rw-r--r--source/blender/collada/TransformWriter.h16
-rw-r--r--source/blender/collada/collada_utils.cpp3
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.cpp2
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.cpp4
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h1
-rw-r--r--source/blender/datatoc/datatoc.c15
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h6
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc55
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc214
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h8
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h21
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc21
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc30
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.h2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_iter.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc8
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.h6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc4
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc392
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc4
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.cc2
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.h4
-rw-r--r--source/blender/draw/DRW_engine.h12
-rw-r--r--source/blender/draw/engines/basic/basic_engine.c7
-rw-r--r--source/blender/draw/engines/eevee/eevee_bloom.c8
-rw-r--r--source/blender/draw/engines/eevee/eevee_depth_of_field.c23
-rw-r--r--source/blender/draw/engines/eevee/eevee_effects.c20
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c45
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c30
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.h5
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c78
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c43
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c16
-rw-r--r--source/blender/draw/engines/eevee/eevee_lut.h5355
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c205
-rw-r--r--source/blender/draw/engines/eevee/eevee_mist.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c83
-rw-r--r--source/blender/draw/engines/eevee/eevee_occlusion.c8
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h18
-rw-r--r--source/blender/draw/engines/eevee/eevee_render.c32
-rw-r--r--source/blender/draw/engines/eevee/eevee_screen_raytrace.c20
-rw-r--r--source/blender/draw/engines/eevee/eevee_subsurface.c13
-rw-r--r--source/blender/draw/engines/eevee/eevee_temporal_sampling.c7
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c64
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl19
-rw-r--r--source/blender/draw/engines/eevee/shaders/default_world_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl16
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_downsample_cube_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl9
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl16
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl2
-rw-r--r--source/blender/draw/engines/eevee/shaders/ltc_lib.glsl44
-rw-r--r--source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl7
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl20
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl5
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl6
-rw-r--r--source/blender/draw/engines/external/external_engine.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c53
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_utils.c57
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c161
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h5
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_render.c20
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_shader_fx.c75
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl4
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl4
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl4
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl21
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl2
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_zdepth_mix_frag.glsl8
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl27
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl7
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl3
-rw-r--r--source/blender/draw/engines/workbench/workbench_deferred.c137
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_dof.c14
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_taa.c17
-rw-r--r--source/blender/draw/engines/workbench/workbench_forward.c174
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c41
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h17
-rw-r--r--source/blender/draw/engines/workbench/workbench_render.c14
-rw-r--r--source/blender/draw/engines/workbench/workbench_studiolight.c4
-rw-r--r--source/blender/draw/engines/workbench/workbench_volume.c10
-rw-r--r--source/blender/draw/intern/DRW_render.h24
-rw-r--r--source/blender/draw/intern/draw_anim_viz.c2
-rw-r--r--source/blender/draw/intern/draw_armature.c131
-rw-r--r--source/blender/draw/intern/draw_cache.c72
-rw-r--r--source/blender/draw/intern/draw_cache.h4
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h4
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c24
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c99
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c167
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c47
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c10
-rw-r--r--source/blender/draw/intern/draw_common.c96
-rw-r--r--source/blender/draw/intern/draw_common.h10
-rw-r--r--source/blender/draw/intern/draw_hair.c4
-rw-r--r--source/blender/draw/intern/draw_instance_data.c13
-rw-r--r--source/blender/draw/intern/draw_manager.c357
-rw-r--r--source/blender/draw/intern/draw_manager.h13
-rw-r--r--source/blender/draw/intern/draw_manager_data.c18
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c49
-rw-r--r--source/blender/draw/intern/draw_manager_profiling.c6
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c6
-rw-r--r--source/blender/draw/intern/draw_manager_texture.c34
-rw-r--r--source/blender/draw/intern/draw_view.c10
-rw-r--r--source/blender/draw/modes/edit_armature_mode.c4
-rw-r--r--source/blender/draw/modes/edit_curve_mode.c83
-rw-r--r--source/blender/draw/modes/edit_lattice_mode.c4
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c161
-rw-r--r--source/blender/draw/modes/edit_mesh_mode_text.c10
-rw-r--r--source/blender/draw/modes/edit_metaball_mode.c16
-rw-r--r--source/blender/draw/modes/edit_text_mode.c6
-rw-r--r--source/blender/draw/modes/object_mode.c485
-rw-r--r--source/blender/draw/modes/overlay_mode.c10
-rw-r--r--source/blender/draw/modes/paint_texture_mode.c50
-rw-r--r--source/blender/draw/modes/paint_vertex_mode.c2
-rw-r--r--source/blender/draw/modes/pose_mode.c3
-rw-r--r--source/blender/draw/modes/shaders/armature_axes_vert.glsl11
-rw-r--r--source/blender/draw/modes/shaders/armature_envelope_outline_vert.glsl11
-rw-r--r--source/blender/draw/modes/shaders/armature_envelope_solid_vert.glsl12
-rw-r--r--source/blender/draw/modes/shaders/common_hair_lib.glsl25
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl4
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl40
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl6
-rw-r--r--source/blender/draw/modes/shaders/object_empty_axes_vert.glsl8
-rw-r--r--source/blender/draw/modes/shaders/object_empty_image_frag.glsl15
-rw-r--r--source/blender/draw/modes/shaders/object_grid_frag.glsl2
-rw-r--r--source/blender/draw/modes/shaders/paint_texture_frag.glsl26
-rw-r--r--source/blender/draw/modes/shaders/paint_texture_vert.glsl14
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c97
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c11
-rw-r--r--source/blender/editors/animation/anim_deps.c4
-rw-r--r--source/blender/editors/animation/anim_filter.c108
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c2
-rw-r--r--source/blender/editors/animation/keyframing.c18
-rw-r--r--source/blender/editors/animation/keyingsets.c2
-rw-r--r--source/blender/editors/armature/armature_edit.c4
-rw-r--r--source/blender/editors/armature/armature_select.c75
-rw-r--r--source/blender/editors/armature/pose_select.c37
-rw-r--r--source/blender/editors/armature/pose_slide.c73
-rw-r--r--source/blender/editors/armature/pose_transform.c2
-rw-r--r--source/blender/editors/armature/pose_utils.c2
-rw-r--r--source/blender/editors/curve/editcurve.c508
-rw-r--r--source/blender/editors/curve/editcurve_add.c72
-rw-r--r--source/blender/editors/curve/editcurve_paint.c8
-rw-r--r--source/blender/editors/curve/editcurve_select.c302
-rw-r--r--source/blender/editors/curve/editcurve_undo.c3
-rw-r--r--source/blender/editors/curve/editfont.c349
-rw-r--r--source/blender/editors/datafiles/CMakeLists.txt3
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c28
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c12
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c7
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c35
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c40
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c703
-rw-r--r--source/blender/editors/gpencil/gpencil_add_monkey.c13
-rw-r--r--source/blender/editors/gpencil/gpencil_add_stroke.c30
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c71
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c55
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c129
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c298
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h1
-rw-r--r--source/blender/editors/gpencil/gpencil_old.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c174
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c81
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c189
-rw-r--r--source/blender/editors/include/BIF_glutil.h1
-rw-r--r--source/blender/editors/include/ED_anim_api.h12
-rw-r--r--source/blender/editors/include/ED_armature.h12
-rw-r--r--source/blender/editors/include/ED_curve.h14
-rw-r--r--source/blender/editors/include/ED_gizmo_library.h11
-rw-r--r--source/blender/editors/include/ED_gpencil.h26
-rw-r--r--source/blender/editors/include/ED_image.h3
-rw-r--r--source/blender/editors/include/ED_lattice.h6
-rw-r--r--source/blender/editors/include/ED_mball.h4
-rw-r--r--source/blender/editors/include/ED_mesh.h25
-rw-r--r--source/blender/editors/include/ED_particle.h9
-rw-r--r--source/blender/editors/include/ED_render.h2
-rw-r--r--source/blender/editors/include/ED_screen.h2
-rw-r--r--source/blender/editors/include/ED_sculpt.h2
-rw-r--r--source/blender/editors/include/ED_select_utils.h4
-rw-r--r--source/blender/editors/include/ED_view3d.h29
-rw-r--r--source/blender/editors/include/UI_icons.h38
-rw-r--r--source/blender/editors/include/UI_interface.h45
-rw-r--r--source/blender/editors/include/UI_resources.h1
-rw-r--r--source/blender/editors/include/UI_view2d.h10
-rw-r--r--source/blender/editors/interface/interface.c773
-rw-r--r--source/blender/editors/interface/interface_align.c42
-rw-r--r--source/blender/editors/interface/interface_anim.c21
-rw-r--r--source/blender/editors/interface/interface_context_menu.c20
-rw-r--r--source/blender/editors/interface/interface_draw.c147
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c14
-rw-r--r--source/blender/editors/interface/interface_eyedropper_colorband.c28
-rw-r--r--source/blender/editors/interface/interface_eyedropper_driver.c14
-rw-r--r--source/blender/editors/interface/interface_handlers.c1966
-rw-r--r--source/blender/editors/interface/interface_icons.c105
-rw-r--r--source/blender/editors/interface/interface_icons_event.c8
-rw-r--r--source/blender/editors/interface/interface_intern.h148
-rw-r--r--source/blender/editors/interface/interface_layout.c577
-rw-r--r--source/blender/editors/interface/interface_ops.c149
-rw-r--r--source/blender/editors/interface/interface_panel.c374
-rw-r--r--source/blender/editors/interface/interface_query.c393
-rw-r--r--source/blender/editors/interface/interface_region_color_picker.c33
-rw-r--r--source/blender/editors/interface/interface_region_hud.c14
-rw-r--r--source/blender/editors/interface/interface_region_menu_pie.c10
-rw-r--r--source/blender/editors/interface/interface_region_menu_popup.c11
-rw-r--r--source/blender/editors/interface/interface_region_popover.c47
-rw-r--r--source/blender/editors/interface/interface_region_popup.c146
-rw-r--r--source/blender/editors/interface/interface_region_search.c37
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c89
-rw-r--r--source/blender/editors/interface/interface_regions.c3
-rw-r--r--source/blender/editors/interface/interface_regions_intern.h2
-rw-r--r--source/blender/editors/interface/interface_style.c49
-rw-r--r--source/blender/editors/interface/interface_templates.c368
-rw-r--r--source/blender/editors/interface/interface_utils.c109
-rw-r--r--source/blender/editors/interface/interface_widgets.c505
-rw-r--r--source/blender/editors/interface/resources.c64
-rw-r--r--source/blender/editors/interface/view2d.c442
-rw-r--r--source/blender/editors/interface/view2d_ops.c221
-rw-r--r--source/blender/editors/io/io_collada.c10
-rw-r--r--source/blender/editors/lattice/editlattice_select.c66
-rw-r--r--source/blender/editors/mask/mask_draw.c8
-rw-r--r--source/blender/editors/mesh/editface.c129
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c167
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c6
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c6
-rw-r--r--source/blender/editors/mesh/editmesh_intersect.c10
-rw-r--r--source/blender/editors/mesh/editmesh_select.c97
-rw-r--r--source/blender/editors/mesh/editmesh_select_similar.c176
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c36
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c5
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c14
-rw-r--r--source/blender/editors/mesh/mesh_mirror.c14
-rw-r--r--source/blender/editors/mesh/meshtools.c51
-rw-r--r--source/blender/editors/metaball/mball_edit.c143
-rw-r--r--source/blender/editors/object/object_add.c8
-rw-r--r--source/blender/editors/object/object_bake_api.c2
-rw-r--r--source/blender/editors/object/object_collection.c41
-rw-r--r--source/blender/editors/object/object_constraint.c2
-rw-r--r--source/blender/editors/object/object_data_transfer.c38
-rw-r--r--source/blender/editors/object/object_edit.c13
-rw-r--r--source/blender/editors/object/object_hook.c24
-rw-r--r--source/blender/editors/object/object_modifier.c69
-rw-r--r--source/blender/editors/object/object_relations.c65
-rw-r--r--source/blender/editors/object/object_select.c13
-rw-r--r--source/blender/editors/physics/particle_edit.c358
-rw-r--r--source/blender/editors/physics/particle_object.c14
-rw-r--r--source/blender/editors/render/render_opengl.c12
-rw-r--r--source/blender/editors/render/render_preview.c3
-rw-r--r--source/blender/editors/render/render_shading.c47
-rw-r--r--source/blender/editors/render/render_update.c7
-rw-r--r--source/blender/editors/scene/scene_edit.c18
-rw-r--r--source/blender/editors/screen/area.c42
-rw-r--r--source/blender/editors/screen/glutil.c15
-rw-r--r--source/blender/editors/screen/screen_context.c9
-rw-r--r--source/blender/editors/screen/screen_draw.c8
-rw-r--r--source/blender/editors/screen/screen_edit.c35
-rw-r--r--source/blender/editors/screen/screen_ops.c107
-rw-r--r--source/blender/editors/screen/screendump.c2
-rw-r--r--source/blender/editors/screen/workspace_edit.c32
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve_undo.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c12
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c65
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h1
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c7
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c11
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c14
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c10
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c41
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c2
-rw-r--r--source/blender/editors/sound/sound_ops.c2
-rw-r--r--source/blender/editors/space_action/action_draw.c4
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c149
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c13
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c65
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c39
-rw-r--r--source/blender/editors/space_clip/clip_draw.c4
-rw-r--r--source/blender/editors/space_console/console_draw.c3
-rw-r--r--source/blender/editors/space_console/console_ops.c75
-rw-r--r--source/blender/editors/space_console/space_console.c9
-rw-r--r--source/blender/editors/space_file/file_draw.c8
-rw-r--r--source/blender/editors/space_file/filelist.c2
-rw-r--r--source/blender/editors/space_graph/graph_draw.c4
-rw-r--r--source/blender/editors/space_image/image_buttons.c63
-rw-r--r--source/blender/editors/space_image/image_draw.c73
-rw-r--r--source/blender/editors/space_image/image_edit.c71
-rw-r--r--source/blender/editors/space_image/image_ops.c213
-rw-r--r--source/blender/editors/space_image/space_image.c77
-rw-r--r--source/blender/editors/space_info/info_ops.c69
-rw-r--r--source/blender/editors/space_info/info_report.c3
-rw-r--r--source/blender/editors/space_info/info_stats.c59
-rw-r--r--source/blender/editors/space_info/space_info.c15
-rw-r--r--source/blender/editors/space_info/textview.c12
-rw-r--r--source/blender/editors/space_nla/nla_draw.c4
-rw-r--r--source/blender/editors/space_node/drawnode.c199
-rw-r--r--source/blender/editors/space_node/node_add.c41
-rw-r--r--source/blender/editors/space_node/node_buttons.c9
-rw-r--r--source/blender/editors/space_node/node_draw.c305
-rw-r--r--source/blender/editors/space_node/node_edit.c362
-rw-r--r--source/blender/editors/space_node/node_group.c100
-rw-r--r--source/blender/editors/space_node/node_ops.c4
-rw-r--r--source/blender/editors/space_node/node_relationships.c269
-rw-r--r--source/blender/editors/space_node/node_select.c207
-rw-r--r--source/blender/editors/space_node/node_templates.c146
-rw-r--r--source/blender/editors/space_node/node_toolbar.c3
-rw-r--r--source/blender/editors/space_node/node_view.c3
-rw-r--r--source/blender/editors/space_node/space_node.c128
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c95
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.c74
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c66
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c253
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h3
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c42
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c125
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c265
-rw-r--r--source/blender/editors/space_outliner/outliner_utils.c19
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c21
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c64
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c190
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c327
-rw-r--r--source/blender/editors/space_sequencer/sequencer_modifier.c15
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c18
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c103
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c9
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c99
-rw-r--r--source/blender/editors/space_statusbar/space_statusbar.c12
-rw-r--r--source/blender/editors/space_text/text_format_py.c26
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c32
-rw-r--r--source/blender/editors/space_view3d/drawobject.c62
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c124
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c44
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c164
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c413
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c398
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c135
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_armature.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_camera.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c21
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c54
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c613
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c66
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c132
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c101
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c67
-rw-r--r--source/blender/editors/transform/transform.c37
-rw-r--r--source/blender/editors/transform/transform_conversions.c13
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c14
-rw-r--r--source/blender/editors/transform/transform_ops.c12
-rw-r--r--source/blender/editors/transform/transform_snap_object.c14
-rw-r--r--source/blender/editors/util/select_utils.c7
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c89
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp2
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h7
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h2
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.h2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c10
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c5
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c11
-rw-r--r--source/blender/gpu/GPU_batch.h2
-rw-r--r--source/blender/gpu/GPU_draw.h5
-rw-r--r--source/blender/gpu/GPU_extensions.h1
-rw-r--r--source/blender/gpu/GPU_framebuffer.h18
-rw-r--r--source/blender/gpu/GPU_material.h1
-rw-r--r--source/blender/gpu/GPU_select.h1
-rw-r--r--source/blender/gpu/GPU_shader_interface.h1
-rw-r--r--source/blender/gpu/GPU_state.h1
-rw-r--r--source/blender/gpu/GPU_texture.h16
-rw-r--r--source/blender/gpu/GPU_vertex_format.h4
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c158
-rw-r--r--source/blender/gpu/intern/gpu_draw.c172
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c12
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c10
-rw-r--r--source/blender/gpu/intern/gpu_material.c4
-rw-r--r--source/blender/gpu/intern/gpu_matrix.c65
-rw-r--r--source/blender/gpu/intern/gpu_select.c38
-rw-r--r--source/blender/gpu/intern/gpu_shader.c15
-rw-r--r--source/blender/gpu/intern/gpu_shader_interface.c1
-rw-r--r--source/blender/gpu/intern/gpu_state.c16
-rw-r--r--source/blender/gpu/intern/gpu_texture.c77
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.c20
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c10
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl8
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl10
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl8
-rw-r--r--source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl30
-rw-r--r--source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl2
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl87
-rw-r--r--source/blender/gpu/shaders/gpu_shader_selection_id_frag.glsl12
-rw-r--r--source/blender/imbuf/IMB_imbuf.h4
-rw-r--r--source/blender/imbuf/intern/anim_movie.c13
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c6
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp2
-rw-r--r--source/blender/imbuf/intern/indexer.c18
-rw-r--r--source/blender/imbuf/intern/iris.c8
-rw-r--r--source/blender/imbuf/intern/jp2.c2
-rw-r--r--source/blender/imbuf/intern/readimage.c4
-rw-r--r--source/blender/makesdna/DNA_ID.h17
-rw-r--r--source/blender/makesdna/DNA_action_types.h6
-rw-r--r--source/blender/makesdna/DNA_anim_types.h354
-rw-r--r--source/blender/makesdna/DNA_armature_types.h50
-rw-r--r--source/blender/makesdna/DNA_boid_types.h2
-rw-r--r--source/blender/makesdna/DNA_brush_types.h24
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h195
-rw-r--r--source/blender/makesdna/DNA_curve_types.h4
-rw-r--r--source/blender/makesdna/DNA_customdata_types.h2
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h10
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h1
-rw-r--r--source/blender/makesdna/DNA_image_types.h18
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h38
-rw-r--r--source/blender/makesdna/DNA_material_types.h2
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h15
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h4
-rw-r--r--source/blender/makesdna/DNA_meta_types.h2
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h10
-rw-r--r--source/blender/makesdna/DNA_movieclip_types.h4
-rw-r--r--source/blender/makesdna/DNA_nla_types.h24
-rw-r--r--source/blender/makesdna/DNA_node_types.h14
-rw-r--r--source/blender/makesdna/DNA_object_fluidsim_types.h22
-rw-r--r--source/blender/makesdna/DNA_object_force_types.h28
-rw-r--r--source/blender/makesdna/DNA_object_types.h29
-rw-r--r--source/blender/makesdna/DNA_particle_types.h102
-rw-r--r--source/blender/makesdna/DNA_rigidbody_types.h16
-rw-r--r--source/blender/makesdna/DNA_scene_types.h101
-rw-r--r--source/blender/makesdna/DNA_screen_types.h19
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h10
-rw-r--r--source/blender/makesdna/DNA_smoke_types.h16
-rw-r--r--source/blender/makesdna/DNA_space_types.h54
-rw-r--r--source/blender/makesdna/DNA_speaker_types.h6
-rw-r--r--source/blender/makesdna/DNA_text_types.h18
-rw-r--r--source/blender/makesdna/DNA_texture_types.h2
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h4
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h116
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h23
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h6
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h44
-rw-r--r--source/blender/makesdna/DNA_world_types.h16
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt4
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c97
-rw-r--r--source/blender/makesdna/intern/dna_rename_defs.h4
-rw-r--r--source/blender/makesdna/intern/makesdna.c149
-rw-r--r--source/blender/makesrna/RNA_access.h4
-rw-r--r--source/blender/makesrna/RNA_types.h5
-rw-r--r--source/blender/makesrna/intern/makesrna.c5
-rw-r--r--source/blender/makesrna/intern/rna_ID.c2
-rw-r--r--source/blender/makesrna/intern/rna_access.c3
-rw-r--r--source/blender/makesrna/intern/rna_action.c10
-rw-r--r--source/blender/makesrna/intern/rna_armature.c2
-rw-r--r--source/blender/makesrna/intern/rna_boid.c6
-rw-r--r--source/blender/makesrna/intern/rna_brush.c261
-rw-r--r--source/blender/makesrna/intern/rna_camera.c66
-rw-r--r--source/blender/makesrna/intern/rna_color.c8
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c13
-rw-r--r--source/blender/makesrna/intern/rna_curve.c5
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c7
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c148
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c33
-rw-r--r--source/blender/makesrna/intern/rna_internal.h2
-rw-r--r--source/blender/makesrna/intern/rna_key.c2
-rw-r--r--source/blender/makesrna/intern/rna_material.c16
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c3
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c18
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c103
-rw-r--r--source/blender/makesrna/intern/rna_object.c32
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c184
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c17
-rw-r--r--source/blender/makesrna/intern/rna_particle.c122
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c6
-rw-r--r--source/blender/makesrna/intern/rna_scene.c104
-rw-r--r--source/blender/makesrna/intern/rna_screen.c4
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c86
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c1
-rw-r--r--source/blender/makesrna/intern/rna_shader_fx.c1
-rw-r--r--source/blender/makesrna/intern/rna_space.c72
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c6
-rw-r--r--source/blender/makesrna/intern/rna_ui.c34
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c84
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c27
-rw-r--r--source/blender/makesrna/intern/rna_wm.c1
-rw-r--r--source/blender/makesrna/intern/rna_wm_gizmo.c2
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c31
-rw-r--r--source/blender/makesrna/intern/rna_workspace_api.c18
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c15
-rw-r--r--source/blender/modifiers/intern/MOD_array.c15
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c7
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c9
-rw-r--r--source/blender/modifiers/intern/MOD_build.c7
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c15
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c7
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c13
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c7
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c9
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c11
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c7
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c9
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c16
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c7
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c19
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim.c7
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c11
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c7
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c7
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c9
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c9
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c7
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c9
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c7
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c11
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c54
-rw-r--r--source/blender/modifiers/intern/MOD_none.c7
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c15
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c13
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c7
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c7
-rw-r--r--source/blender/modifiers/intern/MOD_remesh.c7
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c9
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c7
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c7
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c11
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c7
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c7
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c7
-rw-r--r--source/blender/modifiers/intern/MOD_softbody.c7
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c23
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c51
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c7
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c11
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c14
-rw-r--r--source/blender/modifiers/intern/MOD_util.c6
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c11
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c11
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c13
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c11
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.c8
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c1
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c7
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c7
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c13
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c7
-rw-r--r--source/blender/nodes/NOD_composite.h2
-rw-r--r--source/blender/nodes/NOD_shader.h2
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_common.c14
-rw-r--r--source/blender/nodes/intern/node_exec.c3
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c23
-rw-r--r--source/blender/nodes/shader/node_shader_util.c6
-rw-r--r--source/blender/nodes/shader/node_shader_util.h2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_common.c19
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_curves.c39
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mixRgb.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_coord.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c9
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectMath.c6
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c2
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops.c6
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c105
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c34
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.c6
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_select.c19
-rw-r--r--source/blender/python/generic/bgl.c99
-rw-r--r--source/blender/python/generic/blf_py_api.c42
-rw-r--r--source/blender/python/generic/bpy_internal_import.c24
-rw-r--r--source/blender/python/generic/idprop_py_api.c68
-rw-r--r--source/blender/python/generic/py_capi_utils.c24
-rw-r--r--source/blender/python/gpu/gpu_py_offscreen.c11
-rw-r--r--source/blender/python/gpu/gpu_py_types.c18
-rw-r--r--source/blender/python/intern/bpy.c31
-rw-r--r--source/blender/python/intern/bpy_app.c16
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c3
-rw-r--r--source/blender/python/intern/bpy_app_translations.c15
-rw-r--r--source/blender/python/intern/bpy_capi_utils.c19
-rw-r--r--source/blender/python/intern/bpy_capi_utils.h1
-rw-r--r--source/blender/python/intern/bpy_driver.c44
-rw-r--r--source/blender/python/intern/bpy_interface.c36
-rw-r--r--source/blender/python/intern/bpy_library_load.c3
-rw-r--r--source/blender/python/intern/bpy_library_write.c2
-rw-r--r--source/blender/python/intern/bpy_msgbus.c25
-rw-r--r--source/blender/python/intern/bpy_operator.c11
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c3
-rw-r--r--source/blender/python/intern/bpy_props.c181
-rw-r--r--source/blender/python/intern/bpy_rna.c455
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c21
-rw-r--r--source/blender/python/intern/bpy_rna_array.c32
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c36
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.c87
-rw-r--r--source/blender/python/intern/bpy_traceback.c24
-rw-r--r--source/blender/python/mathutils/mathutils.c33
-rw-r--r--source/blender/python/mathutils/mathutils_Color.c136
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.c116
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c357
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c209
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c250
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.c14
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c24
-rw-r--r--source/blender/python/mathutils/mathutils_interpolate.c12
-rw-r--r--source/blender/python/mathutils/mathutils_kdtree.c44
-rw-r--r--source/blender/python/mathutils/mathutils_noise.c72
-rw-r--r--source/blender/render/extern/include/RE_engine.h2
-rw-r--r--source/blender/render/intern/source/bake_api.c22
-rw-r--r--source/blender/render/intern/source/external_engine.c6
-rw-r--r--source/blender/render/intern/source/imagetexture.c886
-rw-r--r--source/blender/render/intern/source/initrender.c2
-rw-r--r--source/blender/render/intern/source/multires_bake.c42
-rw-r--r--source/blender/render/intern/source/pipeline.c20
-rw-r--r--source/blender/render/intern/source/pointdensity.c25
-rw-r--r--source/blender/render/intern/source/render_result.c32
-rw-r--r--source/blender/render/intern/source/render_texture.c800
-rw-r--r--source/blender/render/intern/source/zbuf.c142
-rw-r--r--source/blender/windowmanager/WM_toolsystem.h2
-rw-r--r--source/blender/windowmanager/WM_types.h23
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c3
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c21
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c5
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c58
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c7
-rw-r--r--source/blender/windowmanager/intern/wm_files.c4
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c12
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c4
-rw-r--r--source/blender/windowmanager/intern/wm_keymap_utils.c21
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c51
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c18
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c30
-rw-r--r--source/blender/windowmanager/intern/wm_window.c17
901 files changed, 31385 insertions, 20767 deletions
diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index 28c0ad05c49..c78f31b671f 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -449,10 +449,10 @@ Mesh *AbcCurveReader::read_mesh(Mesh *existing_mesh,
catch(Alembic::Util::Exception &ex) {
*err_str = "Error reading curve sample; more detail on the console";
printf("Alembic: error reading curve sample for '%s/%s' at time %f: %s\n",
- m_iobject.getFullName().c_str(),
- m_curves_schema.getName().c_str(),
- sample_sel.getRequestedTime(),
- ex.what());
+ m_iobject.getFullName().c_str(),
+ m_curves_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
return existing_mesh;
}
diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc
index 09875fda6b0..1587f333e3d 100644
--- a/source/blender/alembic/intern/abc_customdata.cc
+++ b/source/blender/alembic/intern/abc_customdata.cc
@@ -157,9 +157,9 @@ static void write_uv(const OCompoundProperty &prop, const CDStreamConfig &config
OV2fGeomParam param(prop, name, true, kFacevaryingScope, 1);
OV2fGeomParam::Sample sample(
- V2fArraySample(&uvs.front(), uvs.size()),
- UInt32ArraySample(&indices.front(), indices.size()),
- kFacevaryingScope);
+ V2fArraySample(&uvs.front(), uvs.size()),
+ UInt32ArraySample(&indices.front(), indices.size()),
+ kFacevaryingScope);
param.set(sample);
}
@@ -205,9 +205,9 @@ static void write_mcol(const OCompoundProperty &prop, const CDStreamConfig &conf
OC4fGeomParam param(prop, name, true, kFacevaryingScope, 1);
OC4fGeomParam::Sample sample(
- C4fArraySample(&buffer.front(), buffer.size()),
- UInt32ArraySample(&indices.front(), indices.size()),
- kVertexScope);
+ C4fArraySample(&buffer.front(), buffer.size()),
+ UInt32ArraySample(&indices.front(), indices.size()),
+ kVertexScope);
param.set(sample);
}
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index e7771827b2b..cdb9312b3db 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -552,7 +552,7 @@ Mesh *AbcGenericMeshWriter::getFinalMesh(bool &r_needsfree)
struct BMeshFromMeshParams bmfmp = {true, false, false, 0};
BMesh *bm = BKE_mesh_to_bmesh_ex(mesh, &bmcp, &bmfmp);
- BM_mesh_triangulate(bm, quad_method, ngon_method, tag_only, NULL, NULL, NULL);
+ BM_mesh_triangulate(bm, quad_method, ngon_method, 4, tag_only, NULL, NULL, NULL);
Mesh *result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
@@ -1101,10 +1101,10 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
catch(Alembic::Util::Exception &ex) {
*err_str = "Error reading mesh sample; more detail on the console";
printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
- m_iobject.getFullName().c_str(),
- m_schema.getName().c_str(),
- sample_sel.getRequestedTime(),
- ex.what());
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
return existing_mesh;
}
@@ -1350,10 +1350,10 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
}
catch(Alembic::Util::Exception &ex) {
printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
- m_iobject.getFullName().c_str(),
- m_schema.getName().c_str(),
- sample_sel.getRequestedTime(),
- ex.what());
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
return;
}
@@ -1398,10 +1398,10 @@ Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
catch(Alembic::Util::Exception &ex) {
*err_str = "Error reading mesh sample; more detail on the console";
printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n",
- m_iobject.getFullName().c_str(),
- m_schema.getName().c_str(),
- sample_sel.getRequestedTime(),
- ex.what());
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
return existing_mesh;
}
diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc
index b0cc9fc2c6b..463396c0b65 100644
--- a/source/blender/alembic/intern/abc_nurbs.cc
+++ b/source/blender/alembic/intern/abc_nurbs.cc
@@ -257,10 +257,10 @@ void AbcNurbsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
}
catch(Alembic::Util::Exception &ex) {
printf("Alembic: error reading nurbs sample for '%s/%s' at time %f: %s\n",
- m_iobject.getFullName().c_str(),
- schema.getName().c_str(),
- sample_sel.getRequestedTime(),
- ex.what());
+ m_iobject.getFullName().c_str(),
+ schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
return;
}
diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc
index d9b78f83ff5..88154dabeed 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -223,10 +223,10 @@ struct Mesh *AbcPointsReader::read_mesh(struct Mesh *existing_mesh,
catch(Alembic::Util::Exception &ex) {
*err_str = "Error reading points sample; more detail on the console";
printf("Alembic: error reading points sample for '%s/%s' at time %f: %s\n",
- m_iobject.getFullName().c_str(),
- m_schema.getName().c_str(),
- sample_sel.getRequestedTime(),
- ex.what());
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime(),
+ ex.what());
return existing_mesh;
}
diff --git a/source/blender/avi/intern/avi_mjpeg.c b/source/blender/avi/intern/avi_mjpeg.c
index 740f0966141..249cb57afab 100644
--- a/source/blender/avi/intern/avi_mjpeg.c
+++ b/source/blender/avi/intern/avi_mjpeg.c
@@ -337,18 +337,20 @@ void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer,
buf = imb_alloc_pixels(movie->header->Height, movie->header->Width, 3, sizeof(unsigned char), "avi.avi_converter_to_mjpeg 1");
if (buf) {
- Compress_JPEG(movie->streams[stream].sh.Quality / 100,
- buf, buffer,
- movie->header->Width,
- movie->header->Height / 2,
- bufsize / 2);
+ Compress_JPEG(
+ movie->streams[stream].sh.Quality / 100,
+ buf, buffer,
+ movie->header->Width,
+ movie->header->Height / 2,
+ bufsize / 2);
*size += numbytes;
numbytes = 0;
- Compress_JPEG(movie->streams[stream].sh.Quality / 100,
- buf + *size, buffer + (size_t)(movie->header->Height / 2) * (size_t)movie->header->Width * 3,
- movie->header->Width,
- movie->header->Height / 2,
- bufsize / 2);
+ Compress_JPEG(
+ movie->streams[stream].sh.Quality / 100,
+ buf + *size, buffer + (size_t)(movie->header->Height / 2) * (size_t)movie->header->Width * 3,
+ movie->header->Width,
+ movie->header->Height / 2,
+ bufsize / 2);
*size += numbytes;
}
}
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index d26c449dce2..9f81c41bd2d 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -79,7 +79,7 @@ static SpinLock ft_lib_mutex;
* Since most of the Text elems are not covered by other UI elements, we can
* group some strings together and render them in one drawcall. This behavior
* is on demand only, between BLF_batch_start() and BLF_batch_end().
- **/
+ */
static void blf_batch_draw_init(void)
{
GPUVertFormat format = {0};
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 27187f2e84d..20cd6a51a47 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -89,11 +89,11 @@ KerningCacheBLF *blf_kerning_cache_new(FontBLF *font)
FT_UInt glyph_index = FT_Get_Char_Index(font->face, i);
g = blf_glyph_add(font, glyph_index, i);
}
- /* Cannot fail since it has been added just before. */
+ /* Can fail on certain fonts */
GlyphBLF *g_prev = blf_glyph_search(font->glyph_cache, j);
FT_Vector delta = { .x = 0, .y = 0, };
- if (FT_Get_Kerning(font->face, g_prev->idx, g->idx, kc->mode, &delta) == 0) {
+ if (g_prev && FT_Get_Kerning(font->face, g_prev->idx, g->idx, kc->mode, &delta) == 0) {
kc->table[i][j] = (int)delta.x >> 6;
}
else {
@@ -437,10 +437,26 @@ static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
rect->ymax = rect->ymin - (float)g->height;
}
-void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
+static void blf_glyph_calc_rect_test(rctf *rect, GlyphBLF *g, float x, float y)
{
- rctf rect;
+ /* Intentionally check with g->advance, because this is the
+ * width used by BLF_width. This allows that the text slightly
+ * overlaps the clipping border to achieve better alignment. */
+ rect->xmin = floorf(x);
+ rect->xmax = rect->xmin + MIN2(g->advance, (float)g->width);
+ rect->ymin = floorf(y);
+ rect->ymax = rect->ymin - (float)g->height;
+}
+
+static void blf_glyph_calc_rect_shadow(rctf *rect, GlyphBLF *g, float x, float y, FontBLF *font)
+{
+ blf_glyph_calc_rect(rect, g,
+ x + (float)font->shadow_x,
+ y + (float)font->shadow_y);
+}
+void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
+{
if ((!g->width) || (!g->height))
return;
@@ -496,11 +512,9 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
g->build_tex = 1;
}
- blf_glyph_calc_rect(&rect, g, x, y);
-
if (font->flags & BLF_CLIPPING) {
- /* intentionally check clipping without shadow offset */
- rctf rect_test = rect;
+ rctf rect_test;
+ blf_glyph_calc_rect_test(&rect_test, g, x, y);
BLI_rctf_translate(&rect_test, font->pos[0], font->pos[1]);
if (!BLI_rctf_inside_rctf(&font->clip_rec, &rect_test)) {
@@ -518,9 +532,7 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
if (font->flags & BLF_SHADOW) {
rctf rect_ofs;
- blf_glyph_calc_rect(&rect_ofs, g,
- x + (float)font->shadow_x,
- y + (float)font->shadow_y);
+ blf_glyph_calc_rect_shadow(&rect_ofs, g, x, y, font);
if (font->shadow == 0) {
blf_texture_draw(font->shadow_color, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
@@ -535,6 +547,9 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
}
}
+ rctf rect;
+ blf_glyph_calc_rect(&rect, g, x, y);
+
#if BLF_BLUR_ENABLE
switch (font->blur) {
case 3:
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index cd7422415dc..46938b13ea6 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -87,21 +87,11 @@ struct Object;
struct PBVH;
struct Scene;
-/* number of sub-elements each mesh element has (for interpolation) */
-// #define SUB_ELEMS_VERT 0 /* UNUSED */
-#define SUB_ELEMS_EDGE 2
-#define SUB_ELEMS_FACE 50
-
/*
* Note: all mface interfaces now officially operate on tessellated data.
* Also, the mface origindex layer indexes mpolys, not mfaces.
*/
-typedef struct DMCoNo {
- float co[3];
- float no[3];
-} DMCoNo;
-
/* keep in sync with MFace/MPoly types */
typedef struct DMFlagMat {
short mat_nr;
@@ -411,14 +401,6 @@ void *DM_get_tessface_data_layer(struct DerivedMesh *dm, int type);
void *DM_get_poly_data_layer(struct DerivedMesh *dm, int type);
void *DM_get_loop_data_layer(struct DerivedMesh *dm, int type);
-/* custom data setting functions
- * copy supplied data into first layer of type using layer's copy function
- * (deep copy if appropriate)
- */
-void DM_set_vert_data(struct DerivedMesh *dm, int index, int type, void *data);
-void DM_set_edge_data(struct DerivedMesh *dm, int index, int type, void *data);
-void DM_set_tessface_data(struct DerivedMesh *dm, int index, int type, void *data);
-
/* custom data copy functions
* copy count elements from source_index in source to dest_index in dest
* these copy all layers for which the CD_FLAG_NOCOPY flag is not set
@@ -426,28 +408,6 @@ void DM_set_tessface_data(struct DerivedMesh *dm, int index, int type, void *dat
void DM_copy_vert_data(
struct DerivedMesh *source, struct DerivedMesh *dest,
int source_index, int dest_index, int count);
-void DM_copy_edge_data(
- struct DerivedMesh *source, struct DerivedMesh *dest,
- int source_index, int dest_index, int count);
-void DM_copy_tessface_data(
- struct DerivedMesh *source, struct DerivedMesh *dest,
- int source_index, int dest_index, int count);
-void DM_copy_loop_data(
- struct DerivedMesh *source, struct DerivedMesh *dest,
- int source_index, int dest_index, int count);
-void DM_copy_poly_data(
- struct DerivedMesh *source, struct DerivedMesh *dest,
- int source_index, int dest_index, int count);
-
-/* custom data free functions
- * free count elements, starting at index
- * they free all layers for which the CD_FLAG_NOCOPY flag is not set
- */
-void DM_free_vert_data(struct DerivedMesh *dm, int index, int count);
-void DM_free_edge_data(struct DerivedMesh *dm, int index, int count);
-void DM_free_tessface_data(struct DerivedMesh *dm, int index, int count);
-void DM_free_loop_data(struct DerivedMesh *dm, int index, int count);
-void DM_free_poly_data(struct DerivedMesh *dm, int index, int count);
/*sets up mpolys for a DM based on face iterators in source*/
void DM_DupPolys(DerivedMesh *source, DerivedMesh *target);
@@ -461,31 +421,6 @@ void DM_interp_vert_data(
int *src_indices, float *weights,
int count, int dest_index);
-typedef float EdgeVertWeight[SUB_ELEMS_EDGE][SUB_ELEMS_EDGE];
-void DM_interp_edge_data(
- struct DerivedMesh *source, struct DerivedMesh *dest,
- int *src_indices,
- float *weights, EdgeVertWeight *vert_weights,
- int count, int dest_index);
-
-typedef float FaceVertWeight[SUB_ELEMS_FACE][SUB_ELEMS_FACE];
-void DM_interp_tessface_data(
- struct DerivedMesh *source, struct DerivedMesh *dest,
- int *src_indices,
- float *weights, FaceVertWeight *vert_weights,
- int count, int dest_index);
-
-void DM_interp_loop_data(
- struct DerivedMesh *source, struct DerivedMesh *dest,
- int *src_indices,
- float *weights, int count, int dest_index);
-
-void DM_interp_poly_data(
- struct DerivedMesh *source, struct DerivedMesh *dest,
- int *src_indices,
- float *weights, int count, int dest_index);
-
-
void mesh_get_mapped_verts_coords(struct Mesh *me_eval, float (*r_cos)[3], const int totcos);
DerivedMesh *mesh_create_derived_render(
@@ -510,18 +445,12 @@ float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, bool has_prev_mesh);
void makeDerivedMesh(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
- const struct CustomData_MeshMasks *dataMask, const bool build_shapekey_layers);
-
-void DM_add_named_tangent_layer_for_uv(
- CustomData *uv_data, CustomData *tan_data, int numLoopData,
- const char *layer_name);
+ const struct CustomData_MeshMasks *dataMask);
void DM_calc_loop_tangents(
DerivedMesh *dm, bool calc_active_tangent, const char (*tangent_names)[MAX_NAME],
int tangent_names_count);
-void DM_init_origspace(DerivedMesh *dm);
-
/* debug only */
#ifndef NDEBUG
char *DM_debug_info(DerivedMesh *dm);
diff --git a/source/blender/blenkernel/BKE_blender_copybuffer.h b/source/blender/blenkernel/BKE_blender_copybuffer.h
index a98bb6a8c1c..99cd5109632 100644
--- a/source/blender/blenkernel/BKE_blender_copybuffer.h
+++ b/source/blender/blenkernel/BKE_blender_copybuffer.h
@@ -33,8 +33,10 @@ struct bContext;
void BKE_copybuffer_begin(struct Main *bmain_src);
void BKE_copybuffer_tag_ID(struct ID *id);
bool BKE_copybuffer_save(struct Main *bmain_src, const char *filename, struct ReportList *reports);
-bool BKE_copybuffer_read(struct Main *bmain_dst, const char *libname, struct ReportList *reports);
-bool BKE_copybuffer_paste(struct bContext *C, const char *libname, const short flag, struct ReportList *reports);
+bool BKE_copybuffer_read(
+ struct Main *bmain_dst, const char *libname, struct ReportList *reports, const unsigned int id_types_mask);
+int BKE_copybuffer_paste(
+ struct bContext *C, const char *libname, const short flag, struct ReportList *reports, const unsigned int id_types_mask);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index e82efac3891..9ae85725488 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -24,7 +24,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 47
+#define BLENDER_SUBVERSION 53
/* Several breakages with 280, e.g. collections vs layers */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 9360962317c..30746af0b53 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -56,7 +56,6 @@ void BKE_brush_free(struct Brush *brush);
void BKE_brush_sculpt_reset(struct Brush *brush);
void BKE_brush_gpencil_presets(struct bContext *C);
-void BKE_brush_update_material(struct Main *bmain, struct Material *ma, struct Brush *exclude_brush);
/* image icon function */
struct ImBuf *get_brush_icon(struct Brush *brush);
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 6cfce305a04..b5240faed09 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -143,12 +143,12 @@ typedef struct ClothSpring {
ClothSpring;
// some macro enhancements for vector treatment
-#define VECSUBADDSS(v1,v2,aS,v3,bS) {*(v1)-= *(v2)*aS + *(v3)*bS; *(v1+1)-= *(v2+1)*aS + *(v3+1)*bS; *(v1+2)-= *(v2+2)*aS + *(v3+2)*bS;}
-#define VECADDSS(v1,v2,aS,v3,bS) {*(v1)= *(v2)*aS + *(v3)*bS; *(v1+1)= *(v2+1)*aS + *(v3+1)*bS; *(v1+2)= *(v2+2)*aS + *(v3+2)*bS;}
-#define VECADDS(v1,v2,v3,bS) {*(v1)= *(v2) + *(v3)*bS; *(v1+1)= *(v2+1) + *(v3+1)*bS; *(v1+2)= *(v2+2) + *(v3+2)*bS;}
-#define VECSUBMUL(v1,v2,aS) {*(v1)-= *(v2) * aS; *(v1+1)-= *(v2+1) * aS; *(v1+2)-= *(v2+2) * aS;}
-#define VECSUBS(v1,v2,v3,bS) {*(v1)= *(v2) - *(v3)*bS; *(v1+1)= *(v2+1) - *(v3+1)*bS; *(v1+2)= *(v2+2) - *(v3+2)*bS;}
-#define VECADDMUL(v1,v2,aS) {*(v1)+= *(v2) * aS; *(v1+1)+= *(v2+1) * aS; *(v1+2)+= *(v2+2) * aS;}
+#define VECSUBADDSS(v1,v2,aS,v3,bS) {*(v1)-= *(v2)*aS + *(v3)*bS; *(v1+1)-= *(v2+1)*aS + *(v3+1)*bS; *(v1+2)-= *(v2+2)*aS + *(v3+2)*bS;} ((void)0)
+#define VECADDSS(v1,v2,aS,v3,bS) {*(v1)= *(v2)*aS + *(v3)*bS; *(v1+1)= *(v2+1)*aS + *(v3+1)*bS; *(v1+2)= *(v2+2)*aS + *(v3+2)*bS;} ((void)0)
+#define VECADDS(v1,v2,v3,bS) {*(v1)= *(v2) + *(v3)*bS; *(v1+1)= *(v2+1) + *(v3+1)*bS; *(v1+2)= *(v2+2) + *(v3+2)*bS;} ((void)0)
+#define VECSUBMUL(v1,v2,aS) {*(v1)-= *(v2) * aS; *(v1+1)-= *(v2+1) * aS; *(v1+2)-= *(v2+2) * aS;} ((void)0)
+#define VECSUBS(v1,v2,v3,bS) {*(v1)= *(v2) - *(v3)*bS; *(v1+1)= *(v2+1) - *(v3+1)*bS; *(v1+2)= *(v2+2) - *(v3+2)*bS;} ((void)0)
+#define VECADDMUL(v1,v2,aS) {*(v1)+= *(v2) * aS; *(v1+1)+= *(v2+1) * aS; *(v1+2)+= *(v2+2) * aS;} ((void)0)
/* SIMULATION FLAGS: goal flags,.. */
/* These are the bits used in SimSettings.flags. */
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index 0390078fc7f..180823b791a 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -66,12 +66,13 @@ struct Collection *BKE_collection_copy_master(struct Main *bmain, struct Collect
struct Collection *BKE_collection_master(const struct Scene *scene);
struct Collection *BKE_collection_master_add(void);
+struct Scene *BKE_collection_master_scene_search(const struct Main *bmain, const struct Collection *master_collection);
/* Collection Objects */
bool BKE_collection_has_object(struct Collection *collection, struct Object *ob);
bool BKE_collection_has_object_recursive(struct Collection *collection, struct Object *ob);
-struct Collection *BKE_collection_object_find(struct Main *bmain, struct Collection *collection, struct Object *ob);
+struct Collection *BKE_collection_object_find(struct Main *bmain, struct Scene *scene, struct Collection *collection, struct Object *ob);
bool BKE_collection_is_empty(struct Collection *collection);
bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob);
@@ -178,6 +179,32 @@ void BKE_scene_objects_iterator_end(struct BLI_Iterator *iter);
#define FOREACH_SCENE_COLLECTION_END \
ITER_END
+#define FOREACH_COLLECTION_BEGIN(_bmain, _scene, Type, _instance) \
+{ \
+ Type _instance; \
+ Collection *_instance_next; \
+ bool is_scene_collection = (_scene) != NULL; \
+ \
+ if (_scene) { \
+ _instance_next = BKE_collection_master(_scene); \
+ } \
+ else { \
+ _instance_next = (_bmain)->collections.first; \
+ } \
+ \
+ while ((_instance = _instance_next)) { \
+ if (is_scene_collection) { \
+ _instance_next = (_bmain)->collections.first; \
+ is_scene_collection = false; \
+ } \
+ else { \
+ _instance_next = _instance->id.next; \
+ }
+
+#define FOREACH_COLLECTION_END \
+ } \
+} ((void)0)
+
#define FOREACH_SCENE_OBJECT_BEGIN(scene, _instance) \
ITER_BEGIN(BKE_scene_objects_iterator_begin, \
BKE_scene_objects_iterator_next, \
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index cf573232bac..e9ca3c51a5f 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -254,10 +254,10 @@ struct RenderEngineType *CTX_data_engine_type(const bContext *C);
struct ToolSettings *CTX_data_tool_settings(const bContext *C);
const char *CTX_data_mode_string(const bContext *C);
-int CTX_data_mode_enum_ex(
+enum eContextObjectMode CTX_data_mode_enum_ex(
const struct Object *obedit, const struct Object *ob,
const eObjectMode object_mode);
-int CTX_data_mode_enum(const bContext *C);
+enum eContextObjectMode CTX_data_mode_enum(const bContext *C);
void CTX_data_main_set(bContext *C, struct Main *bmain);
void CTX_data_scene_set(bContext *C, struct Scene *bmain);
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index 1cfd8f13c65..6b470a89703 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -24,6 +24,7 @@
struct Depsgraph;
struct DynamicPaintCanvasSettings;
struct DynamicPaintModifierData;
+struct DynamicPaintRuntime;
struct Main;
struct Scene;
struct ViewLayer;
@@ -63,6 +64,7 @@ struct Mesh *dynamicPaint_Modifier_do(
struct DynamicPaintModifierData *pmd, struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, struct Mesh *me);
void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd);
+void dynamicPaint_Modifier_free_runtime(struct DynamicPaintRuntime *runtime);
void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
struct DynamicPaintModifierData *tsmd,
int flag);
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index eb4101fa2f7..e94ba27a8ea 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -132,17 +132,32 @@ void BKE_gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active);
void BKE_gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
struct Material *BKE_gpencil_get_material_from_brush(struct Brush *brush);
+void BKE_gpencil_brush_set_material(struct Brush *brush, struct Material *material);
+
+struct Material *BKE_gpencil_handle_brush_material(struct Main *bmain, struct Object *ob, struct Brush *brush);
+int BKE_gpencil_handle_material(struct Main *bmain, struct Object *ob, struct Material *material);
+
+struct Material *BKE_gpencil_handle_new_material(struct Main *bmain, struct Object *ob, const char *name, int *r_index);
+
+struct Material *BKE_gpencil_get_material_for_brush(struct Object *ob, struct Brush *brush);
+int BKE_gpencil_get_material_index_for_brush(struct Object *ob, struct Brush *brush);
+
+struct Material *BKE_gpencil_current_input_toolsettings_material(struct Main *bmain, struct Object *ob, struct ToolSettings *ts);
+struct Material *BKE_gpencil_current_input_brush_material(struct Main *bmain, struct Object *ob, struct Brush *brush);
+struct Material *BKE_gpencil_current_input_material(struct Main *bmain, struct Object *ob);
+
+
struct Material *BKE_gpencil_material_ensure(struct Main *bmain, struct Object *ob);
/* object boundbox */
bool BKE_gpencil_data_minmax(
- struct Object *ob, const struct bGPdata *gpd,
- float r_min[3], float r_max[3]);
+ const struct bGPdata *gpd,
+ float r_min[3], float r_max[3]);
bool BKE_gpencil_stroke_minmax(
- const struct bGPDstroke *gps, const bool use_select,
- float r_min[3], float r_max[3]);
+ const struct bGPDstroke *gps, const bool use_select,
+ float r_min[3], float r_max[3]);
bool BKE_gpencil_stroke_select_check(
- const struct bGPDstroke *gps);
+ const struct bGPDstroke *gps);
struct BoundBox *BKE_gpencil_boundbox_get(struct Object *ob);
void BKE_gpencil_centroid_3d(struct bGPdata *gpd, float r_centroid[3]);
diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h
index fe95904722f..585ea18e007 100644
--- a/source/blender/blenkernel/BKE_gpencil_modifier.h
+++ b/source/blender/blenkernel/BKE_gpencil_modifier.h
@@ -164,7 +164,7 @@ typedef struct GpencilModifierTypeInfo {
* This function is optional.
*/
int (*remapTime)(struct GpencilModifierData *md, struct Depsgraph *depsgraph,
- struct Scene *scene, struct Object *ob, struct bGPDlayer *gpl, int cfra);
+ struct Scene *scene, struct Object *ob, struct bGPDlayer *gpl, int cfra);
/**
* Initialize new instance data for this modifier type, this function
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index cbf692afd70..f8bc075adf0 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -196,8 +196,6 @@ struct Image *BKE_image_add_from_imbuf(struct Main *bmain, struct ImBuf *ibuf, c
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);
-void BKE_image_walk_id_all_users(struct ID *id, void *customdata,
- void callback(struct Image *ima, struct ImageUser *iuser, void *customdata));
void BKE_image_walk_all_users(const struct Main *mainp, void *customdata,
void callback(struct Image *ima, struct ImageUser *iuser, void *customdata));
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index f10f2f44706..8e66aa55b69 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -344,37 +344,37 @@ bool BKE_view_layer_filter_edit_mesh_has_edges(struct Object *ob, void *user_dat
#define BKE_view_layer_array_from_objects_in_edit_mode(view_layer, v3d, r_len) \
BKE_view_layer_array_from_objects_in_mode( \
view_layer, v3d, r_len, { \
- .object_mode = OB_MODE_EDIT});
+ .object_mode = OB_MODE_EDIT})
#define BKE_view_layer_array_from_bases_in_edit_mode(view_layer, v3d, r_len) \
BKE_view_layer_array_from_bases_in_mode( \
view_layer, v3d, r_len, { \
- .object_mode = OB_MODE_EDIT});
+ .object_mode = OB_MODE_EDIT})
#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, r_len) \
BKE_view_layer_array_from_objects_in_mode( \
view_layer, v3d, r_len, { \
.object_mode = OB_MODE_EDIT, \
- .no_dup_data = true});
+ .no_dup_data = true})
#define BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, v3d, r_len) \
BKE_view_layer_array_from_bases_in_mode( \
view_layer, v3d, r_len, { \
.object_mode = OB_MODE_EDIT, \
- .no_dup_data = true});
+ .no_dup_data = true})
#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(view_layer, v3d, r_len) \
BKE_view_layer_array_from_objects_in_mode( \
view_layer, v3d, r_len, { \
.object_mode = OB_MODE_EDIT, \
.no_dup_data = true, \
- .filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs});
+ .filter_fn = BKE_view_layer_filter_edit_mesh_has_uvs})
#define BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, v3d, r_len, mode) \
BKE_view_layer_array_from_objects_in_mode( \
view_layer, v3d, r_len, { \
.object_mode = mode, \
- .no_dup_data = true});
+ .no_dup_data = true})
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 03f9f9a21ea..12aec58d2a5 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -152,31 +152,29 @@ struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset);
} \
} ((void)0)
-
-#define FOREACH_MAIN_ID_BEGIN(_bmain, _id) \
+#define FOREACH_MAIN_LISTBASE_BEGIN(_bmain, _lb) \
{ \
ListBase *_lbarray[MAX_LIBARRAY]; \
int _i = set_listbasepointers(_bmain, _lbarray); \
while (_i--) { \
- FOREACH_MAIN_LISTBASE_ID_BEGIN(_lbarray[_i], _id)
+ _lb = _lbarray[_i];
-#define FOREACH_MAIN_ID_END \
- FOREACH_MAIN_LISTBASE_ID_END; \
+#define FOREACH_MAIN_LISTBASE_END \
} \
} ((void)0)
-/** \param _do_break A boolean, to allow breaking iteration (only used to break by type,
- * you must also use an explicit `break;` operation if you want to
- * immediately break from inner by-ID loop).
- */
-#define FOREACH_MAIN_ID_BREAKABLE_BEGIN(_bmain, _id, _do_break) \
+/* DO NOT use break statement with that macro, use FOREACH_MAIN_LISTBASE and FOREACH_MAIN_LISTBASE_ID instead
+ * if you need that kind of control flow. */
+#define FOREACH_MAIN_ID_BEGIN(_bmain, _id) \
{ \
- ListBase *_lbarray[MAX_LIBARRAY]; \
- int i = set_listbasepointers(_bmain, _lbarray); \
- while (i-- && !_do_break) { \
- FOREACH_MAIN_LISTBASE_ID_BEGIN(_lbarray[i], _id) \
+ ListBase *_lb; \
+ FOREACH_MAIN_LISTBASE_BEGIN(_bmain, _lb) { \
+ FOREACH_MAIN_LISTBASE_ID_BEGIN(_lb, _id)
-#define FOREACH_MAIN_ID_BREAKABLE_END FOREACH_MAIN_ID_END
+#define FOREACH_MAIN_ID_END \
+ FOREACH_MAIN_LISTBASE_ID_END; \
+ } FOREACH_MAIN_LISTBASE_END; \
+ } ((void)0)
struct BlendThumbnail *BKE_main_thumbnail_from_imbuf(struct Main *bmain, struct ImBuf *img);
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index fc065279aa3..0c2a3c28da9 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -22,6 +22,7 @@
/** \file
* \ingroup bke
*/
+struct Base;
struct BoundBox;
struct Depsgraph;
struct Main;
@@ -39,7 +40,7 @@ struct MetaBall *BKE_mball_copy(struct Main *bmain, const struct MetaBall *mb);
void BKE_mball_make_local(struct Main *bmain, struct MetaBall *mb, const bool lib_local);
bool BKE_mball_is_any_selected(const struct MetaBall *mb);
-bool BKE_mball_is_any_selected_multi(struct Object **objects, int objects_len);
+bool BKE_mball_is_any_selected_multi(struct Base **bases, int bases_len);
bool BKE_mball_is_any_unselected(const struct MetaBall *mb);
bool BKE_mball_is_basis_for(struct Object *ob1, struct Object *ob2);
bool BKE_mball_is_basis(struct Object *ob);
@@ -63,13 +64,13 @@ void BKE_mball_translate(struct MetaBall *mb, const float offset[3]);
struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type);
int BKE_mball_select_count(const struct MetaBall *mb);
-int BKE_mball_select_count_multi(struct Object **objects, int objects_len);
-void BKE_mball_select_all(struct MetaBall *mb);
-void BKE_mball_select_all_multi(struct Object **objects, int objects_len);
-void BKE_mball_deselect_all(struct MetaBall *mb);
-void BKE_mball_deselect_all_multi(struct Object **objects, int objects_len);
-void BKE_mball_select_swap(struct MetaBall *mb);
-void BKE_mball_select_swap_multi(struct Object **objects, int objects_len);
+int BKE_mball_select_count_multi(struct Base **bases, int bases_len);
+bool BKE_mball_select_all(struct MetaBall *mb);
+bool BKE_mball_select_all_multi_ex(struct Base **bases, int bases_len);
+bool BKE_mball_deselect_all(struct MetaBall *mb);
+bool BKE_mball_deselect_all_multi_ex(struct Base **bases, int bases_len);
+bool BKE_mball_select_swap(struct MetaBall *mb);
+bool BKE_mball_select_swap_multi_ex(struct Base **bases, int bases_len);
/* **** Depsgraph evaluation **** */
diff --git a/source/blender/blenkernel/BKE_mesh_remap.h b/source/blender/blenkernel/BKE_mesh_remap.h
index 170ee9f0ccb..754e5b2cd05 100644
--- a/source/blender/blenkernel/BKE_mesh_remap.h
+++ b/source/blender/blenkernel/BKE_mesh_remap.h
@@ -22,6 +22,7 @@
*/
struct CustomData;
+struct CustomData_MeshMasks;
struct MVert;
struct MemArena;
struct Mesh;
@@ -136,6 +137,10 @@ enum {
MREMAP_MODE_TOPOLOGY = MREMAP_MODE_VERT | MREMAP_MODE_EDGE | MREMAP_MODE_LOOP | MREMAP_MODE_POLY,
};
+void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(
+ const int vert_mode, const int edge_mode, const int loop_mode, const int poly_mode,
+ struct CustomData_MeshMasks *cddata_mask);
+
float BKE_mesh_remap_calc_difference_from_mesh(
const struct SpaceTransform *space_transform,
const struct MVert *verts_dst, const int numverts_dst, struct Mesh *me_src);
diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h
index d3eb573bc2d..3be97ad7afe 100644
--- a/source/blender/blenkernel/BKE_mesh_runtime.h
+++ b/source/blender/blenkernel/BKE_mesh_runtime.h
@@ -39,13 +39,6 @@ struct Mesh;
struct Object;
struct Scene;
-/* Undefine to hide DerivedMesh-based function declarations */
-#undef USE_DERIVEDMESH
-
-#ifdef USE_DERIVEDMESH
-struct DerivedMesh;
-#endif
-
void BKE_mesh_runtime_reset(struct Mesh *mesh);
void BKE_mesh_runtime_reset_on_copy(struct Mesh *mesh, const int flag);
int BKE_mesh_runtime_looptri_len(const struct Mesh *mesh);
@@ -64,19 +57,9 @@ void BKE_mesh_runtime_verttri_from_looptri(
* to a more suitable location when that file is removed.
* They should also be renamed to use conventions from BKE, not old DerivedMesh.c.
* For now keep the names similar to avoid confusion. */
-#ifdef USE_DERIVEDMESH
-struct DerivedMesh *mesh_get_derived_final(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, const struct CustomData_MeshMasks *dataMask);
-#endif
struct Mesh *mesh_get_eval_final(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask);
-#ifdef USE_DERIVEDMESH
-struct DerivedMesh *mesh_get_derived_deform(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, const struct CustomData_MeshMasks *dataMask);
-#endif
struct Mesh *mesh_get_eval_deform(
struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
@@ -85,32 +68,20 @@ struct Mesh *mesh_create_eval_final_render(
struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
-#ifdef USE_DERIVEDMESH
-struct DerivedMesh *mesh_create_derived_index_render(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, const struct CustomData_MeshMasks *dataMask, int index);
-#endif
struct Mesh *mesh_create_eval_final_index_render(
struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, const struct CustomData_MeshMasks *dataMask, int index);
-#ifdef USE_DERIVEDMESH
-struct DerivedMesh *mesh_create_derived_view(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, const struct CustomData_MeshMasks *dataMask);
-#endif
struct Mesh *mesh_create_eval_final_view(
struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
struct Mesh *mesh_create_eval_no_deform(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, float (*vertCos)[3],
- const struct CustomData_MeshMasks *dataMask);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask);
struct Mesh *mesh_create_eval_no_deform_render(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, float (*vertCos)[3],
- const struct CustomData_MeshMasks *dataMask);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask);
void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb);
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 1a1e510b9e1..a375ed3044c 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -28,7 +28,6 @@ struct BMEditMesh;
struct CustomData_MeshMasks;
struct DepsNodeHandle;
struct Depsgraph;
-struct DerivedMesh;
struct ID;
struct ListBase;
struct Main;
@@ -155,17 +154,6 @@ typedef struct ModifierTypeInfo {
void (*copyData)(const struct ModifierData *md, struct ModifierData *target, const int flag);
- /********************* Deform modifier functions *********************/ /* DEPRECATED */
-
- void (*deformVerts_DM_removed)(void);
- void (*deformMatrices_DM_removed)(void);
- void (*deformVertsEM_DM_removed)(void);
- void (*deformMatricesEM_DM_removed)(void);
-
- /********************* Non-deform modifier functions *********************/ /* DEPRECATED */
-
- void (*applyModifier_DM_removed)(void);
-
/********************* Deform modifier functions *********************/
/* Only for deform types, should apply the deformation
@@ -233,6 +221,8 @@ typedef struct ModifierTypeInfo {
/* Free internal modifier data variables, this function should
* not free the md variable itself.
*
+ * This function is responsible for freeing the runtime data as well.
+ *
* This function is optional.
*/
void (*freeData)(struct ModifierData *md);
@@ -301,6 +291,18 @@ typedef struct ModifierTypeInfo {
*/
void (*foreachTexLink)(struct ModifierData *md, struct Object *ob,
TexWalkFunc walk, void *userData);
+
+ /* Free given runtime data.
+ *
+ * This data is coming from a modifier of the corresponding type, but actual
+ * modifier data is not known here.
+ *
+ * Notes:
+ * - The data itself is to be de-allocated as well.
+ * - This calback is allowed to receive NULL pointer as a data, so it's
+ * more like "ensure the data is freed".
+ */
+ void (*freeRuntimeData)(void *runtime_data);
} ModifierTypeInfo;
/* Initialize modifier's global data (type info and some common global storages). */
@@ -417,14 +419,6 @@ void modwrap_deformVertsEM(
struct BMEditMesh *em, struct Mesh *me,
float (*vertexCos)[3], int numVerts);
-/* wrappers for modifier callbacks that accept Mesh and select the proper implementation
- * depending on if the modifier has been ported to Mesh or is still using DerivedMesh
- */
-
-struct DerivedMesh *modifier_applyModifier_DM_deprecated(
- struct ModifierData *md, const struct ModifierEvalContext *ctx,
- struct DerivedMesh *dm);
-
struct Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(
struct Object *ob_eval, const bool get_cage_mesh);
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 6e6ec31aa6a..80b0f9a023f 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -337,6 +337,7 @@ void ntreeUserDecrefID(struct bNodeTree *ntree);
struct bNodeTree *ntreeFromID(const struct ID *id);
void ntreeMakeLocal(struct Main *bmain, struct bNodeTree *ntree, bool id_in_mainlist, const bool lib_local);
+void ntreeFreeLocalNode(struct bNodeTree *ntree, struct bNode *node);
void ntreeFreeLocalTree(struct bNodeTree *ntree);
struct bNode *ntreeFindType(const struct bNodeTree *ntree, int type);
bool ntreeHasType(const struct bNodeTree *ntree, int type);
@@ -445,10 +446,8 @@ struct bNode *nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntre
void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node);
-/* Frees the node itself, without affect to anything else. */
-void nodeFreeNode(struct bNodeTree *ntree, struct bNode *node);
-/* Will additionally cleanup things like f-curves which uses this node. */
-void nodeDeleteNode(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node);
+/* Delete node, associated animation data and ID user count. */
+void nodeRemoveNode(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node, bool do_id_user);
struct bNode *BKE_node_copy_ex(struct bNodeTree *ntree, struct bNode *node_src, const int flag);
@@ -502,6 +501,7 @@ void ntreeTagUsedSockets(struct bNodeTree *ntree);
/* Node Clipboard */
void BKE_node_clipboard_init(struct bNodeTree *ntree);
void BKE_node_clipboard_clear(void);
+void BKE_node_clipboard_free(void);
bool BKE_node_clipboard_validate(void);
void BKE_node_clipboard_add_node(struct bNode *node);
void BKE_node_clipboard_add_link(struct bNodeLink *link);
@@ -618,6 +618,7 @@ bool BKE_node_is_connected_to_output(struct bNodeTree *ntree, struct bNode *node
#define NODE_REROUTE 6
#define NODE_GROUP_INPUT 7
#define NODE_GROUP_OUTPUT 8
+#define NODE_CUSTOM_GROUP 9
void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 9cd98232375..4a1470797ba 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -336,10 +336,10 @@ typedef enum eObjectSet {
struct LinkNode *BKE_object_relational_superset(
struct ViewLayer *view_layer, eObjectSet objectSet, eObRelationTypes includeFilter);
-struct LinkNode *BKE_object_groups(struct Main *bmain, struct Object *ob);
-void BKE_object_groups_clear(struct Main *bmain, struct Object *object);
+struct LinkNode *BKE_object_groups(struct Main *bmain, struct Scene *scene, struct Object *ob);
+void BKE_object_groups_clear(struct Main *bmain, struct Scene *scene, struct Object *object);
-struct KDTree *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
+struct KDTree_3d *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
bool BKE_object_modifier_use_time(struct Object *ob, struct ModifierData *md);
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index cc445413f61..abb1b1d9cc5 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -50,13 +50,13 @@ struct Scene;
struct Sculpt;
struct StrokeCache;
struct SubdivCCG;
+struct SubdivCCG;
struct Tex;
struct ToolSettings;
struct UnifiedPaintSettings;
struct ViewLayer;
struct bContext;
struct bToolRef;
-struct SubdivCCG;
enum eOverlayFlags;
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 19036e63a8c..b2b7f9f9cb5 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -45,7 +45,7 @@ struct CustomData_MeshMasks;
struct Depsgraph;
struct Depsgraph;
struct EdgeHash;
-struct KDTree;
+struct KDTree_3d;
struct LatticeDeformData;
struct LinkNode;
struct MCol;
@@ -136,7 +136,7 @@ typedef struct ParticleThreadContext {
struct Material *ma;
/* distribution */
- struct KDTree *tree;
+ struct KDTree_3d *tree;
struct ParticleSeam *seams;
int totseam;
@@ -172,19 +172,6 @@ typedef struct ParticleTask {
int begin, end;
} ParticleTask;
-typedef struct ParticleBillboardData {
- struct Object *ob;
- float vec[3], vel[3];
- float offset[2];
- float size[2];
- float tilt, random, time;
- int uv[3];
- int lock, num;
- int totnum;
- int lifetime;
- short align, uv_split, anim, split_offset;
-} ParticleBillboardData;
-
typedef struct ParticleCollisionElement {
/* pointers to original data */
float *x[3], *v[3];
@@ -391,7 +378,6 @@ void psys_thread_context_free(struct ParticleThreadContext *ctx);
void psys_tasks_create(struct ParticleThreadContext *ctx, int startpart, int endpart, struct ParticleTask **r_tasks, int *r_numtasks);
void psys_tasks_free(struct ParticleTask *tasks, int numtasks);
-void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]);
void psys_apply_hair_lattice(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
/* particle_system.c */
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 87d1a6c6915..9be2d645fde 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -350,7 +350,7 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
#define BKE_pbvh_vertex_iter_end \
} \
} \
- }
+ } ((void)0)
void BKE_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count);
void BKE_pbvh_node_free_proxies(PBVHNode *node);
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 6f0145a493d..9cfc43b2e5b 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -226,7 +226,7 @@ typedef struct PTCacheUndo {
/* particles stuff */
struct ParticleData *particles;
- struct KDTree *emitter_field;
+ struct KDTree_3d *emitter_field;
float *emitter_cosnos;
int psys_flag;
@@ -257,7 +257,7 @@ typedef struct PTCacheEdit {
struct ParticleSystem *psys_eval;
struct ParticleSystemModifierData *psmd;
struct ParticleSystemModifierData *psmd_eval;
- struct KDTree *emitter_field;
+ struct KDTree_3d *emitter_field;
float *emitter_cosnos; /* localspace face centers and normals (average of its verts), from the derived mesh */
int *mirror_cache;
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index a0525a4e9f7..4e4883222cc 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -42,11 +42,10 @@ struct ViewRender;
struct WorkSpace;
typedef enum eSceneCopyMethod {
- SCE_COPY_NEW = 0,
- SCE_COPY_EMPTY = 1,
- SCE_COPY_LINK_OB = 2,
- SCE_COPY_LINK_DATA = 3,
- SCE_COPY_FULL = 4,
+ SCE_COPY_NEW = 0,
+ SCE_COPY_EMPTY = 1,
+ SCE_COPY_LINK_COLLECTION = 2,
+ SCE_COPY_FULL = 3,
} eSceneCopyMethod;
/* Use as the contents of a 'for' loop: for (SETLOOPER(...)) { ... */
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h
index b6fc9d5178e..8ce5099305c 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf.h
@@ -21,10 +21,10 @@
* \ingroup bke
*/
-typedef void* CCGMeshHDL;
-typedef void* CCGVertHDL;
-typedef void* CCGEdgeHDL;
-typedef void* CCGFaceHDL;
+typedef void *CCGMeshHDL;
+typedef void *CCGVertHDL;
+typedef void *CCGEdgeHDL;
+typedef void *CCGFaceHDL;
typedef struct CCGEdge CCGEdge;
typedef struct CCGFace CCGFace;
@@ -40,7 +40,7 @@ typedef struct CCGMeshIFC {
/***/
-typedef void* CCGAllocatorHDL;
+typedef void *CCGAllocatorHDL;
typedef struct CCGAllocatorIFC {
void* (*alloc) (CCGAllocatorHDL a, int numBytes);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 1fe72ce95a7..6d9be9fb639 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -624,7 +624,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, const CustomData_MeshMask
}
/* skip the listbase */
- MEMCPY_STRUCT_OFS(me, &tmp, id.prev);
+ MEMCPY_STRUCT_AFTER(me, &tmp, id.prev);
if (take_ownership) {
if (alloctype == CD_ASSIGN) {
@@ -768,21 +768,6 @@ void *DM_get_loop_data_layer(DerivedMesh *dm, int type)
return CustomData_get_layer(&dm->loopData, type);
}
-void DM_set_vert_data(DerivedMesh *dm, int index, int type, void *data)
-{
- CustomData_set(&dm->vertData, index, type, data);
-}
-
-void DM_set_edge_data(DerivedMesh *dm, int index, int type, void *data)
-{
- CustomData_set(&dm->edgeData, index, type, data);
-}
-
-void DM_set_tessface_data(DerivedMesh *dm, int index, int type, void *data)
-{
- CustomData_set(&dm->faceData, index, type, data);
-}
-
void DM_copy_vert_data(DerivedMesh *source, DerivedMesh *dest,
int source_index, int dest_index, int count)
{
@@ -790,59 +775,6 @@ void DM_copy_vert_data(DerivedMesh *source, DerivedMesh *dest,
source_index, dest_index, count);
}
-void DM_copy_edge_data(DerivedMesh *source, DerivedMesh *dest,
- int source_index, int dest_index, int count)
-{
- CustomData_copy_data(&source->edgeData, &dest->edgeData,
- source_index, dest_index, count);
-}
-
-void DM_copy_tessface_data(DerivedMesh *source, DerivedMesh *dest,
- int source_index, int dest_index, int count)
-{
- CustomData_copy_data(&source->faceData, &dest->faceData,
- source_index, dest_index, count);
-}
-
-void DM_copy_loop_data(DerivedMesh *source, DerivedMesh *dest,
- int source_index, int dest_index, int count)
-{
- CustomData_copy_data(&source->loopData, &dest->loopData,
- source_index, dest_index, count);
-}
-
-void DM_copy_poly_data(DerivedMesh *source, DerivedMesh *dest,
- int source_index, int dest_index, int count)
-{
- CustomData_copy_data(&source->polyData, &dest->polyData,
- source_index, dest_index, count);
-}
-
-void DM_free_vert_data(struct DerivedMesh *dm, int index, int count)
-{
- CustomData_free_elem(&dm->vertData, index, count);
-}
-
-void DM_free_edge_data(struct DerivedMesh *dm, int index, int count)
-{
- CustomData_free_elem(&dm->edgeData, index, count);
-}
-
-void DM_free_tessface_data(struct DerivedMesh *dm, int index, int count)
-{
- CustomData_free_elem(&dm->faceData, index, count);
-}
-
-void DM_free_loop_data(struct DerivedMesh *dm, int index, int count)
-{
- CustomData_free_elem(&dm->loopData, index, count);
-}
-
-void DM_free_poly_data(struct DerivedMesh *dm, int index, int count)
-{
- CustomData_free_elem(&dm->polyData, index, count);
-}
-
/**
* interpolates vertex data from the vertices indexed by src_indices in the
* source mesh using the given weights and stores the result in the vertex
@@ -857,60 +789,6 @@ void DM_interp_vert_data(
weights, NULL, count, dest_index);
}
-/**
- * interpolates edge data from the edges indexed by src_indices in the
- * source mesh using the given weights and stores the result in the edge indexed
- * by dest_index in the dest mesh.
- * if weights is NULL, all weights default to 1.
- * if vert_weights is non-NULL, any per-vertex edge data is interpolated using
- * vert_weights[i] multiplied by weights[i].
- */
-void DM_interp_edge_data(
- DerivedMesh *source, DerivedMesh *dest,
- int *src_indices,
- float *weights, EdgeVertWeight *vert_weights,
- int count, int dest_index)
-{
- CustomData_interp(&source->edgeData, &dest->edgeData, src_indices,
- weights, (float *)vert_weights, count, dest_index);
-}
-
-/**
- * interpolates face data from the faces indexed by src_indices in the
- * source mesh using the given weights and stores the result in the face indexed
- * by dest_index in the dest mesh.
- * if weights is NULL, all weights default to 1.
- * if vert_weights is non-NULL, any per-vertex face data is interpolated using
- * vert_weights[i] multiplied by weights[i].
- */
-void DM_interp_tessface_data(
- DerivedMesh *source, DerivedMesh *dest,
- int *src_indices,
- float *weights, FaceVertWeight *vert_weights,
- int count, int dest_index)
-{
- CustomData_interp(&source->faceData, &dest->faceData, src_indices,
- weights, (float *)vert_weights, count, dest_index);
-}
-
-void DM_interp_loop_data(
- DerivedMesh *source, DerivedMesh *dest,
- int *src_indices,
- float *weights, int count, int dest_index)
-{
- CustomData_interp(&source->loopData, &dest->loopData, src_indices,
- weights, NULL, count, dest_index);
-}
-
-void DM_interp_poly_data(
- DerivedMesh *source, DerivedMesh *dest,
- int *src_indices,
- float *weights, int count, int dest_index)
-{
- CustomData_interp(&source->polyData, &dest->polyData, src_indices,
- weights, NULL, count, dest_index);
-}
-
DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
{
DerivedMesh *dm = CDDM_from_mesh(me);
@@ -1001,18 +879,18 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *me, BMEditMesh *em, int layer)
static void add_orco_mesh(
Object *ob, BMEditMesh *em, Mesh *mesh,
- Mesh *me_orco, int layer)
+ Mesh *mesh_orco, int layer)
{
float (*orco)[3], (*layerorco)[3];
int totvert, free;
totvert = mesh->totvert;
- if (me_orco) {
+ if (mesh_orco) {
free = 1;
- if (me_orco->totvert == totvert) {
- orco = BKE_mesh_vertexCos_get(me_orco, NULL);
+ if (mesh_orco->totvert == totvert) {
+ orco = BKE_mesh_vertexCos_get(mesh_orco, NULL);
}
else {
orco = BKE_mesh_vertexCos_get(mesh, NULL);
@@ -1105,102 +983,130 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
}
}
-static void add_shapekey_layers(Mesh *me_dst, Mesh *me_src, Object *UNUSED(ob))
+static void mesh_copy_autosmooth(Mesh *me, Mesh *me_orig)
{
- KeyBlock *kb;
- Key *key = me_src->key;
- int i;
-
- if (!me_src->key)
- return;
-
- /* ensure we can use mesh vertex count for derived mesh custom data */
- if (me_src->totvert != me_dst->totvert) {
- CLOG_WARN(&LOG, "vertex size mismatch (mesh/eval) '%s' (%d != %d)",
- me_src->id.name + 2, me_src->totvert, me_dst->totvert);
- return;
+ if (me_orig->flag & ME_AUTOSMOOTH) {
+ me->flag |= ME_AUTOSMOOTH;
+ me->smoothresh = me_orig->smoothresh;
}
+}
- for (i = 0, kb = key->block.first; kb; kb = kb->next, i++) {
- int ci;
- float *array;
+static void mesh_calc_modifier_final_normals(
+ const Mesh *mesh_input,
+ const CustomData_MeshMasks *dataMask,
+ const bool sculpt_dyntopo,
+ Mesh *mesh_final)
+{
+ /* Compute normals. */
+ const bool do_loop_normals = ((mesh_input->flag & ME_AUTOSMOOTH) != 0 ||
+ (dataMask->lmask & CD_MASK_NORMAL) != 0);
+ /* Some modifiers may need this info from their target (other) object, simpler to generate it here as well.
+ * Note that they will always be generated when no loop normals are comptuted,
+ * since they are needed by drawing code. */
+ const bool do_poly_normals = ((dataMask->pmask & CD_MASK_NORMAL) != 0);
- if (me_src->totvert != kb->totelem) {
- CLOG_WARN(&LOG, "vertex size mismatch (Mesh '%s':%d != KeyBlock '%s':%d)",
- me_src->id.name + 2, me_src->totvert, kb->name, kb->totelem);
- array = MEM_calloc_arrayN((size_t)me_src->totvert, sizeof(float[3]), __func__);
- }
- else {
- array = MEM_malloc_arrayN((size_t)me_src->totvert, sizeof(float[3]), __func__);
- memcpy(array, kb->data, (size_t)me_src->totvert * sizeof(float[3]));
+ if (do_loop_normals) {
+ /* In case we also need poly normals, add the layer here, then BKE_mesh_calc_normals_split() will fill it. */
+ if (do_poly_normals) {
+ if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) {
+ CustomData_add_layer(&mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly);
+ }
}
+ /* Compute loop normals (note: will compute poly and vert normals as well, if needed!) */
+ BKE_mesh_calc_normals_split(mesh_final);
+ BKE_mesh_tessface_clear(mesh_final);
+ }
- CustomData_add_layer_named(&me_dst->vdata, CD_SHAPEKEY, CD_ASSIGN, array, me_dst->totvert, kb->name);
- ci = CustomData_get_layer_index_n(&me_dst->vdata, CD_SHAPEKEY, i);
+ if (sculpt_dyntopo == false) {
+ /* watch this! after 2.75a we move to from tessface to looptri (by default) */
+ if (dataMask->fmask & CD_MASK_MFACE) {
+ BKE_mesh_tessface_ensure(mesh_final);
+ }
- me_dst->vdata.layers[ci].uid = kb->uid;
+ /* without this, drawing ngon tri's faces will show ugly tessellated face
+ * normals and will also have to calculate normals on the fly, try avoid
+ * this where possible since calculating polygon normals isn't fast,
+ * note that this isn't a problem for subsurf (only quads) or editmode
+ * which deals with drawing differently.
+ *
+ * Only calc vertex normals if they are flagged as dirty.
+ * If using loop normals, poly nors have already been computed.
+ */
+ if (!do_loop_normals) {
+ BKE_mesh_ensure_normals_for_display(mesh_final);
+ }
}
-}
-static void mesh_copy_autosmooth(Mesh *me, Mesh *me_orig)
-{
- if (me_orig->flag & ME_AUTOSMOOTH) {
- me->flag |= ME_AUTOSMOOTH;
- me->smoothresh = me_orig->smoothresh;
+ /* Some modifiers, like datatransfer, may generate those data as temp layer, we do not want to keep them,
+ * as they are used by display code when available (i.e. even if autosmooth is disabled). */
+ if (!do_loop_normals && CustomData_has_layer(&mesh_final->ldata, CD_NORMAL)) {
+ CustomData_free_layers(&mesh_final->ldata, CD_NORMAL, mesh_final->totloop);
}
}
static void mesh_calc_modifiers(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
+ struct Depsgraph *depsgraph,
+ Scene *scene, Object *ob,
int useDeform,
- const bool need_mapping, const CustomData_MeshMasks *dataMask,
- const int index, const bool useCache, const bool build_shapekey_layers,
+ const bool need_mapping,
+ const CustomData_MeshMasks *dataMask,
+ const int index,
+ const bool use_cache,
/* return args */
- Mesh **r_deform, Mesh **r_final)
+ Mesh **r_deform,
+ Mesh **r_final)
{
- ModifierData *firstmd, *md, *previewmd = NULL;
- CDMaskLink *datamasks, *curr;
- /* XXX Always copying POLYINDEX, else tessellated data are no more valid! */
- CustomData_MeshMasks mask, nextmask, previewmask = {0}, append_mask = CD_MASK_BAREMESH_ORIGINDEX;
-
- float (*deformedVerts)[3] = NULL;
- int numVerts = ((Mesh *)ob->data)->totvert;
- const bool useRenderParams = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
- const int required_mode = useRenderParams ? eModifierMode_Render : eModifierMode_Realtime;
+ /* Input and final mesh. Final mesh is only created the moment the first
+ * constructive modifier is executed, or a deform modifier needs normals
+ * or certain data layers. */
+ Mesh *mesh_input = ob->data;
+ Mesh *mesh_final = NULL;
+ Mesh *mesh_deform = NULL;
+ BLI_assert((mesh_input->id.tag & LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT) == 0);
+
+ /* Deformed vertex locations array. Deform only modifier need this type of
+ * float array rather than MVert*. Tracked along with mesh_final as an
+ * optimization to avoid copying coordinates back and forth if there are
+ * multiple sequential deform only modifiers. */
+ float (*deformed_verts)[3] = NULL;
+ int num_deformed_verts = mesh_input->totvert;
bool isPrevDeform = false;
+
+ /* Mesh with constructive modifiers but no deformation applied. Tracked
+ * along with final mesh if undeformed / orco coordinates are requested
+ * for texturing. */
+ Mesh *mesh_orco = NULL;
+ Mesh *mesh_orco_cloth = NULL;
+
+ /* Modifier evaluation modes. */
+ const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
+ const int required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime;
+
+ /* Sculpt can skip certain modifiers. */
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
const bool has_multires = (mmd && mmd->sculptlvl != 0);
bool multires_applied = false;
- const bool sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt && !useRenderParams;
- const bool sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm) && !useRenderParams;
+ const bool sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt && !use_render;
+ const bool sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm) && !use_render;
- /* Generic preview only in object mode! */
- const bool do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
- const bool do_loop_normals = ((((Mesh *)ob->data)->flag & ME_AUTOSMOOTH) != 0 ||
- (dataMask->lmask & CD_MASK_NORMAL) != 0);
+ /* Modifier evaluation contexts for different types of modifiers. */
+ ModifierApplyFlag app_render = use_render ? MOD_APPLY_RENDER : 0;
+ ModifierApplyFlag app_cache = use_cache ? MOD_APPLY_USECACHE : 0;
+ const ModifierEvalContext mectx = {depsgraph, ob, app_render | app_cache};
+ const ModifierEvalContext mectx_orco = {depsgraph, ob, app_render | MOD_APPLY_ORCO};
+ /* Get effective list of modifiers to execute. Some effects like shape keys
+ * are added as virtual modifiers before the user created modifiers. */
VirtualModifierData virtualModifierData;
+ ModifierData *firstmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
+ ModifierData *md = firstmd;
- ModifierApplyFlag app_flags = useRenderParams ? MOD_APPLY_RENDER : 0;
- ModifierApplyFlag deform_app_flags = app_flags;
-
- BLI_assert((((Mesh *)ob->data)->id.tag & LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT) == 0);
-
- if (useCache)
- app_flags |= MOD_APPLY_USECACHE;
- if (useDeform)
- deform_app_flags |= MOD_APPLY_USECACHE;
-
- /* TODO(sybren): do we really need three context objects? Or do we modify
- * them on the fly to change the flags where needed? */
- const ModifierEvalContext mectx_deform = {depsgraph, ob, deform_app_flags};
- const ModifierEvalContext mectx_apply = {depsgraph, ob, app_flags};
- const ModifierEvalContext mectx_orco = {depsgraph, ob, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO};
-
- md = firstmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
-
- modifiers_clearErrors(ob);
-
+ /* Preview colors by modifiers such as dynamic paint, to show the results
+ * even if the resulting data is not used in a material. Only in object mode.
+ * TODO: this is broken, not drawn by the drawn manager. */
+ const bool do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
+ ModifierData *previewmd = NULL;
+ CustomData_MeshMasks previewmask = {0};
if (do_mod_mcol) {
/* Find the last active modifier generating a preview, or NULL if none. */
/* XXX Currently, DPaint modifier just ignores this.
@@ -1209,20 +1115,21 @@ static void mesh_calc_modifiers(
previewmd = modifiers_getLastPreview(scene, md, required_mode);
}
- datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, previewmd, &previewmask);
- curr = datamasks;
+ /* Compute accumulated datamasks needed by each modifier. It helps to do
+ * this fine grained so that for example vertex groups are preserved up to
+ * an armature modifier, but not through a following subsurf modifier where
+ * subdividing them is expensive. */
+ CDMaskLink *datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, previewmd, &previewmask);
+ CDMaskLink *md_datamask = datamasks;
+ /* XXX Always copying POLYINDEX, else tessellated data are no more valid! */
+ CustomData_MeshMasks append_mask = CD_MASK_BAREMESH_ORIGINDEX;
- if (r_deform) {
- *r_deform = NULL;
- }
- *r_final = NULL;
+ /* Clear errors before evaluation. */
+ modifiers_clearErrors(ob);
+ /* Apply all leading deform modifiers. */
if (useDeform) {
- if (inputVertexCos)
- deformedVerts = inputVertexCos;
-
- /* Apply all leading deforming modifiers */
- for (; md; md = md->next, curr = curr->next) {
+ for (; md; md = md->next, md_datamask = md_datamask->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (!modifier_isEnabled(scene, md, required_mode)) {
@@ -1234,10 +1141,20 @@ static void mesh_calc_modifiers(
}
if (mti->type == eModifierTypeType_OnlyDeform && !sculpt_dyntopo) {
- if (!deformedVerts)
- deformedVerts = BKE_mesh_vertexCos_get(ob->data, &numVerts);
+ if (!deformed_verts) {
+ deformed_verts = BKE_mesh_vertexCos_get(mesh_input, &num_deformed_verts);
+ }
+ else if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
+ if (mesh_final == NULL) {
+ mesh_final = BKE_mesh_copy_for_eval(mesh_input, true);
+ ASSERT_IS_VALID_MESH(mesh_final);
+ }
+ BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
+ }
- modwrap_deformVerts(md, &mectx_deform, NULL, deformedVerts, numVerts);
+ modwrap_deformVerts(md, &mectx, mesh_final, deformed_verts, num_deformed_verts);
+
+ isPrevDeform = true;
}
else {
break;
@@ -1250,39 +1167,18 @@ static void mesh_calc_modifiers(
/* Result of all leading deforming modifiers is cached for
* places that wish to use the original mesh but with deformed
- * coordinates (vpaint, etc.)
- */
+ * coordinates (like vertex paint). */
if (r_deform) {
- *r_deform = BKE_mesh_copy_for_eval(ob->data, true);
+ mesh_deform = BKE_mesh_copy_for_eval(mesh_input, true);
- /* XXX: Is build_shapekey_layers ever even true? This should have crashed long ago... */
- BLI_assert(!build_shapekey_layers);
- if (build_shapekey_layers) {
- add_shapekey_layers(*r_deform, ob->data, ob);
- }
-
- if (deformedVerts) {
- BKE_mesh_apply_vert_coords(*r_deform, deformedVerts);
+ if (deformed_verts) {
+ BKE_mesh_apply_vert_coords(mesh_deform, deformed_verts);
}
}
}
- else {
- /* default behavior for meshes */
- if (inputVertexCos)
- deformedVerts = inputVertexCos;
- else
- deformedVerts = BKE_mesh_vertexCos_get(ob->data, &numVerts);
- }
-
-
- /* Now apply all remaining modifiers. If useDeform is off then skip
- * OnlyDeform ones.
- */
- Mesh *me = NULL;
- Mesh *me_orco = NULL;
- Mesh *me_orco_cloth = NULL;
- for (; md; md = md->next, curr = curr->next) {
+ /* Apply all remaining constructive and deforming modifiers. */
+ for (; md; md = md->next, md_datamask = md_datamask->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (!modifier_isEnabled(scene, md, required_mode)) {
@@ -1293,7 +1189,7 @@ static void mesh_calc_modifiers(
continue;
}
- if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && me) {
+ if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && mesh_final) {
modifier_setError(md, "Modifier requires original data, bad stack position");
continue;
}
@@ -1310,7 +1206,7 @@ static void mesh_calc_modifiers(
}
}
- if (sculpt_dyntopo && !useRenderParams)
+ if (sculpt_dyntopo)
unsupported = true;
if (scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM)
@@ -1338,95 +1234,87 @@ static void mesh_calc_modifiers(
continue;
}
- /* add an orco layer if needed by this modifier */
- memset(&mask, 0, sizeof(mask));
- if (mti->requiredDataMask) {
+ /* Add an orco layer if needed by this modifier. */
+ if (mesh_final && mti->requiredDataMask) {
+ CustomData_MeshMasks mask = {0};
mti->requiredDataMask(ob, md, &mask);
- }
-
- if (me && (mask.vmask & CD_MASK_ORCO)) {
- add_orco_mesh(ob, NULL, me, me_orco, CD_ORCO);
+ if (mask.vmask & CD_MASK_ORCO) {
+ add_orco_mesh(ob, NULL, mesh_final, mesh_orco, CD_ORCO);
+ }
}
/* How to apply modifier depends on (a) what we already have as
* a result of previous modifiers (could be a Mesh or just
- * deformed vertices) and (b) what type the modifier is.
- */
-
+ * deformed vertices) and (b) what type the modifier is. */
if (mti->type == eModifierTypeType_OnlyDeform) {
/* No existing verts to deform, need to build them. */
- if (!deformedVerts) {
- if (me) {
+ if (!deformed_verts) {
+ if (mesh_final) {
/* Deforming a mesh, read the vertex locations
* out of the mesh and deform them. Once done with this
- * run of deformers verts will be written back.
- */
- deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
+ * run of deformers verts will be written back. */
+ deformed_verts = BKE_mesh_vertexCos_get(mesh_final, &num_deformed_verts);
}
else {
- deformedVerts = BKE_mesh_vertexCos_get(ob->data, &numVerts);
+ deformed_verts = BKE_mesh_vertexCos_get(mesh_input, &num_deformed_verts);
}
}
-
/* if this is not the last modifier in the stack then recalculate the normals
* to avoid giving bogus normals to the next modifier see: [#23673] */
- if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
+ else if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
/* XXX, this covers bug #23673, but we may need normal calc for other types */
- if (me) {
- BKE_mesh_apply_vert_coords(me, deformedVerts);
+ if (mesh_final) {
+ BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
}
}
- modwrap_deformVerts(md, &mectx_deform, me, deformedVerts, numVerts);
+ modwrap_deformVerts(md, &mectx, mesh_final, deformed_verts, num_deformed_verts);
}
else {
/* determine which data layers are needed by following modifiers */
- if (curr->next)
- nextmask = curr->next->mask;
+ CustomData_MeshMasks nextmask;
+ if (md_datamask->next)
+ nextmask = md_datamask->next->mask;
else
nextmask = *dataMask;
/* apply vertex coordinates or build a Mesh as necessary */
- if (me) {
- if (deformedVerts) {
- BKE_mesh_apply_vert_coords(me, deformedVerts);
+ if (mesh_final) {
+ if (deformed_verts) {
+ BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
}
}
else {
- me = BKE_mesh_copy_for_eval(ob->data, true);
- ASSERT_IS_VALID_MESH(me);
+ mesh_final = BKE_mesh_copy_for_eval(mesh_input, true);
+ ASSERT_IS_VALID_MESH(mesh_final);
- if (build_shapekey_layers) {
- add_shapekey_layers(me, ob->data, ob);
+ if (deformed_verts) {
+ BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
}
- if (deformedVerts) {
- BKE_mesh_apply_vert_coords(me, deformedVerts);
- }
-
- /* Constructive modifiers need to have an origindex
- * otherwise they wont have anywhere to copy the data from.
+ /* Initialize original indices the first time we evaluate a
+ * constructive modifier. Modifiers will then do mapping mostly
+ * automatic by copying them through CustomData_copy_data along
+ * with other data.
*
- * Also create ORIGINDEX data if any of the following modifiers
- * requests it, this way Mirror, Solidify etc will keep ORIGINDEX
- * data by using generic DM_copy_vert_data() functions.
- */
+ * These are created when either requested by evaluation, or if
+ * following modifiers requested them. */
if (need_mapping || ((nextmask.vmask | nextmask.emask | nextmask.pmask) & CD_MASK_ORIGINDEX)) {
/* calc */
- CustomData_add_layer(&me->vdata, CD_ORIGINDEX, CD_CALLOC, NULL, me->totvert);
- CustomData_add_layer(&me->edata, CD_ORIGINDEX, CD_CALLOC, NULL, me->totedge);
- CustomData_add_layer(&me->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, me->totpoly);
+ CustomData_add_layer(&mesh_final->vdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh_final->totvert);
+ CustomData_add_layer(&mesh_final->edata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh_final->totedge);
+ CustomData_add_layer(&mesh_final->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh_final->totpoly);
/* Not worth parallelizing this, gives less than 0.1% overall speedup in best of best cases... */
- range_vn_i(CustomData_get_layer(&me->vdata, CD_ORIGINDEX), me->totvert, 0);
- range_vn_i(CustomData_get_layer(&me->edata, CD_ORIGINDEX), me->totedge, 0);
- range_vn_i(CustomData_get_layer(&me->pdata, CD_ORIGINDEX), me->totpoly, 0);
+ range_vn_i(CustomData_get_layer(&mesh_final->vdata, CD_ORIGINDEX), mesh_final->totvert, 0);
+ range_vn_i(CustomData_get_layer(&mesh_final->edata, CD_ORIGINDEX), mesh_final->totedge, 0);
+ range_vn_i(CustomData_get_layer(&mesh_final->pdata, CD_ORIGINDEX), mesh_final->totpoly, 0);
}
}
/* set the Mesh to only copy needed data */
- mask = curr->mask;
+ CustomData_MeshMasks mask = md_datamask->mask;
/* needMapping check here fixes bug [#28112], otherwise it's
* possible that it won't be copied */
CustomData_MeshMasks_update(&mask, &append_mask);
@@ -1435,93 +1323,96 @@ static void mesh_calc_modifiers(
mask.emask |= CD_MASK_ORIGINDEX;
mask.pmask |= CD_MASK_ORIGINDEX;
}
- mesh_set_only_copy(me, &mask);
+ mesh_set_only_copy(mesh_final, &mask);
/* add cloth rest shape key if needed */
if (mask.vmask & CD_MASK_CLOTH_ORCO) {
- add_orco_mesh(ob, NULL, me, me_orco, CD_CLOTH_ORCO);
+ add_orco_mesh(ob, NULL, mesh_final, mesh_orco, CD_CLOTH_ORCO);
}
/* add an origspace layer if needed */
- if ((curr->mask.lmask) & CD_MASK_ORIGSPACE_MLOOP) {
- if (!CustomData_has_layer(&me->ldata, CD_ORIGSPACE_MLOOP)) {
- CustomData_add_layer(&me->ldata, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL, me->totloop);
- mesh_init_origspace(me);
+ if ((md_datamask->mask.lmask) & CD_MASK_ORIGSPACE_MLOOP) {
+ if (!CustomData_has_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP)) {
+ CustomData_add_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL, mesh_final->totloop);
+ mesh_init_origspace(mesh_final);
}
}
- Mesh *me_next = modwrap_applyModifier(md, &mectx_apply, me);
- ASSERT_IS_VALID_MESH(me_next);
+ Mesh *mesh_next = modwrap_applyModifier(md, &mectx, mesh_final);
+ ASSERT_IS_VALID_MESH(mesh_next);
- if (me_next) {
+ if (mesh_next) {
/* if the modifier returned a new mesh, release the old one */
- if (me && me != me_next) {
- BLI_assert(me != ob->data);
- BKE_id_free(NULL, me);
+ if (mesh_final != mesh_next) {
+ BLI_assert(mesh_final != mesh_input);
+ BKE_id_free(NULL, mesh_final);
}
- me = me_next;
+ mesh_final = mesh_next;
- if (deformedVerts) {
- if (deformedVerts != inputVertexCos) {
- MEM_freeN(deformedVerts);
- }
- deformedVerts = NULL;
+ if (deformed_verts) {
+ MEM_freeN(deformed_verts);
+ deformed_verts = NULL;
}
- mesh_copy_autosmooth(me, ob->data);
+ mesh_copy_autosmooth(mesh_final, mesh_input);
}
/* create an orco mesh in parallel */
if (nextmask.vmask & CD_MASK_ORCO) {
- if (!me_orco) {
- me_orco = create_orco_mesh(ob, ob->data, NULL, CD_ORCO);
+ if (!mesh_orco) {
+ mesh_orco = create_orco_mesh(ob, mesh_input, NULL, CD_ORCO);
}
nextmask.vmask &= ~CD_MASK_ORCO;
- CustomData_MeshMasks temp_cddata_masks = {.vmask=CD_MASK_ORIGINDEX, .emask=CD_MASK_ORIGINDEX, .fmask=CD_MASK_ORIGINDEX, .pmask=CD_MASK_ORIGINDEX};
+ CustomData_MeshMasks temp_cddata_masks = {
+ .vmask = CD_MASK_ORIGINDEX,
+ .emask = CD_MASK_ORIGINDEX,
+ .fmask = CD_MASK_ORIGINDEX,
+ .pmask = CD_MASK_ORIGINDEX,
+ };
if (mti->requiredDataMask != NULL) {
mti->requiredDataMask(ob, md, &temp_cddata_masks);
}
CustomData_MeshMasks_update(&temp_cddata_masks, &nextmask);
- mesh_set_only_copy(me_orco, &temp_cddata_masks);
+ mesh_set_only_copy(mesh_orco, &temp_cddata_masks);
- me_next = modwrap_applyModifier(md, &mectx_orco, me_orco);
- ASSERT_IS_VALID_MESH(me_next);
+ mesh_next = modwrap_applyModifier(md, &mectx_orco, mesh_orco);
+ ASSERT_IS_VALID_MESH(mesh_next);
- if (me_next) {
+ if (mesh_next) {
/* if the modifier returned a new mesh, release the old one */
- if (me_orco && me_orco != me_next) {
- BLI_assert(me_orco != ob->data);
- BKE_id_free(NULL, me_orco);
+ if (mesh_orco != mesh_next) {
+ BLI_assert(mesh_orco != mesh_input);
+ BKE_id_free(NULL, mesh_orco);
}
- me_orco = me_next;
+ mesh_orco = mesh_next;
}
}
/* create cloth orco mesh in parallel */
if (nextmask.vmask & CD_MASK_CLOTH_ORCO) {
- if (!me_orco_cloth) {
- me_orco_cloth = create_orco_mesh(ob, ob->data, NULL, CD_CLOTH_ORCO);
+ if (!mesh_orco_cloth) {
+ mesh_orco_cloth = create_orco_mesh(ob, mesh_input, NULL, CD_CLOTH_ORCO);
}
nextmask.vmask &= ~CD_MASK_CLOTH_ORCO;
nextmask.vmask |= CD_MASK_ORIGINDEX;
nextmask.emask |= CD_MASK_ORIGINDEX;
nextmask.pmask |= CD_MASK_ORIGINDEX;
- mesh_set_only_copy(me_orco_cloth, &nextmask);
+ mesh_set_only_copy(mesh_orco_cloth, &nextmask);
- me_next = modwrap_applyModifier(md, &mectx_orco, me_orco_cloth);
- ASSERT_IS_VALID_MESH(me_next);
+ mesh_next = modwrap_applyModifier(md, &mectx_orco, mesh_orco_cloth);
+ ASSERT_IS_VALID_MESH(mesh_next);
- if (me_next) {
+ if (mesh_next) {
/* if the modifier returned a new mesh, release the old one */
- if (me_orco_cloth && me_orco_cloth != me_next) {
- BLI_assert(me_orco != ob->data);
- BKE_id_free(NULL, me_orco_cloth);
+ if (mesh_orco_cloth != mesh_next) {
+ BLI_assert(mesh_orco != mesh_input);
+ BKE_id_free(NULL, mesh_orco_cloth);
}
- me_orco_cloth = me_next;
+ mesh_orco_cloth = mesh_next;
}
}
@@ -1531,7 +1422,7 @@ static void mesh_calc_modifiers(
append_mask.lmask |= CD_MASK_PREVIEW_MLOOPCOL;
}
- me->runtime.deformed_only = false;
+ mesh_final->runtime.deformed_only = false;
}
isPrevDeform = (mti->type == eModifierTypeType_OnlyDeform);
@@ -1545,112 +1436,49 @@ static void mesh_calc_modifiers(
}
}
+ BLI_linklist_free((LinkNode *)datamasks, NULL);
+
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
- * Mesh then we need to build one.
- */
- if (me) {
- *r_final = me;
-
- if (deformedVerts) {
- BKE_mesh_apply_vert_coords(*r_final, deformedVerts);
- }
+ * Mesh then we need to build one. */
+ if (mesh_final == NULL) {
+ mesh_final = BKE_mesh_copy_for_eval(mesh_input, true);
}
- else {
- *r_final = BKE_mesh_copy_for_eval(ob->data, true);
-
- if (build_shapekey_layers) {
- add_shapekey_layers(*r_final, ob->data, ob);
- }
-
- if (deformedVerts) {
- BKE_mesh_apply_vert_coords(*r_final, deformedVerts);
- }
+ if (deformed_verts) {
+ BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
+ MEM_freeN(deformed_verts);
+ deformed_verts = NULL;
}
- /* add an orco layer if needed */
+ /* Add orco coordinates to final and deformed mesh if requested. */
if (dataMask->vmask & CD_MASK_ORCO) {
- add_orco_mesh(ob, NULL, *r_final, me_orco, CD_ORCO);
+ add_orco_mesh(ob, NULL, mesh_final, mesh_orco, CD_ORCO);
- if (r_deform && *r_deform)
- add_orco_mesh(ob, NULL, *r_deform, NULL, CD_ORCO);
+ if (mesh_deform)
+ add_orco_mesh(ob, NULL, mesh_deform, NULL, CD_ORCO);
}
- if (do_loop_normals) {
- /* Compute loop normals (note: will compute poly and vert normals as well, if needed!) */
- BKE_mesh_calc_normals_split(*r_final);
- BKE_mesh_tessface_clear(*r_final);
+ if (mesh_orco) {
+ BKE_id_free(NULL, mesh_orco);
}
-
- if (sculpt_dyntopo == false) {
- /* watch this! after 2.75a we move to from tessface to looptri (by default) */
- if (dataMask->fmask & CD_MASK_MFACE) {
- BKE_mesh_tessface_ensure(*r_final);
- }
-
- /* without this, drawing ngon tri's faces will show ugly tessellated face
- * normals and will also have to calculate normals on the fly, try avoid
- * this where possible since calculating polygon normals isn't fast,
- * note that this isn't a problem for subsurf (only quads) or editmode
- * which deals with drawing differently.
- *
- * Only calc vertex normals if they are flagged as dirty.
- * If using loop normals, poly nors have already been computed.
- */
- if (!do_loop_normals) {
- BKE_mesh_ensure_normals_for_display(*r_final);
- }
+ if (mesh_orco_cloth) {
+ BKE_id_free(NULL, mesh_orco_cloth);
}
- /* Some modifiers, like datatransfer, may generate those data as temp layer, we do not want to keep them,
- * as they are used by display code when available (i.e. even if autosmooth is disabled). */
- if (!do_loop_normals && CustomData_has_layer(&(*r_final)->ldata, CD_NORMAL)) {
- CustomData_free_layers(&(*r_final)->ldata, CD_NORMAL, (*r_final)->totloop);
- }
+ /* Compute normals. */
+ mesh_calc_modifier_final_normals(mesh_input, dataMask, sculpt_dyntopo, mesh_final);
- if (me_orco) {
- BKE_id_free(NULL, me_orco);
- }
- if (me_orco_cloth) {
- BKE_id_free(NULL, me_orco_cloth);
+ /* Return final mesh */
+ *r_final = mesh_final;
+ if (r_deform) {
+ *r_deform = mesh_deform;
}
-
- if (deformedVerts && deformedVerts != inputVertexCos)
- MEM_freeN(deformedVerts);
-
- BLI_linklist_free((LinkNode *)datamasks, NULL);
}
-#ifdef USE_DERIVEDMESH
-static void mesh_calc_modifiers_dm(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
- int useDeform,
- const bool need_mapping, const CustomData_MeshMasks *dataMask,
- const int index, const bool useCache, const bool build_shapekey_layers,
- /* return args */
- DerivedMesh **r_deformdm, DerivedMesh **r_finaldm)
-{
- Mesh *deform_mesh = NULL, *final_mesh = NULL;
-
- mesh_calc_modifiers(
- depsgraph, scene, ob, inputVertexCos, useDeform,
- need_mapping, dataMask, index, useCache, build_shapekey_layers,
- (r_deformdm ? &deform_mesh : NULL), &final_mesh);
-
- if (deform_mesh) {
- *r_deformdm = CDDM_from_mesh_ex(deform_mesh, CD_DUPLICATE, &CD_MASK_MESH);
- BKE_id_free(NULL, deform_mesh);
- }
-
- *r_finaldm = CDDM_from_mesh_ex(final_mesh, CD_DUPLICATE, &CD_MASK_MESH);
- BKE_id_free(NULL, final_mesh);
-}
-#endif
-
float (*editbmesh_get_vertex_cos(BMEditMesh *em, int *r_numVerts))[3]
{
BMIter iter;
@@ -1686,220 +1514,288 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, bool has_prev
return true;
}
+static void editbmesh_calc_modifier_final_normals(
+ const Mesh *mesh_input,
+ const CustomData_MeshMasks *dataMask,
+ Mesh *mesh_final)
+{
+ const bool do_loop_normals = ((mesh_input->flag & ME_AUTOSMOOTH) != 0 ||
+ (dataMask->lmask & CD_MASK_NORMAL) != 0);
+ /* Some modifiers may need this info from their target (other) object, simpler to generate it here as well. */
+ const bool do_poly_normals = ((dataMask->pmask & CD_MASK_NORMAL) != 0);
+
+ if (do_loop_normals) {
+ /* In case we also need poly normals, add the layer here, then BKE_mesh_calc_normals_split() will fill it. */
+ if (do_poly_normals) {
+ if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) {
+ CustomData_add_layer(&mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly);
+ }
+ }
+ /* Compute loop normals */
+ BKE_mesh_calc_normals_split(mesh_final);
+ BKE_mesh_tessface_clear(mesh_final);
+ }
+
+ /* BMESH_ONLY, ensure tessface's used for drawing,
+ * but don't recalculate if the last modifier in the stack gives us tessfaces
+ * check if the derived meshes are DM_TYPE_EDITBMESH before calling, this isn't essential
+ * but quiets annoying error messages since tessfaces wont be created. */
+ if (dataMask->fmask & CD_MASK_MFACE) {
+ if (mesh_final->edit_mesh == NULL) {
+ BKE_mesh_tessface_ensure(mesh_final);
+ }
+ }
+
+ /* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */
+ if (!do_loop_normals) {
+ BKE_mesh_ensure_normals_for_display(mesh_final);
+
+ /* Some modifiers, like datatransfer, may generate those data, we do not want to keep them,
+ * as they are used by display code when available (i.e. even if autosmooth is disabled). */
+ if (CustomData_has_layer(&mesh_final->ldata, CD_NORMAL)) {
+ CustomData_free_layers(&mesh_final->ldata, CD_NORMAL, mesh_final->totloop);
+ }
+ }
+}
+
static void editbmesh_calc_modifiers(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob,
- BMEditMesh *em, const CustomData_MeshMasks *dataMask,
+ struct Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob,
+ BMEditMesh *em_input,
+ const CustomData_MeshMasks *dataMask,
/* return args */
- Mesh **r_cage, Mesh **r_final)
+ Mesh **r_cage,
+ Mesh **r_final)
{
- ModifierData *md;
- float (*deformedVerts)[3] = NULL;
- CustomData_MeshMasks mask = {0}, append_mask = CD_MASK_BAREMESH;
- int i, numVerts = 0, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
- CDMaskLink *datamasks, *curr;
+ /* Input and final mesh. Final mesh is only created the moment the first
+ * constructive modifier is executed, or a deform modifier needs normals
+ * or certain data layers. */
+ Mesh *mesh_input = ob->data;
+ Mesh *mesh_final = NULL;
+ Mesh *mesh_cage = NULL;
+
+ /* Deformed vertex locations array. Deform only modifier need this type of
+ * float array rather than MVert*. Tracked along with mesh_final as an
+ * optimization to avoid copying coordinates back and forth if there are
+ * multiple sequential deform only modifiers. */
+ float (*deformed_verts)[3] = NULL;
+ int num_deformed_verts = 0;
+ bool isPrevDeform = false;
+
+ /* Mesh with constructive modifiers but no deformation applied. Tracked
+ * along with final mesh if undeformed / orco coordinates are requested
+ * for texturing. */
+ Mesh *mesh_orco = NULL;
+
+ /* Modifier evaluation modes. */
const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
const bool do_init_statvis = false; /* FIXME: use V3D_OVERLAY_EDIT_STATVIS. */
- VirtualModifierData virtualModifierData;
- /* TODO(sybren): do we really need multiple objects, or shall we change the flags where needed? */
- const ModifierEvalContext mectx = {depsgraph, ob, 0};
+ /* Modifier evaluation contexts for different types of modifiers. */
+ const ModifierEvalContext mectx = {depsgraph, ob, MOD_APPLY_USECACHE};
const ModifierEvalContext mectx_orco = {depsgraph, ob, MOD_APPLY_ORCO};
- const ModifierEvalContext mectx_cache = {depsgraph, ob, MOD_APPLY_USECACHE};
-
- const bool do_loop_normals = ((((Mesh *)(ob->data))->flag & ME_AUTOSMOOTH) != 0 ||
- (dataMask->lmask & CD_MASK_NORMAL) != 0);
-
- modifiers_clearErrors(ob);
+ /* Evaluate modifiers up to certain index to get the mesh cage. */
+ int cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
if (r_cage && cageIndex == -1) {
- *r_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, dataMask, NULL);
- mesh_copy_autosmooth(*r_cage, ob->data);
+ mesh_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(em_input, dataMask, NULL);
+ mesh_copy_autosmooth(mesh_cage, mesh_input);
}
- md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
-
- /* copied from mesh_calc_modifiers */
- datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, NULL, NULL);
+ /* Get effective list of modifiers to execute. Some effects like shape keys
+ * are added as virtual modifiers before the user created modifiers. */
+ VirtualModifierData virtualModifierData;
+ ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
- curr = datamasks;
+ /* Compute accumulated datamasks needed by each modifier. It helps to do
+ * this fine grained so that for example vertex groups are preserved up to
+ * an armature modifier, but not through a following subsurf modifier where
+ * subdividing them is expensive. */
+ CDMaskLink *datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, NULL, NULL);
+ CDMaskLink *md_datamask = datamasks;
+ CustomData_MeshMasks append_mask = CD_MASK_BAREMESH;
- Mesh *me = NULL;
- Mesh *me_orco = NULL;
+ /* Clear errors before evaluation. */
+ modifiers_clearErrors(ob);
- for (i = 0; md; i++, md = md->next, curr = curr->next) {
+ for (int i = 0; md; i++, md = md->next, md_datamask = md_datamask->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- memset(&mask, 0, sizeof(mask));
- if (!editbmesh_modifier_is_enabled(scene, md, me != NULL)) {
+ if (!editbmesh_modifier_is_enabled(scene, md, mesh_final != NULL)) {
continue;
}
- /* add an orco layer if needed by this modifier */
- if (me && mti->requiredDataMask) {
+ /* Add an orco layer if needed by this modifier. */
+ if (mesh_final && mti->requiredDataMask) {
+ CustomData_MeshMasks mask = {0};
mti->requiredDataMask(ob, md, &mask);
if (mask.vmask & CD_MASK_ORCO) {
- add_orco_mesh(ob, em, me, me_orco, CD_ORCO);
+ add_orco_mesh(ob, em_input, mesh_final, mesh_orco, CD_ORCO);
}
}
/* How to apply modifier depends on (a) what we already have as
- * a result of previous modifiers (could be a DerivedMesh or just
- * deformed vertices) and (b) what type the modifier is.
- */
-
+ * a result of previous modifiers (could be a mesh or just
+ * deformed vertices) and (b) what type the modifier is. */
if (mti->type == eModifierTypeType_OnlyDeform) {
/* No existing verts to deform, need to build them. */
- if (!deformedVerts) {
- if (me) {
+ if (!deformed_verts) {
+ if (mesh_final) {
/* Deforming a derived mesh, read the vertex locations
* out of the mesh and deform them. Once done with this
- * run of deformers verts will be written back.
- */
- deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
+ * run of deformers verts will be written back. */
+ deformed_verts = BKE_mesh_vertexCos_get(mesh_final, &num_deformed_verts);
}
else {
- deformedVerts = editbmesh_get_vertex_cos(em, &numVerts);
+ deformed_verts = editbmesh_get_vertex_cos(em_input, &num_deformed_verts);
}
}
+ else if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
+ if (mesh_final == NULL) {
+ mesh_final = BKE_mesh_from_bmesh_for_eval_nomain(em_input->bm, NULL);
+ ASSERT_IS_VALID_MESH(mesh_final);
+ mesh_copy_autosmooth(mesh_final, mesh_input);
+ }
+ BLI_assert(deformed_verts != NULL);
+ BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
+ }
if (mti->deformVertsEM)
- modwrap_deformVertsEM(md, &mectx, em, me, deformedVerts, numVerts);
+ modwrap_deformVertsEM(md, &mectx, em_input, mesh_final, deformed_verts, num_deformed_verts);
else
- modwrap_deformVerts(md, &mectx, me, deformedVerts, numVerts);
+ modwrap_deformVerts(md, &mectx, mesh_final, deformed_verts, num_deformed_verts);
}
else {
- Mesh *me_next;
-
/* apply vertex coordinates or build a DerivedMesh as necessary */
- if (me) {
- if (deformedVerts) {
- Mesh *me_temp = BKE_mesh_copy_for_eval(me, false);
-
- if (!(r_cage && me == *r_cage)) {
- BKE_id_free(NULL, me);
+ if (mesh_final) {
+ if (deformed_verts) {
+ Mesh *mesh_tmp = BKE_mesh_copy_for_eval(mesh_final, false);
+ if (mesh_final != mesh_cage) {
+ BKE_id_free(NULL, mesh_final);
}
- me = me_temp;
- BKE_mesh_apply_vert_coords(me, deformedVerts);
+ mesh_final = mesh_tmp;
+ BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
}
- else if (r_cage && me == *r_cage) {
+ else if (mesh_final == mesh_cage) {
/* 'me' may be changed by this modifier, so we need to copy it. */
- me = BKE_mesh_copy_for_eval(me, false);
+ mesh_final = BKE_mesh_copy_for_eval(mesh_final, false);
}
}
else {
- me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
- ASSERT_IS_VALID_MESH(me);
+ mesh_final = BKE_mesh_from_bmesh_for_eval_nomain(em_input->bm, NULL);
+ ASSERT_IS_VALID_MESH(mesh_final);
- mesh_copy_autosmooth(me, ob->data);
+ mesh_copy_autosmooth(mesh_final, mesh_input);
- if (deformedVerts) {
- BKE_mesh_apply_vert_coords(me, deformedVerts);
+ if (deformed_verts) {
+ BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
}
}
/* create an orco derivedmesh in parallel */
- mask = curr->mask;
+ CustomData_MeshMasks mask = md_datamask->mask;
if (mask.vmask & CD_MASK_ORCO) {
- if (!me_orco) {
- me_orco = create_orco_mesh(ob, ob->data, em, CD_ORCO);
+ if (!mesh_orco) {
+ mesh_orco = create_orco_mesh(ob, mesh_input, em_input, CD_ORCO);
}
mask.vmask &= ~CD_MASK_ORCO;
mask.vmask |= CD_MASK_ORIGINDEX;
mask.emask |= CD_MASK_ORIGINDEX;
mask.pmask |= CD_MASK_ORIGINDEX;
- mesh_set_only_copy(me_orco, &mask);
+ mesh_set_only_copy(mesh_orco, &mask);
- me_next = modwrap_applyModifier(md, &mectx_orco, me_orco);
- ASSERT_IS_VALID_MESH(me_next);
+ Mesh *mesh_next = modwrap_applyModifier(md, &mectx_orco, mesh_orco);
+ ASSERT_IS_VALID_MESH(mesh_next);
- if (me_next) {
+ if (mesh_next) {
/* if the modifier returned a new dm, release the old one */
- if (me_orco && me_orco != me_next) {
- BKE_id_free(NULL, me_orco);
+ if (mesh_orco && mesh_orco != mesh_next) {
+ BKE_id_free(NULL, mesh_orco);
}
- me_orco = me_next;
+ mesh_orco = mesh_next;
}
}
/* set the DerivedMesh to only copy needed data */
CustomData_MeshMasks_update(&mask, &append_mask);
- mask = curr->mask; /* CD_MASK_ORCO may have been cleared above */ /* XXX WHAT? ovewrites mask ??? */
+ mask = md_datamask->mask; /* CD_MASK_ORCO may have been cleared above */ /* XXX WHAT? ovewrites mask ??? */
mask.vmask |= CD_MASK_ORIGINDEX;
mask.emask |= CD_MASK_ORIGINDEX;
mask.pmask |= CD_MASK_ORIGINDEX;
- mesh_set_only_copy(me, &mask);
+ mesh_set_only_copy(mesh_final, &mask);
if (mask.lmask & CD_MASK_ORIGSPACE_MLOOP) {
- if (!CustomData_has_layer(&me->ldata, CD_ORIGSPACE_MLOOP)) {
- CustomData_add_layer(&me->ldata, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL, me->totloop);
- mesh_init_origspace(me);
+ if (!CustomData_has_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP)) {
+ CustomData_add_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL, mesh_final->totloop);
+ mesh_init_origspace(mesh_final);
}
}
- me_next = modwrap_applyModifier(md, &mectx_cache, me);
- ASSERT_IS_VALID_MESH(me_next);
+ Mesh *mesh_next = modwrap_applyModifier(md, &mectx, mesh_final);
+ ASSERT_IS_VALID_MESH(mesh_next);
- if (me_next) {
- if (me && me != me_next) {
- BKE_id_free(NULL, me);
+ if (mesh_next) {
+ if (mesh_final && mesh_final != mesh_next) {
+ BKE_id_free(NULL, mesh_final);
}
- me = me_next;
+ mesh_final = mesh_next;
- if (deformedVerts) {
- MEM_freeN(deformedVerts);
- deformedVerts = NULL;
+ if (deformed_verts) {
+ MEM_freeN(deformed_verts);
+ deformed_verts = NULL;
}
- mesh_copy_autosmooth(me, ob->data);
+ mesh_copy_autosmooth(mesh_final, mesh_input);
}
- me->runtime.deformed_only = false;
+ mesh_final->runtime.deformed_only = false;
}
if (r_cage && i == cageIndex) {
- if (me && deformedVerts) {
- *r_cage = BKE_mesh_copy_for_eval(me, false);
- BKE_mesh_apply_vert_coords(*r_cage, deformedVerts);
+ if (mesh_final && deformed_verts) {
+ mesh_cage = BKE_mesh_copy_for_eval(mesh_final, false);
+ BKE_mesh_apply_vert_coords(mesh_cage, deformed_verts);
}
- else if (me) {
- *r_cage = me;
+ else if (mesh_final) {
+ mesh_cage = mesh_final;
}
else {
- Mesh *me_orig = ob->data;
+ Mesh *me_orig = mesh_input;
if (me_orig->id.tag & LIB_TAG_COPIED_ON_WRITE) {
BKE_mesh_runtime_ensure_edit_data(me_orig);
- me_orig->runtime.edit_data->vertexCos = MEM_dupallocN(deformedVerts);
+ me_orig->runtime.edit_data->vertexCos = MEM_dupallocN(deformed_verts);
}
- *r_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(
- em, &mask,
- deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
- mesh_copy_autosmooth(*r_cage, ob->data);
+ mesh_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(
+ em_input, dataMask,
+ deformed_verts ? MEM_dupallocN(deformed_verts) : NULL);
+ mesh_copy_autosmooth(mesh_cage, mesh_input);
}
}
+
+ isPrevDeform = (mti->type == eModifierTypeType_OnlyDeform);
}
BLI_linklist_free((LinkNode *)datamasks, NULL);
/* Yay, we are done. If we have a DerivedMesh and deformed vertices need
* to apply these back onto the DerivedMesh. If we have no DerivedMesh
- * then we need to build one.
- */
- if (me && deformedVerts) {
- *r_final = BKE_mesh_copy_for_eval(me, false);
-
- if (!(r_cage && me == *r_cage)) {
- BKE_id_free(NULL, me);
+ * then we need to build one. */
+ if (mesh_final) {
+ if (deformed_verts) {
+ Mesh *mesh_tmp = BKE_mesh_copy_for_eval(mesh_final, false);
+ if (mesh_final != mesh_cage) {
+ BKE_id_free(NULL, mesh_final);
+ }
+ mesh_final = mesh_tmp;
+ BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
}
- BKE_mesh_apply_vert_coords(*r_final, deformedVerts);
- }
- else if (me) {
- *r_final = me;
}
- else if (!deformedVerts && r_cage && *r_cage) {
+ else if (!deformed_verts && mesh_cage) {
/* cage should already have up to date normals */
- *r_final = *r_cage;
+ mesh_final = mesh_cage;
/* In this case, we should never have weight-modifying modifiers in stack... */
if (do_init_statvis) {
@@ -1908,10 +1804,10 @@ static void editbmesh_calc_modifiers(
}
else {
/* this is just a copy of the editmesh, no need to calc normals */
- *r_final = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, dataMask, deformedVerts);
- deformedVerts = NULL;
+ mesh_final = BKE_mesh_from_editmesh_with_coords_thin_wrap(em_input, dataMask, deformed_verts);
+ deformed_verts = NULL;
- mesh_copy_autosmooth(*r_final, ob->data);
+ mesh_copy_autosmooth(mesh_final, mesh_input);
/* In this case, we should never have weight-modifying modifiers in stack... */
if (do_init_statvis) {
@@ -1919,62 +1815,29 @@ static void editbmesh_calc_modifiers(
}
}
- if (do_loop_normals) {
- /* Compute loop normals */
- BKE_mesh_calc_normals_split(*r_final);
- BKE_mesh_tessface_clear(*r_final);
- if (r_cage && *r_cage && (*r_cage != *r_final)) {
- BKE_mesh_calc_normals_split(*r_cage);
- BKE_mesh_tessface_clear(*r_cage);
- }
+ if (deformed_verts) {
+ MEM_freeN(deformed_verts);
}
- /* BMESH_ONLY, ensure tessface's used for drawing,
- * but don't recalculate if the last modifier in the stack gives us tessfaces
- * check if the derived meshes are DM_TYPE_EDITBMESH before calling, this isn't essential
- * but quiets annoying error messages since tessfaces wont be created. */
- if (dataMask->fmask & CD_MASK_MFACE) {
- if ((*r_final)->edit_mesh == NULL) {
- BKE_mesh_tessface_ensure(*r_final);
- }
- if (r_cage && *r_cage) {
- if ((*r_cage)->edit_mesh == NULL) {
- if (*r_cage != *r_final) {
- BKE_mesh_tessface_ensure(*r_cage);
- }
- }
- }
+ /* Add orco coordinates to final and deformed mesh if requested. */
+ if (dataMask->vmask & CD_MASK_ORCO) {
+ add_orco_mesh(ob, em_input, mesh_final, mesh_orco, CD_ORCO);
}
- /* --- */
- /* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */
- if (!do_loop_normals) {
- BKE_mesh_ensure_normals_for_display(*r_final);
-
- if (r_cage && *r_cage && (*r_cage != *r_final)) {
- BKE_mesh_ensure_normals_for_display(*r_cage);
- }
-
- /* Some modifiers, like datatransfer, may generate those data, we do not want to keep them,
- * as they are used by display code when available (i.e. even if autosmooth is disabled). */
- if (CustomData_has_layer(&(*r_final)->ldata, CD_NORMAL)) {
- CustomData_free_layers(&(*r_final)->ldata, CD_NORMAL, (*r_final)->totloop);
- }
- if (r_cage && CustomData_has_layer(&(*r_cage)->ldata, CD_NORMAL)) {
- CustomData_free_layers(&(*r_cage)->ldata, CD_NORMAL, (*r_cage)->totloop);
- }
+ if (mesh_orco) {
+ BKE_id_free(NULL, mesh_orco);
}
- /* add an orco layer if needed */
- if (dataMask->vmask & CD_MASK_ORCO)
- add_orco_mesh(ob, em, *r_final, me_orco, CD_ORCO);
-
- if (me_orco) {
- BKE_id_free(NULL, me_orco);
+ /* Compute normals. */
+ editbmesh_calc_modifier_final_normals(mesh_input, dataMask, mesh_final);
+ if (mesh_cage && (mesh_cage != mesh_final)) {
+ editbmesh_calc_modifier_final_normals(mesh_input, dataMask, mesh_cage);
}
- if (deformedVerts) {
- MEM_freeN(deformedVerts);
+ /* Return final mesh. */
+ *r_final = mesh_final;
+ if (r_cage) {
+ *r_cage = mesh_cage;
}
}
@@ -2039,7 +1902,7 @@ static void mesh_runtime_check_normals_valid(const Mesh *mesh)
static void mesh_build_data(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask,
- const bool build_shapekey_layers, const bool need_mapping)
+ const bool need_mapping)
{
BLI_assert(ob->type == OB_MESH);
@@ -2060,15 +1923,9 @@ static void mesh_build_data(
#endif
mesh_calc_modifiers(
- depsgraph, scene, ob, NULL, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
+ depsgraph, scene, ob, 1, need_mapping, dataMask, -1, true,
&ob->runtime.mesh_deform_eval, &ob->runtime.mesh_eval);
-#ifdef USE_DERIVEDMESH
- /* TODO(campbell): remove these copies, they are expected in various places over the code. */
- ob->derivedDeform = CDDM_from_mesh_ex(ob->runtime.mesh_deform_eval, CD_REFERENCE, &CD_MASK_MESH);
- ob->derivedFinal = CDDM_from_mesh_ex(ob->runtime.mesh_eval, CD_REFERENCE, &CD_MASK_MESH);
-#endif
-
BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval);
/* Only copy texspace from orig mesh if some modifier (hint: smoke sim, see T58492)
* did not re-enable that flag (which always get disabled for eval mesh as a start). */
@@ -2078,10 +1935,6 @@ static void mesh_build_data(
mesh_finalize_eval(ob);
-#ifdef USE_DERIVEDMESH
- ob->derivedFinal->needsFree = 0;
- ob->derivedDeform->needsFree = 0;
-#endif
ob->runtime.last_data_mask = *dataMask;
ob->runtime.last_need_mapping = need_mapping;
@@ -2166,7 +2019,7 @@ static void object_get_datamask(const Depsgraph *depsgraph, Object *ob, CustomDa
void makeDerivedMesh(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, BMEditMesh *em,
- const CustomData_MeshMasks *dataMask, const bool build_shapekey_layers)
+ const CustomData_MeshMasks *dataMask)
{
bool need_mapping;
CustomData_MeshMasks cddata_masks = *dataMask;
@@ -2176,35 +2029,12 @@ void makeDerivedMesh(
editbmesh_build_data(depsgraph, scene, ob, em, &cddata_masks);
}
else {
- mesh_build_data(depsgraph, scene, ob, &cddata_masks, build_shapekey_layers, need_mapping);
+ mesh_build_data(depsgraph, scene, ob, &cddata_masks, need_mapping);
}
}
/***/
-#ifdef USE_DERIVEDMESH
-/* Deprecated DM, use: 'mesh_get_eval_final'. */
-DerivedMesh *mesh_get_derived_final(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
-{
- /* if there's no derived mesh or the last data mask used doesn't include
- * the data we need, rebuild the derived mesh
- */
- bool need_mapping;
- CustomData_MeshMasks cddata_masks = *dataMask;
- object_get_datamask(depsgraph, ob, &cddata_masks, &need_mapping);
-
- if (!ob->derivedFinal ||
- !CustomData_MeshMasks_are_matching(&(ob->lastDataMask), &cddata_masks) ||
- (need_mapping != ob->lastNeedMapping))
- {
- mesh_build_data(depsgraph, scene, ob, cddata_masks, false, need_mapping);
- }
-
- if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); }
- return ob->derivedFinal;
-}
-#endif
Mesh *mesh_get_eval_final(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
{
/* This function isn't thread-safe and can't be used during evaluation. */
@@ -2227,35 +2057,13 @@ Mesh *mesh_get_eval_final(struct Depsgraph *depsgraph, Scene *scene, Object *ob,
{
CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask);
mesh_build_data(depsgraph, scene, ob, &cddata_masks,
- false, need_mapping || ob->runtime.last_need_mapping);
+ need_mapping || ob->runtime.last_need_mapping);
}
if (ob->runtime.mesh_eval) { BLI_assert(!(ob->runtime.mesh_eval->runtime.cd_dirty_vert & CD_MASK_NORMAL)); }
return ob->runtime.mesh_eval;
}
-#ifdef USE_DERIVEDMESH
-/* Deprecated DM, use: 'mesh_get_eval_deform' instead. */
-DerivedMesh *mesh_get_derived_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
-{
- /* if there's no derived mesh or the last data mask used doesn't include
- * the data we need, rebuild the derived mesh
- */
- bool need_mapping;
-
- CustomData_MeshMasks cddata_masks = *dataMask;
- object_get_datamask(depsgraph, ob, &cddata_masks, &need_mapping);
-
- if (!ob->derivedDeform ||
- !CustomData_MeshMasks_are_matching(&(ob->lastDataMask), &cddata_masks) ||
- (need_mapping != ob->lastNeedMapping))
- {
- mesh_build_data(depsgraph, scene, ob, cddata_masks, false, need_mapping);
- }
-
- return ob->derivedDeform;
-}
-#endif
Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
{
/* This function isn't thread-safe and can't be used during evaluation. */
@@ -2279,52 +2087,24 @@ Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob
{
CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask);
mesh_build_data(depsgraph, scene, ob, &cddata_masks,
- false, need_mapping || ob->runtime.last_need_mapping);
+ need_mapping || ob->runtime.last_need_mapping);
}
return ob->runtime.mesh_deform_eval;
}
-#ifdef USE_DERIVEDMESH
-/* Deprecated, use `mesh_create_eval_final_render` instead. */
-DerivedMesh *mesh_create_derived_render(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
-{
- DerivedMesh *final;
-
- mesh_calc_modifiers_dm(
- depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false,
- NULL, &final);
-
- return final;
-}
-#endif
Mesh *mesh_create_eval_final_render(Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
{
Mesh *final;
mesh_calc_modifiers(
- depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false,
+ depsgraph, scene, ob, 1, false, dataMask, -1, false,
NULL, &final);
return final;
}
-#ifdef USE_DERIVEDMESH
-/* Deprecated, use `mesh_create_eval_final_index_render` instead. */
-DerivedMesh *mesh_create_derived_index_render(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask, int index)
-{
- DerivedMesh *final;
-
- mesh_calc_modifiers_dm(
- depsgraph, scene, ob, NULL, 1, false, dataMask, index, false, false,
- NULL, &final);
-
- return final;
-}
-#endif
Mesh *mesh_create_eval_final_index_render(
Depsgraph *depsgraph, Scene *scene,
Object *ob, const CustomData_MeshMasks *dataMask, int index)
@@ -2332,35 +2112,11 @@ Mesh *mesh_create_eval_final_index_render(
Mesh *final;
mesh_calc_modifiers(
- depsgraph, scene, ob, NULL, 1, false, dataMask, index, false, false,
- NULL, &final);
-
- return final;
-}
-
-#ifdef USE_DERIVEDMESH
-/* Deprecated, use `mesh_create_eval_final_view` instead. */
-DerivedMesh *mesh_create_derived_view(
- struct Depsgraph *depsgraph, Scene *scene,
- Object *ob, const CustomData_MeshMasks *dataMask)
-{
- DerivedMesh *final;
-
- /* XXX hack
- * psys modifier updates particle state when called during dupli-list generation,
- * which can lead to wrong transforms. This disables particle system modifier execution.
- */
- ob->transflag |= OB_NO_PSYS_UPDATE;
-
- mesh_calc_modifiers_dm(
- depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false,
+ depsgraph, scene, ob, 1, false, dataMask, index, false,
NULL, &final);
- ob->transflag &= ~OB_NO_PSYS_UPDATE;
-
return final;
}
-#endif
Mesh *mesh_create_eval_final_view(
Depsgraph *depsgraph, Scene *scene,
@@ -2375,7 +2131,7 @@ Mesh *mesh_create_eval_final_view(
ob->transflag |= OB_NO_PSYS_UPDATE;
mesh_calc_modifiers(
- depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false,
+ depsgraph, scene, ob, 1, false, dataMask, -1, false,
NULL, &final);
ob->transflag &= ~OB_NO_PSYS_UPDATE;
@@ -2385,12 +2141,12 @@ Mesh *mesh_create_eval_final_view(
Mesh *mesh_create_eval_no_deform(
Depsgraph *depsgraph, Scene *scene, Object *ob,
- float (*vertCos)[3], const CustomData_MeshMasks *dataMask)
+ const CustomData_MeshMasks *dataMask)
{
Mesh *final;
mesh_calc_modifiers(
- depsgraph, scene, ob, vertCos, 0, false, dataMask, -1, false, false,
+ depsgraph, scene, ob, 0, false, dataMask, -1, false,
NULL, &final);
return final;
@@ -2398,12 +2154,12 @@ Mesh *mesh_create_eval_no_deform(
Mesh *mesh_create_eval_no_deform_render(
Depsgraph *depsgraph, Scene *scene, Object *ob,
- float (*vertCos)[3], const CustomData_MeshMasks *dataMask)
+ const CustomData_MeshMasks *dataMask)
{
Mesh *final;
mesh_calc_modifiers(
- depsgraph, scene, ob, vertCos, 0, false, dataMask, -1, false, false,
+ depsgraph, scene, ob, 0, false, dataMask, -1, false,
NULL, &final);
return final;
@@ -2468,66 +2224,6 @@ Mesh *editbmesh_get_eval_cage_from_orig(
/***/
-/* UNUSED */
-#if 0
-
-/* ********* For those who don't grasp derived stuff! (ton) :) *************** */
-
-static void make_vertexcosnos__mapFunc(void *userData, int index, const float co[3],
- const float no_f[3], const short no_s[3])
-{
- DMCoNo *co_no = &((DMCoNo *)userData)[index];
-
- /* check if we've been here before (normal should not be 0) */
- if (!is_zero_v3(co_no->no)) {
- return;
- }
-
- copy_v3_v3(co_no->co, co);
- if (no_f) {
- copy_v3_v3(co_no->no, no_f);
- }
- else {
- normal_short_to_float_v3(co_no->no, no_s);
- }
-}
-
-/* always returns original amount me->totvert of vertices and normals, but fully deformed and subsurfered */
-/* this is needed for all code using vertexgroups (no subsurf support) */
-/* it stores the normals as floats, but they can still be scaled as shorts (32767 = unit) */
-/* in use now by vertex/weight paint and particle generating */
-
-DMCoNo *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
-{
- Mesh *me = ob->data;
- DerivedMesh *dm;
- DMCoNo *vertexcosnos;
-
- /* lets prevent crashing... */
- if (ob->type != OB_MESH || me->totvert == 0)
- return NULL;
-
- dm = mesh_get_derived_final(scene, ob, &CD_MASK_BAREMESH_ORIGINDEX);
-
- if (dm->foreachMappedVert) {
- vertexcosnos = MEM_calloc_arrayN(me->totvert, sizeof(DMCoNo), "vertexcosnos map");
- dm->foreachMappedVert(dm, make_vertexcosnos__mapFunc, vertexcosnos);
- }
- else {
- DMCoNo *v_co_no = vertexcosnos = MEM_malloc_arrayN(me->totvert, sizeof(DMCoNo), "vertexcosnos map");
- int a;
- for (a = 0; a < me->totvert; a++, v_co_no++) {
- dm->getVertCo(dm, a, v_co_no->co);
- dm->getVertNo(dm, a, v_co_no->no);
- }
- }
-
- dm->release(dm);
- return vertexcosnos;
-}
-
-#endif
-
/* same as above but for vert coords */
typedef struct {
float (*vertexcos)[3];
@@ -2567,19 +2263,6 @@ void mesh_get_mapped_verts_coords(Mesh *me_eval, float (*r_cos)[3], const int to
}
}
-void DM_add_named_tangent_layer_for_uv(
- CustomData *uv_data, CustomData *tan_data, int numLoopData,
- const char *layer_name)
-{
- if (CustomData_get_named_layer_index(tan_data, CD_TANGENT, layer_name) == -1 &&
- CustomData_get_named_layer_index(uv_data, CD_MLOOPUV, layer_name) != -1)
- {
- CustomData_add_layer_named(
- tan_data, CD_TANGENT, CD_CALLOC, NULL,
- numLoopData, layer_name);
- }
-}
-
void DM_calc_loop_tangents(
DerivedMesh *dm, bool calc_active_tangent,
const char (*tangent_names)[MAX_NAME], int tangent_names_len)
@@ -2600,77 +2283,6 @@ void DM_calc_loop_tangents(
&dm->tangent_mask);
}
-void DM_init_origspace(DerivedMesh *dm)
-{
- const float default_osf[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
-
- OrigSpaceLoop *lof_array = CustomData_get_layer(&dm->loopData, CD_ORIGSPACE_MLOOP);
- const int numpoly = dm->getNumPolys(dm);
- // const int numloop = dm->getNumLoops(dm);
- MVert *mv = dm->getVertArray(dm);
- MLoop *ml = dm->getLoopArray(dm);
- MPoly *mp = dm->getPolyArray(dm);
- int i, j, k;
-
- float (*vcos_2d)[2] = NULL;
- BLI_array_staticdeclare(vcos_2d, 64);
-
- for (i = 0; i < numpoly; i++, mp++) {
- OrigSpaceLoop *lof = lof_array + mp->loopstart;
-
- if (mp->totloop == 3 || mp->totloop == 4) {
- for (j = 0; j < mp->totloop; j++, lof++) {
- copy_v2_v2(lof->uv, default_osf[j]);
- }
- }
- else {
- MLoop *l = &ml[mp->loopstart];
- float p_nor[3], co[3];
- float mat[3][3];
-
- float min[2] = {FLT_MAX, FLT_MAX}, max[2] = {-FLT_MAX, -FLT_MAX};
- float translate[2], scale[2];
-
- BKE_mesh_calc_poly_normal(mp, l, mv, p_nor);
- axis_dominant_v3_to_m3(mat, p_nor);
-
- BLI_array_clear(vcos_2d);
- BLI_array_reserve(vcos_2d, mp->totloop);
- for (j = 0; j < mp->totloop; j++, l++) {
- mul_v3_m3v3(co, mat, mv[l->v].co);
- copy_v2_v2(vcos_2d[j], co);
-
- for (k = 0; k < 2; k++) {
- if (co[k] > max[k])
- max[k] = co[k];
- else if (co[k] < min[k])
- min[k] = co[k];
- }
- }
-
- /* Brings min to (0, 0). */
- negate_v2_v2(translate, min);
-
- /* Scale will bring max to (1, 1). */
- sub_v2_v2v2(scale, max, min);
- if (scale[0] == 0.0f)
- scale[0] = 1e-9f;
- 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. */
- for (j = 0; j < mp->totloop; j++, lof++) {
- add_v2_v2v2(lof->uv, vcos_2d[j], translate);
- mul_v2_v2(lof->uv, scale);
- }
- }
- }
-
- dm->dirty |= DM_DIRTY_TESS_CDLAYERS;
- BLI_array_free(vcos_2d);
-}
-
static void mesh_init_origspace(Mesh *mesh)
{
const float default_osf[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
@@ -2778,7 +2390,7 @@ char *DM_debug_info(DerivedMesh *dm)
char *ret;
const char *tstr;
- BLI_dynstr_appendf(dynstr, "{\n");
+ BLI_dynstr_append(dynstr, "{\n");
BLI_dynstr_appendf(dynstr, " 'ptr': '%p',\n", (void *)dm);
switch (dm->type) {
case DM_TYPE_CDDM: tstr = "DM_TYPE_CDDM"; break;
@@ -2792,27 +2404,27 @@ char *DM_debug_info(DerivedMesh *dm)
BLI_dynstr_appendf(dynstr, " 'numPolyData': %d,\n", dm->numPolyData);
BLI_dynstr_appendf(dynstr, " 'deformedOnly': %d,\n", dm->deformedOnly);
- BLI_dynstr_appendf(dynstr, " 'vertexLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'vertexLayers': (\n");
dm_debug_info_layers(dynstr, dm, &dm->vertData, dm->getVertDataArray);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, " 'edgeLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'edgeLayers': (\n");
dm_debug_info_layers(dynstr, dm, &dm->edgeData, dm->getEdgeDataArray);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, " 'loopLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'loopLayers': (\n");
dm_debug_info_layers(dynstr, dm, &dm->loopData, dm->getLoopDataArray);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, " 'polyLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'polyLayers': (\n");
dm_debug_info_layers(dynstr, dm, &dm->polyData, dm->getPolyDataArray);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, " 'tessFaceLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'tessFaceLayers': (\n");
dm_debug_info_layers(dynstr, dm, &dm->faceData, dm->getTessFaceDataArray);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, "}\n");
+ BLI_dynstr_append(dynstr, "}\n");
ret = BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index df424ff9346..a4ebfec657c 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -376,6 +376,9 @@ static void motionpaths_calc_bake_targets(ListBase *targets, int cframe)
if (BLI_dlrbTree_search_exact(&mpt->keys, compare_ak_cfraPtr, &mframe)) {
mpv->flag |= MOTIONPATH_VERT_KEY;
}
+ else {
+ mpv->flag &= ~MOTIONPATH_VERT_KEY;
+ }
/* Incremental update on evaluated object if possible, for fast updating
* while dragging in transform. */
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index bc265b6c465..c8882be0dd0 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -244,7 +244,7 @@ bool BKE_appdir_app_is_portable_install(void)
* \param targetpath: String to return path.
* \param subfolder_name: optional name of subfolder within folder.
* \param envvar: name of environment variable to check folder_name.
- * \return true if it was able to construct such a path.
+ * \return true if it was able to construct such a path and the path exists.
*/
static bool get_path_environment(
char *targetpath,
@@ -272,11 +272,40 @@ static bool get_path_environment(
}
/**
+ * Returns the path of a folder from environment variables
+ *
+ * \param targetpath: String to return path.
+ * \param subfolder_name: optional name of subfolder within folder.
+ * \param envvar: name of environment variable to check folder_name.
+ * \return true if it was able to construct such a path.
+ */
+static bool get_path_environment_notest(
+ char *targetpath,
+ size_t targetpath_len,
+ const char *subfolder_name,
+ const char *envvar)
+{
+ char user_path[FILE_MAX];
+
+ if (test_env_path(user_path, envvar)) {
+ if (subfolder_name) {
+ BLI_join_dirfile(targetpath, targetpath_len, user_path, subfolder_name);
+ return true;
+ }
+ else {
+ BLI_strncpy(targetpath, user_path, FILE_MAX);
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
* Returns the path of a folder within the user-files area.
* \param targetpath: String to return path
* \param folder_name: default name of folder within user area
* \param subfolder_name: optional name of subfolder within folder
- * \param ver: Blender version, used to construct a subdirectory name
+ * \param ver: Blender version, used to construct a subdirectory name
* \return true if it was able to construct such a path.
*/
static bool get_path_user(
@@ -447,19 +476,19 @@ 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(path, sizeof(path), subfolder, "BLENDER_USER_DATAFILES")) break;
+ 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(path, sizeof(path), subfolder, "BLENDER_USER_CONFIG")) break;
+ 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(path, sizeof(path), subfolder, "BLENDER_USER_AUTOSAVE")) break;
+ 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(path, sizeof(path), subfolder, "BLENDER_USER_SCRIPTS")) break;
+ if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_SCRIPTS")) break;
get_path_user(path, sizeof(path), "scripts", subfolder, ver);
break;
default:
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index cf7b9981b72..6e0767836d7 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -823,9 +823,7 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param, Mat4 result_arr
/* ************ Armature Deform ******************* */
typedef struct bPoseChanDeform {
- Mat4 *b_bone_mats;
DualQuat *dual_quat;
- DualQuat *b_bone_dual_quats;
} bPoseChanDeform;
/* Definition of cached object bbone deformations. */
@@ -915,9 +913,10 @@ void BKE_pchan_bbone_segments_cache_copy(bPoseChannel *pchan, bPoseChannel *pcha
}
}
-static void b_bone_deform(const bPoseChanDeform *pdef_info, Bone *bone, float co[3], DualQuat *dq, float defmat[3][3])
+static void b_bone_deform(const bPoseChannel *pchan, float co[3], DualQuat *dq, float defmat[3][3])
{
- const Mat4 *b_bone = pdef_info->b_bone_mats;
+ Bone *bone = pchan->bone;
+ const Mat4 *b_bone = pchan->runtime.bbone_deform_mats;
const float (*mat)[4] = b_bone[0].mat;
float segment, y;
int a;
@@ -934,7 +933,7 @@ static void b_bone_deform(const bPoseChanDeform *pdef_info, Bone *bone, float co
CLAMP(a, 0, bone->segments - 1);
if (dq) {
- copy_dq_dq(dq, &(pdef_info->b_bone_dual_quats)[a]);
+ copy_dq_dq(dq, &(pchan->runtime.bbone_dual_quats)[a]);
}
else {
mul_m4_v3(b_bone[a + 1].mat, co);
@@ -1030,9 +1029,9 @@ static float dist_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i
contrib = fac;
if (contrib > 0.0f) {
if (vec) {
- if (bone->segments > 1 && pdef_info->b_bone_mats != NULL)
+ if (bone->segments > 1 && pchan->runtime.bbone_segments == bone->segments)
/* applies on cop and bbonemat */
- b_bone_deform(pdef_info, bone, cop, NULL, (mat) ? bbonemat : NULL);
+ b_bone_deform(pchan, cop, NULL, (mat) ? bbonemat : NULL);
else
mul_m4_v3(pchan->chan_mat, cop);
@@ -1044,8 +1043,8 @@ static float dist_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i
pchan_deform_mat_add(pchan, fac, bbonemat, mat);
}
else {
- if (bone->segments > 1 && pdef_info->b_bone_mats != NULL) {
- b_bone_deform(pdef_info, bone, cop, &bbonedq, NULL);
+ if (bone->segments > 1 && pchan->runtime.bbone_segments == bone->segments) {
+ b_bone_deform(pchan, cop, &bbonedq, NULL);
add_weighted_dq_dq(dq, &bbonedq, fac);
}
else
@@ -1061,6 +1060,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i
float weight, float vec[3], DualQuat *dq,
float mat[3][3], const float co[3], float *contrib)
{
+ Bone *bone = pchan->bone;
float cop[3], bbonemat[3][3];
DualQuat bbonedq;
@@ -1070,9 +1070,9 @@ static void pchan_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i
copy_v3_v3(cop, co);
if (vec) {
- if (pchan->bone->segments > 1)
+ if (bone->segments > 1 && bone->segments == pchan->runtime.bbone_segments)
/* applies on cop and bbonemat */
- b_bone_deform(pdef_info, pchan->bone, cop, NULL, (mat) ? bbonemat : NULL);
+ b_bone_deform(pchan, cop, NULL, (mat) ? bbonemat : NULL);
else
mul_m4_v3(pchan->chan_mat, cop);
@@ -1084,8 +1084,8 @@ static void pchan_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i
pchan_deform_mat_add(pchan, weight, bbonemat, mat);
}
else {
- if (pchan->bone->segments > 1) {
- b_bone_deform(pdef_info, pchan->bone, cop, &bbonedq, NULL);
+ if (bone->segments > 1 && bone->segments == pchan->runtime.bbone_segments) {
+ b_bone_deform(pchan, cop, &bbonedq, NULL);
add_weighted_dq_dq(dq, &bbonedq, weight);
}
else
@@ -1110,13 +1110,6 @@ static void armature_bbone_defmats_cb(void *userdata, Link *iter, int index)
bPoseChanDeform *pdef_info = &data->pdef_info_array[index];
const bool use_quaternion = data->use_quaternion;
- if (pchan->bone->segments > 1) {
- BLI_assert(pchan->runtime.bbone_segments == pchan->bone->segments);
-
- pdef_info->b_bone_mats = pchan->runtime.bbone_deform_mats;
- pdef_info->b_bone_dual_quats = pchan->runtime.bbone_dual_quats;
- }
-
if (use_quaternion) {
pdef_info->dual_quat = &data->dualquats[index];
mat4_to_dquat(pdef_info->dual_quat, pchan->bone->arm_mat, pchan->chan_mat);
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 12f3f5c7354..5cd82803fae 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -704,7 +704,9 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph,
}
bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
float imat[4][4];
- DEG_debug_print_eval(depsgraph, __func__, pchan->name, pchan);
+ DEG_debug_print_eval_subdata(
+ depsgraph, __func__, object->id.name, object,
+ "pchan", pchan->name, pchan);
if (pchan->bone) {
invert_m4_m4(imat, pchan->bone->arm_mat);
mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
@@ -731,7 +733,9 @@ void BKE_pose_eval_bbone_segments(struct Depsgraph *depsgraph,
return;
}
bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
- DEG_debug_print_eval(depsgraph, __func__, pchan->name, pchan);
+ DEG_debug_print_eval_subdata(
+ depsgraph, __func__, object->id.name, object,
+ "pchan", pchan->name, pchan);
if (pchan->bone != NULL && pchan->bone->segments > 1) {
BKE_pchan_bbone_segments_cache_compute(pchan);
if (DEG_is_active(depsgraph)) {
@@ -862,8 +866,10 @@ void BKE_pose_eval_proxy_copy_bone(
return;
}
BLI_assert(ID_IS_LINKED(object) && object->proxy_from != NULL);
- DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
+ DEG_debug_print_eval_subdata(
+ depsgraph, __func__, object->id.name, object,
+ "pchan", pchan->name, pchan);
/* TODO(sergey): Use indexec lookup, once it's guaranteed to be kept
* around for the time while proxies are evaluating.
*/
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 08d49dee754..36e9c8f36dc 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -275,7 +275,7 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use
memcpy(&(userdef_tmp.id), &(userdef_a->id), sizeof(userdef_tmp.id)); \
memcpy(&(userdef_a->id), &(userdef_b->id), sizeof(userdef_tmp.id)); \
memcpy(&(userdef_b->id), &(userdef_tmp.id), sizeof(userdef_tmp.id)); \
- }
+ } ((void)0)
#define LIST_SWAP(id) { \
SWAP(ListBase, userdef_a->id, userdef_b->id); \
diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c
index bc935f0b760..2ac013df620 100644
--- a/source/blender/blenkernel/intern/blender_copybuffer.c
+++ b/source/blender/blenkernel/intern/blender_copybuffer.c
@@ -82,7 +82,7 @@ bool BKE_copybuffer_save(Main *bmain_src, const char *filename, ReportList *repo
return retval;
}
-bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *reports)
+bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *reports, const unsigned int id_types_mask)
{
BlendHandle *bh = BLO_blendhandle_from_file(libname, reports);
if (bh == NULL) {
@@ -91,7 +91,7 @@ bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *repor
}
/* Here appending/linking starts. */
Main *mainl = BLO_library_link_begin(bmain_dst, &bh, libname);
- BLO_library_link_copypaste(mainl, bh);
+ BLO_library_link_copypaste(mainl, bh, id_types_mask);
BLO_library_link_end(mainl, &bh, 0, NULL, NULL, NULL, NULL);
/* Mark all library linked objects to be updated. */
BKE_main_lib_objects_recalc_all(bmain_dst);
@@ -108,9 +108,10 @@ bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *repor
}
/**
- * \return Success.
+ * \return Number of IDs directly pasted from the buffer (does not includes indirectly pulled out ones).
*/
-bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, ReportList *reports)
+int BKE_copybuffer_paste(
+ bContext *C, const char *libname, const short flag, ReportList *reports, const unsigned int id_types_mask)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -124,7 +125,7 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re
if (bh == NULL) {
/* error reports will have been made by BLO_blendhandle_from_file() */
- return false;
+ return 0;
}
BKE_view_layer_base_deselect_all(view_layer);
@@ -138,7 +139,7 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re
/* here appending/linking starts */
mainl = BLO_library_link_begin(bmain, &bh, libname);
- BLO_library_link_copypaste(mainl, bh);
+ const int num_pasted = BLO_library_link_copypaste(mainl, bh, id_types_mask);
BLO_library_link_end(mainl, &bh, flag, bmain, scene, view_layer, v3d);
@@ -164,7 +165,7 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re
BLO_blendhandle_close(bh);
/* remove library... */
- return true;
+ return num_pasted;
}
/** \} */
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 455f73c65c0..cd17911d65d 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -460,16 +460,21 @@ bool BKE_blendfile_read_from_memfile(
void BKE_blendfile_read_make_empty(bContext *C)
{
Main *bmain = CTX_data_main(C);
+ ListBase *lb;
ID *id;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
+ FOREACH_MAIN_LISTBASE_BEGIN(bmain, lb)
{
- if (ELEM(GS(id->name), ID_SCE, ID_SCR, ID_WM, ID_WS)) {
- break; /* Only breaks iter on that ID type, and continues with IDs of next type. */
+ FOREACH_MAIN_LISTBASE_ID_BEGIN(lb, id)
+ {
+ if (ELEM(GS(id->name), ID_SCE, ID_SCR, ID_WM, ID_WS)) {
+ break;
+ }
+ BKE_id_delete(bmain, id);
}
- BKE_id_delete(bmain, id);
+ FOREACH_MAIN_LISTBASE_ID_END;
}
- FOREACH_MAIN_ID_END;
+ FOREACH_MAIN_LISTBASE_END;
}
/* only read the userdef from a .blend */
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 54a8929a7f7..c092b2c7e79 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -45,6 +45,23 @@
#include "RNA_enum_types.h"
+static float len_squared_v3v3_with_normal_bias(
+ const float co_search[3], const float co_test[3], const void *user_data)
+{
+ const float *normal = user_data;
+ float d[3], dist;
+
+ sub_v3_v3v3(d, co_test, co_search);
+
+ dist = len_squared_v3(d);
+
+ /* Avoid head-on collisions. */
+ if (dot_v3v3(d, normal) < 0.0f) {
+ dist *= 10.0f;
+ }
+ return dist;
+}
+
typedef struct BoidValues {
float max_speed, max_acc;
float max_ave, min_speed;
@@ -189,7 +206,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
{
const int raycast_flag = BVH_RAYCAST_DEFAULT & ~(BVH_RAYCAST_WATERTIGHT);
BoidRuleAvoidCollision *acbr = (BoidRuleAvoidCollision*) rule;
- KDTreeNearest *ptn = NULL;
+ KDTreeNearest_3d *ptn = NULL;
ParticleTarget *pt;
BoidParticle *bpa = pa->boid;
ColliderCache *coll;
@@ -257,9 +274,9 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
//check boids in own system
if (acbr->options & BRULE_ACOLL_WITH_BOIDS) {
- neighbors = BLI_kdtree_range_search__normal(
- bbd->sim->psys->tree, pa->prev_state.co, pa->prev_state.ave,
- &ptn, acbr->look_ahead * len_v3(pa->prev_state.vel));
+ neighbors = BLI_kdtree_3d_range_search_with_len_squared_cb(
+ bbd->sim->psys->tree, pa->prev_state.co, &ptn, acbr->look_ahead * len_v3(pa->prev_state.vel),
+ len_squared_v3v3_with_normal_bias, pa->prev_state.ave);
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);
@@ -306,9 +323,9 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
if (epsys) {
BLI_assert(epsys->tree != NULL);
- neighbors = BLI_kdtree_range_search__normal(
- epsys->tree, pa->prev_state.co, pa->prev_state.ave,
- &ptn, acbr->look_ahead * len_v3(pa->prev_state.vel));
+ neighbors = BLI_kdtree_3d_range_search_with_len_squared_cb(
+ epsys->tree, pa->prev_state.co, &ptn, acbr->look_ahead * len_v3(pa->prev_state.vel),
+ len_squared_v3v3_with_normal_bias, pa->prev_state.ave);
if (neighbors > 0) for (n=0; n<neighbors; n++) {
copy_v3_v3(co1, pa->prev_state.co);
@@ -360,11 +377,11 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
}
static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
{
- KDTreeNearest *ptn = NULL;
+ KDTreeNearest_3d *ptn = NULL;
ParticleTarget *pt;
float len = 2.0f * val->personal_space * pa->size + 1.0f;
float vec[3] = {0.0f, 0.0f, 0.0f};
- int neighbors = BLI_kdtree_range_search(
+ int neighbors = BLI_kdtree_3d_range_search(
bbd->sim->psys->tree, pa->prev_state.co,
&ptn, 2.0f * val->personal_space * pa->size);
int ret = 0;
@@ -384,7 +401,7 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
if (epsys) {
- neighbors = BLI_kdtree_range_search(
+ neighbors = BLI_kdtree_3d_range_search(
epsys->tree, pa->prev_state.co,
&ptn, 2.0f * val->personal_space * pa->size);
@@ -404,9 +421,11 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
}
static int rule_flock(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues *UNUSED(val), ParticleData *pa)
{
- KDTreeNearest ptn[11];
+ KDTreeNearest_3d ptn[11];
float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f};
- int neighbors = BLI_kdtree_find_nearest_n__normal(bbd->sim->psys->tree, pa->state.co, pa->prev_state.ave, ptn, 11);
+ int neighbors = BLI_kdtree_3d_find_nearest_n_with_len_squared_cb(
+ bbd->sim->psys->tree, pa->state.co, ptn, ARRAY_SIZE(ptn),
+ len_squared_v3v3_with_normal_bias, pa->prev_state.ave);
int n;
int ret = 0;
@@ -620,7 +639,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
{
BoidRuleFight *fbr = (BoidRuleFight*)rule;
- KDTreeNearest *ptn = NULL;
+ KDTreeNearest_3d *ptn = NULL;
ParticleTarget *pt;
ParticleData *epars;
ParticleData *enemy_pa = NULL;
@@ -633,7 +652,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
int n, ret = 0;
/* calculate own group strength */
- int neighbors = BLI_kdtree_range_search(
+ int neighbors = BLI_kdtree_3d_range_search(
bbd->sim->psys->tree, pa->prev_state.co,
&ptn, fbr->distance);
for (n=0; n<neighbors; n++) {
@@ -651,7 +670,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
if (epsys) {
epars = epsys->particles;
- neighbors = BLI_kdtree_range_search(
+ neighbors = BLI_kdtree_3d_range_search(
epsys->tree, pa->prev_state.co,
&ptn, fbr->distance);
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index e85cb700bce..3d91283e1cc 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -211,7 +211,7 @@ static bool missing_files_find__recursive(
char *filename_new,
const char *dirname,
const char *filename,
- off_t *r_filesize,
+ int64_t *r_filesize,
int *r_recur_depth)
{
/* file searching stuff */
@@ -219,7 +219,7 @@ static bool missing_files_find__recursive(
struct dirent *de;
BLI_stat_t status;
char path[FILE_MAX];
- off_t size;
+ int64_t size;
bool found = false;
dir = opendir(dirname);
@@ -275,7 +275,7 @@ static bool missing_files_find__visit_cb(void *userdata, char *path_dst, const c
BPathFind_Data *data = (BPathFind_Data *)userdata;
char filename_new[FILE_MAX];
- off_t filesize = -1;
+ int64_t filesize = -1;
int recur_depth = 0;
bool found;
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 58813c9878d..ea5605d8ed1 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -131,7 +131,7 @@ static void brush_defaults(Brush *brush)
void BKE_brush_init(Brush *brush)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(brush, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(brush, id));
/* enable fake user by default */
id_fake_user_set(&brush->id);
@@ -207,14 +207,15 @@ typedef enum eGPCurveMappingPreset {
GPCURVE_PRESET_PENCIL = 0,
GPCURVE_PRESET_INK = 1,
GPCURVE_PRESET_INKNOISE = 2,
+ GPCURVE_PRESET_MARKER = 3
} eGPCurveMappingPreset;
-static void brush_gpencil_curvemap_reset(CurveMap *cuma, int preset)
+static void brush_gpencil_curvemap_reset(CurveMap *cuma, int tot, int preset)
{
if (cuma->curve)
MEM_freeN(cuma->curve);
- cuma->totpoint = 3;
+ cuma->totpoint = tot;
cuma->curve = MEM_callocN(cuma->totpoint * sizeof(CurveMapPoint), __func__);
switch (preset) {
@@ -242,6 +243,16 @@ static void brush_gpencil_curvemap_reset(CurveMap *cuma, int preset)
cuma->curve[2].x = 1.0f;
cuma->curve[2].y = 1.0f;
break;
+ case GPCURVE_PRESET_MARKER:
+ cuma->curve[0].x = 0.0f;
+ cuma->curve[0].y = 0.0f;
+ cuma->curve[1].x = 0.38f;
+ cuma->curve[1].y = 0.22f;
+ cuma->curve[2].x = 0.65f;
+ cuma->curve[2].y = 0.68f;
+ cuma->curve[3].x = 1.0f;
+ cuma->curve[3].y = 1.0f;
+ break;
}
if (cuma->table) {
@@ -358,7 +369,7 @@ void BKE_brush_gpencil_presets(bContext *C)
custom_curve = brush->gpencil_settings->curve_sensitivity;
curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
curvemapping_initialize(custom_curve);
- brush_gpencil_curvemap_reset(custom_curve->cm, GPCURVE_PRESET_INK);
+ brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INK);
/* Ink Noise brush */
brush = BKE_brush_add_gpencil(bmain, ts, "Draw Noise");
@@ -395,7 +406,7 @@ void BKE_brush_gpencil_presets(bContext *C)
custom_curve = brush->gpencil_settings->curve_sensitivity;
curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
curvemapping_initialize(custom_curve);
- brush_gpencil_curvemap_reset(custom_curve->cm, GPCURVE_PRESET_INKNOISE);
+ brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INKNOISE);
/* Block Basic brush */
brush = BKE_brush_add_gpencil(bmain, ts, "Draw Block");
@@ -403,8 +414,7 @@ void BKE_brush_gpencil_presets(bContext *C)
brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
brush->gpencil_settings->draw_sensitivity = 1.0f;
- brush->gpencil_settings->draw_strength = 0.7f;
- brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+ brush->gpencil_settings->draw_strength = 1.0f;
brush->gpencil_settings->draw_random_press = 0.0f;
@@ -414,8 +424,7 @@ void BKE_brush_gpencil_presets(bContext *C)
brush->gpencil_settings->draw_angle = 0.0f;
brush->gpencil_settings->draw_angle_factor = 0.0f;
- brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
- brush->gpencil_settings->draw_smoothfac = 0.0f;
+ brush->gpencil_settings->draw_smoothfac = 0.1f;
brush->gpencil_settings->draw_smoothlvl = 1;
brush->gpencil_settings->thick_smoothfac = 1.0f;
brush->gpencil_settings->thick_smoothlvl = 3;
@@ -442,7 +451,7 @@ void BKE_brush_gpencil_presets(bContext *C)
brush->gpencil_settings->draw_jitter = 0.0f;
brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
- brush->gpencil_settings->draw_angle = M_PI_4; /* 45 degrees */
+ brush->gpencil_settings->draw_angle = DEG2RAD(20.0f);
brush->gpencil_settings->draw_angle_factor = 1.0f;
brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
@@ -457,6 +466,11 @@ void BKE_brush_gpencil_presets(bContext *C)
brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+ /* Curve */
+ custom_curve = brush->gpencil_settings->curve_sensitivity;
+ curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
+ curvemapping_initialize(custom_curve);
+ brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_MARKER);
/* Fill brush */
brush = BKE_brush_add_gpencil(bmain, ts, "Fill Area");
@@ -466,6 +480,7 @@ void BKE_brush_gpencil_presets(bContext *C)
brush->gpencil_settings->fill_leak = 3;
brush->gpencil_settings->fill_threshold = 0.1f;
brush->gpencil_settings->fill_simplylvl = 1;
+ brush->gpencil_settings->fill_factor = 1;
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_FILL;
brush->gpencil_tool = GPAINT_TOOL_FILL;
@@ -525,24 +540,6 @@ void BKE_brush_gpencil_presets(bContext *C)
}
-void BKE_brush_update_material(Main *bmain, Material *ma, Brush *exclude_brush)
-{
- for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if ((exclude_brush != NULL) && (brush == exclude_brush)) {
- continue;
- }
-
- if (brush->gpencil_settings != NULL) {
- BrushGpencilSettings *gpencil_settings = brush->gpencil_settings;
- if (((gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) == 0) &&
- (gpencil_settings->material != ma))
- {
- gpencil_settings->material = ma;
- }
- }
- }
-}
-
struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode)
{
Brush *brush;
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index b4f64087f8c..2c9e4966fc9 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -210,7 +210,7 @@ bool BKE_cachefile_filepath_get(
if (cache_file->is_sequence && BLI_path_frame_get(r_filepath, &fframe, &frame_len)) {
char ext[32];
- BLI_path_frame_strip(r_filepath, true, ext);
+ BLI_path_frame_strip(r_filepath, ext);
BLI_path_frame(r_filepath, frame, frame_len);
BLI_path_extension_ensure(r_filepath, FILE_MAX, ext);
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index cfcf5eeed96..ce3db985c49 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -54,7 +54,7 @@
void BKE_camera_init(Camera *cam)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(cam, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cam, id));
cam->lens = 50.0f;
cam->sensor_x = DEFAULT_SENSOR_WIDTH;
@@ -206,9 +206,6 @@ void BKE_camera_params_from_object(CameraParams *params, const Object *ob)
params->lens = 16.0f / tanf(la->spotsize * 0.5f);
if (params->lens == 0.0f)
params->lens = 35.0f;
-
- params->clip_start = la->clipsta;
- params->clip_end = la->clipend;
}
else {
params->lens = 35.0f;
@@ -366,7 +363,7 @@ void BKE_camera_view_frame_ex(
facy = 0.5f * camera->ortho_scale * r_asp[1] * scale[1];
r_shift[0] = camera->shiftx * camera->ortho_scale * scale[0];
r_shift[1] = camera->shifty * camera->ortho_scale * scale[1];
- depth = do_clip ? -((camera->clip_start * scale[2]) + 0.1f) : -drawsize * scale[2];
+ depth = -drawsize * scale[2];
*r_drawsize = 0.5f * camera->ortho_scale;
}
@@ -376,24 +373,12 @@ void BKE_camera_view_frame_ex(
float half_sensor = 0.5f * ((camera->sensor_fit == CAMERA_SENSOR_FIT_VERT) ?
(camera->sensor_y) : (camera->sensor_x));
-
- if (do_clip) {
- /* fixed depth, variable size (avoids exceeding clipping range) */
- /* r_drawsize shouldn't be used in this case, set to dummy value */
- *r_drawsize = 1.0f;
- depth = -(camera->clip_start + 0.1f) * scale[2];
- fac = depth / (camera->lens / (-half_sensor));
- scale_x = scale[0] / scale[2];
- scale_y = scale[1] / scale[2];
- }
- else {
- /* fixed size, variable depth (stays a reasonable size in the 3D view) */
- *r_drawsize = (drawsize / 2.0f) / ((scale[0] + scale[1] + scale[2]) / 3.0f);
- depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2];
- fac = *r_drawsize;
- scale_x = scale[0];
- scale_y = scale[1];
- }
+ /* fixed size, variable depth (stays a reasonable size in the 3D view) */
+ *r_drawsize = (drawsize / 2.0f) / ((scale[0] + scale[1] + scale[2]) / 3.0f);
+ depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2];
+ fac = *r_drawsize;
+ scale_x = scale[0];
+ scale_y = scale[1];
facx = fac * r_asp[0] * scale_x;
facy = fac * r_asp[1] * scale_y;
@@ -405,6 +390,19 @@ void BKE_camera_view_frame_ex(
r_vec[1][0] = r_shift[0] + facx; r_vec[1][1] = r_shift[1] - facy; r_vec[1][2] = depth;
r_vec[2][0] = r_shift[0] - facx; r_vec[2][1] = r_shift[1] - facy; r_vec[2][2] = depth;
r_vec[3][0] = r_shift[0] - facx; r_vec[3][1] = r_shift[1] + facy; r_vec[3][2] = depth;
+
+ if (do_clip) {
+ /* Ensure the frame isn't behind the near clipping plane, T62814. */
+ float fac = (camera->clip_start + 0.1f) / -r_vec[0][2];
+ for (uint i = 0; i < 4; i++) {
+ if (camera->type == CAM_ORTHO) {
+ r_vec[i][2] *= fac;
+ }
+ else {
+ mul_v3_fl(r_vec[i], fac);
+ }
+ }
+ }
}
void BKE_camera_view_frame(const Scene *scene, const Camera *camera, float r_vec[4][3])
@@ -414,7 +412,7 @@ void BKE_camera_view_frame(const Scene *scene, const Camera *camera, float r_vec
float dummy_drawsize;
const float dummy_scale[3] = {1.0f, 1.0f, 1.0f};
- BKE_camera_view_frame_ex(scene, camera, 0.0, true, dummy_scale,
+ BKE_camera_view_frame_ex(scene, camera, 1.0, false, dummy_scale,
dummy_asp, dummy_shift, &dummy_drawsize, r_vec);
}
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 859c5534183..9634cbccd91 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -53,7 +53,7 @@ typedef struct {
DerivedMesh dm;
/* these point to data in the DerivedMesh custom data layers,
- * they are only here for efficiency and convenience **/
+ * they are only here for efficiency and convenience */
MVert *mvert;
MEdge *medge;
MFace *mface;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 10f16fc6bcf..dddb34afd39 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -584,9 +584,8 @@ void cloth_free_modifier_extern(ClothModifierData *clmd )
******************************************************************************/
/**
- * cloth_to_object - copies the deformed vertices to the object.
- *
- **/
+ * Copies the deformed vertices to the object.
+ */
static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*vertexCos)[3])
{
unsigned int i = 0;
@@ -614,12 +613,11 @@ int cloth_uses_vgroup(ClothModifierData *clmd)
}
/**
- * cloth_apply_vgroup - applies a vertex group as specified by type
- *
- **/
-/* can be optimized to do all groups in one loop */
+ * Applies a vertex group as specified by type.
+ */
static void cloth_apply_vgroup ( ClothModifierData *clmd, Mesh *mesh )
{
+ /* Can be optimized to do all groups in one loop. */
int i = 0;
int j = 0;
MDeformVert *dvert = NULL;
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 8a71c0c2e10..336a4739760 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -298,9 +298,11 @@ Collection *BKE_collection_copy(Main *bmain, Collection *parent, Collection *col
*
* \warning If any 'deep copy' behavior is enabled, this functions will clear all \a bmain id.idnew pointers.
*
- * \param do_hierarchy If true, it will recursively make shallow copies of children collections and objects.
+ * \param do_hierarchy If true, it will recursively make shallow copies of children collections.
+ * \param do_objects If true, it will also make duplicates of objects.
+ * This one does nothing if \a do_hierarchy is not set.
* \param do_obdata If true, it will also make deep duplicates of objects, using behavior defined in user settings
- * (U.dupflag). This one does nothing if \a do_hierarchy is not set.
+ * (U.dupflag). This one does nothing if \a do_hierarchy and \a do_objects are not set.
*/
Collection *BKE_collection_duplicate(
Main *bmain, Collection *parent, Collection *collection,
@@ -358,7 +360,7 @@ void BKE_collection_new_name_get(Collection *collection_parent, char *rname)
char *name;
if (!collection_parent) {
- name = BLI_sprintfN("Collection");
+ name = BLI_strdup("Collection");
}
else if (collection_parent->flag & COLLECTION_IS_MASTER) {
name = BLI_sprintfN("Collection %d", BLI_listbase_count(&collection_parent->children) + 1);
@@ -481,6 +483,19 @@ Collection *BKE_collection_master(const Scene *scene)
return scene->master_collection;
}
+Scene *BKE_collection_master_scene_search(const Main *bmain, const Collection *master_collection)
+{
+ BLI_assert((master_collection->flag & COLLECTION_IS_MASTER) != 0);
+
+ for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ if (scene->master_collection == master_collection) {
+ return scene;
+ }
+ }
+
+ return NULL;
+}
+
/*********************** Cyclic Checks ************************/
static bool collection_object_cyclic_check_internal(Object *object, Collection *collection)
@@ -543,17 +558,32 @@ bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
return (BLI_findptr(&objects, ob, offsetof(Base, object)));
}
-Collection *BKE_collection_object_find(Main *bmain, Collection *collection, Object *ob)
+static Collection *collection_next_find(Main *bmain, Scene *scene, Collection *collection)
{
- if (collection)
- collection = collection->id.next;
- else
+ if (scene && collection == BKE_collection_master(scene)) {
+ return bmain->collections.first;
+ }
+ else {
+ return collection->id.next;
+ }
+}
+
+Collection *BKE_collection_object_find(Main *bmain, Scene *scene, Collection *collection, Object *ob)
+{
+ if (collection) {
+ collection = collection_next_find(bmain, scene, collection);
+ }
+ else if (scene) {
+ collection = BKE_collection_master(scene);
+ }
+ else {
collection = bmain->collections.first;
+ }
while (collection) {
if (BKE_collection_has_object(collection, ob))
return collection;
- collection = collection->id.next;
+ collection = collection_next_find(bmain, scene, collection);
}
return NULL;
}
diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c
index 57c5e8eb0fe..5630a3268e2 100644
--- a/source/blender/blenkernel/intern/colorband.c
+++ b/source/blender/blenkernel/intern/colorband.c
@@ -350,7 +350,9 @@ static float colorband_hue_interp(
}
case COLBAND_HUE_FAR:
{
- if ((h1 < h2) && (h2 - h1) < +0.5f) mode = 1;
+ /* Do full loop in Hue space in case both stops are the same... */
+ if (h1 == h2) mode = 1;
+ else if ((h1 < h2) && (h2 - h1) < +0.5f) mode = 1;
else if ((h1 > h2) && (h2 - h1) > -0.5f) mode = 2;
else mode = 0;
break;
@@ -402,6 +404,8 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
cbd1 = coba->data;
+ /* Note: when ipotype >= COLBAND_INTERP_B_SPLINE, we cannot do early-out with a constant color before
+ * first color stop and after last one, because interpolation starts before and ends after those... */
ipotype = (coba->color_mode == COLBAND_BLEND_RGB) ? coba->ipotype : COLBAND_INTERP_LINEAR;
if (coba->tot == 1) {
@@ -410,7 +414,8 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
out[2] = cbd1->b;
out[3] = cbd1->a;
}
- else if ((in <= cbd1->pos) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE)) {
+ else if ((in <= cbd1->pos) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE, COLBAND_INTERP_CONSTANT)) {
+ /* We are before first color stop. */
out[0] = cbd1->r;
out[1] = cbd1->g;
out[2] = cbd1->b;
@@ -441,14 +446,21 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
cbd2 = cbd1 - 1;
}
- if ((in >= cbd1->pos) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE)) {
- out[0] = cbd1->r;
- out[1] = cbd1->g;
- out[2] = cbd1->b;
- out[3] = cbd1->a;
+ if ((a == coba->tot) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE, COLBAND_INTERP_CONSTANT)) {
+ /* We are after last color stop. */
+ out[0] = cbd2->r;
+ out[1] = cbd2->g;
+ out[2] = cbd2->b;
+ out[3] = cbd2->a;
+ }
+ else if (ipotype == COLBAND_INTERP_CONSTANT) {
+ /* constant */
+ out[0] = cbd2->r;
+ out[1] = cbd2->g;
+ out[2] = cbd2->b;
+ out[3] = cbd2->a;
}
else {
-
if (cbd2->pos != cbd1->pos) {
fac = (in - cbd1->pos) / (cbd2->pos - cbd1->pos);
}
@@ -458,14 +470,7 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
fac = (a != coba->tot) ? 0.0f : 1.0f;
}
- if (ipotype == COLBAND_INTERP_CONSTANT) {
- /* constant */
- out[0] = cbd2->r;
- out[1] = cbd2->g;
- out[2] = cbd2->b;
- out[3] = cbd2->a;
- }
- else if (ipotype >= COLBAND_INTERP_B_SPLINE) {
+ if (ELEM(ipotype, COLBAND_INTERP_B_SPLINE, COLBAND_INTERP_CARDINAL)) {
/* ipo from right to left: 3 2 1 0 */
float t[4];
@@ -493,14 +498,11 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
CLAMP(out[3], 0.0f, 1.0f);
}
else {
- float mfac;
-
if (ipotype == COLBAND_INTERP_EASE) {
- mfac = fac * fac;
- fac = 3.0f * mfac - 2.0f * mfac * fac;
+ const float fac2 = fac * fac;
+ fac = 3.0f * fac2 - 2.0f * fac2 * fac;
}
-
- mfac = 1.0f - fac;
+ const float mfac = 1.0f - fac;
if (UNLIKELY(coba->color_mode == COLBAND_BLEND_HSV)) {
float col1[3], col2[3];
@@ -538,6 +540,7 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
}
}
}
+
return true; /* OK */
}
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index a8e0cbed707..a16656253d3 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -975,7 +975,7 @@ Collection *CTX_data_collection(const bContext *C)
return BKE_collection_master(scene);
}
-int CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectMode object_mode)
+enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectMode object_mode)
{
// Object *obedit = CTX_data_edit_object(C);
if (obedit) {
@@ -1015,7 +1015,7 @@ int CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectM
return CTX_MODE_OBJECT;
}
-int CTX_data_mode_enum(const bContext *C)
+enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
Object *obact = obedit ? NULL : CTX_data_active_object(C);
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 3b83d7308a4..5dd5e014cc8 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -105,7 +105,7 @@ float (*BKE_crazyspace_get_mapped_editverts(
/* disable subsurf temporal, get mapped cos, and enable it */
if (modifiers_disable_subsurf_temporary(obedit)) {
/* need to make new derivemesh */
- makeDerivedMesh(depsgraph, scene, obedit, me->edit_mesh, &CD_MASK_BAREMESH, false);
+ makeDerivedMesh(depsgraph, scene, obedit, me->edit_mesh, &CD_MASK_BAREMESH);
}
/* now get the cage */
@@ -305,6 +305,24 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
return numleft;
}
+/* Crazyspace evaluation needs to have an object which has all the fields
+ * evaluated, but the mesh data being at undeformed state. This way it can
+ * re-apply modifiers and also have proper pointers to key data blocks.
+ *
+ * Similar to BKE_object_eval_reset(), but does not modify the actual evaluated
+ * object. */
+static void crazyspace_init_object_for_eval(
+ struct Depsgraph *depsgraph,
+ Object *object,
+ Object *object_crazy)
+{
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
+ *object_crazy = *object_eval;
+ if (object_crazy->runtime.mesh_orig != NULL) {
+ object_crazy->data = object_crazy->runtime.mesh_orig;
+ }
+}
+
int BKE_sculpt_get_first_deform_matrices(
struct Depsgraph *depsgraph, Scene *scene,
Object *object, float (**deformmats)[3][3], float (**deformcos)[3])
@@ -315,10 +333,11 @@ int BKE_sculpt_get_first_deform_matrices(
float (*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL;
int numleft = 0;
VirtualModifierData virtualModifierData;
- Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
- MultiresModifierData *mmd = get_multires_modifier(scene, object_eval, 0);
+ Object object_eval;
+ crazyspace_init_object_for_eval(depsgraph, object, &object_eval);
+ MultiresModifierData *mmd = get_multires_modifier(scene, &object_eval, 0);
const bool has_multires = mmd != NULL && mmd->sculptlvl > 0;
- const ModifierEvalContext mectx = {depsgraph, object_eval, 0};
+ const ModifierEvalContext mectx = {depsgraph, &object_eval, 0};
if (has_multires) {
*deformmats = NULL;
@@ -327,7 +346,8 @@ int BKE_sculpt_get_first_deform_matrices(
}
me_eval = NULL;
- md = modifiers_getVirtualModifierList(object_eval, &virtualModifierData);
+
+ md = modifiers_getVirtualModifierList(&object_eval, &virtualModifierData);
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -336,8 +356,9 @@ int BKE_sculpt_get_first_deform_matrices(
if (mti->type == eModifierTypeType_OnlyDeform) {
if (!defmats) {
- /* NOTE: Need to start with original undeformed mesh. */
- Mesh *me = object->data;
+ /* NOTE: Evaluated object si re-set to its original undeformed
+ * state. */
+ Mesh *me = object_eval.data;
me_eval = BKE_mesh_copy_for_eval(me, true);
deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats");
@@ -387,9 +408,10 @@ void BKE_crazyspace_build_sculpt(
float (*quats)[4];
int i, deformed = 0;
VirtualModifierData virtualModifierData;
- Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
- ModifierData *md = modifiers_getVirtualModifierList(object_eval, &virtualModifierData);
- const ModifierEvalContext mectx = {depsgraph, object_eval, 0};
+ Object object_eval;
+ crazyspace_init_object_for_eval(depsgraph, object, &object_eval);
+ ModifierData *md = modifiers_getVirtualModifierList(&object_eval, &virtualModifierData);
+ const ModifierEvalContext mectx = {depsgraph, &object_eval, 0};
Mesh *mesh = (Mesh *)object->data;
for (; md; md = md->next) {
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 2c6392fdf90..0ab5a6ca963 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -138,10 +138,10 @@ void BKE_curve_free(Curve *cu)
void BKE_curve_init(Curve *cu)
{
- /* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(cu, id)); */ /* cu->type is already initialized... */
+ /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cu, id)); */ /* cu->type is already initialized... */
copy_v3_fl(cu->size, 1.0f);
- cu->flag = CU_FRONT | CU_BACK | CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS;
+ cu->flag = CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS;
cu->pathlen = 100;
cu->resolu = cu->resolv = (cu->type == OB_SURF) ? 4 : 12;
cu->width = 1.0;
@@ -157,10 +157,12 @@ void BKE_curve_init(Curve *cu)
cu->bevfac2 = 1.0f;
cu->bevfac1_mapping = CU_BEVFAC_MAP_RESOLU;
cu->bevfac2_mapping = CU_BEVFAC_MAP_RESOLU;
+ cu->bevresol = 4;
cu->bb = BKE_boundbox_alloc_unit();
if (cu->type == OB_FONT) {
+ cu->flag |= CU_FRONT | CU_BACK;
cu->vfont = cu->vfontb = cu->vfonti = cu->vfontbi = BKE_vfont_builtin_get();
cu->vfont->id.us += 4;
cu->str = MEM_malloc_arrayN(12, sizeof(unsigned char), "str");
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index c3e45480a57..1b1cc1fa30f 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1252,9 +1252,8 @@ static void layerSwap_flnor(void *data, const int *corner_indices)
static void layerDefault_fmap(void *data, int count)
{
int *fmap_num = (int *)data;
- int i;
- for (i = 0; i < count; i++) {
- *fmap_num = -1;
+ for (int i = 0; i < count; i++) {
+ fmap_num[i] = -1;
}
}
@@ -1407,9 +1406,8 @@ const CustomData_MeshMasks CD_MASK_BAREMESH_ORIGINDEX = {
.pmask = CD_MASK_MPOLY | CD_MASK_FACEMAP | CD_MASK_ORIGINDEX,
};
const CustomData_MeshMasks CD_MASK_MESH = {
- .vmask = (CD_MASK_MVERT | CD_MASK_MDEFORMVERT | CD_MASK_BWEIGHT | CD_MASK_MVERT_SKIN | CD_MASK_PAINT_MASK |
- CD_MASK_GENERIC_DATA),
- .emask = (CD_MASK_MEDGE | CD_MASK_BWEIGHT | CD_MASK_FREESTYLE_EDGE | CD_MASK_GENERIC_DATA),
+ .vmask = (CD_MASK_MVERT | CD_MASK_MDEFORMVERT | CD_MASK_MVERT_SKIN | CD_MASK_PAINT_MASK | CD_MASK_GENERIC_DATA),
+ .emask = (CD_MASK_MEDGE | CD_MASK_FREESTYLE_EDGE | CD_MASK_GENERIC_DATA),
.fmask = 0,
.lmask = (CD_MASK_MLOOP | CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_CUSTOMLOOPNORMAL |
CD_MASK_GRID_PAINT_MASK | CD_MASK_GENERIC_DATA),
@@ -1420,9 +1418,9 @@ const CustomData_MeshMasks CD_MASK_EDITMESH = {
CD_MASK_SHAPE_KEYINDEX | CD_MASK_GENERIC_DATA),
.emask = (CD_MASK_GENERIC_DATA),
.fmask = 0,
- .lmask = (CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_GRID_PAINT_MASK |
- CD_MASK_GENERIC_DATA),
- .pmask = (CD_MASK_MDISPS | CD_MASK_RECAST | CD_MASK_FACEMAP | CD_MASK_GENERIC_DATA),
+ .lmask = (CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_CUSTOMLOOPNORMAL |
+ CD_MASK_GRID_PAINT_MASK | CD_MASK_GENERIC_DATA),
+ .pmask = (CD_MASK_RECAST | CD_MASK_FACEMAP | CD_MASK_GENERIC_DATA),
};
const CustomData_MeshMasks CD_MASK_DERIVEDMESH = {
.vmask = (CD_MASK_ORIGINDEX | CD_MASK_MDEFORMVERT | CD_MASK_SHAPEKEY | CD_MASK_MVERT_SKIN |
@@ -1430,7 +1428,7 @@ const CustomData_MeshMasks CD_MASK_DERIVEDMESH = {
.emask = (CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_EDGE | CD_MASK_GENERIC_DATA),
.fmask = (CD_MASK_ORIGINDEX | CD_MASK_ORIGSPACE | CD_MASK_PREVIEW_MCOL | CD_MASK_TANGENT),
.lmask = (CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_PREVIEW_MLOOPCOL |
- CD_MASK_ORIGSPACE_MLOOP | CD_MASK_TANGENT | CD_MASK_GENERIC_DATA),
+ CD_MASK_ORIGSPACE_MLOOP | CD_MASK_GENERIC_DATA), /* XXX MISSING CD_MASK_MLOOPTANGENT ? */
.pmask = (CD_MASK_ORIGINDEX | CD_MASK_RECAST | CD_MASK_FREESTYLE_FACE | CD_MASK_FACEMAP | CD_MASK_GENERIC_DATA),
};
const CustomData_MeshMasks CD_MASK_BMESH = {
@@ -2320,8 +2318,8 @@ static void CustomData_copy_data_layer(
if (!count || !src_data || !dst_data) {
if (count && !(src_data == NULL && dst_data == NULL)) {
CLOG_WARN(&LOG, "null data for %s type (%p --> %p), skipping",
- layerType_getName(source->layers[src_i].type),
- (void *)src_data, (void *)dst_data);
+ layerType_getName(source->layers[src_i].type),
+ (void *)src_data, (void *)dst_data);
}
return;
}
@@ -3642,6 +3640,19 @@ bool CustomData_verify_versions(struct CustomData *data, int index)
{
keeplayer = false; /* multiple layers of which we only support one */
}
+ /* This is a pre-emptive fix for cases that should not happen (layers that should not be written
+ * in .blend files), but can happen due to bugs (see e.g. T62318).
+ * Also for forward compatibility, in future, we may put into .blend file some currently un-written data types,
+ * this should cover that case as well.
+ * Better to be safe here, and fix issue on the fly rather than crash... */
+ /* 0 structnum is used in writing code to tag layer types that should not be written. */
+ else if (typeInfo->structnum == 0 &&
+ /* XXX Not sure why those two are exception, maybe that should be fixed? */
+ !ELEM(layer->type, CD_PAINT_MASK, CD_FACEMAP))
+ {
+ keeplayer = false;
+ CLOG_WARN(&LOG, ".blend file read: removing a data layer that should not have been written");
+ }
}
if (!keeplayer) {
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 4c4d57ddbac..779128bfb3f 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -257,7 +257,7 @@ int BKE_object_data_transfer_dttype_to_srcdst_index(const int dtdata_type)
static void data_transfer_dtdata_type_preprocess(
Mesh *me_src, Mesh *me_dst,
- const int dtdata_type, const bool dirty_nors_dst, const bool is_modifier)
+ const int dtdata_type, const bool dirty_nors_dst)
{
if (dtdata_type == DT_TYPE_LNOR) {
/* Compute custom normals into regular loop normals, which will be used for the transfer. */
@@ -275,9 +275,10 @@ static void data_transfer_dtdata_type_preprocess(
const bool use_split_nors_dst = (me_dst->flag & ME_AUTOSMOOTH) != 0;
const float split_angle_dst = me_dst->smoothresh;
- if (!is_modifier) {
- BKE_mesh_calc_normals_split(me_src);
- }
+ /* This should be ensured by cddata_masks we pass to code generating/giving us me_src now. */
+ BLI_assert(CustomData_get_layer(&me_src->ldata, CD_NORMAL) != NULL);
+ BLI_assert(CustomData_get_layer(&me_src->pdata, CD_NORMAL) != NULL);
+ (void)me_src;
float (*poly_nors_dst)[3];
float (*loop_nors_dst)[3];
@@ -1121,6 +1122,8 @@ bool BKE_object_data_transfer_ex(
/* Get source evaluated mesh.*/
BKE_object_data_transfer_dttypes_to_cdmask(data_types, &me_src_mask);
+ BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(
+ map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode, &me_src_mask);
if (is_modifier) {
me_src = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_src, false);
@@ -1155,7 +1158,7 @@ bool BKE_object_data_transfer_ex(
continue;
}
- data_transfer_dtdata_type_preprocess(me_src, me_dst, dtdata_type, dirty_nors_dst, is_modifier);
+ data_transfer_dtdata_type_preprocess(me_src, me_dst, dtdata_type, dirty_nors_dst);
cddata_type = BKE_object_data_transfer_dttype_to_cdtype(dtdata_type);
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index daadc2e1fad..aedc301af92 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -98,7 +98,8 @@ static const float gaussianFactors[5] = {
0.596145f,
0.596145f,
0.596145f,
- 0.524141f};
+ 0.524141f,
+};
static const float gaussianTotal = 3.309425f;
/* UV Image neighboring pixel table x and y list */
@@ -231,6 +232,50 @@ typedef struct PaintAdjData {
int total_border; /* size of border */
} PaintAdjData;
+/************************* Runtime evaluation store ***************************/
+
+void dynamicPaint_Modifier_free_runtime(DynamicPaintRuntime *runtime_data)
+{
+ if (runtime_data == NULL) {
+ return;
+ }
+ if (runtime_data->canvas_mesh) {
+ BKE_id_free(NULL, runtime_data->canvas_mesh);
+ }
+ if (runtime_data->brush_mesh) {
+ BKE_id_free(NULL, runtime_data->brush_mesh);
+ }
+ MEM_freeN(runtime_data);
+}
+
+static DynamicPaintRuntime *dynamicPaint_Modifier_runtime_ensure(
+ DynamicPaintModifierData *pmd)
+{
+ if (pmd->modifier.runtime == NULL) {
+ pmd->modifier.runtime = MEM_callocN(
+ sizeof(DynamicPaintRuntime), "dynamic paint runtime");
+ }
+ return (DynamicPaintRuntime *)pmd->modifier.runtime;
+}
+
+static Mesh *dynamicPaint_canvas_mesh_get(DynamicPaintCanvasSettings *canvas)
+{
+ if (canvas->pmd->modifier.runtime == NULL) {
+ return NULL;
+ }
+ DynamicPaintRuntime *runtime_data = (DynamicPaintRuntime *)canvas->pmd->modifier.runtime;
+ return runtime_data->canvas_mesh;
+}
+
+static Mesh *dynamicPaint_brush_mesh_get(DynamicPaintBrushSettings *brush)
+{
+ if (brush->pmd->modifier.runtime == NULL) {
+ return NULL;
+ }
+ DynamicPaintRuntime *runtime_data = (DynamicPaintRuntime *)brush->pmd->modifier.runtime;
+ return runtime_data->brush_mesh;
+}
+
/***************************** General Utils ******************************/
/* Set canvas error string to display at the bake report */
@@ -249,7 +294,8 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
return 0; /* not supported atm */
}
else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
- return (surface->canvas->mesh) ? surface->canvas->mesh->totvert : 0;
+ const Mesh *canvas_mesh = dynamicPaint_canvas_mesh_get(surface->canvas);
+ return (canvas_mesh) ? canvas_mesh->totvert : 0;
}
return 0;
@@ -812,11 +858,6 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd)
{
if (pmd->brush) {
- if (pmd->brush->mesh) {
- BKE_id_free(NULL, pmd->brush->mesh);
- }
- pmd->brush->mesh = NULL;
-
if (pmd->brush->paint_ramp)
MEM_freeN(pmd->brush->paint_ramp);
if (pmd->brush->vel_ramp)
@@ -945,27 +986,22 @@ void dynamicPaint_freeCanvas(DynamicPaintModifierData *pmd)
surface = next_surface;
}
- /* free mesh copy */
- if (pmd->canvas->mesh) {
- BKE_id_free(NULL, pmd->canvas->mesh);
- }
- pmd->canvas->mesh = NULL;
-
MEM_freeN(pmd->canvas);
pmd->canvas = NULL;
}
}
/* Free whole dp modifier */
-void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd)
+void dynamicPaint_Modifier_free(DynamicPaintModifierData *pmd)
{
- if (pmd) {
- dynamicPaint_freeCanvas(pmd);
- dynamicPaint_freeBrush(pmd);
+ if (pmd == NULL) {
+ return;
}
+ dynamicPaint_freeCanvas(pmd);
+ dynamicPaint_freeBrush(pmd);
+ dynamicPaint_Modifier_free_runtime(pmd->modifier.runtime);
}
-
/***************************** Initialize and reset ******************************/
/*
@@ -1061,7 +1097,6 @@ bool dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, str
if (!canvas)
return false;
canvas->pmd = pmd;
- canvas->mesh = NULL;
/* Create one surface */
if (!dynamicPaint_createNewSurface(canvas, scene))
@@ -1101,8 +1136,6 @@ bool dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, str
brush->smudge_strength = 0.3f;
brush->max_velocity = 1.0f;
- brush->mesh = NULL;
-
/* Paint proximity falloff colorramp. */
{
CBData *ramp;
@@ -1299,7 +1332,7 @@ static bool surface_usesAdjData(DynamicPaintSurface *surface)
static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, const bool force_init)
{
PaintSurfaceData *sData = surface->data;
- Mesh *mesh = surface->canvas->mesh;
+ Mesh *mesh = dynamicPaint_canvas_mesh_get(surface->canvas);
PaintAdjData *ad;
int *temp_data;
int neigh_points = 0;
@@ -1533,7 +1566,7 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
{
PaintSurfaceData *sData = surface->data;
PaintPoint *pPoint = (PaintPoint *)sData->type_data;
- Mesh *mesh = surface->canvas->mesh;
+ Mesh *mesh = dynamicPaint_canvas_mesh_get(surface->canvas);
int i;
const bool scene_color_manage = BKE_scene_check_color_management_enabled(scene);
@@ -2032,10 +2065,11 @@ static Mesh *dynamicPaint_Modifier_apply(
}
/* make a copy of mesh to use as brush data */
if (pmd->brush) {
- if (pmd->brush->mesh) {
- BKE_id_free(NULL, pmd->brush->mesh);
+ DynamicPaintRuntime *runtime_data = dynamicPaint_Modifier_runtime_ensure(pmd);
+ if (runtime_data->brush_mesh != NULL) {
+ BKE_id_free(NULL, runtime_data->brush_mesh);
}
- pmd->brush->mesh = BKE_mesh_copy_for_eval(result, false);
+ runtime_data->brush_mesh = BKE_mesh_copy_for_eval(result, false);
}
return result;
@@ -2052,11 +2086,12 @@ void dynamicPaint_cacheUpdateFrames(DynamicPaintSurface *surface)
static void canvas_copyMesh(DynamicPaintCanvasSettings *canvas, Mesh *mesh)
{
- if (canvas->mesh) {
- BKE_id_free(NULL, canvas->mesh);
+ DynamicPaintRuntime *runtime = dynamicPaint_Modifier_runtime_ensure(canvas->pmd);
+ if (runtime->canvas_mesh != NULL) {
+ BKE_id_free(NULL, runtime->canvas_mesh);
}
- canvas->mesh = BKE_mesh_copy_for_eval(mesh, false);
+ runtime->canvas_mesh = BKE_mesh_copy_for_eval(mesh, false);
}
/*
@@ -2402,13 +2437,14 @@ static float dist_squared_to_looptri_uv_edges(const MLoopTri *mlooptri, const ML
for (int i = 0; i < 3; i++) {
const float dist_squared = dist_squared_to_line_segment_v2(
- point,
- mloopuv[mlooptri[tri_index].tri[(i + 0)]].uv,
- mloopuv[mlooptri[tri_index].tri[(i + 1) % 3]].uv
+ point,
+ mloopuv[mlooptri[tri_index].tri[(i + 0)]].uv,
+ mloopuv[mlooptri[tri_index].tri[(i + 1) % 3]].uv
);
- if (dist_squared < min_distance)
+ if (dist_squared < min_distance) {
min_distance = dist_squared;
+ }
}
return min_distance;
@@ -2768,7 +2804,7 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface, flo
PaintSurfaceData *sData;
DynamicPaintCanvasSettings *canvas = surface->canvas;
- Mesh *mesh = canvas->mesh;
+ Mesh *mesh = dynamicPaint_canvas_mesh_get(canvas);
PaintUVPoint *tempPoints = NULL;
Vec3f *tempWeights = NULL;
@@ -3677,7 +3713,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
BKE_object_modifier_update_subframe(
depsgraph, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
- mesh_p = BKE_mesh_copy_for_eval(brush->mesh, false);
+ mesh_p = BKE_mesh_copy_for_eval(dynamicPaint_brush_mesh_get(brush), false);
numOfVerts_p = mesh_p->totvert;
mvert_p = mesh_p->mvert;
copy_m4_m4(prev_obmat, ob->obmat);
@@ -3688,7 +3724,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
BKE_object_modifier_update_subframe(
depsgraph, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
- mesh_c = brush->mesh;
+ mesh_c = dynamicPaint_brush_mesh_get(brush);
numOfVerts_c = mesh_c->totvert;
mvert_c = mesh_c->mvert;
@@ -4122,8 +4158,10 @@ static int dynamicPaint_paintMesh(Depsgraph *depsgraph, DynamicPaintSurface *sur
if (brush->flags & MOD_DPAINT_USES_VELOCITY)
dynamicPaint_brushMeshCalculateVelocity(depsgraph, scene, brushOb, brush, &brushVelocity, timescale);
- if (!brush->mesh)
+ Mesh *brush_mesh = dynamicPaint_brush_mesh_get(brush);
+ if (brush_mesh == NULL) {
return 0;
+ }
{
BVHTreeFromMesh treeData = {NULL};
@@ -4134,7 +4172,7 @@ static int dynamicPaint_paintMesh(Depsgraph *depsgraph, DynamicPaintSurface *sur
Bounds3D mesh_bb = {{0}};
VolumeGrid *grid = bData->grid;
- mesh = BKE_mesh_copy_for_eval(brush->mesh, false);
+ mesh = BKE_mesh_copy_for_eval(brush_mesh, false);
mvert = mesh->mvert;
mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
mloop = mesh->mloop;
@@ -4236,7 +4274,7 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
const float timescale = data->timescale;
const int c_index = data->c_index;
- KDTree *tree = data->treeData;
+ KDTree_3d *tree = data->treeData;
const float solidradius = data->solidradius;
const float smooth = brush->particle_smooth * surface->radius_scale;
@@ -4254,11 +4292,11 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
* It's enough to just find the nearest one.
*/
{
- KDTreeNearest nearest;
+ KDTreeNearest_3d nearest;
float smooth_range, part_solidradius;
/* Find nearest particle and get distance to it */
- BLI_kdtree_find_nearest(tree, bData->realCoord[bData->s_pos[index]].v, &nearest);
+ 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)
return;
@@ -4290,7 +4328,7 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
* If we use per particle radius, we have to sample all particles
* within max radius range
*/
- KDTreeNearest *nearest;
+ KDTreeNearest_3d *nearest;
float smooth_range = smooth * (1.0f - strength), dist;
/* calculate max range that can have particles with higher influence than the nearest one */
@@ -4298,7 +4336,7 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
/* Make gcc happy! */
dist = max_range;
- const int particles = BLI_kdtree_range_search(
+ const int particles = BLI_kdtree_3d_range_search(
tree, bData->realCoord[bData->s_pos[index]].v, &nearest, max_range);
/* Find particle that produces highest influence */
@@ -4396,7 +4434,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
PaintBakeData *bData = sData->bData;
VolumeGrid *grid = bData->grid;
- KDTree *tree;
+ KDTree_3d *tree;
int particlesAdded = 0;
int invalidParticles = 0;
int p = 0;
@@ -4415,7 +4453,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
/*
* Build a kd-tree to optimize distance search
*/
- tree = BLI_kdtree_new(psys->totpart);
+ tree = BLI_kdtree_3d_new(psys->totpart);
/* loop through particles and insert valid ones to the tree */
p = 0;
@@ -4439,7 +4477,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
if (!boundIntersectPoint(&grid->grid_bounds, pa->state.co, range))
continue;
- BLI_kdtree_insert(tree, p, pa->state.co);
+ BLI_kdtree_3d_insert(tree, p, pa->state.co);
/* calc particle system bounds */
boundInsert(&part_bb, pa->state.co);
@@ -4451,7 +4489,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
/* If no suitable particles were found, exit */
if (particlesAdded < 1) {
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
return 1;
}
@@ -4464,7 +4502,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
int total_cells = grid->dim[0] * grid->dim[1] * grid->dim[2];
/* balance tree */
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
/* loop through space partitioning grid */
for (c_index = 0; c_index < total_cells; c_index++) {
@@ -4492,7 +4530,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
}
}
BLI_threaded_malloc_end();
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
return 1;
}
@@ -4603,7 +4641,8 @@ static int dynamicPaint_paintSinglePoint(
if (brush->flags & MOD_DPAINT_USES_VELOCITY)
dynamicPaint_brushObjectCalculateVelocity(depsgraph, scene, brushOb, &brushVel, timescale);
- const MVert *mvert = brush->mesh->mvert;
+ const Mesh *brush_mesh = dynamicPaint_brush_mesh_get(brush);
+ const MVert *mvert = brush_mesh->mvert;
/*
* Loop through every surface point
@@ -5622,7 +5661,7 @@ static bool dynamicPaint_surfaceHasMoved(DynamicPaintSurface *surface, Object *o
{
PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData;
- Mesh *mesh = surface->canvas->mesh;
+ Mesh *mesh = dynamicPaint_canvas_mesh_get(surface->canvas);
MVert *mvert = mesh->mvert;
int numOfVerts = mesh->totvert;
@@ -5770,7 +5809,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Depsgraph
{
PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData;
- Mesh *mesh = surface->canvas->mesh;
+ Mesh *mesh = dynamicPaint_canvas_mesh_get(surface->canvas);
int index;
bool new_bdata = false;
const bool do_velocity_data = ((surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) ||
@@ -6044,8 +6083,9 @@ int dynamicPaint_calculateFrame(
float timescale = 1.0f;
/* apply previous displace on derivedmesh if incremental surface */
- if (surface->flags & MOD_DPAINT_DISP_INCREMENTAL)
- dynamicPaint_applySurfaceDisplace(surface, surface->canvas->mesh);
+ if (surface->flags & MOD_DPAINT_DISP_INCREMENTAL) {
+ dynamicPaint_applySurfaceDisplace(surface, dynamicPaint_canvas_mesh_get(surface->canvas));
+ }
/* update bake data */
dynamicPaint_generateBakeData(surface, depsgraph, cObject);
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index d1ad7f10206..5628fce226c 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -618,7 +618,6 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
efd->size = 0.0f;
- /**/
ret = 1;
}
}
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index c9cb38fcc4e..2ef8568e308 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -374,6 +374,8 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
/* thickness parameter represents "thickness change", not absolute thickness */
gpl->thickness = 0;
gpl->opacity = 1.0f;
+ /* default channel color */
+ ARRAY_SET_ITEMS(gpl->color, 0.2f, 0.2f, 0.2f);
}
/* auto-name */
@@ -996,6 +998,134 @@ Material *BKE_gpencil_get_material_from_brush(Brush *brush)
return ma;
}
+void BKE_gpencil_brush_set_material(Brush *brush, Material *ma)
+{
+ BLI_assert(brush);
+ BLI_assert(brush->gpencil_settings);
+ if (brush->gpencil_settings->material != ma) {
+ if (brush->gpencil_settings->material) {
+ id_us_min(&brush->gpencil_settings->material->id);
+ }
+ if (ma) {
+ id_us_plus(&ma->id);
+ }
+ brush->gpencil_settings->material = ma;
+ }
+}
+
+/* Adds the pinned material to the object if necessary. */
+Material *BKE_gpencil_handle_brush_material(Main *bmain, Object *ob, Brush *brush)
+{
+ if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
+ Material *ma = BKE_gpencil_get_material_from_brush(brush);
+
+ /* check if the material is already on object material slots and add it if missing */
+ if (ma && BKE_gpencil_get_material_index(ob, ma) < 0) {
+ BKE_object_material_slot_add(bmain, ob);
+ assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
+ }
+
+ return ma;
+ }
+ else {
+ /* using active material instead */
+ return give_current_material(ob, ob->actcol);
+ }
+}
+
+/* Assigns the material to object (if not already present) and returns its index (mat_nr). */
+int BKE_gpencil_handle_material(Main *bmain, Object *ob, Material *material)
+{
+ if (!material) {
+ return -1;
+ }
+ int index = BKE_gpencil_get_material_index(ob, material);
+ if (index < 0) {
+ BKE_object_material_slot_add(bmain, ob);
+ assign_material(bmain, ob, material, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
+ return ob->totcol - 1;
+ }
+ return index;
+}
+
+/** Creates a new gpencil material and assigns it to object.
+ *
+ * \param *r_index: value is set to zero based index of the new material if r_index is not NULL
+ */
+Material *BKE_gpencil_handle_new_material(Main *bmain, Object *ob, const char *name, int *r_index)
+{
+ Material *ma = BKE_material_add_gpencil(bmain, name);
+ id_us_min(&ma->id); /* no users yet */
+
+ BKE_object_material_slot_add(bmain, ob);
+ assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
+
+ if (r_index) {
+ *r_index = ob->actcol - 1;
+ }
+ return ma;
+}
+
+/* Returns the material for a brush with respect to its pinned state. */
+Material *BKE_gpencil_get_material_for_brush(Object *ob, Brush *brush)
+{
+ if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
+ Material *ma = BKE_gpencil_get_material_from_brush(brush);
+ return ma;
+ }
+ else {
+ return give_current_material(ob, ob->actcol);
+ }
+}
+
+/* Returns the material index for a brush with respect to its pinned state. */
+int BKE_gpencil_get_material_index_for_brush(Object *ob, Brush *brush)
+{
+ if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
+ return BKE_gpencil_get_material_index(ob, brush->gpencil_settings->material);
+ }
+ else {
+ return ob->actcol - 1;
+ }
+}
+
+/* Guaranteed to return a material assigned to object. Returns never NULL. */
+Material *BKE_gpencil_current_input_toolsettings_material(Main *bmain, Object *ob, ToolSettings *ts)
+{
+ if (ts && ts->gp_paint && ts->gp_paint->paint.brush) {
+ return BKE_gpencil_current_input_brush_material(bmain, ob, ts->gp_paint->paint.brush);
+ }
+ else {
+ return BKE_gpencil_current_input_brush_material(bmain, ob, NULL);
+ }
+}
+
+/* Guaranteed to return a material assigned to object. Returns never NULL. */
+Material *BKE_gpencil_current_input_brush_material(Main *bmain, Object *ob, Brush *brush)
+{
+ if (brush) {
+ Material *ma = BKE_gpencil_handle_brush_material(bmain, ob, brush);
+ if (ma) {
+ return ma;
+ }
+ else if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
+ /* it is easier to just unpin a NULL material, instead of setting a new one */
+ brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
+ }
+ }
+ return BKE_gpencil_current_input_material(bmain, ob);
+}
+
+/* Guaranteed to return a material assigned to object. Returns never NULL. Only use this for materials unrelated to user input */
+Material *BKE_gpencil_current_input_material(Main *bmain, Object *ob)
+{
+ Material *ma = give_current_material(ob, ob->actcol);
+ if (ma) {
+ return ma;
+ }
+ return BKE_gpencil_handle_new_material(bmain, ob, "Material", NULL);
+}
+
/* Get active color, and add all default settings if we don't find anything */
Material *BKE_gpencil_material_ensure(Main *bmain, Object *ob)
{
@@ -1005,15 +1135,8 @@ Material *BKE_gpencil_material_ensure(Main *bmain, Object *ob)
if (ELEM(NULL, bmain, ob))
return NULL;
- ma = give_current_material(ob, ob->actcol);
- if (ma == NULL) {
- if (ob->totcol == 0) {
- BKE_object_material_slot_add(bmain, ob);
- }
- ma = BKE_material_add_gpencil(bmain, DATA_("Material"));
- assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
- }
- else if (ma->gp_style == NULL) {
+ ma = BKE_gpencil_current_input_material(bmain, ob);
+ if (ma->gp_style == NULL) {
BKE_material_init_gpencil_settings(ma);
}
@@ -1048,9 +1171,8 @@ bool BKE_gpencil_stroke_minmax(
}
/* get min/max bounds of all strokes in GP datablock */
-bool BKE_gpencil_data_minmax(Object *ob, const bGPdata *gpd, float r_min[3], float r_max[3])
+bool BKE_gpencil_data_minmax(const bGPdata *gpd, float r_min[3], float r_max[3])
{
- float bmat[3][3];
bool changed = false;
INIT_MINMAX(r_min, r_max);
@@ -1068,14 +1190,6 @@ bool BKE_gpencil_data_minmax(Object *ob, const bGPdata *gpd, float r_min[3], flo
}
}
- if ((changed) && (ob)) {
- copy_m3_m4(bmat, ob->obmat);
- mul_m3_v3(bmat, r_min);
- add_v3_v3(r_min, ob->obmat[3]);
- mul_m3_v3(bmat, r_max);
- add_v3_v3(r_max, ob->obmat[3]);
- }
-
return changed;
}
@@ -1097,7 +1211,7 @@ void BKE_gpencil_centroid_3d(bGPdata *gpd, float r_centroid[3])
{
float min[3], max[3], tot[3];
- BKE_gpencil_data_minmax(NULL, gpd, min, max);
+ BKE_gpencil_data_minmax(gpd, min, max);
add_v3_v3v3(tot, min, max);
mul_v3_v3fl(r_centroid, tot, 0.5f);
@@ -1118,7 +1232,11 @@ static void boundbox_gpencil(Object *ob)
bb = ob->runtime.bb;
gpd = ob->data;
- BKE_gpencil_data_minmax(NULL, gpd, min, max);
+ if (!BKE_gpencil_data_minmax(gpd, min, max)) {
+ min[0] = min[1] = min[2] = -1.0f;
+ max[0] = max[1] = max[2] = 1.0f;
+ }
+
BKE_boundbox_init_from_minmax(bb, min, max);
bb->flag &= ~BOUNDBOX_DIRTY;
@@ -1127,15 +1245,11 @@ static void boundbox_gpencil(Object *ob)
/* get bounding box */
BoundBox *BKE_gpencil_boundbox_get(Object *ob)
{
- bGPdata *gpd;
-
if (ELEM(NULL, ob, ob->data))
return NULL;
- gpd = ob->data;
- if ((ob->runtime.bb) && ((ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) &&
- ((gpd->flag & GP_DATA_CACHE_IS_DIRTY) == 0))
- {
+ bGPdata *gpd = (bGPdata *)ob->data;
+ if ((ob->runtime.bb) && ((gpd->flag & GP_DATA_CACHE_IS_DIRTY) == 0)) {
return ob->runtime.bb;
}
@@ -1547,7 +1661,7 @@ void BKE_gpencil_stats_update(bGPdata *gpd)
}
-/* get material index */
+/* get material index (0-based like mat_nr not actcol) */
int BKE_gpencil_get_material_index(Object *ob, Material *ma)
{
short *totcol = give_totcolp(ob);
@@ -1555,11 +1669,11 @@ int BKE_gpencil_get_material_index(Object *ob, Material *ma)
for (short i = 0; i < *totcol; i++) {
read_ma = give_current_material(ob, i + 1);
if (ma == read_ma) {
- return i + 1;
+ return i;
}
}
- return 0;
+ return -1;
}
/* Get points of stroke always flat to view not affected by camera view or view position */
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index bd83e93ef00..30bf30e2842 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -419,15 +419,18 @@ void BKE_gpencil_stroke_modifiers(Depsgraph *depsgraph, Object *ob, bGPDlayer *g
if (GPENCIL_MODIFIER_ACTIVE(md, is_render)) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
- if (GPENCIL_MODIFIER_EDIT(md, is_edit)) {
+ if ((GPENCIL_MODIFIER_EDIT(md, is_edit)) && (!is_render)) {
continue;
}
if (mti && mti->deformStroke) {
mti->deformStroke(md, depsgraph, ob, gpl, gps);
-
+ /* subdivide allways requires update */
+ if (md->type == eGpencilModifierType_Subdiv) {
+ gps->flag |= GP_STROKE_RECALC_GEOMETRY;
+ }
/* some modifiers could require a recalc of fill triangulation data */
- if (gpd->flag & GP_DATA_STROKE_FORCE_RECALC) {
+ else if (gpd->flag & GP_DATA_STROKE_FORCE_RECALC) {
if (ELEM(md->type,
eGpencilModifierType_Armature,
eGpencilModifierType_Hook,
@@ -454,7 +457,7 @@ void BKE_gpencil_geometry_modifiers(Depsgraph *depsgraph, Object *ob, bGPDlayer
if (GPENCIL_MODIFIER_ACTIVE(md, is_render)) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
- if (GPENCIL_MODIFIER_EDIT(md, is_edit)) {
+ if ((GPENCIL_MODIFIER_EDIT(md, is_edit)) && (!is_render)) {
continue;
}
@@ -478,7 +481,7 @@ int BKE_gpencil_time_modifier(Depsgraph *depsgraph, Scene *scene, Object *ob,
if (GPENCIL_MODIFIER_ACTIVE(md, is_render)) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
- if (GPENCIL_MODIFIER_EDIT(md, is_edit)) {
+ if ((GPENCIL_MODIFIER_EDIT(md, is_edit)) && (!is_render)) {
continue;
}
@@ -512,10 +515,10 @@ void BKE_gpencil_eval_geometry(Depsgraph *depsgraph,
* This would be better than inventing our own logic for this stuff...
*/
- /* TODO: Move the following code to "BKE_gpencil_eval_done()" (marked as an exit node)
- * later when there's more happening here. For now, let's just keep this in here to avoid
- * needing to have one more node slowing down evaluation...
- */
+ /* TODO: Move the following code to "BKE_gpencil_eval_done()" (marked as an exit node)
+ * later when there's more happening here. For now, let's just keep this in here to avoid
+ * needing to have one more node slowing down evaluation...
+ */
if (DEG_is_active(depsgraph)) {
bGPdata *gpd_orig = (bGPdata *)DEG_get_original_id(&gpd->id);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 177601c4746..b00e4cbcdd9 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -293,7 +293,7 @@ void BKE_image_free(Image *ima)
/* only image block itself */
static void image_init(Image *ima, short source, short type)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ima, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ima, id));
ima->ok = IMA_OK;
@@ -1259,6 +1259,8 @@ char BKE_imtype_from_arg(const char *imtype_arg)
else if (STREQ(imtype_arg, "TIFF")) return R_IMF_IMTYPE_TIFF;
#endif
#ifdef WITH_OPENEXR
+ else if (STREQ(imtype_arg, "OPEN_EXR")) return R_IMF_IMTYPE_OPENEXR;
+ else if (STREQ(imtype_arg, "OPEN_EXR_MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER;
else if (STREQ(imtype_arg, "EXR")) return R_IMF_IMTYPE_OPENEXR;
else if (STREQ(imtype_arg, "MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER;
#endif
@@ -2684,8 +2686,8 @@ static void image_walk_ntree_all_users(bNodeTree *ntree, void *customdata,
}
}
-void BKE_image_walk_id_all_users(ID *id, void *customdata,
- void callback(Image *ima, ImageUser *iuser, void *customdata))
+static void image_walk_id_all_users(ID *id, bool skip_nested_nodes, void *customdata,
+ void callback(Image *ima, ImageUser *iuser, void *customdata))
{
switch (GS(id->name)) {
case ID_OB:
@@ -2699,18 +2701,34 @@ void BKE_image_walk_id_all_users(ID *id, void *customdata,
case ID_MA:
{
Material *ma = (Material *)id;
- if (ma->nodetree && ma->use_nodes) {
+ if (ma->nodetree && ma->use_nodes && !skip_nested_nodes) {
image_walk_ntree_all_users(ma->nodetree, customdata, callback);
}
break;
}
+ case ID_LA:
+ {
+ Light *light = (Light *)id;
+ if (light->nodetree && light->use_nodes && !skip_nested_nodes) {
+ image_walk_ntree_all_users(light->nodetree, customdata, callback);
+ }
+ break;
+ }
+ case ID_WO:
+ {
+ World *world = (World *)id;
+ if (world->nodetree && world->use_nodes && !skip_nested_nodes) {
+ image_walk_ntree_all_users(world->nodetree, customdata, callback);
+ }
+ break;
+ }
case ID_TE:
{
Tex *tex = (Tex *)id;
if (tex->type == TEX_IMAGE && tex->ima) {
callback(tex->ima, &tex->iuser, customdata);
}
- if (tex->nodetree && tex->use_nodes) {
+ if (tex->nodetree && tex->use_nodes && !skip_nested_nodes) {
image_walk_ntree_all_users(tex->nodetree, customdata, callback);
}
break;
@@ -2747,7 +2765,7 @@ void BKE_image_walk_id_all_users(ID *id, void *customdata,
case ID_SCE:
{
Scene *scene = (Scene *)id;
- if (scene->nodetree && scene->use_nodes) {
+ if (scene->nodetree && scene->use_nodes && !skip_nested_nodes) {
image_walk_ntree_all_users(scene->nodetree, customdata, callback);
}
}
@@ -2760,31 +2778,39 @@ void BKE_image_walk_all_users(const Main *mainp, void *customdata,
void callback(Image *ima, ImageUser *iuser, void *customdata))
{
for (Scene *scene = mainp->scenes.first; scene; scene = scene->id.next) {
- BKE_image_walk_id_all_users(&scene->id, customdata, callback);
+ image_walk_id_all_users(&scene->id, false, customdata, callback);
}
for (Object *ob = mainp->objects.first; ob; ob = ob->id.next) {
- BKE_image_walk_id_all_users(&ob->id, customdata, callback);
+ image_walk_id_all_users(&ob->id, false, customdata, callback);
}
for (bNodeTree *ntree = mainp->nodetrees.first; ntree; ntree = ntree->id.next) {
- BKE_image_walk_id_all_users(&ntree->id, customdata, callback);
+ image_walk_id_all_users(&ntree->id, false, customdata, callback);
}
for (Material *ma = mainp->materials.first; ma; ma = ma->id.next) {
- BKE_image_walk_id_all_users(&ma->id, customdata, callback);
+ image_walk_id_all_users(&ma->id, false, customdata, callback);
+ }
+
+ for (Light *light = mainp->materials.first; light; light = light->id.next) {
+ image_walk_id_all_users(&light->id, false, customdata, callback);
+ }
+
+ for (World *world = mainp->materials.first; world; world = world->id.next) {
+ image_walk_id_all_users(&world->id, false, customdata, callback);
}
for (Tex *tex = mainp->textures.first; tex; tex = tex->id.next) {
- BKE_image_walk_id_all_users(&tex->id, customdata, callback);
+ image_walk_id_all_users(&tex->id, false, customdata, callback);
}
for (Camera *cam = mainp->cameras.first; cam; cam = cam->id.next) {
- BKE_image_walk_id_all_users(&cam->id, customdata, callback);
+ image_walk_id_all_users(&cam->id, false, customdata, callback);
}
for (wmWindowManager *wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
- BKE_image_walk_id_all_users(&wm->id, customdata, callback);
+ image_walk_id_all_users(&wm->id, false, customdata, callback);
}
}
@@ -3301,10 +3327,6 @@ static ImBuf *load_sequence_single(Image *ima, ImageUser *iuser, int frame, cons
int flag;
ImageUser iuser_t = {0};
- /* XXX temp stuff? */
- if (ima->lastframe != frame)
- ima->gpuflag |= IMA_GPU_REFRESH;
-
ima->lastframe = frame;
if (iuser) {
@@ -3317,7 +3339,7 @@ static ImBuf *load_sequence_single(Image *ima, ImageUser *iuser, int frame, cons
iuser_t.view = view_id;
BKE_image_user_file_path(&iuser_t, ima, name);
- flag = IB_rect | IB_multilayer;
+ flag = IB_rect | IB_multilayer | IB_metadata;
flag |= imbuf_alpha_flags_for_image(ima);
/* read ibuf */
@@ -4034,20 +4056,12 @@ static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_frame,
if (ima->source == IMA_SRC_MOVIE) {
frame = iuser ? iuser->framenr : ima->lastframe;
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, frame);
- /* XXX temp stuff? */
- if (ima->lastframe != frame)
- ima->gpuflag |= IMA_GPU_REFRESH;
ima->lastframe = frame;
}
else if (ima->source == IMA_SRC_SEQUENCE) {
if (ima->type == IMA_TYPE_IMAGE) {
frame = iuser ? iuser->framenr : ima->lastframe;
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, frame);
-
- /* XXX temp stuff? */
- if (ima->lastframe != frame) {
- ima->gpuflag |= IMA_GPU_REFRESH;
- }
ima->lastframe = frame;
/* counter the fact that image is set as invalid when loading a frame
@@ -4447,15 +4461,21 @@ void BKE_image_user_frame_calc(ImageUser *iuser, int cfra)
}
/* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
-static void image_editors_update_frame(struct Image *UNUSED(ima), struct ImageUser *iuser, void *customdata)
+static void image_editors_update_frame(struct Image *ima, struct ImageUser *iuser, void *customdata)
{
int cfra = *(int *)customdata;
if ((iuser->flag & IMA_ANIM_ALWAYS) ||
(iuser->flag & IMA_NEED_FRAME_RECALC))
{
+ int framenr = iuser->framenr;
+
BKE_image_user_frame_calc(iuser, cfra);
iuser->flag &= ~IMA_NEED_FRAME_RECALC;
+
+ if (ima && iuser->framenr != framenr) {
+ ima->gpuflag |= IMA_GPU_REFRESH;
+ }
}
}
@@ -4464,7 +4484,7 @@ void BKE_image_editors_update_frame(const Main *bmain, int cfra)
/* This only updates images used by the user interface. For others the
* dependency graph will call BKE_image_user_id_eval_animation. */
wmWindowManager *wm = bmain->wm.first;
- BKE_image_walk_id_all_users(&wm->id, &cfra, image_editors_update_frame);
+ image_walk_id_all_users(&wm->id, false, &cfra, image_editors_update_frame);
}
static void image_user_id_has_animation(struct Image *ima, struct ImageUser *UNUSED(iuser), void *customdata)
@@ -4476,8 +4496,11 @@ static void image_user_id_has_animation(struct Image *ima, struct ImageUser *UNU
bool BKE_image_user_id_has_animation(ID *id)
{
+ /* For the dependency graph, this does not consider nested node
+ * trees as these are handled as their own datablock. */
bool has_animation = false;
- BKE_image_walk_id_all_users(id, &has_animation, image_user_id_has_animation);
+ bool skip_nested_nodes = true;
+ image_walk_id_all_users(id, skip_nested_nodes, &has_animation, image_user_id_has_animation);
return has_animation;
}
@@ -4510,8 +4533,11 @@ void BKE_image_user_id_eval_animation(Depsgraph *depsgraph, ID *id)
{
/* This is called from the dependency graph to update the image
* users in datablocks. It computes the current frame number
- * and tags the image to be refreshed. */
- BKE_image_walk_id_all_users(id, depsgraph, image_user_id_eval_animation);
+ * and tags the image to be refreshed.
+ * This does not consider nested node trees as these are handled
+ * as their own datablock. */
+ bool skip_nested_nodes = true;
+ image_walk_id_all_users(id, skip_nested_nodes, depsgraph, image_user_id_eval_animation);
}
void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath)
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index b3d1b71b1bd..f8ccddbe691 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -242,7 +242,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
void BKE_lattice_init(Lattice *lt)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(lt, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(lt, id));
lt->flag = LT_GRID;
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index a5360f34312..7fc1d9e14ae 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -35,6 +35,7 @@
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_object.h"
+#include "BKE_scene.h"
#include "DNA_ID.h"
#include "DNA_space_types.h"
@@ -95,6 +96,7 @@ static Base *object_base_new(Object *ob)
{
Base *base = MEM_callocN(sizeof(Base), "Object Base");
base->object = ob;
+ BKE_scene_object_base_flag_sync_from_object(base);
return base;
}
@@ -1443,23 +1445,35 @@ void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *UNUSED(iter))
/* Evaluation */
/* Applies object's restrict flags on top of flags coming from the collection
- * and stores those in base->flag. */
+ * and stores those in base->flag. BASE_VISIBLE is based on viewport visibility. */
void BKE_base_eval_flags(Base *base)
{
- const int object_restrict = base->object->restrictflag;
+ /* Apply collection flags. */
base->flag &= ~g_base_collection_flags;
base->flag |= (base->flag_from_collection & g_base_collection_flags);
+
+ /* Apply object restrictions. */
+ const int object_restrict = base->object->restrictflag;
if (object_restrict & OB_RESTRICT_VIEW) {
- base->flag &= ~(BASE_ENABLED_VIEWPORT | BASE_SELECTABLE);
+ base->flag &= ~BASE_ENABLED_VIEWPORT;
+ }
+ if (object_restrict & OB_RESTRICT_RENDER) {
+ base->flag &= ~BASE_ENABLED_RENDER;
}
if (object_restrict & OB_RESTRICT_SELECT) {
base->flag &= ~BASE_SELECTABLE;
}
- if (object_restrict & OB_RESTRICT_RENDER) {
- base->flag &= ~BASE_ENABLED_RENDER;
+
+ /* Apply viewport visibility by default. The dependency graph for render
+ * can change these again, but for tools we always want the viewport
+ * visibility to be in sync regardless if depsgraph was evaluated. */
+ if (!(base->flag & BASE_ENABLED_VIEWPORT) || (base->flag & BASE_HIDDEN)) {
+ base->flag &= ~(BASE_VISIBLE | BASE_SELECTABLE);
}
- if (base->flag & BASE_HIDDEN) {
- base->flag &= ~BASE_VISIBLE;
+
+ /* Deselect unselectable objects. */
+ if (!(base->flag & BASE_SELECTABLE)) {
+ base->flag &= ~BASE_SELECTED;
}
}
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 2db67939d42..517ecd78558 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -515,7 +515,7 @@ static int id_copy_libmanagement_cb(void *user_data, ID *UNUSED(id_self), ID **i
bool BKE_id_copy_is_allowed(const ID *id)
{
-#define LIB_ID_TYPES_NOCOPY ID_LI, ID_SCR, ID_WM, /* Not supported */ \
+#define LIB_ID_TYPES_NOCOPY ID_LI, ID_SCR, ID_WM, ID_WS, /* Not supported */ \
ID_IP /* Deprecated */
return !ELEM(GS(id->name), LIB_ID_TYPES_NOCOPY);
@@ -770,9 +770,8 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
/* if property isn't editable, we're going to have an extra block hanging around until we save */
if (RNA_property_editable(ptr, prop)) {
Main *bmain = CTX_data_main(C);
- if (BKE_id_copy(bmain, id, &newid) && newid) {
- /* copy animation actions too */
- BKE_animdata_copy_id_action(bmain, id, false);
+ /* copy animation actions too */
+ if (BKE_id_copy_ex(bmain, id, &newid, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS) && newid) {
/* us is 1 by convention with new IDs, but RNA_property_pointer_set
* will also increment it, decrement it here. */
id_us_min(newid);
@@ -1969,7 +1968,7 @@ void BKE_library_make_local(
* relationship), se we tag it to be fully recomputed, but this does not seems to be enough in some cases,
* and evaluation code ends up trying to evaluate a not-yet-updated armature object's deformations.
* Try "make all local" in 04_01_H.lighting.blend from Agent327 without this, e.g. */
- /* Also, use this object loop to we handle rigid body resetting. */
+ /* Also, we use this object loop to handle rigid body resetting. */
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->data != NULL && ob->type == OB_ARMATURE && ob->pose != NULL && ob->pose->flag & POSE_RECALC) {
BKE_pose_rebuild(bmain, ob, ob->data, true);
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 267699b67c1..453cbe16de0 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -1204,9 +1204,9 @@ static int foreach_libblock_id_users_callback(void *user_data, ID *UNUSED(self_i
if (*id_p == iter->id) {
#if 0
printf("%s uses %s (refcounted: %d, userone: %d, used_one: %d, used_one_active: %d, indirect_usage: %d)\n",
- iter->curr_id->name, iter->id->name, (cb_flag & IDWALK_USER) ? 1 : 0, (cb_flag & IDWALK_USER_ONE) ? 1 : 0,
- (iter->id->tag & LIB_TAG_EXTRAUSER) ? 1 : 0, (iter->id->tag & LIB_TAG_EXTRAUSER_SET) ? 1 : 0,
- (cb_flag & IDWALK_INDIRECT_USAGE) ? 1 : 0);
+ iter->curr_id->name, iter->id->name, (cb_flag & IDWALK_USER) ? 1 : 0, (cb_flag & IDWALK_USER_ONE) ? 1 : 0,
+ (iter->id->tag & LIB_TAG_EXTRAUSER) ? 1 : 0, (iter->id->tag & LIB_TAG_EXTRAUSER_SET) ? 1 : 0,
+ (cb_flag & IDWALK_INDIRECT_USAGE) ? 1 : 0);
#endif
if (cb_flag & IDWALK_CB_INDIRECT_USAGE) {
iter->count_indirect++;
@@ -1331,20 +1331,14 @@ void BKE_library_ID_test_usages(Main *bmain, void *idv, bool *is_used_local, boo
/* ***** IDs usages.checking/tagging. ***** */
static int foreach_libblock_used_linked_data_tag_clear_cb(
- void *user_data, ID *self_id, ID **id_p, int UNUSED(cb_flag))
+ void *user_data, ID *self_id, ID **id_p, int cb_flag)
{
bool *is_changed = user_data;
if (*id_p) {
- /* XXX This is actually some kind of hack...
- * Issue is, shapekeys' 'from' ID pointer is not actually ID usage.
- * Maybe we should even nuke it from BKE_library_foreach_ID_link, not 100% sure yet...
- */
- if ((GS(self_id->name) == ID_KE) && (((Key *)self_id)->from == *id_p)) {
- return IDWALK_RET_NOP;
- }
- /* XXX another hack, for similar reasons as above one. */
- if ((GS(self_id->name) == ID_OB) && (((Object *)self_id)->proxy_from == (Object *)*id_p)) {
+ /* The infamous 'from' pointers (Key.from, Object.proxy_from, ...).
+ * those are not actually ID usage, so we ignore them here. */
+ if (cb_flag & IDWALK_CB_LOOPBACK) {
return IDWALK_RET_NOP;
}
@@ -1384,19 +1378,16 @@ void BKE_library_unused_linked_data_set_tag(Main *bmain, const bool do_init_tag)
}
for (bool do_loop = true; do_loop; ) {
- bool do_break = false;
do_loop = false;
- FOREACH_MAIN_ID_BREAKABLE_BEGIN(bmain, id, do_break)
+ 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(
bmain, id, foreach_libblock_used_linked_data_tag_clear_cb, &do_loop, IDWALK_READONLY);
}
- /* Else it is an unused ID (so far), no need to check it further. */
- do_break = true;
- break;
}
- FOREACH_MAIN_ID_BREAKABLE_END;
+ FOREACH_MAIN_ID_END;
}
}
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 04ccdc729da..1f46286b831 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -833,7 +833,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
* \param flag: Set of \a LIB_ID_FREE_... flags controlling/overriding usual freeing process,
* 0 to get default safe behavior.
* \param use_flag_from_idtag: Still use freeing info flags from given ID datablock,
- * even if some overriding ones are passed in \a falg parameter.
+ * even if some overriding ones are passed in \a flag parameter.
*/
void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_idtag)
{
@@ -1001,7 +1001,9 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
if ((id->tag & tag) || (id->lib != NULL && (id->lib->id.tag & tag))) {
BLI_remlink(lb, id);
BLI_addtail(&tagged_deleted_ids, id);
- id->tag |= tag | LIB_TAG_NO_MAIN;
+ /* Do not tag as no_main now, we want to unlink it first (lower-level ID management code
+ * has some specific handling of 'nom main' IDs that would be a problem in that case). */
+ id->tag |= tag;
keep_looping = true;
}
}
@@ -1021,6 +1023,8 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
ID_REMAP_FLAG_NEVER_NULL_USAGE | ID_REMAP_FORCE_NEVER_NULL_USAGE);
/* Since we removed ID from Main, we also need to unlink its own other IDs usages ourself. */
BKE_libblock_relink_ex(bmain, id, NULL, NULL, true);
+ /* Now we can safely mark that ID as not being in Main database anymore. */
+ id->tag |= LIB_TAG_NO_MAIN;
/* This is needed because we may not have remapped usages of that ID by other deleted ones. */
// id->us = 0; /* Is it actually? */
}
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index b1ec5ba6954..ae68182c55a 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -46,7 +46,7 @@
void BKE_light_init(Light *la)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(la, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(la, id));
la->r = la->g = la->b = la->k = 1.0f;
la->energy = 10.0f;
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index 1d46f1aa5d3..12568c9aa2a 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -33,7 +33,7 @@
void BKE_lightprobe_init(LightProbe *probe)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(probe, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(probe, id));
probe->grid_resolution_x = probe->grid_resolution_y = probe->grid_resolution_z = 4;
probe->distinf = 2.5f;
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 4ec9755bec8..47201d30b63 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -74,7 +74,7 @@ static const char *modifier_name[LS_MODIFIER_NUM] = {
void BKE_linestyle_init(FreestyleLineStyle *linestyle)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(linestyle, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(linestyle, id));
linestyle->panel = LS_PANEL_STROKES;
linestyle->r = linestyle->g = linestyle->b = 0.0f;
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index d821052f2f4..52e7c687694 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -127,7 +127,7 @@ void BKE_material_init_gpencil_settings(Material *ma)
void BKE_material_init(Material *ma)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ma, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ma, id));
ma->r = ma->g = ma->b = 0.8;
ma->specr = ma->specg = ma->specb = 1.0;
@@ -142,6 +142,7 @@ void BKE_material_init(Material *ma)
ma->alpha_threshold = 0.5f;
+ ma->blend_shadow = MA_BS_SOLID;
}
Material *BKE_material_add(Main *bmain, const char *name)
@@ -164,7 +165,6 @@ Material *BKE_material_add_gpencil(Main *bmain, const char *name)
/* grease pencil settings */
if (ma != NULL) {
BKE_material_init_gpencil_settings(ma);
- BKE_brush_update_material(bmain, ma, NULL);
}
return ma;
}
@@ -1038,7 +1038,7 @@ static int count_texture_nodes_recursive(bNodeTree *nodetree)
if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
tex_nodes++;
}
- else if (node->type == NODE_GROUP && node->id) {
+ else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) {
/* recurse into the node group and see if it contains any textures */
tex_nodes += count_texture_nodes_recursive((bNodeTree *)node->id);
}
@@ -1073,7 +1073,7 @@ static void fill_texpaint_slots_recursive(bNodeTree *nodetree, bNode *active_nod
}
(*index)++;
}
- else if (node->type == NODE_GROUP && node->id) {
+ else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) {
/* recurse into the node group and see if it contains any textures */
fill_texpaint_slots_recursive((bNodeTree *)node->id, active_node, ma, index);
}
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index ae5cbcc4f49..6a28c341fac 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -75,7 +75,7 @@ void BKE_mball_free(MetaBall *mb)
void BKE_mball_init(MetaBall *mb)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(mb, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(mb, id));
mb->size[0] = mb->size[1] = mb->size[2] = 1.0;
mb->texflag = MB_AUTOSPACE;
@@ -331,10 +331,10 @@ bool BKE_mball_is_any_selected(const MetaBall *mb)
}
-bool BKE_mball_is_any_selected_multi(Object **objects, int objects_len)
+bool BKE_mball_is_any_selected_multi(Base **bases, int bases_len)
{
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
MetaBall *mb = (MetaBall *)obedit->data;
if (BKE_mball_is_any_selected(mb)) {
return true;
@@ -559,64 +559,83 @@ int BKE_mball_select_count(const MetaBall *mb)
return sel;
}
-int BKE_mball_select_count_multi(Object **objects, int objects_len)
+int BKE_mball_select_count_multi(Base **bases, int bases_len)
{
int sel = 0;
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- const Object *obedit = objects[ob_index];
+ for (uint ob_index = 0; ob_index < bases_len; ob_index++) {
+ const Object *obedit = bases[ob_index]->object;
const MetaBall *mb = (MetaBall *)obedit->data;
sel += BKE_mball_select_count(mb);
}
return sel;
}
-void BKE_mball_select_all(MetaBall *mb)
+bool BKE_mball_select_all(MetaBall *mb)
{
+ bool changed = false;
for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
- ml->flag |= SELECT;
+ if ((ml->flag & SELECT) == 0) {
+ ml->flag |= SELECT;
+ changed = true;
+ }
}
+ return changed;
}
-void BKE_mball_select_all_multi(Object **objects, int objects_len)
+bool BKE_mball_select_all_multi_ex(Base **bases, int bases_len)
{
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ bool changed_multi = false;
+ for (uint ob_index = 0; ob_index < bases_len; ob_index++) {
+ Object *obedit = bases[ob_index]->object;
MetaBall *mb = obedit->data;
- BKE_mball_select_all(mb);
+ changed_multi |= BKE_mball_select_all(mb);
}
+ return changed_multi;
}
-void BKE_mball_deselect_all(MetaBall *mb)
+bool BKE_mball_deselect_all(MetaBall *mb)
{
+ bool changed = false;
for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
- ml->flag &= ~SELECT;
+ if ((ml->flag & SELECT) != 0) {
+ ml->flag &= ~SELECT;
+ changed = true;
+ }
}
+ return changed;
}
-void BKE_mball_deselect_all_multi(Object **objects, int objects_len)
+bool BKE_mball_deselect_all_multi_ex(Base **bases, int bases_len)
{
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ bool changed_multi = false;
+ for (uint ob_index = 0; ob_index < bases_len; ob_index++) {
+ Object *obedit = bases[ob_index]->object;
MetaBall *mb = obedit->data;
-
- BKE_mball_deselect_all(mb);
+ changed_multi |= BKE_mball_deselect_all(mb);
+ DEG_id_tag_update(&mb->id, ID_RECALC_SELECT);
}
+ return changed_multi;
}
-void BKE_mball_select_swap(MetaBall *mb)
+bool BKE_mball_select_swap(MetaBall *mb)
{
+ bool changed = false;
for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
ml->flag ^= SELECT;
+ changed = true;
}
+ return changed;
}
-void BKE_mball_select_swap_multi(Object **objects, int objects_len)
+bool BKE_mball_select_swap_multi_ex(Base **bases, int bases_len)
{
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ bool changed_multi = false;
+ for (uint ob_index = 0; ob_index < bases_len; ob_index++) {
+ Object *obedit = bases[ob_index]->object;
MetaBall *mb = (MetaBall *)obedit->data;
- BKE_mball_select_swap(mb);
+ changed_multi |= BKE_mball_select_swap(mb);
}
+ return changed_multi;
}
/* **** Depsgraph evaluation **** */
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 592f3a26a12..449c2f86b04 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -492,7 +492,7 @@ static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata)
void BKE_mesh_init(Mesh *me)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(me, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(me, id));
me->size[0] = me->size[1] = me->size[2] = 1.0;
me->smoothresh = DEG2RADF(30);
@@ -584,18 +584,6 @@ static void mesh_ensure_cdlayers_primary(Mesh *mesh, bool do_tessface)
if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_MFACE))
CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_CALLOC, NULL, mesh->totface);
}
-static void mesh_ensure_cdlayers_origindex(Mesh *mesh, bool do_tessface)
-{
- if (!CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))
- CustomData_add_layer(&mesh->vdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totvert);
- if (!CustomData_get_layer(&mesh->edata, CD_ORIGINDEX))
- CustomData_add_layer(&mesh->edata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totedge);
- if (!CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX))
- CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totpoly);
-
- if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX))
- CustomData_add_layer(&mesh->fdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totface);
-}
Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
{
@@ -619,7 +607,6 @@ Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int lo
mesh->totpoly = polys_len;
mesh_ensure_cdlayers_primary(mesh, true);
- mesh_ensure_cdlayers_origindex(mesh, true);
BKE_mesh_update_customdata_pointers(mesh, false);
return mesh;
@@ -662,7 +649,6 @@ static Mesh *mesh_new_nomain_from_template_ex(
/* The destination mesh should at least have valid primary CD layers,
* even in cases where the source mesh does not. */
mesh_ensure_cdlayers_primary(me_dst, do_tessface);
- mesh_ensure_cdlayers_origindex(me_dst, false);
BKE_mesh_update_customdata_pointers(me_dst, false);
return me_dst;
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 83a20758ab3..664698afa38 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -592,7 +592,7 @@ void BKE_mesh_from_nurbs_displist(
else {
me = BKE_mesh_add(bmain, obdata_name);
ob->runtime.mesh_eval = NULL;
- BKE_mesh_nomain_to_mesh(me_eval, me, ob, &CD_MASK_MESH, false);
+ BKE_mesh_nomain_to_mesh(me_eval, me, ob, &CD_MASK_MESH, true);
}
me->totcol = cu->totcol;
@@ -837,7 +837,25 @@ void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *UNUSED(scene),
}
}
-/* settings: 1 - preview, 2 - render */
+/* settings: 1 - preview, 2 - render
+ *
+ * The convention goes as following:
+ *
+ * - Passing original object with apply_modifiers=false will give a
+ * non-modified non-deformed mesh.
+ * The result mesh will point to datablocks from the original "domain". For
+ * example, materials will be original.
+ *
+ * - Passing original object with apply_modifiers=true will give a mesh which
+ * has all modifiers applied.
+ * The result mesh will point to datablocks from the original "domain". For
+ * example, materials will be original.
+ *
+ * - Passing evaluated object will ignore apply_modifiers argument, and the
+ * result always contains all modifiers applied.
+ * The result mesh will point to an evaluated datablocks. For example,
+ * materials will be an evaluated IDs from the dependency graph.
+ */
Mesh *BKE_mesh_new_from_object(
Depsgraph *depsgraph, Main *bmain, Scene *sce, Object *ob,
const bool apply_modifiers, const bool calc_undeformed)
@@ -846,11 +864,37 @@ Mesh *BKE_mesh_new_from_object(
Curve *tmpcu = NULL, *copycu;
int i;
const bool render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
- const bool cage = !apply_modifiers;
+ bool effective_apply_modifiers = apply_modifiers;
bool do_mat_id_data_us = true;
+ Object *object_input = ob;
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, object_input);
+ Object object_for_eval = *object_eval;
+
+ if (object_eval == object_input) {
+ /* Evaluated mesh contains all modifiers applied already.
+ * The other types of object has them applied, but are stored in other
+ * data structures than a mesh. So need to apply modifiers again on a
+ * temporary copy before converting result to mesh. */
+ if (object_for_eval.type == OB_MESH) {
+ effective_apply_modifiers = false;
+ }
+ else {
+ effective_apply_modifiers = true;
+ }
+ }
+ else {
+ if (apply_modifiers) {
+ if (object_for_eval.runtime.mesh_orig != NULL) {
+ object_for_eval.data = object_for_eval.runtime.mesh_orig;
+ }
+ }
+ }
+
+ const bool cage = !effective_apply_modifiers;
+
/* perform the mesh extraction based on type */
- switch (ob->type) {
+ switch (object_for_eval.type) {
case OB_FONT:
case OB_CURVE:
case OB_SURF:
@@ -861,7 +905,7 @@ Mesh *BKE_mesh_new_from_object(
/* copies object and modifiers (but not the data) */
Object *tmpobj;
- BKE_id_copy_ex(NULL, &ob->id, (ID **)&tmpobj, LIB_ID_COPY_LOCALIZE);
+ BKE_id_copy_ex(NULL, &object_for_eval.id, (ID **)&tmpobj, LIB_ID_COPY_LOCALIZE);
tmpcu = (Curve *)tmpobj->data;
/* Copy cached display list, it might be needed by the stack evaluation.
@@ -870,11 +914,11 @@ Mesh *BKE_mesh_new_from_object(
*
* TODO(sergey): Look into more proper solution.
*/
- if (ob->runtime.curve_cache != NULL) {
+ if (object_for_eval.runtime.curve_cache != NULL) {
if (tmpobj->runtime.curve_cache == NULL) {
tmpobj->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for curve types");
}
- BKE_displist_copy(&tmpobj->runtime.curve_cache->disp, &ob->runtime.curve_cache->disp);
+ BKE_displist_copy(&tmpobj->runtime.curve_cache->disp, &object_for_eval.runtime.curve_cache->disp);
}
/* if getting the original caged mesh, delete object modifiers */
@@ -882,7 +926,7 @@ Mesh *BKE_mesh_new_from_object(
BKE_object_free_modifiers(tmpobj, LIB_ID_CREATE_NO_USER_REFCOUNT);
/* copies the data, but *not* the shapekeys. */
- BKE_id_copy_ex(NULL, ob->data, (ID **)&copycu, LIB_ID_COPY_LOCALIZE);
+ BKE_id_copy_ex(NULL, object_for_eval.data, (ID **)&copycu, LIB_ID_COPY_LOCALIZE);
tmpobj->data = copycu;
/* make sure texture space is calculated for a copy of curve,
@@ -938,32 +982,34 @@ Mesh *BKE_mesh_new_from_object(
case OB_MBALL:
{
/* metaballs don't have modifiers, so just convert to mesh */
- Object *basis_ob = BKE_mball_basis_find(sce, ob);
+ Object *basis_ob = BKE_mball_basis_find(sce, object_input);
/* todo, re-generatre for render-res */
/* metaball_polygonize(scene, ob) */
- if (ob != basis_ob)
- return NULL; /* only do basis metaball */
+ if (basis_ob != object_input) {
+ /* Only do basis metaball. */
+ return NULL;
+ }
- tmpmesh = BKE_mesh_add(bmain, ((ID *)ob->data)->name + 2);
+ tmpmesh = BKE_mesh_add(bmain, ((ID *)object_for_eval.data)->name + 2);
/* BKE_mesh_add gives us a user count we don't need */
id_us_min(&tmpmesh->id);
if (render) {
ListBase disp = {NULL, NULL};
- BKE_displist_make_mball_forRender(depsgraph, sce, ob, &disp);
+ BKE_displist_make_mball_forRender(depsgraph, sce, &object_for_eval, &disp);
BKE_mesh_from_metaball(&disp, tmpmesh);
BKE_displist_free(&disp);
}
else {
ListBase disp = {NULL, NULL};
- if (ob->runtime.curve_cache) {
- disp = ob->runtime.curve_cache->disp;
+ if (object_for_eval.runtime.curve_cache) {
+ disp = object_for_eval.runtime.curve_cache->disp;
}
BKE_mesh_from_metaball(&disp, tmpmesh);
}
- BKE_mesh_texspace_copy_from_object(tmpmesh, ob);
+ BKE_mesh_texspace_copy_from_object(tmpmesh, &object_for_eval);
break;
@@ -972,7 +1018,7 @@ Mesh *BKE_mesh_new_from_object(
/* copies object and modifiers (but not the data) */
if (cage) {
/* copies the data (but *not* the shapekeys). */
- Mesh *mesh = ob->data;
+ Mesh *mesh = object_for_eval.data;
BKE_id_copy_ex(bmain, &mesh->id, (ID **)&tmpmesh, 0);
/* XXX BKE_mesh_copy() already handles materials usercount. */
do_mat_id_data_us = false;
@@ -982,24 +1028,24 @@ Mesh *BKE_mesh_new_from_object(
/* Make a dummy mesh, saves copying */
Mesh *me_eval;
CustomData_MeshMasks mask = CD_MASK_MESH; /* this seems more suitable, exporter,
- * for example, needs CD_MASK_MDEFORMVERT */
+ * for example, needs CD_MASK_MDEFORMVERT */
if (calc_undeformed) {
mask.vmask |= CD_MASK_ORCO;
}
if (render) {
- me_eval = mesh_create_eval_final_render(depsgraph, sce, ob, &mask);
+ me_eval = mesh_create_eval_final_render(depsgraph, sce, &object_for_eval, &mask);
}
else {
- me_eval = mesh_create_eval_final_view(depsgraph, sce, ob, &mask);
+ me_eval = mesh_create_eval_final_view(depsgraph, sce, &object_for_eval, &mask);
}
- tmpmesh = BKE_mesh_add(bmain, ((ID *)ob->data)->name + 2);
- BKE_mesh_nomain_to_mesh(me_eval, tmpmesh, ob, &mask, true);
+ tmpmesh = BKE_mesh_add(bmain, ((ID *)object_for_eval.data)->name + 2);
+ BKE_mesh_nomain_to_mesh(me_eval, tmpmesh, &object_for_eval, &mask, true);
/* Copy autosmooth settings from original mesh. */
- Mesh *me = (Mesh *)ob->data;
+ Mesh *me = (Mesh *)object_for_eval.data;
tmpmesh->flag |= (me->flag & ME_AUTOSMOOTH);
tmpmesh->smoothresh = me->smoothresh;
}
@@ -1014,7 +1060,7 @@ Mesh *BKE_mesh_new_from_object(
}
/* Copy materials to new mesh */
- switch (ob->type) {
+ switch (object_for_eval.type) {
case OB_SURF:
case OB_FONT:
case OB_CURVE:
@@ -1024,9 +1070,9 @@ Mesh *BKE_mesh_new_from_object(
if (tmpcu->mat) {
for (i = tmpcu->totcol; i-- > 0; ) {
/* are we an object material or data based? */
- tmpmesh->mat[i] = give_current_material(ob, i + 1);
+ tmpmesh->mat[i] = give_current_material(object_input, i + 1);
- if (((ob->matbits && ob->matbits[i]) || do_mat_id_data_us) && tmpmesh->mat[i]) {
+ if (((object_for_eval.matbits && object_for_eval.matbits[i]) || do_mat_id_data_us) && tmpmesh->mat[i]) {
id_us_plus(&tmpmesh->mat[i]->id);
}
}
@@ -1035,7 +1081,7 @@ Mesh *BKE_mesh_new_from_object(
case OB_MBALL:
{
- MetaBall *tmpmb = (MetaBall *)ob->data;
+ MetaBall *tmpmb = (MetaBall *)object_for_eval.data;
tmpmesh->mat = MEM_dupallocN(tmpmb->mat);
tmpmesh->totcol = tmpmb->totcol;
@@ -1043,9 +1089,9 @@ Mesh *BKE_mesh_new_from_object(
if (tmpmb->mat) {
for (i = tmpmb->totcol; i-- > 0; ) {
/* are we an object material or data based? */
- tmpmesh->mat[i] = give_current_material(ob, i + 1);
+ tmpmesh->mat[i] = give_current_material(object_input, i + 1);
- if (((ob->matbits && ob->matbits[i]) || do_mat_id_data_us) && tmpmesh->mat[i]) {
+ if (((object_for_eval.matbits && object_for_eval.matbits[i]) || do_mat_id_data_us) && tmpmesh->mat[i]) {
id_us_plus(&tmpmesh->mat[i]->id);
}
}
@@ -1055,7 +1101,7 @@ Mesh *BKE_mesh_new_from_object(
case OB_MESH:
if (!cage) {
- Mesh *origmesh = ob->data;
+ Mesh *origmesh = object_for_eval.data;
tmpmesh->flag = origmesh->flag;
tmpmesh->mat = MEM_dupallocN(origmesh->mat);
tmpmesh->totcol = origmesh->totcol;
@@ -1063,9 +1109,9 @@ Mesh *BKE_mesh_new_from_object(
if (origmesh->mat) {
for (i = origmesh->totcol; i-- > 0; ) {
/* are we an object material or data based? */
- tmpmesh->mat[i] = give_current_material(ob, i + 1);
+ tmpmesh->mat[i] = give_current_material(object_input, i + 1);
- if (((ob->matbits && ob->matbits[i]) || do_mat_id_data_us) && tmpmesh->mat[i]) {
+ if (((object_for_eval.matbits && object_for_eval.matbits[i]) || do_mat_id_data_us) && tmpmesh->mat[i]) {
id_us_plus(&tmpmesh->mat[i]->id);
}
}
@@ -1120,7 +1166,7 @@ Mesh *BKE_mesh_create_derived_for_modifier(
struct Depsgraph *depsgraph, Scene *scene, Object *ob,
ModifierData *md, int build_shapekey_layers)
{
- Mesh *me = ob->data;
+ Mesh *me = ob->runtime.mesh_orig ? ob->runtime.mesh_orig : ob->data;
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
Mesh *result;
KeyBlock *kb;
@@ -1367,7 +1413,7 @@ void BKE_mesh_nomain_to_mesh(
}
/* skip the listbase */
- MEMCPY_STRUCT_OFS(mesh_dst, &tmp, id.prev);
+ MEMCPY_STRUCT_AFTER(mesh_dst, &tmp, id.prev);
if (take_ownership) {
if (alloctype == CD_ASSIGN) {
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index a5338b3a6be..1e4c9a6950a 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -355,27 +355,28 @@ void BKE_mesh_ensure_normals(Mesh *mesh)
*/
void BKE_mesh_ensure_normals_for_display(Mesh *mesh)
{
- /* Note: mesh *may* have a poly CD_NORMAL layer (generated by a modifier needing poly normals e.g.).
- * We do not use it here, though. And it should be tagged as temp!
- */
- /* BLI_assert((CustomData_has_layer(&mesh->pdata, CD_NORMAL) == false)); */
-
- if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL || !CustomData_has_layer(&mesh->pdata, CD_NORMAL)) {
- float (*poly_nors)[3] = NULL;
- poly_nors = MEM_malloc_arrayN((size_t)mesh->totpoly, sizeof(*poly_nors), __func__);
+ float (*poly_nors)[3] = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
+ const bool do_vert_normals = (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) != 0;
+ const bool do_poly_normals = (mesh->runtime.cd_dirty_poly & CD_MASK_NORMAL || poly_nors == NULL);
- /* if normals are dirty we want to calculate vertex normals too */
- bool only_face_normals = !(mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL);
+ if (do_vert_normals || do_poly_normals) {
+ const bool do_add_poly_nors_cddata = (poly_nors == NULL);
+ if (do_add_poly_nors_cddata) {
+ poly_nors = MEM_malloc_arrayN((size_t)mesh->totpoly, sizeof(*poly_nors), __func__);
+ }
- /* calculate face normals */
+ /* calculate poly/vert normals */
BKE_mesh_calc_normals_poly(
mesh->mvert, NULL, mesh->totvert, mesh->mloop, mesh->mpoly,
mesh->totloop, mesh->totpoly, poly_nors,
- only_face_normals);
+ !do_vert_normals);
- CustomData_add_layer(&mesh->pdata, CD_NORMAL, CD_ASSIGN, poly_nors, mesh->totpoly);
+ if (do_add_poly_nors_cddata) {
+ CustomData_add_layer(&mesh->pdata, CD_NORMAL, CD_ASSIGN, poly_nors, mesh->totpoly);
+ }
mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
+ mesh->runtime.cd_dirty_poly &= ~CD_MASK_NORMAL;
}
}
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index ccb6265b17a..7219332774a 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -303,6 +303,22 @@ void BKE_mesh_remap_find_best_match_from_mesh(
/** \name Mesh to mesh mapping
* \{ */
+void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(
+ const int UNUSED(vert_mode), const int UNUSED(edge_mode), const int loop_mode, const int UNUSED(poly_mode),
+ CustomData_MeshMasks *cddata_mask)
+{
+ /* vert, edge and poly mapping modes never need extra cddata from source object. */
+ const bool need_lnors_src = (loop_mode & MREMAP_USE_LOOP) && (loop_mode & MREMAP_USE_NORMAL);
+ const bool need_pnors_src = need_lnors_src || ((loop_mode & MREMAP_USE_POLY) && (loop_mode & MREMAP_USE_NORMAL));
+
+ if (need_lnors_src) {
+ cddata_mask->lmask |= CD_MASK_NORMAL;
+ }
+ if (need_pnors_src) {
+ cddata_mask->pmask |= CD_MASK_NORMAL;
+ }
+}
+
void BKE_mesh_remap_init(MeshPairRemap *map, const int items_num)
{
MemArena *mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
@@ -1235,18 +1251,13 @@ void BKE_mesh_remap_calc_loops_from_mesh(
}
}
if (need_pnors_src || need_lnors_src) {
- /* Simpler for now, calcNormals never stores pnors :( */
- if (!CustomData_has_layer(&me_src->pdata, CD_NORMAL)) {
- CustomData_add_layer(&me_src->pdata, CD_NORMAL, CD_CALLOC, NULL, me_src->totpoly);
- CustomData_set_layer_flag(&me_src->pdata, CD_NORMAL, CD_FLAG_TEMPORARY);
- }
- BKE_mesh_calc_normals_split(me_src);
-
if (need_pnors_src) {
poly_nors_src = CustomData_get_layer(&me_src->pdata, CD_NORMAL);
+ BLI_assert(poly_nors_src != NULL);
}
if (need_lnors_src) {
loop_nors_src = CustomData_get_layer(&me_src->ldata, CD_NORMAL);
+ BLI_assert(loop_nors_src != NULL);
}
}
}
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index 2f845e32ee7..f7c16b763fe 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -274,7 +274,7 @@ char *BKE_mesh_runtime_debug_info(Mesh *me_eval)
DynStr *dynstr = BLI_dynstr_new();
char *ret;
- BLI_dynstr_appendf(dynstr, "{\n");
+ BLI_dynstr_append(dynstr, "{\n");
BLI_dynstr_appendf(dynstr, " 'ptr': '%p',\n", (void *)me_eval);
#if 0
const char *tstr;
@@ -291,27 +291,27 @@ char *BKE_mesh_runtime_debug_info(Mesh *me_eval)
BLI_dynstr_appendf(dynstr, " 'totpoly': %d,\n", me_eval->totpoly);
BLI_dynstr_appendf(dynstr, " 'deformed_only': %d,\n", me_eval->runtime.deformed_only);
- BLI_dynstr_appendf(dynstr, " 'vertexLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'vertexLayers': (\n");
mesh_runtime_debug_info_layers(dynstr, &me_eval->vdata);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, " 'edgeLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'edgeLayers': (\n");
mesh_runtime_debug_info_layers(dynstr, &me_eval->edata);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, " 'loopLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'loopLayers': (\n");
mesh_runtime_debug_info_layers(dynstr, &me_eval->ldata);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, " 'polyLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'polyLayers': (\n");
mesh_runtime_debug_info_layers(dynstr, &me_eval->pdata);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, " 'tessFaceLayers': (\n");
+ BLI_dynstr_append(dynstr, " 'tessFaceLayers': (\n");
mesh_runtime_debug_info_layers(dynstr, &me_eval->fdata);
- BLI_dynstr_appendf(dynstr, " ),\n");
+ BLI_dynstr_append(dynstr, " ),\n");
- BLI_dynstr_appendf(dynstr, "}\n");
+ BLI_dynstr_append(dynstr, "}\n");
ret = BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 189bd8623c4..fe955ced5f5 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -299,6 +299,9 @@ void modifier_copyData_generic(const ModifierData *md_src, ModifierData *md_dst,
char *md_dst_data = ((char *)md_dst) + data_size;
BLI_assert(data_size <= (size_t)mti->structSize);
memcpy(md_dst_data, md_src_data, (size_t)mti->structSize - data_size);
+
+ /* Runtime fields are never to be preserved. */
+ md_dst->runtime = NULL;
}
static void modifier_copy_data_id_us_cb(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin, int cb_flag)
@@ -856,41 +859,6 @@ void modwrap_deformVertsEM(
/* end modifier callback wrappers */
-/* wrappers for modifier callbacks that accept Mesh and select the proper implementation
- * depending on if the modifier has been ported to Mesh or is still using DerivedMesh
- */
-
-/* deprecated variants of above that accept DerivedMesh */
-
-struct DerivedMesh *modifier_applyModifier_DM_deprecated(
- struct ModifierData *md, const ModifierEvalContext *ctx,
- struct DerivedMesh *dm)
-{
- const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
-
- /* TODO(sybren): deduplicate all the copies of this code in this file. */
- Mesh *mesh = NULL;
- if (dm != NULL) {
- mesh = BKE_id_new_nomain(ID_ME, NULL);
- DM_to_mesh(dm, mesh, ctx->object, &CD_MASK_EVERYTHING, false);
- }
-
- struct Mesh *new_mesh = mti->applyModifier(md, ctx, mesh);
-
- /* Make a DM that doesn't reference new_mesh so we can free the latter. */
- DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, &CD_MASK_EVERYTHING);
-
- if (new_mesh != mesh) {
- BKE_id_free(NULL, new_mesh);
- }
- if (mesh != NULL) {
- BKE_id_free(NULL, mesh);
- }
-
- return ndm;
-
-}
-
/**
* Get evaluated mesh for other evaluated object, which is used as an operand for the modifier,
* e.g. second operand for boolean modifier.
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index bfa4c4ba068..1c056c9b652 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -66,6 +66,7 @@
#include "IMB_moviecache.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#ifdef WITH_OPENEXR
# include "intern/openexr/openexr_multi.h"
@@ -831,24 +832,24 @@ static ImBuf *get_undistorted_ibuf(MovieClip *clip,
return undistibuf;
}
-static int need_undistortion_postprocess(const MovieClipUser *user)
+static bool need_undistortion_postprocess(const MovieClipUser *user, int clip_flag)
{
- int result = 0;
-
- /* only full undistorted render can be used as on-fly undistorting image */
- result |= (user->render_size == MCLIP_PROXY_RENDER_SIZE_FULL) &&
+ bool result = 0;
+ const bool uses_full_frame =
+ ((clip_flag & MCLIP_USE_PROXY) == 0) ||
+ (user->render_size == MCLIP_PROXY_RENDER_SIZE_FULL);
+ /* Only full undistorted render can be used as on-fly undistorting image. */
+ result |= uses_full_frame &&
(user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) != 0;
-
return result;
}
-static int need_postprocessed_frame(const MovieClipUser *user,
- int postprocess_flag)
+static bool need_postprocessed_frame(const MovieClipUser *user,
+ int clip_flag,
+ int postprocess_flag)
{
- int result = postprocess_flag;
-
- result |= need_undistortion_postprocess(user);
-
+ bool result = (postprocess_flag != 0);
+ result |= need_undistortion_postprocess(user, clip_flag);
return result;
}
@@ -907,7 +908,7 @@ static ImBuf *get_postprocessed_cached_frame(const MovieClip *clip,
if (cache->postprocessed.flag != postprocess_flag)
return NULL;
- if (need_undistortion_postprocess(user)) {
+ if (need_undistortion_postprocess(user, flag)) {
if (!check_undistortion_cache_flags(clip))
return NULL;
}
@@ -922,11 +923,12 @@ static ImBuf *get_postprocessed_cached_frame(const MovieClip *clip,
static ImBuf *postprocess_frame(MovieClip *clip,
const MovieClipUser *user,
ImBuf *ibuf,
+ int flag,
int postprocess_flag)
{
ImBuf *postproc_ibuf = NULL;
- if (need_undistortion_postprocess(user)) {
+ if (need_undistortion_postprocess(user, flag)) {
postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf);
}
else {
@@ -967,7 +969,7 @@ static void put_postprocessed_frame_to_cache(MovieClip *clip,
cache->postprocessed.render_flag = 0;
}
- if (need_undistortion_postprocess(user)) {
+ if (need_undistortion_postprocess(user, flag)) {
cache->postprocessed.distortion_model = camera->distortion_model;
copy_v2_v2(cache->postprocessed.principal, camera->principal);
copy_v3_v3(&cache->postprocessed.polynomial_k1, &camera->k1);
@@ -1001,7 +1003,7 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip,
BLI_thread_lock(LOCK_MOVIECLIP);
/* try to obtain cached postprocessed frame first */
- if (need_postprocessed_frame(user, postprocess_flag)) {
+ if (need_postprocessed_frame(user, flag, postprocess_flag)) {
ibuf = get_postprocessed_cached_frame(clip, user, flag, postprocess_flag);
if (!ibuf)
@@ -1037,7 +1039,7 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip,
/* postprocess frame and put to cache if needed*/
if (need_postprocess) {
ImBuf *tmpibuf = ibuf;
- ibuf = postprocess_frame(clip, user, tmpibuf, postprocess_flag);
+ ibuf = postprocess_frame(clip, user, tmpibuf, flag, postprocess_flag);
IMB_freeImBuf(tmpibuf);
if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) {
put_postprocessed_frame_to_cache(clip, user, ibuf, flag, postprocess_flag);
@@ -1047,6 +1049,17 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip,
BLI_thread_unlock(LOCK_MOVIECLIP);
+ /* Fallback render in case proxies are not enabled or built */
+ if (!ibuf &&
+ user->render_flag & MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER &&
+ user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL)
+ {
+ MovieClipUser user_fallback = *user;
+ user_fallback.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
+
+ ibuf = movieclip_get_postprocessed_ibuf(clip, &user_fallback, flag, postprocess_flag, cache_flag);
+ }
+
return ibuf;
}
@@ -1720,6 +1733,10 @@ void BKE_movieclip_eval_update(struct Depsgraph *depsgraph, MovieClip *clip)
{
DEG_debug_print_eval(depsgraph, __func__, clip->id.name, clip);
BKE_tracking_dopesheet_tag_update(&clip->tracking);
+ if (DEG_is_active(depsgraph)) {
+ MovieClip *clip_orig = (MovieClip *)DEG_get_original_id(&clip->id);
+ BKE_tracking_dopesheet_tag_update(&clip_orig->tracking);
+ }
}
void BKE_movieclip_eval_selection_update(struct Depsgraph *depsgraph, MovieClip *clip)
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 774fde0af7d..e546119b86d 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -76,7 +76,7 @@ typedef enum {
static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert);
static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, CCGElem **oldGridData, int totlvl);
-/** Customdata **/
+/** Customdata */
void multires_customdata_delete(Mesh *me)
{
@@ -102,7 +102,7 @@ void multires_customdata_delete(Mesh *me)
}
}
-/** Grid hiding **/
+/** Grid hiding */
static BLI_bitmap *multires_mdisps_upsample_hidden(
BLI_bitmap *lo_hidden,
int lo_level, int hi_level,
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 09b44db02e5..aabd32d9cb6 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -139,6 +139,9 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
if (ntree->typeinfo->node_add_init != NULL)
ntree->typeinfo->node_add_init(ntree, node);
+ if (node->id)
+ id_us_plus(node->id);
+
/* extra init callback */
if (ntype->initfunc_api) {
PointerRNA ptr;
@@ -151,9 +154,6 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
ntype->initfunc_api(C, &ptr);
}
- if (node->id)
- id_us_plus(node->id);
-
node->flag |= NODE_INIT;
}
@@ -1007,7 +1007,8 @@ bNode *BKE_node_copy_ex(bNodeTree *ntree, bNode *node_src, const int flag)
node_src->new_node = node_dst;
node_dst->new_node = NULL;
- if (node_dst->typeinfo->copyfunc_api) {
+ bool do_copy_api = !((flag & LIB_ID_CREATE_NO_MAIN) || (flag & LIB_ID_COPY_LOCALIZE));
+ if (node_dst->typeinfo->copyfunc_api && do_copy_api) {
PointerRNA ptr;
RNA_pointer_create((ID *)ntree, &RNA_Node, node_dst, &ptr);
@@ -1677,26 +1678,12 @@ static void node_unlink_attached(bNodeTree *ntree, bNode *parent)
}
}
-/** \note caller needs to manage node->id user */
-static void node_free_node_ex(
- Main *bmain, bNodeTree *ntree, bNode *node,
- bool remove_animdata, bool use_api_free_cb)
+/* Free the node itself. ID user refcounting is up the caller,
+ * that does not happen here. */
+static void node_free_node(bNodeTree *ntree, bNode *node)
{
bNodeSocket *sock, *nextsock;
- /* don't remove node animdata if the tree is localized,
- * Action is shared with the original tree (T38221)
- */
- remove_animdata &= ntree && !(ntree->id.tag & LIB_TAG_LOCALIZED);
-
- /* extra free callback */
- if (use_api_free_cb && node->typeinfo->freefunc_api) {
- PointerRNA ptr;
- RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
-
- node->typeinfo->freefunc_api(&ptr);
- }
-
/* since it is called while free database, node->id is undefined */
/* can be called for nodes outside a node tree (e.g. clipboard) */
@@ -1707,20 +1694,6 @@ static void node_free_node_ex(
BLI_remlink(&ntree->nodes, node);
- if (remove_animdata) {
- char propname_esc[MAX_IDPROP_NAME * 2];
- char prefix[MAX_IDPROP_NAME * 2];
-
- BLI_strescape(propname_esc, node->name, sizeof(propname_esc));
- BLI_snprintf(prefix, sizeof(prefix), "nodes[\"%s\"]", propname_esc);
-
- if (BKE_animdata_fix_paths_remove((ID *)ntree, prefix)) {
- if (bmain != NULL) {
- DEG_relations_tag_update(bmain);
- }
- }
- }
-
if (ntree->typeinfo->free_node_cache)
ntree->typeinfo->free_node_cache(ntree, node);
@@ -1762,14 +1735,49 @@ static void node_free_node_ex(
ntree->update |= NTREE_UPDATE_NODES;
}
-void nodeFreeNode(bNodeTree *ntree, bNode *node)
+void ntreeFreeLocalNode(bNodeTree *ntree, bNode *node)
{
- node_free_node_ex(NULL, ntree, node, false, true);
+ /* For removing nodes while editing localized node trees. */
+ BLI_assert((ntree->id.tag & LIB_TAG_LOCALIZED) != 0);
+ node_free_node(ntree, node);
}
-void nodeDeleteNode(Main *bmain, bNodeTree *ntree, bNode *node)
+void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
{
- node_free_node_ex(bmain, ntree, node, true, true);
+ /* This function is not for localized node trees, we do not want
+ * do to ID user refcounting and removal of animdation data then. */
+ BLI_assert((ntree->id.tag & LIB_TAG_LOCALIZED) == 0);
+
+ if (do_id_user) {
+ /* Free callback for NodeCustomGroup. */
+ if (node->typeinfo->freefunc_api) {
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
+
+ node->typeinfo->freefunc_api(&ptr);
+ }
+
+ /* Do user counting. */
+ if (node->id) {
+ id_us_min(node->id);
+ }
+ }
+
+ /* Remove animation data. */
+ char propname_esc[MAX_IDPROP_NAME * 2];
+ char prefix[MAX_IDPROP_NAME * 2];
+
+ BLI_strescape(propname_esc, node->name, sizeof(propname_esc));
+ BLI_snprintf(prefix, sizeof(prefix), "nodes[\"%s\"]", propname_esc);
+
+ if (BKE_animdata_fix_paths_remove((ID *)ntree, prefix)) {
+ if (bmain != NULL) {
+ DEG_relations_tag_update(bmain);
+ }
+ }
+
+ /* Free node itself. */
+ node_free_node(ntree, node);
}
static void node_socket_interface_free(bNodeTree *UNUSED(ntree), bNodeSocket *sock)
@@ -1796,7 +1804,7 @@ static void free_localized_node_groups(bNodeTree *ntree)
return;
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == NODE_GROUP && node->id) {
+ if ((ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) && node->id) {
bNodeTree *ngroup = (bNodeTree *)node->id;
ntreeFreeTree(ngroup);
MEM_freeN(ngroup);
@@ -1804,7 +1812,8 @@ static void free_localized_node_groups(bNodeTree *ntree)
}
}
-/** Free (or release) any data used by this nodetree (does not free the nodetree itself). */
+/* Free (or release) any data used by this nodetree. Does not free the
+ * nodetree itself and does no ID user counting. */
void ntreeFreeTree(bNodeTree *ntree)
{
bNode *node, *next;
@@ -1839,7 +1848,7 @@ void ntreeFreeTree(bNodeTree *ntree)
for (node = ntree->nodes.first; node; node = next) {
next = node->next;
- node_free_node_ex(NULL, ntree, node, false, false);
+ node_free_node(ntree, node);
}
/* free interface sockets */
@@ -2036,8 +2045,10 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
(LIB_ID_COPY_LOCALIZE |
LIB_ID_COPY_NO_ANIMDATA));
+ ltree->id.tag |= LIB_TAG_LOCALIZED;
+
for (node = ltree->nodes.first; node; node = node->next) {
- if (node->type == NODE_GROUP && node->id) {
+ if ((ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) && node->id) {
node->id = (ID *)ntreeLocalize((bNodeTree *)node->id);
}
}
@@ -2053,8 +2064,6 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
if (ntree->typeinfo->localize)
ntree->typeinfo->localize(ltree, ntree);
- ltree->id.tag |= LIB_TAG_LOCALIZED;
-
BLI_mutex_unlock(ntree->duplilock);
return ltree;
@@ -2360,7 +2369,7 @@ bool ntreeHasTree(const bNodeTree *ntree, const bNodeTree *lookup)
return true;
for (node = ntree->nodes.first; node; node = node->next)
- if (node->type == NODE_GROUP && node->id)
+ if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id)
if (ntreeHasTree((bNodeTree *)node->id, lookup))
return true;
@@ -2594,7 +2603,7 @@ void BKE_node_clipboard_clear(void)
for (node = node_clipboard.nodes.first; node; node = node_next) {
node_next = node->next;
- node_free_node_ex(NULL, NULL, node, false, false);
+ node_free_node(NULL, node);
}
BLI_listbase_clear(&node_clipboard.nodes);
@@ -2697,6 +2706,11 @@ int BKE_node_clipboard_get_type(void)
return node_clipboard.type;
}
+void BKE_node_clipboard_free(void)
+{
+ BKE_node_clipboard_validate();
+ BKE_node_clipboard_clear();
+}
/* Node Instance Hash */
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index bdca469dc8e..9985c8026e7 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -808,7 +808,7 @@ void *BKE_object_obdata_add_from_type(Main *bmain, int type, const char *name)
void BKE_object_init(Object *ob)
{
- /* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ob, id)); */ /* ob->type is already initialized... */
+ /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ob, id)); */ /* ob->type is already initialized... */
copy_v4_fl(ob->color, 1.0f);
@@ -1427,6 +1427,14 @@ Object *BKE_object_copy(Main *bmain, const Object *ob)
return ob_copy;
}
+/** Perform deep-copy of object and its 'children' data-blocks (obdata, materials, actions, etc.).
+ *
+ * \param dupflag Controls which sub-data are also duplicated (see \a eDupli_ID_Flags in \a DNA_userdef_types.h).
+ *
+ * \note This function does not do any remapping to new IDs, caller must do it (\a BKE_libblock_relink_to_newid()).
+ * \note Caller MUST free \a newid pointers itself (\a BKE_main_id_clear_newpoins()) and call updates of DEG too
+ * (\a DAG_relations_tag_update()).
+ */
Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
{
Material ***matarar;
@@ -1547,17 +1555,19 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
}
break;
case OB_ARMATURE:
- DEG_id_tag_update(&obn->id, ID_RECALC_GEOMETRY);
- if (obn->pose)
- BKE_pose_tag_recalc(bmain, obn->pose);
- if (dupflag & USER_DUP_ARM) {
- ID_NEW_REMAP_US2(obn->data)
- else {
- obn->data = ID_NEW_SET(obn->data, BKE_armature_copy(bmain, obn->data));
- BKE_pose_rebuild(bmain, obn, obn->data, true);
- didit = 1;
+ if (dupflag != 0) {
+ DEG_id_tag_update(&obn->id, ID_RECALC_GEOMETRY);
+ if (obn->pose)
+ BKE_pose_tag_recalc(bmain, obn->pose);
+ if (dupflag & USER_DUP_ARM) {
+ ID_NEW_REMAP_US2(obn->data)
+ else {
+ obn->data = ID_NEW_SET(obn->data, BKE_armature_copy(bmain, obn->data));
+ BKE_pose_rebuild(bmain, obn, obn->data, true);
+ didit = 1;
+ }
+ id_us_min(id);
}
- id_us_min(id);
}
break;
case OB_LATTICE:
@@ -1648,16 +1658,10 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
#undef ID_NEW_REMAP_US
#undef ID_NEW_REMAP_US2
- BKE_libblock_relink_to_newid(&obn->id);
-
- /* DAG_relations_tag_update(bmain); */ /* caller must do */
-
if (ob->data != NULL) {
DEG_id_tag_update_ex(bmain, (ID *)obn->data, ID_RECALC_EDITORS);
}
- /* BKE_main_id_clear_newpoins(bmain); */ /* Called must do. */
-
return obn;
}
@@ -2762,6 +2766,20 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
changed = true;
break;
}
+ case OB_MESH:
+ {
+ bb = *BKE_mesh_boundbox_get(ob);
+ BKE_boundbox_minmax(&bb, ob->obmat, min_r, max_r);
+ changed = true;
+ break;
+ }
+ case OB_GPENCIL:
+ {
+ bb = *BKE_gpencil_boundbox_get(ob);
+ BKE_boundbox_minmax(&bb, ob->obmat, min_r, max_r);
+ changed = true;
+ break;
+ }
case OB_LATTICE:
{
Lattice *lt = ob->data;
@@ -2784,17 +2802,6 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
changed = BKE_pose_minmax(ob, min_r, max_r, use_hidden, false);
break;
}
- case OB_MESH:
- {
- Mesh *me = BKE_mesh_from_object(ob);
-
- if (me) {
- bb = *BKE_mesh_boundbox_get(ob);
- BKE_boundbox_minmax(&bb, ob->obmat, min_r, max_r);
- changed = true;
- }
- break;
- }
case OB_MBALL:
{
float ob_min[3], ob_max[3];
@@ -3944,28 +3951,28 @@ LinkNode *BKE_object_relational_superset(struct ViewLayer *view_layer, eObjectSe
/**
* return all groups this object is apart of, caller must free.
*/
-struct LinkNode *BKE_object_groups(Main *bmain, Object *ob)
+struct LinkNode *BKE_object_groups(Main *bmain, Scene *scene, Object *ob)
{
LinkNode *collection_linknode = NULL;
Collection *collection = NULL;
- while ((collection = BKE_collection_object_find(bmain, collection, ob))) {
+ while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) {
BLI_linklist_prepend(&collection_linknode, collection);
}
return collection_linknode;
}
-void BKE_object_groups_clear(Main *bmain, Object *ob)
+void BKE_object_groups_clear(Main *bmain, Scene *scene, Object *ob)
{
Collection *collection = NULL;
- while ((collection = BKE_collection_object_find(bmain, collection, ob))) {
+ while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) {
BKE_collection_object_remove(bmain, collection, ob, false);
DEG_id_tag_update(&collection->id, ID_RECALC_COPY_ON_WRITE);
}
}
/**
- * Return a KDTree from the deformed object (in worldspace)
+ * Return a KDTree_3d from the deformed object (in worldspace)
*
* \note Only mesh objects currently support deforming, others are TODO.
*
@@ -3973,9 +3980,9 @@ void BKE_object_groups_clear(Main *bmain, Object *ob)
* \param r_tot:
* \return The kdtree or NULL if it can't be created.
*/
-KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
+KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot)
{
- KDTree *tree = NULL;
+ KDTree_3d *tree = NULL;
unsigned int tot = 0;
switch (ob->type) {
@@ -3993,14 +4000,14 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
/* tree over-allocs in case where some verts have ORIGINDEX_NONE */
tot = 0;
- tree = BLI_kdtree_new(totvert);
+ tree = BLI_kdtree_3d_new(totvert);
/* we don't how how many verts from the DM we can use */
for (i = 0; i < totvert; i++) {
if (index[i] != ORIGINDEX_NONE) {
float co[3];
mul_v3_m4v3(co, ob->obmat, mvert[i].co);
- BLI_kdtree_insert(tree, index[i], co);
+ BLI_kdtree_3d_insert(tree, index[i], co);
tot++;
}
}
@@ -4009,16 +4016,16 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
MVert *mvert = me->mvert;
tot = me->totvert;
- tree = BLI_kdtree_new(tot);
+ tree = BLI_kdtree_3d_new(tot);
for (i = 0; i < tot; i++) {
float co[3];
mul_v3_m4v3(co, ob->obmat, mvert[i].co);
- BLI_kdtree_insert(tree, i, co);
+ BLI_kdtree_3d_insert(tree, i, co);
}
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
break;
}
case OB_CURVE:
@@ -4031,7 +4038,7 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
Nurb *nu;
tot = BKE_nurbList_verts_count_without_handles(&cu->nurb);
- tree = BLI_kdtree_new(tot);
+ tree = BLI_kdtree_3d_new(tot);
i = 0;
nu = cu->nurb.first;
@@ -4044,7 +4051,7 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
while (a--) {
float co[3];
mul_v3_m4v3(co, ob->obmat, bezt->vec[1]);
- BLI_kdtree_insert(tree, i++, co);
+ BLI_kdtree_3d_insert(tree, i++, co);
bezt++;
}
}
@@ -4056,14 +4063,14 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
while (a--) {
float co[3];
mul_v3_m4v3(co, ob->obmat, bp->vec);
- BLI_kdtree_insert(tree, i++, co);
+ BLI_kdtree_3d_insert(tree, i++, co);
bp++;
}
}
nu = nu->next;
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
break;
}
case OB_LATTICE:
@@ -4074,16 +4081,16 @@ KDTree *BKE_object_as_kdtree(Object *ob, int *r_tot)
unsigned int i;
tot = lt->pntsu * lt->pntsv * lt->pntsw;
- tree = BLI_kdtree_new(tot);
+ tree = BLI_kdtree_3d_new(tot);
i = 0;
for (bp = lt->def; i < tot; bp++) {
float co[3];
mul_v3_m4v3(co, ob->obmat, bp->vec);
- BLI_kdtree_insert(tree, i++, co);
+ BLI_kdtree_3d_insert(tree, i++, co);
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
break;
}
}
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 1f3680eb850..41fb78761b8 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -316,26 +316,19 @@ typedef struct VertexDupliData {
float child_imat[4][4];
} VertexDupliData;
-static void get_duplivert_transform(const float co[3], const float nor_f[3], const short nor_s[3],
+static void get_duplivert_transform(const float co[3], const short no[3],
bool use_rotation, short axis, short upflag, float mat[4][4])
{
float quat[4];
const float size[3] = {1.0f, 1.0f, 1.0f};
if (use_rotation) {
- float nor[3];
/* construct rotation matrix from normals */
- if (nor_f) {
- nor[0] = -nor_f[0];
- nor[1] = -nor_f[1];
- nor[2] = -nor_f[2];
- }
- else if (nor_s) {
- nor[0] = (float)-nor_s[0];
- nor[1] = (float)-nor_s[1];
- nor[2] = (float)-nor_s[2];
- }
- vec_to_quat(quat, nor, axis, upflag);
+ float nor_f[3];
+ nor_f[0] = (float)-no[0];
+ nor_f[1] = (float)-no[1];
+ nor_f[2] = (float)-no[2];
+ vec_to_quat(quat, nor_f, axis, upflag);
}
else
unit_qt(quat);
@@ -343,16 +336,14 @@ static void get_duplivert_transform(const float co[3], const float nor_f[3], con
loc_quat_size_to_mat4(mat, co, quat, size);
}
-static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
- const float nor_f[3], const short nor_s[3])
+static void vertex_dupli(const VertexDupliData *vdd, int index, const float co[3], const short no[3])
{
- const VertexDupliData *vdd = userData;
Object *inst_ob = vdd->inst_ob;
DupliObject *dob;
float obmat[4][4], space_mat[4][4];
/* obmat is transform to vertex */
- get_duplivert_transform(co, nor_f, nor_s, vdd->use_rotation, inst_ob->trackflag, inst_ob->upflag, obmat);
+ get_duplivert_transform(co, no, vdd->use_rotation, inst_ob->trackflag, inst_ob->upflag, obmat);
/* make offset relative to inst_ob using relative child transform */
mul_mat3_m4_v3((float (*)[4])vdd->child_imat, obmat[3]);
/* apply obmat _after_ the local vertex transform */
@@ -382,8 +373,14 @@ static void make_child_duplis_verts(const DupliContext *ctx, void *userdata, Obj
/* relative transform from parent to child space */
mul_m4_m4m4(vdd->child_imat, child->imat, ctx->object->obmat);
- BKE_mesh_foreach_mapped_vert(me_eval, vertex_dupli__mapFunc, vdd,
- vdd->use_rotation ? MESH_FOREACH_USE_NORMAL : 0);
+ const MVert *mvert = me_eval->mvert;
+ const int *origindex = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX);
+
+ for (int i = 0, j = 0; i < me_eval->totvert; i++) {
+ if (origindex == NULL || origindex[i] != ORIGINDEX_NONE) {
+ vertex_dupli(vdd, j++, mvert[i].co, mvert[i].no);
+ }
+ }
}
static void make_duplis_verts(const DupliContext *ctx)
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 304c9985f10..c03fffc4098 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -68,7 +68,7 @@
* before being re-evaluated.
* For example, we need to call this before BKE_mesh_new_from_object(),
* in case we removed/added modifiers in the evaluated object.
- **/
+ */
void BKE_object_eval_reset(Object *ob_eval)
{
BKE_object_free_derived_caches(ob_eval);
@@ -178,10 +178,10 @@ void BKE_object_handle_data_update(
}
#endif
if (em) {
- makeDerivedMesh(depsgraph, scene, ob, em, &cddata_masks, false); /* was CD_MASK_BAREMESH */
+ makeDerivedMesh(depsgraph, scene, ob, em, &cddata_masks); /* was CD_MASK_BAREMESH */
}
else {
- makeDerivedMesh(depsgraph, scene, ob, NULL, &cddata_masks, false);
+ makeDerivedMesh(depsgraph, scene, ob, NULL, &cddata_masks);
}
break;
}
@@ -425,27 +425,18 @@ void BKE_object_eval_eval_base_flags(Depsgraph *depsgraph,
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
- /* Visibility based on depsgraph mode. */
- const eEvaluationMode mode = DEG_get_mode(depsgraph);
- const int base_enabled_flag = (mode == DAG_EVAL_VIEWPORT)
- ? BASE_ENABLED_VIEWPORT
- : BASE_ENABLED_RENDER;
-
+ /* Set base flags based on collection and object restriction. */
BKE_base_eval_flags(base);
- /* Compute visibility for depsgraph evaluation mode. */
- if (base->flag & base_enabled_flag) {
- /* When rendering, visibility is controlled by the enable/disable option. */
- if (mode == DAG_EVAL_RENDER) {
+ /* For render, compute base visibility again since BKE_base_eval_flags
+ * assumed viewport visibility. Selectability does not matter here. */
+ if (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER) {
+ if (base->flag & BASE_ENABLED_RENDER) {
base->flag |= BASE_VISIBLE;
}
- }
- else {
- base->flag &= ~(BASE_VISIBLE | BASE_SELECTABLE);
- }
- /* If base is not selectable, clear select. */
- if ((base->flag & BASE_SELECTABLE) == 0) {
- base->flag &= ~BASE_SELECTED;
+ else {
+ base->flag &= ~BASE_VISIBLE;
+ }
}
/* Copy flags and settings from base. */
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index da2975d8efc..35869c44b87 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -650,7 +650,7 @@ void psys_free(Object *ob, ParticleSystem *psys)
BLI_freelistN(&psys->targets);
BLI_bvhtree_free(psys->bvhtree);
- BLI_kdtree_free(psys->tree);
+ BLI_kdtree_3d_free(psys->tree);
if (psys->fluid_springs)
MEM_freeN(psys->fluid_springs);
@@ -1920,7 +1920,7 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
{
ParticleSystem *psys = sim->psys;
ParticleSettings *part = sim->psys->part;
- KDTree *tree;
+ KDTree_3d *tree;
ChildParticle *cpa;
ParticleTexture ptex;
int p, totparent, totchild = sim->psys->totchild;
@@ -1936,7 +1936,7 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
totparent = sim->psys->totpart;
}
- tree = BLI_kdtree_new(totparent);
+ tree = BLI_kdtree_3d_new(totparent);
for (p = 0, cpa = sim->psys->child; p < totparent; p++, cpa++) {
psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco);
@@ -1945,18 +1945,18 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
get_cpa_texture(sim->psmd->mesh_final, psys, part, psys->particles + cpa->pa[0], p, cpa->num, cpa->fuv, orco, &ptex, PAMAP_DENS | PAMAP_CHILD, psys->cfra);
if (ptex.exist >= psys_frand(psys, p + 24)) {
- BLI_kdtree_insert(tree, p, orco);
+ BLI_kdtree_3d_insert(tree, p, orco);
}
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
for (; p < totchild; p++, cpa++) {
psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco);
- cpa->parent = BLI_kdtree_find_nearest(tree, orco, NULL);
+ cpa->parent = BLI_kdtree_3d_find_nearest(tree, orco, NULL);
}
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
}
static bool psys_thread_context_init_path(
@@ -2373,7 +2373,7 @@ void psys_cache_child_paths(
totparent = ctx.totparent;
if (editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) {
- ; /* just overwrite the existing cache */
+ /* just overwrite the existing cache */
}
else {
/* clear out old and create new empty path cache */
@@ -3150,8 +3150,6 @@ static void default_particle_settings(ParticleSettings *part)
part->draw_as = PART_DRAW_REND;
part->ren_as = PART_DRAW_HALO;
part->bb_uv_split = 1;
- part->bb_align = PART_BB_VIEW;
- part->bb_split_offset = PART_BB_OFF_LINEAR;
part->flag = PART_EDISTR | PART_TRAND | PART_HIDE_ADVANCED_HAIR;
part->sta = 1.0;
@@ -4207,88 +4205,6 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
*scale = len;
}
-void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3])
-{
- float onevec[3] = {0.0f, 0.0f, 0.0f}, tvec[3], tvec2[3];
-
- xvec[0] = 1.0f; xvec[1] = 0.0f; xvec[2] = 0.0f;
- yvec[0] = 0.0f; yvec[1] = 1.0f; yvec[2] = 0.0f;
-
- /* can happen with bad pointcache or physics calculation
- * since this becomes geometry, nan's and inf's crash raytrace code.
- * better not allow this. */
- if (!is_finite_v3(bb->vec) || !is_finite_v3(bb->vec)) {
- zero_v3(bb->vec);
- zero_v3(bb->vel);
-
- zero_v3(xvec);
- zero_v3(yvec);
- zero_v3(zvec);
- zero_v3(center);
-
- return;
- }
-
- if (bb->align < PART_BB_VIEW)
- onevec[bb->align] = 1.0f;
-
- if (bb->lock && (bb->align == PART_BB_VIEW)) {
- normalize_v3_v3(xvec, bb->ob->obmat[0]);
- normalize_v3_v3(yvec, bb->ob->obmat[1]);
- normalize_v3_v3(zvec, bb->ob->obmat[2]);
- }
- else if (bb->align == PART_BB_VEL) {
- float temp[3];
-
- normalize_v3_v3(temp, bb->vel);
-
- sub_v3_v3v3(zvec, bb->ob->obmat[3], bb->vec);
-
- if (bb->lock) {
- float fac = -dot_v3v3(zvec, temp);
-
- madd_v3_v3fl(zvec, temp, fac);
- }
- normalize_v3(zvec);
-
- cross_v3_v3v3(xvec, temp, zvec);
- normalize_v3(xvec);
-
- cross_v3_v3v3(yvec, zvec, xvec);
- }
- else {
- sub_v3_v3v3(zvec, bb->ob->obmat[3], bb->vec);
- if (bb->lock)
- zvec[bb->align] = 0.0f;
- normalize_v3(zvec);
-
- if (bb->align < PART_BB_VIEW)
- cross_v3_v3v3(xvec, onevec, zvec);
- else
- cross_v3_v3v3(xvec, bb->ob->obmat[1], zvec);
- normalize_v3(xvec);
-
- cross_v3_v3v3(yvec, zvec, xvec);
- }
-
- copy_v3_v3(tvec, xvec);
- copy_v3_v3(tvec2, yvec);
-
- mul_v3_fl(xvec, cosf(bb->tilt * (float)M_PI));
- mul_v3_fl(tvec2, sinf(bb->tilt * (float)M_PI));
- add_v3_v3(xvec, tvec2);
-
- mul_v3_fl(yvec, cosf(bb->tilt * (float)M_PI));
- mul_v3_fl(tvec, -sinf(bb->tilt * (float)M_PI));
- add_v3_v3(yvec, tvec);
-
- mul_v3_fl(xvec, bb->size[0]);
- mul_v3_fl(yvec, bb->size[1]);
-
- madd_v3_v3v3fl(center, bb->vec, xvec, bb->offset[0]);
- madd_v3_v3fl(center, yvec, bb->offset[1]);
-}
-
void psys_apply_hair_lattice(Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys)
{
ParticleSimulationData sim = {0};
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 4485afb09de..fc8292531dc 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -315,7 +315,7 @@ static void hammersley_create(float *out, int n, int seed, float amount)
BLI_rng_free(rng);
for (int k = 0; k < n; k++) {
- BLI_hammersley_1D(k, &t);
+ BLI_hammersley_1d(k, &t);
out[2*k + 0] = fmod((double)k/(double)n + offs[0], 1.0);
out[2*k + 1] = fmod(t + offs[1], 1.0);
@@ -464,12 +464,12 @@ static void distribute_from_verts_exec(ParticleTask *thread, ParticleData *pa, i
#if ONLY_WORKING_WITH_PA_VERTS
if (ctx->tree) {
- KDTreeNearest ptn[3];
+ KDTreeNearest_3d ptn[3];
int w, maxw;
psys_particle_on_dm(ctx->mesh,from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co1,0,0,0,orco1,0);
BKE_mesh_orco_verts_transform(ob->data, &orco1, 1, 1);
- maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
+ maxw = BLI_kdtree_3d_find_nearest_n(ctx->tree,orco1,ptn,3);
for (w=0; w<maxw; w++) {
pa->verts[w]=ptn->num;
@@ -654,7 +654,7 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
cpa->num = ctx->index[p];
if (ctx->tree) {
- KDTreeNearest ptn[10];
+ KDTreeNearest_3d ptn[10];
int w,maxw;//, do_seams;
float maxd /*, mind,dd */, totw= 0.0f;
int parent[10];
@@ -662,7 +662,7 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
psys_particle_on_dm(mesh,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1);
BKE_mesh_orco_verts_transform(ob->data, &orco1, 1, 1);
- maxw = BLI_kdtree_find_nearest_n(ctx->tree,orco1,ptn,3);
+ maxw = BLI_kdtree_3d_find_nearest_n(ctx->tree,orco1,ptn,3);
maxd=ptn[maxw-1].dist;
/* mind=ptn[0].dist; */ /* UNUSED */
@@ -809,7 +809,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
ParticleData *pa=0, *tpars= 0;
ParticleSettings *part;
ParticleSeam *seams= 0;
- KDTree *tree=0;
+ KDTree_3d *tree=0;
Mesh *mesh = NULL;
float *jit= NULL;
int i, p=0;
@@ -883,15 +883,15 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
children=1;
- tree=BLI_kdtree_new(totpart);
+ tree=BLI_kdtree_3d_new(totpart);
for (p=0,pa=psys->particles; p<totpart; p++,pa++) {
psys_particle_on_dm(mesh,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco);
BKE_mesh_orco_verts_transform(ob->data, &orco, 1, 1);
- BLI_kdtree_insert(tree, p, orco);
+ BLI_kdtree_3d_insert(tree, p, orco);
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
totpart = psys_get_tot_child(scene, psys, use_render_params);
cfrom = from = PART_FROM_FACE;
@@ -909,15 +909,19 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
BKE_mesh_tessface_ensure(mesh);
/* we need orco for consistent distributions */
- if (!CustomData_has_layer(&mesh->vdata, CD_ORCO))
- CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob), mesh->totvert);
+ if (!CustomData_has_layer(&mesh->vdata, CD_ORCO)) {
+ /* Orcos are stored in normalized 0..1 range by convention. */
+ float (*orcodata)[3] = BKE_mesh_orco_verts_get(ob);
+ BKE_mesh_orco_verts_transform(mesh, orcodata, mesh->totvert, false);
+ CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_ASSIGN, orcodata, mesh->totvert);
+ }
if (from == PART_FROM_VERT) {
MVert *mv = mesh->mvert;
float (*orcodata)[3] = CustomData_get_layer(&mesh->vdata, CD_ORCO);
int totvert = mesh->totvert;
- tree=BLI_kdtree_new(totvert);
+ tree=BLI_kdtree_3d_new(totvert);
for (p=0; p<totvert; p++) {
if (orcodata) {
@@ -926,10 +930,10 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
}
else
copy_v3_v3(co,mv[p].co);
- BLI_kdtree_insert(tree, p, co);
+ BLI_kdtree_3d_insert(tree, p, co);
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
}
}
@@ -944,7 +948,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
if (mesh != final_mesh) BKE_id_free(NULL, mesh);
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
BLI_rng_free(rng);
return 0;
@@ -966,6 +970,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
MFace *mf = &mesh->mface[i];
if (orcodata) {
+ /* Transform orcos from normalized 0..1 to object space. */
copy_v3_v3(co1, orcodata[mf->v1]);
copy_v3_v3(co2, orcodata[mf->v2]);
copy_v3_v3(co3, orcodata[mf->v3]);
@@ -1050,6 +1055,14 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
if (totmapped == 0) {
/* We are not allowed to distribute particles anywhere... */
+ if (mesh != final_mesh) {
+ BKE_id_free(NULL, mesh);
+ }
+ BLI_kdtree_3d_free(tree);
+ BLI_rng_free(rng);
+ MEM_freeN(element_weight);
+ MEM_freeN(particle_element);
+ MEM_freeN(jitter_offset);
return 0;
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 2975eaaf5fc..7ec50ead0bb 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -512,7 +512,7 @@ void psys_thread_context_free(ParticleThreadContext *ctx)
if (ctx->index) MEM_freeN(ctx->index);
if (ctx->seams) MEM_freeN(ctx->seams);
//if (ctx->vertpart) MEM_freeN(ctx->vertpart);
- BLI_kdtree_free(ctx->tree);
+ BLI_kdtree_3d_free(ctx->tree);
if (ctx->clumpcurve != NULL) {
curvemapping_free(ctx->clumpcurve);
@@ -1280,18 +1280,18 @@ void psys_update_particle_tree(ParticleSystem *psys, float cfra)
totpart++;
}
- BLI_kdtree_free(psys->tree);
- psys->tree = BLI_kdtree_new(psys->totpart);
+ BLI_kdtree_3d_free(psys->tree);
+ psys->tree = BLI_kdtree_3d_new(psys->totpart);
LOOP_SHOWN_PARTICLES {
if (pa->alive == PARS_ALIVE) {
if (pa->state.time == cfra)
- BLI_kdtree_insert(psys->tree, p, pa->prev_state.co);
+ BLI_kdtree_3d_insert(psys->tree, p, pa->prev_state.co);
else
- BLI_kdtree_insert(psys->tree, p, pa->state.co);
+ BLI_kdtree_3d_insert(psys->tree, p, pa->state.co);
}
}
- BLI_kdtree_balance(psys->tree);
+ BLI_kdtree_3d_balance(psys->tree);
psys->tree_frame = cfra;
}
@@ -1557,7 +1557,7 @@ typedef struct SPHRangeData {
SPHNeighbor neighbors[SPH_NEIGHBORS];
int tot_neighbors;
- float* data;
+ float *data;
ParticleSystem *npsys;
ParticleData *pa;
@@ -1623,8 +1623,8 @@ static void sph_density_accum_cb(void *userdata, int index, const float co[3], f
if (pfr->use_size)
q *= npa->size;
- pfr->data[0] += q*q;
- pfr->data[1] += q*q*q;
+ pfr->data[0] += q * q;
+ pfr->data[1] += q * q * q;
}
/*
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index cd97fcf432e..c75a748574c 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -107,7 +107,7 @@ static void pbvh_bmesh_verify(PBVH *bvh);
#define BM_FACES_OF_VERT_ITER_END \
} \
BM_LOOPS_OF_VERT_ITER_END; \
-}
+} ((void)0)
static void bm_edges_from_tri(BMesh *bm, BMVert *v_tri[3], BMEdge *e_tri[3])
{
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index ed949e68f13..3371c3dbe48 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -3202,7 +3202,7 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
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) {
@@ -3258,9 +3258,10 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
/* verify cached_frames array is up to date */
if (cache->cached_frames) {
- if (MEM_allocN_len(cache->cached_frames) != sizeof(char) * (cache->endframe-cache->startframe+1)) {
+ if (cache->cached_frames_len != (cache->endframe - cache->startframe + 1)) {
MEM_freeN(cache->cached_frames);
cache->cached_frames = NULL;
+ cache->cached_frames_len = 0;
}
}
@@ -3268,7 +3269,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
unsigned int sta=cache->startframe;
unsigned int end=cache->endframe;
- cache->cached_frames = MEM_callocN(sizeof(char) * (cache->endframe-cache->startframe+1), "cached frames array");
+ cache->cached_frames_len = cache->endframe - cache->startframe + 1;
+ cache->cached_frames = MEM_callocN(sizeof(char) * cache->cached_frames_len, "cached frames array");
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
/* mode is same as fopen's modes */
@@ -3544,6 +3546,7 @@ static PointCache *ptcache_copy(PointCache *cache, const bool copy_data)
if (copy_data == false) {
ncache->cached_frames = NULL;
+ ncache->cached_frames_len = 0;
/* flag is a mix of user settings and simulator/baking state */
ncache->flag= ncache->flag & (PTCACHE_DISK_CACHE|PTCACHE_EXTERNAL|PTCACHE_IGNORE_LIBPATH);
@@ -3902,7 +3905,8 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
if (cache->cached_frames) {
MEM_freeN(cache->cached_frames);
- cache->cached_frames=NULL;
+ cache->cached_frames = NULL;
+ cache->cached_frames_len = 0;
}
if (cache->flag & PTCACHE_DISK_CACHE)
@@ -4082,7 +4086,8 @@ void BKE_ptcache_load_external(PTCacheID *pid)
/* make sure all new frames are loaded */
if (cache->cached_frames) {
MEM_freeN(cache->cached_frames);
- cache->cached_frames=NULL;
+ cache->cached_frames = NULL;
+ cache->cached_frames_len = 0;
}
BKE_ptcache_update_info(pid);
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index b2bc578bd3b..d859f9fbee8 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -318,6 +318,7 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
}
sce_dst->eevee.light_cache = NULL;
+ sce_dst->eevee.light_cache_info[0] = '\0';
/* TODO Copy the cache. */
}
@@ -339,6 +340,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
sce_copy->unit = sce->unit;
sce_copy->physics_settings = sce->physics_settings;
sce_copy->audio = sce->audio;
+ sce_copy->eevee = sce->eevee;
+ sce_copy->eevee.light_cache = NULL;
+ sce_copy->eevee.light_cache_info[0] = '\0';
if (sce->id.properties)
sce_copy->id.properties = IDP_CopyProperty(sce->id.properties);
@@ -427,15 +431,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
BKE_sequencer_editing_free(sce_copy, true);
}
- /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations
+ /* NOTE: part of SCE_COPY_FULL operations
* are done outside of blenkernel with ED_object_single_users! */
- /* camera */
- /* XXX This is most certainly useless? Object have not yet been duplicated... */
- if (ELEM(type, SCE_COPY_LINK_DATA, SCE_COPY_FULL)) {
- ID_NEW_REMAP(sce_copy->camera);
- }
-
return sce_copy;
}
}
@@ -542,7 +540,7 @@ void BKE_scene_init(Scene *sce)
SceneRenderView *srv;
CurveMapping *mblur_shutter_curve;
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(sce, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(sce, id));
sce->cursor.rotation_mode = ROT_MODE_XYZ;
@@ -780,6 +778,18 @@ void BKE_scene_init(Scene *sce)
BLI_strncpy(sce->sequencer_colorspace_settings.name, colorspace_name,
sizeof(sce->sequencer_colorspace_settings.name));
+ /* Those next two sets (render and baking settings) are not currently in use,
+ * but are exposed to RNA API and hence must have valid data. */
+ BKE_color_managed_display_settings_init(&sce->r.im_format.display_settings);
+ BKE_color_managed_view_settings_init_render(&sce->r.im_format.view_settings,
+ &sce->r.im_format.display_settings,
+ "Filmic");
+
+ BKE_color_managed_display_settings_init(&sce->r.bake.im_format.display_settings);
+ BKE_color_managed_view_settings_init_render(&sce->r.bake.im_format.view_settings,
+ &sce->r.bake.im_format.display_settings,
+ "Filmic");
+
/* Safe Areas */
copy_v2_fl2(sce->safe_areas.title, 10.0f / 100.0f, 5.0f / 100.0f);
copy_v2_fl2(sce->safe_areas.action, 3.5f / 100.0f, 3.5f / 100.0f);
@@ -1650,11 +1660,11 @@ int get_render_child_particle_number(const RenderData *r, int num, bool for_rend
}
/**
- * Helper function for the SETLOOPER and SETLOOPER_VIEW_LAYER macros
- *
- * It iterates over the bases of the active layer and then the bases
- * of the active layer of the background (set) scenes recursively.
- */
+ * Helper function for the SETLOOPER and SETLOOPER_VIEW_LAYER macros
+ *
+ * It iterates over the bases of the active layer and then the bases
+ * of the active layer of the background (set) scenes recursively.
+ */
Base *_setlooper_base_step(Scene **sce_iter, ViewLayer *view_layer, Base *base)
{
if (base && base->next) {
@@ -1742,9 +1752,8 @@ void BKE_scene_object_base_flag_sync_from_object(Base *base)
Object *ob = base->object;
base->flag = ob->flag;
- if ((ob->flag & SELECT) != 0) {
+ if ((ob->flag & SELECT) != 0 && (base->flag & BASE_SELECTABLE) != 0) {
base->flag |= BASE_SELECTED;
- BLI_assert((base->flag & BASE_SELECTABLE) != 0);
}
else {
base->flag &= ~BASE_SELECTED;
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index f9a1eed0ba7..9609a4ab1f4 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -3060,8 +3060,9 @@ static ImBuf *seq_render_movieclip_strip(const SeqRenderData *context, Sequence
BKE_movieclip_user_set_frame(&user, nr + seq->anim_startofs + seq->clip->start_frame);
- user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
+ user.render_flag |= MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER;
+ user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
switch (seq_rendersize_to_proxysize(context->preview_render_size)) {
case IMB_PROXY_NONE:
user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
@@ -3081,14 +3082,14 @@ static ImBuf *seq_render_movieclip_strip(const SeqRenderData *context, Sequence
}
if (seq->clip_flag & SEQ_MOVIECLIP_RENDER_UNDISTORTED) {
- user.render_flag = MCLIP_PROXY_RENDER_UNDISTORT;
+ user.render_flag |= MCLIP_PROXY_RENDER_UNDISTORT;
}
if (seq->clip_flag & SEQ_MOVIECLIP_RENDER_STABILIZED) {
ibuf = BKE_movieclip_get_stable_ibuf(seq->clip, &user, tloc, &tscale, &tangle, 0);
}
else {
- ibuf = BKE_movieclip_get_ibuf_flag(seq->clip, &user, 0, MOVIECLIP_CACHE_SKIP);
+ ibuf = BKE_movieclip_get_ibuf_flag(seq->clip, &user, seq->clip->flag, MOVIECLIP_CACHE_SKIP);
}
return ibuf;
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 4b9dd9ac6e3..82acc272c6b 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -1200,7 +1200,7 @@ static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int hires_mult
typedef struct EmitFromParticlesData {
SmokeFlowSettings *sfs;
- KDTree *tree;
+ KDTree_3d *tree;
int hires_multiplier;
EmissionMap *em;
@@ -1237,9 +1237,9 @@ static void emit_from_particles_task_cb(
const float ray_start[3] = {((float)lx) + 0.5f, ((float)ly) + 0.5f, ((float)lz) + 0.5f};
/* find particle distance from the kdtree */
- KDTreeNearest nearest;
+ KDTreeNearest_3d nearest;
const float range = data->solid + data->smooth;
- BLI_kdtree_find_nearest(data->tree, ray_start, &nearest);
+ BLI_kdtree_3d_find_nearest(data->tree, ray_start, &nearest);
if (nearest.dist < range) {
em->influence[index] = (nearest.dist < data->solid) ?
@@ -1263,9 +1263,9 @@ static void emit_from_particles_task_cb(
const float ray_start[3] = {lx + 0.5f * data->hr, ly + 0.5f * data->hr, lz + 0.5f * data->hr};
/* find particle distance from the kdtree */
- KDTreeNearest nearest;
+ KDTreeNearest_3d nearest;
const float range = data->solid + data->hr_smooth;
- BLI_kdtree_find_nearest(data->tree, ray_start, &nearest);
+ BLI_kdtree_3d_find_nearest(data->tree, ray_start, &nearest);
if (nearest.dist < range) {
em->influence_high[index] = (nearest.dist < data->solid) ?
@@ -1295,7 +1295,7 @@ static void emit_from_particles(
const float solid = sfs->particle_size * 0.5f;
const float smooth = 0.5f; /* add 0.5 cells of linear falloff to reduce aliasing */
int hires_multiplier = 1;
- KDTree *tree = NULL;
+ KDTree_3d *tree = NULL;
sim.depsgraph = depsgraph;
sim.scene = scene;
@@ -1325,7 +1325,7 @@ static void emit_from_particles(
/* setup particle radius emission if enabled */
if (sfs->flags & MOD_SMOKE_FLOW_USE_PART_SIZE) {
- tree = BLI_kdtree_new(psys->totpart + psys->totchild);
+ tree = BLI_kdtree_3d_new(psys->totpart + psys->totchild);
/* check need for high resolution map */
if ((sds->flags & MOD_SMOKE_HIGHRES) && (sds->highres_sampling == SM_HRES_FULLSAMPLE)) {
@@ -1365,7 +1365,7 @@ static void emit_from_particles(
mul_mat3_m4_v3(sds->imat, &particle_vel[valid_particles * 3]);
if (sfs->flags & MOD_SMOKE_FLOW_USE_PART_SIZE) {
- BLI_kdtree_insert(tree, valid_particles, pos);
+ BLI_kdtree_3d_insert(tree, valid_particles, pos);
}
/* calculate emission map bounds */
@@ -1423,7 +1423,7 @@ static void emit_from_particles(
res[i] = em->res[i] * hires_multiplier;
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
EmitFromParticlesData data = {
.sfs = sfs, .tree = tree, .hires_multiplier = hires_multiplier, .hr = hr,
@@ -1441,7 +1441,7 @@ static void emit_from_particles(
}
if (sfs->flags & MOD_SMOKE_FLOW_USE_PART_SIZE) {
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
}
/* free data */
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index a1e2e0971d1..0d8b2381572 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -1443,13 +1443,14 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
if (bs->springtype == SB_EDGE) {
/* +++ springs colliding */
if (ob->softflag & OB_SB_EDGECOLL) {
- if ( sb_detect_edge_collisionCached (sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos,
- &damp, feedback, ob, timenow)) {
- add_v3_v3(bs->ext_force, feedback);
- bs->flag |= BSF_INTERSECT;
- //bs->cf=damp;
- bs->cf=sb->choke*0.01f;
-
+ if (sb_detect_edge_collisionCached(
+ sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos,
+ &damp, feedback, ob, timenow))
+ {
+ add_v3_v3(bs->ext_force, feedback);
+ bs->flag |= BSF_INTERSECT;
+ //bs->cf=damp;
+ bs->cf=sb->choke*0.01f;
}
}
/* ---- springs colliding */
@@ -1564,7 +1565,7 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph, Scene *scene, stru
/* --- the spring external section*/
-static int choose_winner(float*w, float* pos, float*a, float*b, float*c, float*ca, float*cb, float*cc)
+static int choose_winner(float *w, float *pos, float *a, float *b, float *c, float *ca, float *cb, float *cc)
{
float mindist, cp;
int winner =1;
@@ -1862,7 +1863,6 @@ static void sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, floa
}
else {
/* TODO make this debug option */
- /**/
CLOG_WARN(&LOG, "bodypoint <bpi> is not attached to spring <*bs>");
return;
}
@@ -1885,13 +1885,13 @@ static void sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, floa
switch (bs->springtype) {
case SB_EDGE:
case SB_HANDLE:
- forcefactor *= kw;
+ forcefactor *= kw;
break;
case SB_BEND:
- forcefactor *=sb->secondspring*kw;
+ forcefactor *= sb->secondspring * kw;
break;
case SB_STIFFQUAD:
- forcefactor *=sb->shearstiff*sb->shearstiff* kw;
+ forcefactor *= sb->shearstiff * sb->shearstiff * kw;
break;
default:
break;
@@ -2043,11 +2043,11 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
BKE_effectors_apply(effectors, NULL, sb->effector_weights, &epoint, force, speed);
/* apply forcefield*/
- mul_v3_fl(force, fieldfactor* eval_sb_fric_force_scale);
+ mul_v3_fl(force, fieldfactor * eval_sb_fric_force_scale);
add_v3_v3(bp->force, force);
/* BP friction in moving media */
- kd= sb->mediafrict* eval_sb_fric_force_scale;
+ kd= sb->mediafrict * eval_sb_fric_force_scale;
bp->force[0] -= kd * (bp->vec[0] + windfactor*speed[0]/eval_sb_fric_force_scale);
bp->force[1] -= kd * (bp->vec[1] + windfactor*speed[1]/eval_sb_fric_force_scale);
bp->force[2] -= kd * (bp->vec[2] + windfactor*speed[2]/eval_sb_fric_force_scale);
@@ -2056,7 +2056,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo
}
else {
/* BP friction in media (not) moving*/
- float kd = sb->mediafrict* sb_fric_force_scale(ob);
+ float kd = sb->mediafrict * sb_fric_force_scale(ob);
/* assume it to be proportional to actual velocity */
bp->force[0]-= bp->vec[0]*kd;
bp->force[1]-= bp->vec[1]*kd;
@@ -3037,7 +3037,7 @@ void sbFree(Object *ob)
free_softbody_intern(sb);
- if ((ob->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0) {
+ if ((ob->id.tag & LIB_TAG_NO_MAIN) == 0) {
/* Only free shared data on non-CoW copies */
BKE_ptcache_free_list(&sb->shared->ptcaches);
sb->shared->pointcache = NULL;
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index 25684dbbe22..70ca76d409b 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -32,7 +32,7 @@
void BKE_speaker_init(Speaker *spk)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(spk, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(spk, id));
spk->attenuation = 1.0f;
spk->cone_angle_inner = 360.0f;
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index 16bfee755f4..38975f9a227 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -368,7 +368,7 @@ static void studiolight_create_equirect_radiance_gputexture(StudioLight *sl)
MEM_SAFE_FREE(gpu_matcap_3components);
}
else {
- sl->equirect_radiance_gputexture = GPU_texture_create_2D(
+ sl->equirect_radiance_gputexture = GPU_texture_create_2d(
ibuf->x, ibuf->y, GPU_RGBA16F, ibuf->rect_float, error);
GPUTexture *tex = sl->equirect_radiance_gputexture;
GPU_texture_bind(tex, 0);
@@ -386,7 +386,7 @@ static void studiolight_create_equirect_irradiance_gputexture(StudioLight *sl)
char error[256];
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_IRRADIANCE_IMAGE_CALCULATED);
ImBuf *ibuf = sl->equirect_irradiance_buffer;
- sl->equirect_irradiance_gputexture = GPU_texture_create_2D(
+ sl->equirect_irradiance_gputexture = GPU_texture_create_2d(
ibuf->x, ibuf->y, GPU_RGBA16F, ibuf->rect_float, error);
GPUTexture *tex = sl->equirect_irradiance_gputexture;
GPU_texture_bind(tex, 0);
@@ -1184,7 +1184,7 @@ void BKE_studiolight_init(void)
STUDIOLIGHT_INTERNAL | STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED | STUDIOLIGHT_TYPE_STUDIO);
BLI_strncpy(sl->name, "Default", FILE_MAXFILE);
- copy_v4_fl4(sl->light_ambient, 0.025000, 0.025000, 0.025000, 1.000000);
+ copy_v3_fl3(sl->light_ambient, 0.025000, 0.025000, 0.025000);
copy_v4_fl4(sl->light[0].vec, -0.580952, 0.228571, 0.781185, 0.0);
copy_v4_fl4(sl->light[0].col, 0.900000, 0.900000, 0.900000, 1.000000);
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c
index 6840e07c129..c262ccfe16f 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.c
+++ b/source/blender/blenkernel/intern/subdiv_ccg.c
@@ -1007,17 +1007,53 @@ static void average_grid_element(SubdivCCG *subdiv_ccg,
}
}
-static void copy_grid_element(SubdivCCG *subdiv_ccg,
- CCGKey *key,
- CCGElem *destination,
- CCGElem *source)
+/* Accumulator to hold data during averaging. */
+typedef struct GridElementAccumulator {
+ float co[3];
+ float no[3];
+ float mask;
+} GridElementAccumulator;
+
+static void element_accumulator_init(GridElementAccumulator *accumulator)
{
- copy_v3_v3(CCG_elem_co(key, destination), CCG_elem_co(key, source));
+ zero_v3(accumulator->co);
+ zero_v3(accumulator->no);
+ accumulator->mask = 0.0f;
+}
+
+static void element_accumulator_add(GridElementAccumulator *accumulator,
+ const SubdivCCG *subdiv_ccg,
+ CCGKey *key,
+ /*const*/ CCGElem *grid_element)
+{
+ add_v3_v3(accumulator->co, CCG_elem_co(key, grid_element));
+ if (subdiv_ccg->has_normal) {
+ add_v3_v3(accumulator->no, CCG_elem_no(key, grid_element));
+ }
+ if (subdiv_ccg->has_mask) {
+ accumulator->mask += *CCG_elem_mask(key, grid_element);
+ }
+}
+
+static void element_accumulator_mul_fl(GridElementAccumulator *accumulator,
+ const float f)
+{
+ mul_v3_fl(accumulator->co, f);
+ mul_v3_fl(accumulator->no, f);
+ accumulator->mask *= f;
+}
+
+static void element_accumulator_copy(SubdivCCG *subdiv_ccg,
+ CCGKey *key,
+ CCGElem *destination,
+ const GridElementAccumulator *accumulator)
+{
+ copy_v3_v3(CCG_elem_co(key, destination), accumulator->co);
if (subdiv_ccg->has_normal) {
- copy_v3_v3(CCG_elem_no(key, destination), CCG_elem_no(key, source));
+ copy_v3_v3(CCG_elem_no(key, destination), accumulator->no);
}
if (subdiv_ccg->has_mask) {
- *CCG_elem_mask(key, destination) = *CCG_elem_mask(key, source);
+ *CCG_elem_mask(key, destination) = accumulator->mask;
}
}
@@ -1061,10 +1097,15 @@ typedef struct AverageGridsBoundariesData {
CCGKey *key;
} AverageGridsBoundariesData;
+typedef struct AverageGridsBoundariesTLSData {
+ GridElementAccumulator *accumulators;
+} AverageGridsBoundariesTLSData;
+
static void subdiv_ccg_average_grids_boundary(
SubdivCCG *subdiv_ccg,
CCGKey *key,
- SubdivCCGAdjacentEdge *adjacent_edge)
+ SubdivCCGAdjacentEdge *adjacent_edge,
+ AverageGridsBoundariesTLSData *tls)
{
const int num_adjacent_faces = adjacent_edge->num_adjacent_faces;
const int grid_size2 = subdiv_ccg->grid_size * 2;
@@ -1072,39 +1113,35 @@ static void subdiv_ccg_average_grids_boundary(
/* Nothing to average with. */
return;
}
- /* Incrementall average result to elements of a first adjacent face.
- *
- * Arguably, this is less precise than accumulating and then diving once,
- * but on another hand this is more stable when coordinates are big. */
- for (int face_index = 1; face_index < num_adjacent_faces; face_index++) {
- /* NOTE: We ignore very first and very last elements, they correspond
- * to corner vertices, and they can belong to multiple edges.
- * The fact, that they can belong to multiple edges means we can't
- * safely average them.
- * The fact, that they correspond to a corner elements, means they will
- * be handled at the upcoming pass over corner elements. */
+ if (tls->accumulators == NULL) {
+ tls->accumulators = MEM_calloc_arrayN(sizeof(GridElementAccumulator),
+ grid_size2,
+ "average accumulators");
+ }
+ else {
for (int i = 1; i < grid_size2 - 1; i++) {
- CCGElem *grid_element_0 =
- adjacent_edge->boundary_elements[0][i];
- CCGElem *grid_element_face_index =
+ element_accumulator_init(&tls->accumulators[i]);
+ }
+ }
+ for (int face_index = 0; face_index < num_adjacent_faces; face_index++) {
+ for (int i = 1; i < grid_size2 - 1; i++) {
+ CCGElem *grid_element =
adjacent_edge->boundary_elements[face_index][i];
- average_grid_element(subdiv_ccg,
- key,
- grid_element_0,
- grid_element_face_index);
+ element_accumulator_add(
+ &tls->accumulators[i], subdiv_ccg, key, grid_element);
}
}
+ for (int i = 1; i < grid_size2 -1; i++) {
+ element_accumulator_mul_fl(
+ &tls->accumulators[i], 1.0f / (float)num_adjacent_faces);
+ }
/* Copy averaged value to all the other faces. */
- for (int face_index = 1; face_index < num_adjacent_faces; face_index++) {
- for (int i = 1; i < grid_size2 -1; i++) {
- CCGElem *grid_element_0 =
- adjacent_edge->boundary_elements[0][i];
- CCGElem *grid_element_face_index =
+ for (int face_index = 0; face_index < num_adjacent_faces; face_index++) {
+ for (int i = 1; i < grid_size2 - 1; i++) {
+ CCGElem *grid_element =
adjacent_edge->boundary_elements[face_index][i];
- copy_grid_element(subdiv_ccg,
- key,
- grid_element_face_index,
- grid_element_0);
+ element_accumulator_copy(
+ subdiv_ccg, key, grid_element, &tls->accumulators[i]);
}
}
}
@@ -1112,14 +1149,23 @@ static void subdiv_ccg_average_grids_boundary(
static void subdiv_ccg_average_grids_boundaries_task(
void *__restrict userdata_v,
const int adjacent_edge_index,
- const ParallelRangeTLS *__restrict UNUSED(tls_v))
+ const ParallelRangeTLS *__restrict tls_v)
{
AverageGridsBoundariesData *data = userdata_v;
+ AverageGridsBoundariesTLSData *tls = tls_v->userdata_chunk;
SubdivCCG *subdiv_ccg = data->subdiv_ccg;
CCGKey *key = data->key;
SubdivCCGAdjacentEdge *adjacent_edge =
&subdiv_ccg->adjacent_edges[adjacent_edge_index];
- subdiv_ccg_average_grids_boundary(subdiv_ccg, key, adjacent_edge);
+ subdiv_ccg_average_grids_boundary(subdiv_ccg, key, adjacent_edge, tls);
+}
+
+static void subdiv_ccg_average_grids_boundaries_finalize(
+ void *__restrict UNUSED(userdata),
+ void *__restrict tls_v)
+{
+ AverageGridsBoundariesTLSData *tls = tls_v;
+ MEM_SAFE_FREE(tls->accumulators);
}
typedef struct AverageGridsCornerData {
@@ -1137,28 +1183,17 @@ static void subdiv_ccg_average_grids_corners(
/* Nothing to average with. */
return;
}
- /* Incrementall average result to elements of a first adjacent face.
- * See comment to the boundary averaging. */
- for (int face_index = 1; face_index < num_adjacent_faces; face_index++) {
- CCGElem *grid_element_0 =
- adjacent_vertex->corner_elements[0];
- CCGElem *grid_element_face_index =
- adjacent_vertex->corner_elements[face_index];
- average_grid_element(subdiv_ccg,
- key,
- grid_element_0,
- grid_element_face_index);
+ GridElementAccumulator accumulator;
+ element_accumulator_init(&accumulator);
+ for (int face_index = 0; face_index < num_adjacent_faces; face_index++) {
+ CCGElem *grid_element = adjacent_vertex->corner_elements[face_index];
+ element_accumulator_add(&accumulator, subdiv_ccg, key, grid_element);
}
+ element_accumulator_mul_fl(&accumulator, 1.0f / (float)num_adjacent_faces);
/* Copy averaged value to all the other faces. */
- for (int face_index = 1; face_index < num_adjacent_faces; face_index++) {
- CCGElem *grid_element_0 =
- adjacent_vertex->corner_elements[0];
- CCGElem *grid_element_face_index =
- adjacent_vertex->corner_elements[face_index];
- copy_grid_element(subdiv_ccg,
- key,
- grid_element_face_index,
- grid_element_0);
+ for (int face_index = 0; face_index < num_adjacent_faces; face_index++) {
+ CCGElem *grid_element = adjacent_vertex->corner_elements[face_index];
+ element_accumulator_copy(subdiv_ccg, key, grid_element, &accumulator);
}
}
@@ -1175,22 +1210,33 @@ static void subdiv_ccg_average_grids_corners_task(
subdiv_ccg_average_grids_corners(subdiv_ccg, key, adjacent_vertex);
}
-static void subdiv_ccg_average_all_boundaries_and_corners(
+static void subdiv_ccg_average_all_boundaries(
SubdivCCG *subdiv_ccg,
CCGKey *key)
{
ParallelRangeSettings parallel_range_settings;
BLI_parallel_range_settings_defaults(&parallel_range_settings);
- /* Average grids across coarse edges. */
AverageGridsBoundariesData boundaries_data = {
.subdiv_ccg = subdiv_ccg,
.key = key,
};
+ AverageGridsBoundariesTLSData tls_data = {NULL};
+ parallel_range_settings.userdata_chunk = &tls_data;
+ parallel_range_settings.userdata_chunk_size = sizeof(tls_data);
+ parallel_range_settings.func_finalize =
+ subdiv_ccg_average_grids_boundaries_finalize;
BLI_task_parallel_range(0, subdiv_ccg->num_adjacent_edges,
&boundaries_data,
subdiv_ccg_average_grids_boundaries_task,
&parallel_range_settings);
- /* Average grids at coarse vertices. */
+}
+
+static void subdiv_ccg_average_all_corners(
+ SubdivCCG *subdiv_ccg,
+ CCGKey *key)
+{
+ ParallelRangeSettings parallel_range_settings;
+ BLI_parallel_range_settings_defaults(&parallel_range_settings);
AverageGridsCornerData corner_data = {
.subdiv_ccg = subdiv_ccg,
.key = key,
@@ -1201,6 +1247,14 @@ static void subdiv_ccg_average_all_boundaries_and_corners(
&parallel_range_settings);
}
+static void subdiv_ccg_average_all_boundaries_and_corners(
+ SubdivCCG *subdiv_ccg,
+ CCGKey *key)
+{
+ subdiv_ccg_average_all_boundaries(subdiv_ccg, key);
+ subdiv_ccg_average_all_corners(subdiv_ccg, key);
+}
+
void BKE_subdiv_ccg_average_grids(SubdivCCG *subdiv_ccg)
{
CCGKey key;
diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.c b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
index 8aac77c0bd8..00a2436098e 100644
--- a/source/blender/blenkernel/intern/subdiv_converter_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
@@ -324,12 +324,12 @@ static void initialize_manifold_index_array(const BLI_bitmap *used_map,
int *indices = NULL;
if (indices_r != NULL) {
indices = MEM_malloc_arrayN(
- num_elements, sizeof(int), "manifold indices");
+ num_elements, sizeof(int), "manifold indices");
}
int *indices_reverse = NULL;
if (indices_reverse_r != NULL) {
indices_reverse = MEM_malloc_arrayN(
- num_elements, sizeof(int), "manifold indices reverse");
+ num_elements, sizeof(int), "manifold indices reverse");
}
int offset = 0;
for (int i = 0; i < num_elements; i++) {
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 9690e847b38..b383c049e2e 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -577,6 +577,9 @@ static void set_subsurf_uv(CCGSubSurf *ss,
}
/* face weighting */
+#define SUB_ELEMS_FACE 50
+typedef float FaceVertWeight[SUB_ELEMS_FACE][SUB_ELEMS_FACE];
+
typedef struct FaceVertWeightEntry {
FaceVertWeight *weight;
float *w;
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index a340fadc0ea..ef77f847d83 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -205,7 +205,7 @@ void BKE_text_init(Text *ta)
{
TextLine *tmp;
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ta, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ta, id));
ta->name = NULL;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index e3ce946c5cf..8cfe3d2476d 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -210,7 +210,7 @@ void BKE_texture_free(Tex *tex)
void BKE_texture_default(Tex *tex)
{
- /* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(tex, id)); */ /* Not here, can be called with some pointers set. :/ */
+ /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); */ /* Not here, can be called with some pointers set. :/ */
tex->type = TEX_IMAGE;
tex->ima = NULL;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 79102742927..28f47cbf067 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -2998,7 +2998,7 @@ void BKE_tracking_get_rna_path_prefix_for_track(
MovieTrackingObject *object =
BKE_tracking_find_object_for_track(tracking, track);
if (object == NULL) {
- BLI_snprintf(rna_path, rna_path_len, "tracking.tracks");
+ BLI_strncpy(rna_path, "tracking.tracks", rna_path_len);
}
else {
char object_name_esc[MAX_NAME * 2];
@@ -3043,7 +3043,7 @@ void BKE_tracking_get_rna_path_prefix_for_plane_track(
MovieTrackingObject *object =
BKE_tracking_find_object_for_plane_track(tracking, plane_track);
if (object == NULL) {
- BLI_snprintf(rna_path, rna_path_len, "tracking.plane_tracks");
+ BLI_strncpy(rna_path, "tracking.plane_tracks", rna_path_len);
}
else {
char object_name_esc[MAX_NAME * 2];
diff --git a/source/blender/blenkernel/intern/tracking_auto.c b/source/blender/blenkernel/intern/tracking_auto.c
index 38124ddf97c..bddb5315781 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -538,7 +538,7 @@ void BKE_autotrack_context_sync(AutoTrackContext *context)
for (track = 0; track < context->num_tracks; ++track) {
AutoTrackOptions *options = &context->options[track];
int track_frame = BKE_movieclip_remap_scene_to_clip_frame(
- context->clips[options->clip_index], frame);
+ context->clips[options->clip_index], frame);
if (options->is_failed) {
if (options->failed_frame == track_frame) {
MovieTrackingMarker *prev_marker =
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index c9d629c4e19..448fe6cb167 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -858,7 +858,7 @@ static bool undosys_ID_map_lookup_index(const UndoIDPtrMap *map, const void *key
const UndoIDPtrMapItem *pmap = map->pmap;
const uint len = map->len;
if (len == 0) {
- if (*r_index) {
+ if (r_index) {
*r_index = 0;
}
return false;
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index c2bded42bc1..e264856acb2 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -18,9 +18,6 @@
* \ingroup bke
*/
-/* allow accessing private members of DNA_workspace_types.h */
-#define DNA_PRIVATE_WORKSPACE_ALLOW
-
#include <stdlib.h>
#include <string.h>
@@ -331,7 +328,7 @@ WorkSpaceLayout *BKE_workspace_layout_iter_circular(
return iter_layout;
}
}
- LISTBASE_CIRCULAR_FORWARD_END(&workspace->layouts, iter_layout, start)
+ LISTBASE_CIRCULAR_FORWARD_END(&workspace->layouts, iter_layout, start);
}
return NULL;
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 4cc6ae190e0..2118f9adda9 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -70,7 +70,7 @@ void BKE_world_free(World *wrld)
void BKE_world_init(World *wrld)
{
- BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(wrld, id));
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wrld, id));
wrld->horr = 0.05f;
wrld->horg = 0.05f;
diff --git a/source/blender/blenlib/BLI_assert.h b/source/blender/blenlib/BLI_assert.h
index b6d5242ae57..52d4858548a 100644
--- a/source/blender/blenlib/BLI_assert.h
+++ b/source/blender/blenlib/BLI_assert.h
@@ -34,6 +34,10 @@ extern "C" {
#include <stdio.h>
#endif
+#ifdef _MSC_VER
+#include <crtdbg.h> /* for _STATIC_ASSERT */
+#endif
+
/* BLI_assert(), default only to print
* for aborting need to define WITH_ASSERT_ABORT
*/
@@ -72,24 +76,20 @@ extern "C" {
(!defined(__COVERITY__)) && \
(defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) /* gcc4.6+ only */
# define BLI_STATIC_ASSERT(a, msg) __extension__ _Static_assert(a, msg);
-#else
-/* Code adapted from http://www.pixelbeat.org/programming/gcc/static_assert.html */
-/* Note we need the two concats below because arguments to ## are not expanded, so we need to
- * expand __LINE__ with one indirection before doing the actual concatenation. */
+#elif defined(_MSC_VER)
+# define BLI_STATIC_ASSERT(a, msg) _STATIC_ASSERT(a);
+#else /* older gcc, clang... */
+ /* Code adapted from http://www.pixelbeat.org/programming/gcc/static_assert.html */
+ /* Note we need the two concats below because arguments to ## are not expanded, so we need to
+ * expand __LINE__ with one indirection before doing the actual concatenation. */
# define _BLI_ASSERT_CONCAT_(a, b) a##b
# define _BLI_ASSERT_CONCAT(a, b) _BLI_ASSERT_CONCAT_(a, b)
- /* These can't be used after statements in c89. */
-# if defined(__COUNTER__) /* MSVC */
-# define BLI_STATIC_ASSERT(a, msg) \
- ; enum { _BLI_ASSERT_CONCAT(static_assert_, __COUNTER__) = 1 / (int)(!!(a)) };
-# else /* older gcc, clang... */
- /* This can't be used twice on the same line so ensure if using in headers
- * that the headers are not included twice (by wrapping in #ifndef...#endif)
- * Note it doesn't cause an issue when used on same line of separate modules
- * compiled with gcc -combine -fwhole-program. */
-# define BLI_STATIC_ASSERT(a, msg) \
- ; enum { _BLI_ASSERT_CONCAT(assert_line_, __LINE__) = 1 / (int)(!!(a)) };
-# endif
+ /* This can't be used twice on the same line so ensure if using in headers
+ * that the headers are not included twice (by wrapping in #ifndef...#endif)
+ * Note it doesn't cause an issue when used on same line of separate modules
+ * compiled with gcc -combine -fwhole-program. */
+# define BLI_STATIC_ASSERT(a, msg) \
+ ; enum { _BLI_ASSERT_CONCAT(assert_line_, __LINE__) = 1 / (int)(!!(a)) };
#endif
#define BLI_STATIC_ASSERT_ALIGN(st, align) \
diff --git a/source/blender/blenlib/BLI_kdtree.h b/source/blender/blenlib/BLI_kdtree.h
index 864055127fc..4baff208ca7 100644
--- a/source/blender/blenlib/BLI_kdtree.h
+++ b/source/blender/blenlib/BLI_kdtree.h
@@ -22,54 +22,48 @@
* \brief A kd-tree for nearest neighbor search.
*/
-#include "BLI_compiler_attrs.h"
+/* 1D version */
+#define KD_DIMS 1
+#define KDTREE_PREFIX_ID BLI_kdtree_1d
+#define KDTree KDTree_1d
+#define KDTreeNearest KDTreeNearest_1d
+#include "BLI_kdtree_impl.h"
+#undef KD_DIMS
+#undef KDTree
+#undef KDTreeNearest
+#undef KDTREE_PREFIX_ID
-struct KDTree;
-typedef struct KDTree KDTree;
+/* 2D version */
+#define KD_DIMS 2
+#define KDTREE_PREFIX_ID BLI_kdtree_2d
+#define KDTree KDTree_2d
+#define KDTreeNearest KDTreeNearest_2d
+#include "BLI_kdtree_impl.h"
+#undef KD_DIMS
+#undef KDTree
+#undef KDTreeNearest
+#undef KDTREE_PREFIX_ID
-typedef struct KDTreeNearest {
- int index;
- float dist;
- float co[3];
-} KDTreeNearest;
+/* 3D version */
+#define KD_DIMS 3
+#define KDTREE_PREFIX_ID BLI_kdtree_3d
+#define KDTree KDTree_3d
+#define KDTreeNearest KDTreeNearest_3d
+#include "BLI_kdtree_impl.h"
+#undef KD_DIMS
+#undef KDTree
+#undef KDTreeNearest
+#undef KDTREE_PREFIX_ID
-KDTree *BLI_kdtree_new(unsigned int maxsize);
-void BLI_kdtree_free(KDTree *tree);
-void BLI_kdtree_balance(KDTree *tree) ATTR_NONNULL(1);
-
-void BLI_kdtree_insert(
- KDTree *tree, int index,
- const float co[3]) ATTR_NONNULL(1, 3);
-int BLI_kdtree_find_nearest(
- const KDTree *tree, const float co[3],
- KDTreeNearest *r_nearest) ATTR_NONNULL(1, 2);
-
-#define BLI_kdtree_find_nearest_n(tree, co, r_nearest, n) \
- BLI_kdtree_find_nearest_n__normal(tree, co, NULL, r_nearest, n)
-#define BLI_kdtree_range_search(tree, co, r_nearest, range) \
- BLI_kdtree_range_search__normal(tree, co, NULL, r_nearest, range)
-
-int BLI_kdtree_find_nearest_cb(
- const KDTree *tree, const float co[3],
- int (*filter_cb)(void *user_data, int index, const float co[3], float dist_sq), void *user_data,
- KDTreeNearest *r_nearest);
-void BLI_kdtree_range_search_cb(
- const KDTree *tree, const float co[3], float range,
- bool (*search_cb)(void *user_data, int index, const float co[3], float dist_sq), void *user_data);
-
-int BLI_kdtree_calc_duplicates_fast(
- const KDTree *tree, const float range, bool use_index_order,
- int *doubles);
-
-/* Normal use is deprecated */
-/* remove __normal functions when last users drop */
-int BLI_kdtree_find_nearest_n__normal(
- const KDTree *tree, const float co[3], const float nor[3],
- KDTreeNearest *r_nearest,
- unsigned int n) ATTR_NONNULL(1, 2, 4);
-int BLI_kdtree_range_search__normal(
- const KDTree *tree, const float co[3], const float nor[3],
- KDTreeNearest **r_nearest,
- float range) ATTR_NONNULL(1, 2, 4) ATTR_WARN_UNUSED_RESULT;
+/* 4D version */
+#define KD_DIMS 4
+#define KDTREE_PREFIX_ID BLI_kdtree_4d
+#define KDTree KDTree_4d
+#define KDTreeNearest KDTreeNearest_4d
+#include "BLI_kdtree_impl.h"
+#undef KD_DIMS
+#undef KDTree
+#undef KDTreeNearest
+#undef KDTREE_PREFIX_ID
#endif /* __BLI_KDTREE_H__ */
diff --git a/source/blender/blenlib/BLI_kdtree_impl.h b/source/blender/blenlib/BLI_kdtree_impl.h
new file mode 100644
index 00000000000..bd4fa908b14
--- /dev/null
+++ b/source/blender/blenlib/BLI_kdtree_impl.h
@@ -0,0 +1,89 @@
+/*
+ * 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 bli
+ * \brief A kd-tree for nearest neighbor search.
+ */
+
+#include "BLI_compiler_attrs.h"
+
+#define _CONCAT_AUX(MACRO_ARG1, MACRO_ARG2) MACRO_ARG1 ## MACRO_ARG2
+#define _CONCAT(MACRO_ARG1, MACRO_ARG2) _CONCAT_AUX(MACRO_ARG1, MACRO_ARG2)
+#define BLI_kdtree_nd_(id) _CONCAT(KDTREE_PREFIX_ID, _##id)
+
+struct KDTree;
+typedef struct KDTree KDTree;
+
+typedef struct KDTreeNearest {
+ int index;
+ float dist;
+ float co[KD_DIMS];
+} KDTreeNearest;
+
+KDTree *BLI_kdtree_nd_(new)(unsigned int maxsize);
+void BLI_kdtree_nd_(free)(KDTree *tree);
+void BLI_kdtree_nd_(balance)(KDTree *tree) ATTR_NONNULL(1);
+
+void BLI_kdtree_nd_(insert)(
+ KDTree *tree, int index,
+ const float co[KD_DIMS]) ATTR_NONNULL(1, 3);
+int BLI_kdtree_nd_(find_nearest)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest *r_nearest) ATTR_NONNULL(1, 2);
+
+int BLI_kdtree_nd_(find_nearest_n)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest *r_nearest,
+ const uint nearest_len_capacity) ATTR_NONNULL(1, 2, 3);
+
+int BLI_kdtree_nd_(range_search)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest **r_nearest,
+ const float range) ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
+
+int BLI_kdtree_nd_(find_nearest_cb)(
+ const KDTree *tree, const float co[KD_DIMS],
+ int (*filter_cb)(void *user_data, int index, const float co[KD_DIMS], float dist_sq), void *user_data,
+ KDTreeNearest *r_nearest);
+void BLI_kdtree_nd_(range_search_cb)(
+ const KDTree *tree, const float co[KD_DIMS], float range,
+ bool (*search_cb)(void *user_data, int index, const float co[KD_DIMS], float dist_sq), void *user_data);
+
+int BLI_kdtree_nd_(calc_duplicates_fast)(
+ const KDTree *tree, const float range, bool use_index_order,
+ int *doubles);
+
+
+int BLI_kdtree_nd_(deduplicate)(KDTree *tree);
+
+/* Versions of find/range search that take a squared distance callback to support bias. */
+int BLI_kdtree_nd_(find_nearest_n_with_len_squared_cb)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest *r_nearest,
+ const uint nearest_len_capacity,
+ float (*len_sq_fn)(const float co_search[KD_DIMS], const float co_test[KD_DIMS], const void *user_data),
+ const void *user_data) ATTR_NONNULL(1, 2, 3);
+int BLI_kdtree_nd_(range_search_with_len_squared_cb)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest **r_nearest,
+ const float range,
+ float (*len_sq_fn)(const float co_search[KD_DIMS], const float co_test[KD_DIMS], const void *user_data),
+ const void *user_data) ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
+
+#undef _CONCAT_AUX
+#undef _CONCAT
+#undef BLI_kdtree_nd_
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index cb0d394bd0b..5e93039c39c 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -111,7 +111,7 @@ if ((lb)->first && (lb_init || (lb_init = (lb)->first))) { \
#define LISTBASE_CIRCULAR_FORWARD_END(lb, lb_iter, lb_init) \
} while ((lb_iter = (lb_iter)->next ? (lb_iter)->next : (lb)->first), \
(lb_iter != lb_init)); \
-}
+} ((void)0)
#define LISTBASE_CIRCULAR_BACKWARD_BEGIN(lb, lb_iter, lb_init) \
if ((lb)->last && (lb_init || (lb_init = (lb)->last))) { \
@@ -120,7 +120,7 @@ if ((lb)->last && (lb_init || (lb_init = (lb)->last))) { \
#define LISTBASE_CIRCULAR_BACKWARD_END(lb, lb_iter, lb_init) \
} while ((lb_iter = (lb_iter)->prev ? (lb_iter)->prev : (lb)->last), \
(lb_iter != lb_init)); \
-}
+} ((void)0)
#define LISTBASE_FOREACH(type, var, list) \
for (type var = (type)((list)->first); \
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 4d095ab1900..2f81fbf37f6 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -441,6 +441,11 @@ void window_translate_m4(float winmat[4][4], float perspmat[4][4],
void planes_from_projmat(float mat[4][4], float left[4], float right[4], float top[4], float bottom[4],
float front[4], float back[4]);
+void projmat_dimensions(const float projmat[4][4],
+ float *r_left, float *r_right,
+ float *r_bottom, float *r_top,
+ float *r_near, float *r_far);
+
int box_clip_bounds_m4(float boundbox[2][3],
const float bounds[4], float winmat[4][4]);
void box_minmax_bounds_m4(float min[3], float max[3],
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 4e897ace95c..8e35b197e14 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -15,9 +15,8 @@
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
-
- * The Original Code is: some of this file.
*
+ * The Original Code is: some of this file.
* */
#ifndef __BLI_MATH_MATRIX_H__
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index 5246d7ad1a9..60adcf8c762 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -77,6 +77,8 @@ void add_qt_qtqt(float q[4], const float a[4], const float b[4], const float t);
void quat_to_mat3(float mat[3][3], const float q[4]);
void quat_to_mat4(float mat[4][4], const float q[4]);
+void quat_to_compatible_quat(float q[4], const float a[4], const float old[4]);
+
void mat3_normalized_to_quat(float q[4], const float mat[3][3]);
void mat4_normalized_to_quat(float q[4], const float mat[4][4]);
void mat3_to_quat(float q[4], const float mat[3][3]);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index f3908cf7462..c9285466259 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -204,6 +204,7 @@ MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESU
MINLINE float len_v2v2_int(const int v1[2], const int v2[2]);
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE float len_squared_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT;
MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
MINLINE int len_manhattan_v2v2_int(const int a[2], const int b[2]) ATTR_WARN_UNUSED_RESULT;
MINLINE float len_manhattan_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
@@ -288,8 +289,6 @@ MINLINE bool compare_v3v3_relative(const float a[3], const float b[3], const flo
MINLINE bool compare_v4v4_relative(const float a[4], const float b[4], const float limit, const int max_ulps) ATTR_WARN_UNUSED_RESULT;
MINLINE bool compare_len_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
-MINLINE bool compare_len_squared_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
-MINLINE bool compare_len_squared_v4v4(const float a[4], const float b[4], const float limit) ATTR_WARN_UNUSED_RESULT;
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h
index 31bd93544b0..f14b6f94a5e 100644
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@ -57,7 +57,7 @@ void *BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr) ATTR_
void BLI_mempool_set_memory_debug(void);
#endif
-/** iteration stuff. note: this may easy to produce bugs with **/
+/** iteration stuff. note: this may easy to produce bugs with */
/* private structure */
typedef struct BLI_mempool_iter {
BLI_mempool *pool;
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index ac87fd21a92..ddb9828129c 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -92,7 +92,7 @@ bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL();
bool BLI_path_frame(char *path, int frame, int digits) ATTR_NONNULL();
bool BLI_path_frame_range(char *path, int sta, int end, int digits) ATTR_NONNULL();
bool BLI_path_frame_get(char *path, int *r_frame, int *numdigits) ATTR_NONNULL();
-void BLI_path_frame_strip(char *path, bool set_frame_char, char *ext) ATTR_NONNULL();
+void BLI_path_frame_strip(char *path, char *ext) ATTR_NONNULL();
bool BLI_path_frame_check_chars(const char *path) ATTR_NONNULL();
bool BLI_path_cwd(char *path, const size_t maxlen) ATTR_NONNULL();
void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h
index fd078ae3a36..b76dadd9ad1 100644
--- a/source/blender/blenlib/BLI_rand.h
+++ b/source/blender/blenlib/BLI_rand.h
@@ -87,16 +87,16 @@ RNG_THREAD_ARRAY *BLI_rng_threaded_new(void);
void BLI_rng_threaded_free(struct RNG_THREAD_ARRAY *rngarr) ATTR_NONNULL(1);
int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) ATTR_WARN_UNUSED_RESULT;
-/** Low-discrepancy sequences **/
+/* Low-discrepancy sequences. */
/** Return the _n_th number of the given low-discrepancy sequence. */
-void BLI_halton_1D(unsigned int prime, double offset, int n, double *r);
-void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r);
-void BLI_halton_3D(unsigned int prime[3], double offset[3], int n, double *r);
-void BLI_hammersley_1D(unsigned int n, double *r);
+void BLI_halton_1d(unsigned int prime, double offset, int n, double *r);
+void BLI_halton_2d(unsigned int prime[2], double offset[2], int n, double *r);
+void BLI_halton_3d(unsigned int prime[3], double offset[3], int n, double *r);
+void BLI_hammersley_1d(unsigned int n, double *r);
/** Return the whole low-discrepancy sequence up to _n_. */
-void BLI_halton_2D_sequence(unsigned int prime[2], double offset[2], int n, double *r);
-void BLI_hammersley_2D_sequence(unsigned int n, double *r);
+void BLI_halton_2d_sequence(unsigned int prime[2], double offset[2], int n, double *r);
+void BLI_hammersley_2d_sequence(unsigned int n, double *r);
#endif /* __BLI_RAND_H__ */
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index d3b285d0ddf..740d6491c92 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -36,6 +36,13 @@ extern "C" {
/* We could remove in future. */
#include "BLI_assert.h"
+/* include after _VA_NARGS macro */
+#include "BLI_compiler_typecheck.h"
+
+/* -------------------------------------------------------------------- */
+/** \name Min/Max Macros
+ * \{ */
+
/* useful for finding bad use of min/max */
#if 0
/* gcc only */
@@ -44,9 +51,6 @@ extern "C" {
# define MAX2(x, y) (_TYPECHECK(x, y), (((x) > (y) ? (x) : (y))))
#endif
-/* include after _VA_NARGS macro */
-#include "BLI_compiler_typecheck.h"
-
/* min/max */
#if defined(__GNUC__) || defined(__clang__)
@@ -129,8 +133,11 @@ extern "C" {
if ((max)[1] < (vec)[1] ) (max)[1] = (vec)[1]; \
} (void)0
-/* some math and copy defines */
+/** \} */
+/* -------------------------------------------------------------------- */
+/** \name Swap/Shift Macros
+ * \{ */
#define SWAP(type, a, b) { \
type sw_ap; \
@@ -150,6 +157,37 @@ extern "C" {
(b) = (tval); \
} (void)0
+/* shift around elements */
+#define SHIFT3(type, a, b, c) { \
+ type tmp; \
+ CHECK_TYPE(a, type); \
+ CHECK_TYPE(b, type); \
+ CHECK_TYPE(c, type); \
+ tmp = a; \
+ a = c; \
+ c = b; \
+ b = tmp; \
+} (void)0
+
+#define SHIFT4(type, a, b, c, d) { \
+ type tmp; \
+ CHECK_TYPE(a, type); \
+ CHECK_TYPE(b, type); \
+ CHECK_TYPE(c, type); \
+ CHECK_TYPE(d, type); \
+ tmp = a; \
+ a = d; \
+ d = c; \
+ c = b; \
+ b = tmp; \
+} (void)0
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Equal to Any Element (ELEM) Macro
+ * \{ */
+
/* ELEM#(v, ...): is the first arg equal any others? */
/* internal helpers*/
#define _VA_ELEM2(v, a) \
@@ -188,35 +226,11 @@ extern "C" {
/* reusable ELEM macro */
#define ELEM(...) VA_NARGS_CALL_OVERLOAD(_VA_ELEM, __VA_ARGS__)
-/* no-op for expressions we don't want to instansiate, but must remian valid */
-#define EXPR_NOP(expr) (void)(0 ? ((void)(expr), 1) : 0)
+/** \} */
-/* shift around elements */
-#define SHIFT3(type, a, b, c) { \
- type tmp; \
- CHECK_TYPE(a, type); \
- CHECK_TYPE(b, type); \
- CHECK_TYPE(c, type); \
- tmp = a; \
- a = c; \
- c = b; \
- b = tmp; \
-} (void)0
-
-#define SHIFT4(type, a, b, c, d) { \
- type tmp; \
- CHECK_TYPE(a, type); \
- CHECK_TYPE(b, type); \
- CHECK_TYPE(c, type); \
- CHECK_TYPE(d, type); \
- tmp = a; \
- a = d; \
- d = c; \
- c = b; \
- b = tmp; \
-} (void)0
-
-/* some misc stuff.... */
+/* -------------------------------------------------------------------- */
+/** \name Simple Math Macros
+ * \{ */
/* avoid multiple access for supported compilers */
#if defined(__GNUC__) || defined(__clang__)
@@ -239,6 +253,36 @@ extern "C" {
#endif
+/* Float equality checks. */
+
+#define IS_EQ(a, b) ( \
+ CHECK_TYPE_INLINE(a, double), CHECK_TYPE_INLINE(b, double), \
+ ((fabs((double)((a) - (b))) >= (double) FLT_EPSILON) ? false : true))
+
+#define IS_EQF(a, b) ( \
+ CHECK_TYPE_INLINE(a, float), CHECK_TYPE_INLINE(b, float), \
+ ((fabsf((float)((a) - (b))) >= (float) FLT_EPSILON) ? false : true))
+
+#define IS_EQT(a, b, c) (((a) > (b)) ? ((((a) - (b)) <= (c))) : (((((b) - (a)) <= (c)))))
+#define IN_RANGE(a, b, c) (((b) < (c)) ? (((b) < (a) && (a) < (c))) : (((c) < (a) && (a) < (b))))
+#define IN_RANGE_INCL(a, b, c) (((b) < (c)) ? (((b) <= (a) && (a) <= (c))) : (((c) <= (a) && (a) <= (b))))
+
+/**
+ * Expands to an integer constant expression evaluating to a close upper bound
+ * on the number the number of decimal digits in a value expressible in the
+ * integer type given by the argument (if it is a type name) or the integer
+ * type of the argument (if it is an expression). The meaning of the resulting
+ * expression is unspecified for other arguments.
+ * i.e: `DECIMAL_DIGITS_BOUND(uchar)` is equal to 3.
+ */
+#define DECIMAL_DIGITS_BOUND(t) (241 * sizeof(t) / 100 + 1)
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Clamp Macros
+ * \{ */
+
#define CLAMPIS(a, b, c) ((a) < (b) ? (b) : (a) > (c) ? (c) : (a))
#define CLAMP(a, b, c) { \
@@ -308,17 +352,11 @@ extern "C" {
CLAMP_MAX((vec)[3], b); \
} (void)0
-#define IS_EQ(a, b) ( \
- CHECK_TYPE_INLINE(a, double), CHECK_TYPE_INLINE(b, double), \
- ((fabs((double)((a) - (b))) >= (double) FLT_EPSILON) ? false : true))
-
-#define IS_EQF(a, b) ( \
- CHECK_TYPE_INLINE(a, float), CHECK_TYPE_INLINE(b, float), \
- ((fabsf((float)((a) - (b))) >= (float) FLT_EPSILON) ? false : true))
+/** \} */
-#define IS_EQT(a, b, c) (((a) > (b)) ? ((((a) - (b)) <= (c))) : (((((b) - (a)) <= (c)))))
-#define IN_RANGE(a, b, c) (((b) < (c)) ? (((b) < (a) && (a) < (c))) : (((c) < (a) && (a) < (b))))
-#define IN_RANGE_INCL(a, b, c) (((b) < (c)) ? (((b) <= (a) && (a) <= (c))) : (((c) <= (a) && (a) <= (b))))
+/* -------------------------------------------------------------------- */
+/** \name Array Unpacking Macros
+ * \{ */
/* unpack vector for args */
#define UNPACK2(a) ((a)[0]), ((a)[1])
@@ -329,6 +367,12 @@ extern "C" {
#define UNPACK3_EX(pre, a, post) UNPACK2_EX(pre, a, post), (pre((a)[2])post)
#define UNPACK4_EX(pre, a, post) UNPACK3_EX(pre, a, post), (pre((a)[3])post)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Array Macros
+ * \{ */
+
/* array helpers */
#define ARRAY_LAST_ITEM(arr_start, arr_dtype, arr_len) \
(arr_dtype *)((char *)(arr_start) + (sizeof(*((arr_dtype *)NULL)) * (size_t)(arr_len - 1)))
@@ -420,6 +464,12 @@ extern "C" {
/* reusable ARRAY_SET_ITEMS macro */
#define ARRAY_SET_ITEMS(...) { VA_NARGS_CALL_OVERLOAD(_VA_ARRAY_SET_ITEMS, __VA_ARGS__); } (void)0
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Pointer Macros
+ * \{ */
+
#if defined(__GNUC__) || defined(__clang__)
#define POINTER_OFFSET(v, ofs) \
((typeof(v))((char *)(v) + (ofs)))
@@ -428,29 +478,47 @@ extern "C" {
((void *)((char *)(v) + (ofs)))
#endif
-/* Like offsetof(typeof(), member), for non-gcc compilers */
-#define OFFSETOF_STRUCT(_struct, _member) \
- ((((char *)&((_struct)->_member)) - ((char *)(_struct))) + sizeof((_struct)->_member))
+/* Warning-free macros for storing ints in pointers. Use these _only_
+ * for storing an int in a pointer, not a pointer in an int (64bit)! */
+#define POINTER_FROM_INT(i) ((void *)(intptr_t)(i))
+#define POINTER_AS_INT(i) ((void)0, ((int)(intptr_t)(i)))
+
+#define POINTER_FROM_UINT(i) ((void *)(uintptr_t)(i))
+#define POINTER_AS_UINT(i) ((void)0, ((unsigned int)(uintptr_t)(i)))
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Struct After Macros
+ *
+ * Typically used to copy/clear polymorphic structs which have a generic
+ * member at the start which needs to be left as-is.
+ *
+ * \{ */
+
+/** Performs `offsetof(typeof(data), member) + sizeof((data)->member)` for non-gcc compilers. */
+#define OFFSETOF_STRUCT_AFTER(_struct, _member) \
+ ((((const char *)&((_struct)->_member)) - ((const char *)(_struct))) + sizeof((_struct)->_member))
/**
* memcpy helper, skipping the first part of a struct,
* ensures 'struct_dst' isn't const and the offset can be computed at compile time.
* This isn't inclusive, the value of \a member isn't copied.
*/
-#define MEMCPY_STRUCT_OFS(struct_dst, struct_src, member) { \
+#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member) { \
CHECK_TYPE_NONCONST(struct_dst); \
((void)(struct_dst == struct_src), \
- memcpy((char *)(struct_dst) + OFFSETOF_STRUCT(struct_dst, member), \
- (char *)(struct_src) + OFFSETOF_STRUCT(struct_dst, member), \
- sizeof(*(struct_dst)) - OFFSETOF_STRUCT(struct_dst, member))); \
-} (void)0
+ memcpy((char *)(struct_dst) + OFFSETOF_STRUCT_AFTER(struct_dst, member), \
+ (const char *)(struct_src) + OFFSETOF_STRUCT_AFTER(struct_dst, member), \
+ sizeof(*(struct_dst)) - OFFSETOF_STRUCT_AFTER(struct_dst, member))); \
+} ((void)0)
-#define MEMSET_STRUCT_OFS(struct_var, value, member) { \
+#define MEMSET_STRUCT_AFTER(struct_var, value, member) { \
CHECK_TYPE_NONCONST(struct_var); \
- memset((char *)(struct_var) + OFFSETOF_STRUCT(struct_var, member), \
+ memset((char *)(struct_var) + OFFSETOF_STRUCT_AFTER(struct_var, member), \
value, \
- sizeof(*(struct_var)) - OFFSETOF_STRUCT(struct_var, member)); \
-} (void)0
+ sizeof(*(struct_var)) - OFFSETOF_STRUCT_AFTER(struct_var, member)); \
+} ((void)0)
/* defined
* in memory_utils.c for now. I do not know where we should put it actually... */
@@ -458,29 +526,16 @@ extern "C" {
extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
#endif
-#define MEMCMP_STRUCT_OFS_IS_ZERO(struct_var, member) \
+#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member) \
(BLI_memory_is_zero( \
- (char *)(struct_var) + OFFSETOF_STRUCT(struct_var, member), \
- sizeof(*(struct_var)) - OFFSETOF_STRUCT(struct_var, member)))
+ (const char *)(struct_var) + OFFSETOF_STRUCT_AFTER(struct_var, member), \
+ sizeof(*(struct_var)) - OFFSETOF_STRUCT_AFTER(struct_var, member)))
-/* Warning-free macros for storing ints in pointers. Use these _only_
- * for storing an int in a pointer, not a pointer in an int (64bit)! */
-#define POINTER_FROM_INT(i) ((void *)(intptr_t)(i))
-#define POINTER_AS_INT(i) ((void)0, ((int)(intptr_t)(i)))
+/** \} */
-#define POINTER_FROM_UINT(i) ((void *)(uintptr_t)(i))
-#define POINTER_AS_UINT(i) ((void)0, ((unsigned int)(uintptr_t)(i)))
-
-/* Set flag from a single test */
-#define SET_FLAG_FROM_TEST(value, test, flag) \
-{ \
- if (test) { \
- (value) |= (flag); \
- } \
- else { \
- (value) &= ~(flag); \
- } \
-} ((void)0)
+/* -------------------------------------------------------------------- */
+/** \name String Macros
+ * \{ */
/* Macro to convert a value to string in the preprocessor
* STRINGIFY_ARG: gives the argument as a string
@@ -504,9 +559,12 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
#define STRCASEEQLEN(a, b, n) (strncasecmp(a, b, n) == 0)
#define STRPREFIX(a, b) (strncmp((a), (b), strlen(b)) == 0)
-/* useful for debugging */
-#define AT __FILE__ ":" STRINGIFY(__LINE__)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Unused Function/Argument Macros
+ * \{ */
/* UNUSED macro, for function argument */
#if defined(__GNUC__) || defined(__clang__)
@@ -577,6 +635,12 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
# define UNUSED_VARS_NDEBUG UNUSED_VARS
#endif
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Branch Prediction Macros
+ * \{ */
+
/* hints for branch prediction, only use in code that runs a _lot_ where */
#ifdef __GNUC__
# define LIKELY(x) __builtin_expect(!!(x), 1)
@@ -586,13 +650,36 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
# define UNLIKELY(x) (x)
#endif
-/* Expands to an integer constant expression evaluating to a close upper bound
- * on the number the number of decimal digits in a value expressible in the
- * integer type given by the argument (if it is a type name) or the integer
- * type of the argument (if it is an expression). The meaning of the resulting
- * expression is unspecified for other arguments.
- * i.e: DECIMAL_DIGITS_BOUND(uchar) is equal to 3. */
-#define DECIMAL_DIGITS_BOUND(t) (241 * sizeof(t) / 100 + 1)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Flag Macros
+ * \{ */
+
+/* Set flag from a single test */
+#define SET_FLAG_FROM_TEST(value, test, flag) \
+{ \
+ if (test) { \
+ (value) |= (flag); \
+ } \
+ else { \
+ (value) &= ~(flag); \
+ } \
+} ((void)0)
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Misc Macros
+ * \{ */
+
+/** Useful for debugging. */
+#define AT __FILE__ ":" STRINGIFY(__LINE__)
+
+/** No-op for expressions we don't want to instansiate, but must remian valid. */
+#define EXPR_NOP(expr) (void)(0 ? ((void)(expr), 1) : 0)
+
+/** \} */
#ifdef __cplusplus
}
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index f1aac6cd5b2..09573d31a76 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -45,7 +45,6 @@ set(SRC
intern/BLI_heap.c
intern/BLI_heap_simple.c
intern/BLI_kdopbvh.c
- intern/BLI_kdtree.c
intern/BLI_linklist.c
intern/BLI_linklist_lockfree.c
intern/BLI_memarena.c
@@ -76,8 +75,11 @@ set(SRC
intern/hash_mm2a.c
intern/hash_mm3.c
intern/jitter_2d.c
+ intern/kdtree_1d.c
+ intern/kdtree_2d.c
+ intern/kdtree_3d.c
+ intern/kdtree_4d.c
intern/lasso_2d.c
- intern/list_sort_impl.h
intern/listbase.c
intern/math_base.c
intern/math_base_inline.c
@@ -124,6 +126,10 @@ set(SRC
intern/winstuff.c
intern/winstuff_dir.c
+ # Header as source (included in C files above).
+ intern/kdtree_impl.h
+ intern/list_sort_impl.h
+
BLI_alloca.h
BLI_args.h
BLI_array.h
@@ -167,6 +173,7 @@ set(SRC
BLI_jitter_2d.h
BLI_kdopbvh.h
BLI_kdtree.h
+ BLI_kdtree_impl.h
BLI_lasso_2d.h
BLI_link_utils.h
BLI_linklist.h
diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index dbd609d914a..61619bc114b 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -71,8 +71,9 @@ static uint case_strhash(const void *ptr)
uint i = 0;
unsigned char c;
- while ( (c = tolower(*s++)) )
+ while ((c = tolower(*s++))) {
i = i * 37 + c;
+ }
return i;
}
@@ -150,8 +151,9 @@ static bArgDoc *internalDocs(struct bArgs *ba, const char *short_arg, const char
d = MEM_callocN(sizeof(bArgDoc), "bArgDoc");
- if (doc == NULL)
+ if (doc == NULL) {
doc = NO_DOCS;
+ }
d->short_arg = short_arg;
d->long_arg = long_arg;
@@ -200,11 +202,13 @@ void BLI_argsAddCase(struct bArgs *ba, int pass,
{
bArgDoc *d = internalDocs(ba, short_arg, long_arg, doc);
- if (short_arg)
+ if (short_arg) {
internalAdd(ba, short_arg, pass, short_case, cb, data, d);
+ }
- if (long_arg)
+ if (long_arg) {
internalAdd(ba, long_arg, pass, long_case, cb, data, d);
+ }
}
void BLI_argsAdd(struct bArgs *ba, int pass,
@@ -216,12 +220,15 @@ void BLI_argsAdd(struct bArgs *ba, int pass,
static void internalDocPrint(bArgDoc *d)
{
- if (d->short_arg && d->long_arg)
+ if (d->short_arg && d->long_arg) {
printf("%s or %s", d->short_arg, d->long_arg);
- else if (d->short_arg)
+ }
+ else if (d->short_arg) {
printf("%s", d->short_arg);
- else if (d->long_arg)
+ }
+ else if (d->long_arg) {
printf("%s", d->long_arg);
+ }
printf(" %s\n\n", d->documentation);
}
@@ -284,8 +291,9 @@ void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *
}
else if (retval == -1) {
if (a) {
- if (a->key->pass != -1)
+ if (a->key->pass != -1) {
ba->passes[i] = pass;
+ }
}
break;
}
diff --git a/source/blender/blenlib/intern/BLI_dial_2d.c b/source/blender/blenlib/intern/BLI_dial_2d.c
index 882d239aa4b..dd983fe7f8f 100644
--- a/source/blender/blenlib/intern/BLI_dial_2d.c
+++ b/source/blender/blenlib/intern/BLI_dial_2d.c
@@ -88,10 +88,12 @@ float BLI_dial_angle(Dial *dial, const float current_position[2])
if ((angle * dial->last_angle < 0.0f) &&
(fabsf(dial->last_angle) > (float)M_PI_2))
{
- if (dial->last_angle < 0.0f)
+ if (dial->last_angle < 0.0f) {
dial->rotations--;
- else
+ }
+ else {
dial->rotations++;
+ }
}
dial->last_angle = angle;
diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c
index 98682101c65..ef45d7b2a47 100644
--- a/source/blender/blenlib/intern/BLI_dynstr.c
+++ b/source/blender/blenlib/intern/BLI_dynstr.c
@@ -112,10 +112,12 @@ void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr)
memcpy(dse->str, cstr, cstrlen + 1);
dse->next = NULL;
- if (!ds->last)
+ if (!ds->last) {
ds->last = ds->elems = dse;
- else
+ }
+ else {
ds->last = ds->last->next = dse;
+ }
ds->curlen += cstrlen;
}
@@ -137,10 +139,12 @@ void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len)
dse->str[cstrlen] = '\0';
dse->next = NULL;
- if (!ds->last)
+ if (!ds->last) {
ds->last = ds->elems = dse;
- else
+ }
+ else {
ds->last = ds->last->next = dse;
+ }
ds->curlen += cstrlen;
}
@@ -154,10 +158,12 @@ void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, v
while (1) {
va_list args_cpy;
- if (len == sizeof(fixedmessage))
+ if (len == sizeof(fixedmessage)) {
message = fixedmessage;
- else
+ }
+ else {
message = MEM_callocN(sizeof(char) * len, "BLI_dynstr_appendf");
+ }
/* cant reuse the same args, so work on a copy */
va_copy(args_cpy, args);
@@ -167,8 +173,9 @@ void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, v
if (retval == -1) {
/* -1 means not enough space, but on windows it may also mean
* there is a formatting error, so we impose a maximum length */
- if (message != fixedmessage)
+ if (message != fixedmessage) {
MEM_freeN(message);
+ }
message = NULL;
len *= 2;
@@ -179,22 +186,25 @@ void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, v
}
else if (retval >= len) {
/* in C99 the actual length required is returned */
- if (message != fixedmessage)
+ if (message != fixedmessage) {
MEM_freeN(message);
+ }
message = NULL;
/* retval doesn't include \0 terminator */
len = retval + 1;
}
- else
+ else {
break;
+ }
}
if (message) {
BLI_dynstr_append(ds, message);
- if (message != fixedmessage)
+ if (message != fixedmessage) {
MEM_freeN(message);
+ }
}
}
@@ -217,10 +227,12 @@ void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ..
* va_start/va_end have to be called for each vsnprintf call */
while (1) {
- if (len == sizeof(fixedmessage))
+ if (len == sizeof(fixedmessage)) {
message = fixedmessage;
- else
+ }
+ else {
message = MEM_callocN(sizeof(char) * (len), "BLI_dynstr_appendf");
+ }
va_start(args, format);
retval = vsnprintf(message, len, format, args);
@@ -229,8 +241,9 @@ void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ..
if (retval == -1) {
/* -1 means not enough space, but on windows it may also mean
* there is a formatting error, so we impose a maximum length */
- if (message != fixedmessage)
+ if (message != fixedmessage) {
MEM_freeN(message);
+ }
message = NULL;
len *= 2;
@@ -241,22 +254,25 @@ void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ..
}
else if (retval >= len) {
/* in C99 the actual length required is returned */
- if (message != fixedmessage)
+ if (message != fixedmessage) {
MEM_freeN(message);
+ }
message = NULL;
/* retval doesn't include \0 terminator */
len = retval + 1;
}
- else
+ else {
break;
+ }
}
if (message) {
BLI_dynstr_append(ds, message);
- if (message != fixedmessage)
+ if (message != fixedmessage) {
MEM_freeN(message);
+ }
}
}
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 8cbba2103d3..243c7d95da1 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -65,28 +65,36 @@ static int bli_compare(struct direntry *entry1, struct direntry *entry2)
/* directories come before non-directories */
if (S_ISDIR(entry1->type)) {
- if (S_ISDIR(entry2->type) == 0) return (-1);
+ if (S_ISDIR(entry2->type) == 0) {
+ return -1;
+ }
}
else {
- if (S_ISDIR(entry2->type)) return (1);
+ if (S_ISDIR(entry2->type)) {
+ return 1;
+ }
}
/* non-regular files come after regular files */
if (S_ISREG(entry1->type)) {
- if (S_ISREG(entry2->type) == 0) return (-1);
+ if (S_ISREG(entry2->type) == 0) {
+ return -1;
+ }
}
else {
- if (S_ISREG(entry2->type)) return (1);
+ if (S_ISREG(entry2->type)) {
+ return 1;
+ }
}
/* arbitrary, but consistent, ordering of different types of non-regular files */
- if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
- if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
+ if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) { return -1; }
+ if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) { return 1; }
/* OK, now we know their S_IFMT fields are the same, go on to a name comparison */
/* make sure "." and ".." are always first */
- if (FILENAME_IS_CURRENT(entry1->relname)) return (-1);
- if (FILENAME_IS_CURRENT(entry2->relname)) return (1);
- if (FILENAME_IS_PARENT(entry1->relname)) return (-1);
- if (FILENAME_IS_PARENT(entry2->relname)) return (1);
+ if (FILENAME_IS_CURRENT(entry1->relname)) { return -1; }
+ if (FILENAME_IS_CURRENT(entry2->relname)) { return 1; }
+ if (FILENAME_IS_PARENT(entry1->relname)) { return -1; }
+ if (FILENAME_IS_PARENT(entry2->relname)) { return 1; }
return (BLI_natstrcmp(entry1->relname, entry2->relname));
}
@@ -159,8 +167,9 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
}
}
- if (dir_ctx->files == NULL)
+ if (dir_ctx->files == NULL) {
dir_ctx->files = (struct direntry *)MEM_mallocN(newnum * sizeof(struct direntry), __func__);
+ }
if (dir_ctx->files) {
struct dirlink * dlink = (struct dirlink *) dirbase.first;
@@ -253,7 +262,9 @@ void BLI_filelist_entry_size_to_string(
if (size > 1024.0) {
const char **u;
- for (u = compact ? units_compact : units, size /= 1024.0; size > 1024.0 && *(u + 1); u++, size /= 1024.0);
+ for (u = compact ? units_compact : units, size /= 1024.0; size > 1024.0 && *(u + 1); u++, size /= 1024.0) {
+ /* pass */
+ }
fmt = size > 100.0 ? "%.0f %s" : (size > 10.0 ? "%.1f %s" : "%.2f %s");
unit = *u;
}
@@ -284,18 +295,30 @@ void BLI_filelist_entry_mode_to_string(
BLI_strncpy(r_mode2, types[(mode & 0070) >> 3], sizeof(*r_mode2) * FILELIST_DIRENTRY_MODE_LEN);
BLI_strncpy(r_mode3, types[(mode & 0007)], sizeof(*r_mode3) * FILELIST_DIRENTRY_MODE_LEN);
- if (((mode & S_ISGID) == S_ISGID) && (r_mode2[2] == '-')) r_mode2[2] = 'l';
+ if (((mode & S_ISGID) == S_ISGID) && (r_mode2[2] == '-')) {
+ r_mode2[2] = 'l';
+ }
if (mode & (S_ISUID | S_ISGID)) {
- if (r_mode1[2] == 'x') r_mode1[2] = 's';
- else r_mode1[2] = 'S';
+ if (r_mode1[2] == 'x') {
+ r_mode1[2] = 's';
+ }
+ else {
+ r_mode1[2] = 'S';
+ }
- if (r_mode2[2] == 'x') r_mode2[2] = 's';
+ if (r_mode2[2] == 'x') {
+ r_mode2[2] = 's';
+ }
}
if (mode & S_ISVTX) {
- if (r_mode3[2] == 'x') r_mode3[2] = 't';
- else r_mode3[2] = 'T';
+ if (r_mode3[2] == 'x') {
+ r_mode3[2] = 't';
+ }
+ else {
+ r_mode3[2] = 'T';
+ }
}
#endif
}
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index fc432c8c8b7..af3a7a4f68a 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -241,7 +241,9 @@ static void ghash_buckets_resize(GHash *gh, const uint nbuckets)
const unsigned bucket_index = ghash_bucket_index(gh, i);
BLI_assert(!buckets_old[i] || (bucket_index == ghash_bucket_index(gh, ghash_entryhash(gh, buckets_old[i]))));
Entry *e;
- for (e = buckets_old[i]; e && e->next; e = e->next);
+ for (e = buckets_old[i]; e && e->next; e = e->next) {
+ /* pass */
+ }
if (e) {
e->next = buckets_new[bucket_index];
buckets_new[bucket_index] = buckets_old[i];
@@ -983,8 +985,9 @@ void BLI_ghash_clear_ex(
GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp,
const uint nentries_reserve)
{
- if (keyfreefp || valfreefp)
+ if (keyfreefp || valfreefp) {
ghash_free_cb(gh, keyfreefp, valfreefp);
+ }
ghash_buckets_reset(gh, nentries_reserve);
BLI_mempool_clear_ex(gh->entrypool, nentries_reserve ? (int)nentries_reserve : -1);
@@ -1008,8 +1011,9 @@ void BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfree
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
{
BLI_assert((int)gh->nentries == BLI_mempool_len(gh->entrypool));
- if (keyfreefp || valfreefp)
+ if (keyfreefp || valfreefp) {
ghash_free_cb(gh, keyfreefp, valfreefp);
+ }
MEM_freeN(gh->buckets);
BLI_mempool_destroy(gh->entrypool);
@@ -1069,8 +1073,9 @@ void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
if (gh->nentries) {
do {
ghi->curBucket++;
- if (UNLIKELY(ghi->curBucket == ghi->gh->nbuckets))
+ if (UNLIKELY(ghi->curBucket == ghi->gh->nbuckets)) {
break;
+ }
ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
} while (!ghi->curEntry);
}
@@ -1087,8 +1092,9 @@ void BLI_ghashIterator_step(GHashIterator *ghi)
ghi->curEntry = ghi->curEntry->next;
while (!ghi->curEntry) {
ghi->curBucket++;
- if (ghi->curBucket == ghi->gh->nbuckets)
+ if (ghi->curBucket == ghi->gh->nbuckets) {
break;
+ }
ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
}
}
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 7199c4126d4..7887c55a907 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -272,24 +272,30 @@ static int bvh_partition(BVHNode **a, int lo, int hi, BVHNode *x, int axis)
static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis)
{
if ((a[mid])->bv[axis] < (a[lo])->bv[axis]) {
- if ((a[hi])->bv[axis] < (a[mid])->bv[axis])
+ if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
return a[mid];
+ }
else {
- if ((a[hi])->bv[axis] < (a[lo])->bv[axis])
+ if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
return a[hi];
- else
+ }
+ else {
return a[lo];
+ }
}
}
else {
if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) {
- if ((a[hi])->bv[axis] < (a[lo])->bv[axis])
+ if ((a[hi])->bv[axis] < (a[lo])->bv[axis]) {
return a[lo];
- else
+ }
+ else {
return a[hi];
+ }
}
- else
+ else {
return a[mid];
+ }
}
}
@@ -320,10 +326,12 @@ static void build_skip_links(BVHTree *tree, BVHNode *node, BVHNode *left, BVHNod
node->skip[1] = right;
for (i = 0; i < node->totnode; i++) {
- if (i + 1 < node->totnode)
+ if (i + 1 < node->totnode) {
build_skip_links(tree, node->children[i], left, node->children[i + 1]);
- else
+ }
+ else {
build_skip_links(tree, node->children[i], left, right);
+ }
left = node->children[i];
}
@@ -349,10 +357,12 @@ static void create_kdop_hull(const BVHTree *tree, BVHNode *node, const float *co
/* for all Axes. */
for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
newminmax = dot_v3v3(&co[k * 3], bvhtree_kdop_axes[axis_iter]);
- if (newminmax < bv[2 * axis_iter])
+ if (newminmax < bv[2 * axis_iter]) {
bv[2 * axis_iter] = newminmax;
- if (newminmax > bv[(2 * axis_iter) + 1])
+ }
+ if (newminmax > bv[(2 * axis_iter) + 1]) {
bv[(2 * axis_iter) + 1] = newminmax;
+ }
}
}
}
@@ -375,12 +385,14 @@ static void refit_kdop_hull(const BVHTree *tree, BVHNode *node, int start, int e
/* for all Axes. */
for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
newmin = node_bv[(2 * axis_iter)];
- if ((newmin < bv[(2 * axis_iter)]))
+ if ((newmin < bv[(2 * axis_iter)])) {
bv[(2 * axis_iter)] = newmin;
+ }
newmax = node_bv[(2 * axis_iter) + 1];
- if ((newmax > bv[(2 * axis_iter) + 1]))
+ if ((newmax > bv[(2 * axis_iter) + 1])) {
bv[(2 * axis_iter) + 1] = newmax;
+ }
}
}
@@ -397,16 +409,20 @@ static char get_largest_axis(const float *bv)
middle_point[1] = (bv[3]) - (bv[2]); /* y axis */
middle_point[2] = (bv[5]) - (bv[4]); /* z axis */
if (middle_point[0] > middle_point[1]) {
- if (middle_point[0] > middle_point[2])
+ if (middle_point[0] > middle_point[2]) {
return 1; /* max x axis */
- else
+ }
+ else {
return 5; /* max z axis */
+ }
}
else {
- if (middle_point[1] > middle_point[2])
+ if (middle_point[1] > middle_point[2]) {
return 3; /* max y axis */
- else
+ }
+ else {
return 5; /* max z axis */
+ }
}
}
@@ -424,16 +440,19 @@ static void node_join(BVHTree *tree, BVHNode *node)
if (node->children[i]) {
for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
/* update minimum */
- if (node->children[i]->bv[(2 * axis_iter)] < node->bv[(2 * axis_iter)])
+ if (node->children[i]->bv[(2 * axis_iter)] < node->bv[(2 * axis_iter)]) {
node->bv[(2 * axis_iter)] = node->children[i]->bv[(2 * axis_iter)];
+ }
/* update maximum */
- if (node->children[i]->bv[(2 * axis_iter) + 1] > node->bv[(2 * axis_iter) + 1])
+ if (node->children[i]->bv[(2 * axis_iter) + 1] > node->bv[(2 * axis_iter) + 1]) {
node->bv[(2 * axis_iter) + 1] = node->children[i]->bv[(2 * axis_iter) + 1];
+ }
}
}
- else
+ else {
break;
+ }
}
}
@@ -448,7 +467,9 @@ static void bvhtree_print_tree(BVHTree *tree, BVHNode *node, int depth)
int i;
axis_t axis_iter;
- for (i = 0; i < depth; i++) printf(" ");
+ for (i = 0; i < depth; i++) {
+ printf(" ");
+ }
printf(" - %d (%ld): ", node->index, (long int)(node - tree->nodearray));
for (axis_iter = (axis_t)(2 * tree->start_axis);
axis_iter < (axis_t)(2 * tree->stop_axis);
@@ -458,9 +479,11 @@ static void bvhtree_print_tree(BVHTree *tree, BVHNode *node, int depth)
}
printf("\n");
- for (i = 0; i < tree->tree_type; i++)
- if (node->children[i])
+ for (i = 0; i < tree->tree_type; i++) {
+ if (node->children[i]) {
bvhtree_print_tree(tree, node->children[i], depth + 1);
+ }
+ }
}
static void bvhtree_info(BVHTree *tree)
@@ -498,8 +521,9 @@ static void bvhtree_verify(BVHTree *tree)
}
else {
for (j = 0; j < tree->tree_type; j++) {
- if (tree->nodes[i]->parent->children[j] == tree->nodes[i])
+ if (tree->nodes[i]->parent->children[j] == tree->nodes[i]) {
check = 1;
+ }
}
if (!check) {
printf("Parent child relationship doesn't match: %d\n", i);
@@ -515,8 +539,9 @@ static void bvhtree_verify(BVHTree *tree)
}
else {
for (j = 0; j < tree->tree_type; j++) {
- if (tree->nodearray[i].parent->children[j] == &tree->nodearray[i])
+ if (tree->nodearray[i].parent->children[j] == &tree->nodearray[i]) {
check = 1;
+ }
}
if (!check) {
printf("Parent child relationship doesn't match: %d\n", i);
@@ -580,12 +605,15 @@ static void build_implicit_tree_helper(const BVHTree *tree, BVHBuildHelper *data
static int implicit_leafs_index(const BVHBuildHelper *data, const int depth, const int child_index)
{
int min_leaf_index = child_index * data->leafs_per_child[depth - 1];
- if (min_leaf_index <= data->remain_leafs)
+ if (min_leaf_index <= data->remain_leafs) {
return min_leaf_index;
- else if (data->leafs_per_child[depth])
+ }
+ else if (data->leafs_per_child[depth]) {
return data->totleafs - (data->branches_on_level[depth - 1] - child_index) * data->leafs_per_child[depth];
- else
+ }
+ else {
return data->remain_leafs;
+ }
}
/**
@@ -636,8 +664,9 @@ static void split_leafs(BVHNode **leafs_array, const int nth[], const int partit
{
int i;
for (i = 0; i < partitions - 1; i++) {
- if (nth[i] >= nth[partitions])
+ if (nth[i] >= nth[partitions]) {
break;
+ }
partition_nth_element(leafs_array, nth[i], nth[partitions], nth[i + 1], split_axis);
}
@@ -970,15 +999,17 @@ bool BLI_bvhtree_update_node(BVHTree *tree, int index, const float co[3], const
axis_t axis_iter;
/* check if index exists */
- if (index > tree->totleaf)
+ if (index > tree->totleaf) {
return false;
+ }
node = tree->nodearray + index;
create_kdop_hull(tree, node, co, numpoints, 0);
- if (co_moving)
+ if (co_moving) {
create_kdop_hull(tree, node, co_moving, numpoints, 1);
+ }
/* inflate the bv with some epsilon */
for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) {
@@ -999,8 +1030,9 @@ void BLI_bvhtree_update_tree(BVHTree *tree)
BVHNode **root = tree->nodes + tree->totleaf;
BVHNode **index = tree->nodes + tree->totleaf + tree->totbranch - 1;
- for (; index >= root; index--)
+ for (; index >= root; index--) {
node_join(tree, *index);
+ }
}
/**
* Number of times #BLI_bvhtree_insert has been called.
@@ -1225,8 +1257,9 @@ BVHTreeOverlap *BLI_bvhtree_overlap(
bvhtree_overlap_task_cb,
&settings);
- for (j = 0; j < thread_num; j++)
+ for (j = 0; j < thread_num; j++) {
total += BLI_stack_count(data[j].overlap);
+ }
to = overlap = MEM_mallocN(sizeof(BVHTreeOverlap) * total, "BVHTreeOverlap");
@@ -1258,10 +1291,12 @@ static float calc_nearest_point_squared(const float proj[3], BVHNode *node, floa
/* nearest on AABB hull */
for (i = 0; i != 3; i++, bv += 2) {
float val = proj[i];
- if (bv[0] > val)
+ if (bv[0] > val) {
val = bv[0];
- if (bv[1] < val)
+ }
+ if (bv[1] < val) {
val = bv[1];
+ }
nearest[i] = val;
}
@@ -1272,8 +1307,9 @@ static float calc_nearest_point_squared(const float proj[3], BVHNode *node, floa
static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node)
{
if (node->totnode == 0) {
- if (data->callback)
+ if (data->callback) {
data->callback(data->userdata, node->index, data->co, &data->nearest);
+ }
else {
data->nearest.index = node->index;
data->nearest.dist_sq = calc_nearest_point_squared(data->proj, node, data->nearest.co);
@@ -1287,15 +1323,17 @@ static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node)
if (data->proj[node->main_axis] <= node->children[0]->bv[node->main_axis * 2 + 1]) {
for (i = 0; i != node->totnode; i++) {
- if (calc_nearest_point_squared(data->proj, node->children[i], nearest) >= data->nearest.dist_sq)
+ if (calc_nearest_point_squared(data->proj, node->children[i], nearest) >= data->nearest.dist_sq) {
continue;
+ }
dfs_find_nearest_dfs(data, node->children[i]);
}
}
else {
for (i = node->totnode - 1; i >= 0; i--) {
- if (calc_nearest_point_squared(data->proj, node->children[i], nearest) >= data->nearest.dist_sq)
+ if (calc_nearest_point_squared(data->proj, node->children[i], nearest) >= data->nearest.dist_sq) {
continue;
+ }
dfs_find_nearest_dfs(data, node->children[i]);
}
}
@@ -1316,8 +1354,9 @@ static void dfs_find_nearest_begin(BVHNearestData *data, BVHNode *node)
static void heap_find_nearest_inner(BVHNearestData *data, HeapSimple *heap, BVHNode *node)
{
if (node->totnode == 0) {
- if (data->callback)
+ if (data->callback) {
data->callback(data->userdata, node->index, data->co, &data->nearest);
+ }
else {
data->nearest.index = node->index;
data->nearest.dist_sq = calc_nearest_point_squared(data->proj, node, data->nearest.co);
@@ -1441,15 +1480,25 @@ static float ray_nearest_hit(const BVHRayCastData *data, const float bv[6])
float lu = (bv[1] + data->ray.radius - data->ray.origin[i]) / data->ray_dot_axis[i];
if (data->ray_dot_axis[i] > 0.0f) {
- if (ll > low) low = ll;
- if (lu < upper) upper = lu;
+ if (ll > low) {
+ low = ll;
+ }
+ if (lu < upper) {
+ upper = lu;
+ }
}
else {
- if (lu > low) low = lu;
- if (ll < upper) upper = ll;
+ if (lu > low) {
+ low = lu;
+ }
+ if (ll < upper) {
+ upper = ll;
+ }
}
- if (low > upper) return FLT_MAX;
+ if (low > upper) {
+ return FLT_MAX;
+ }
}
}
return low;
@@ -1622,8 +1671,9 @@ int BLI_bvhtree_ray_cast_ex(
}
- if (hit)
+ if (hit) {
memcpy(hit, &data.hit, sizeof(*hit));
+ }
return data.hit.index;
}
@@ -1750,8 +1800,9 @@ static void dfs_range_query(RangeQueryData *data, BVHNode *node)
data->hits++;
data->callback(data->userdata, node->children[i]->index, data->center, dist_sq);
}
- else
+ else {
dfs_range_query(data, node->children[i]);
+ }
}
}
}
@@ -1781,8 +1832,9 @@ int BLI_bvhtree_range_query(
data.hits++;
data.callback(data.userdata, root->index, co, dist_sq);
}
- else
+ else {
dfs_range_query(&data, root);
+ }
}
}
diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c
deleted file mode 100644
index ce06324ebca..00000000000
--- a/source/blender/blenlib/intern/BLI_kdtree.c
+++ /dev/null
@@ -1,809 +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 bli
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_math.h"
-#include "BLI_kdtree.h"
-#include "BLI_utildefines.h"
-#include "BLI_strict_flags.h"
-
-typedef struct KDTreeNode_head {
- uint left, right;
- float co[3];
- int index;
-} KDTreeNode_head;
-
-typedef struct KDTreeNode {
- uint left, right;
- float co[3];
- int index;
- uint d; /* range is only (0-2) */
-} KDTreeNode;
-
-struct KDTree {
- KDTreeNode *nodes;
- uint totnode;
- uint root;
-#ifdef DEBUG
- bool is_balanced; /* ensure we call balance first */
- uint maxsize; /* max size of the tree */
-#endif
-};
-
-#define KD_STACK_INIT 100 /* initial size for array (on the stack) */
-#define KD_NEAR_ALLOC_INC 100 /* alloc increment for collecting nearest */
-#define KD_FOUND_ALLOC_INC 50 /* alloc increment for collecting nearest */
-
-#define KD_NODE_UNSET ((uint)-1)
-
-/** When set we know all values are unbalanced, otherwise clear them when re-balancing: see T62210. */
-#define KD_NODE_ROOT_IS_INIT ((uint)-2)
-
-/**
- * Creates or free a kdtree
- */
-KDTree *BLI_kdtree_new(uint maxsize)
-{
- KDTree *tree;
-
- tree = MEM_mallocN(sizeof(KDTree), "KDTree");
- tree->nodes = MEM_mallocN(sizeof(KDTreeNode) * maxsize, "KDTreeNode");
- tree->totnode = 0;
- tree->root = KD_NODE_ROOT_IS_INIT;
-
-#ifdef DEBUG
- tree->is_balanced = false;
- tree->maxsize = maxsize;
-#endif
-
- return tree;
-}
-
-void BLI_kdtree_free(KDTree *tree)
-{
- if (tree) {
- MEM_freeN(tree->nodes);
- MEM_freeN(tree);
- }
-}
-
-/**
- * Construction: first insert points, then call balance. Normal is optional.
- */
-void BLI_kdtree_insert(KDTree *tree, int index, const float co[3])
-{
- KDTreeNode *node = &tree->nodes[tree->totnode++];
-
-#ifdef DEBUG
- BLI_assert(tree->totnode <= tree->maxsize);
-#endif
-
- /* note, array isn't calloc'd,
- * need to initialize all struct members */
-
- node->left = node->right = KD_NODE_UNSET;
- copy_v3_v3(node->co, co);
- node->index = index;
- node->d = 0;
-
-#ifdef DEBUG
- tree->is_balanced = false;
-#endif
-}
-
-static uint kdtree_balance(KDTreeNode *nodes, uint totnode, uint axis, const uint ofs)
-{
- KDTreeNode *node;
- float co;
- uint left, right, median, i, j;
-
- if (totnode <= 0)
- return KD_NODE_UNSET;
- else if (totnode == 1)
- return 0 + ofs;
-
- /* quicksort style sorting around median */
- left = 0;
- right = totnode - 1;
- median = totnode / 2;
-
- while (right > left) {
- co = nodes[right].co[axis];
- i = left - 1;
- j = right;
-
- while (1) {
- while (nodes[++i].co[axis] < co) ;
- while (nodes[--j].co[axis] > co && j > left) ;
-
- if (i >= j)
- break;
-
- SWAP(KDTreeNode_head, *(KDTreeNode_head *)&nodes[i], *(KDTreeNode_head *)&nodes[j]);
- }
-
- SWAP(KDTreeNode_head, *(KDTreeNode_head *)&nodes[i], *(KDTreeNode_head *)&nodes[right]);
- if (i >= median)
- right = i - 1;
- if (i <= median)
- left = i + 1;
- }
-
- /* set node and sort subnodes */
- node = &nodes[median];
- node->d = axis;
- axis = (axis + 1) % 3;
- node->left = kdtree_balance(nodes, median, axis, ofs);
- node->right = kdtree_balance(nodes + median + 1, (totnode - (median + 1)), axis, (median + 1) + ofs);
-
- return median + ofs;
-}
-
-void BLI_kdtree_balance(KDTree *tree)
-{
- if (tree->root != KD_NODE_ROOT_IS_INIT) {
- for (uint i = 0; i < tree->totnode; i++) {
- tree->nodes[i].left = KD_NODE_UNSET;
- tree->nodes[i].right = KD_NODE_UNSET;
- }
- }
-
- tree->root = kdtree_balance(tree->nodes, tree->totnode, 0, 0);
-
-#ifdef DEBUG
- tree->is_balanced = true;
-#endif
-}
-
-static float squared_distance(const float v2[3], const float v1[3], const float n2[3])
-{
- float d[3], dist;
-
- d[0] = v2[0] - v1[0];
- d[1] = v2[1] - v1[1];
- d[2] = v2[2] - v1[2];
-
- dist = len_squared_v3(d);
-
- /* can someone explain why this is done?*/
- if (n2 && (dot_v3v3(d, n2) < 0.0f)) {
- dist *= 10.0f;
- }
-
- return dist;
-}
-
-static uint *realloc_nodes(uint *stack, uint *totstack, const bool is_alloc)
-{
- uint *stack_new = MEM_mallocN((*totstack + KD_NEAR_ALLOC_INC) * sizeof(uint), "KDTree.treestack");
- memcpy(stack_new, stack, *totstack * sizeof(uint));
- // memset(stack_new + *totstack, 0, sizeof(uint) * KD_NEAR_ALLOC_INC);
- if (is_alloc)
- MEM_freeN(stack);
- *totstack += KD_NEAR_ALLOC_INC;
- return stack_new;
-}
-
-/**
- * Find nearest returns index, and -1 if no node is found.
- */
-int BLI_kdtree_find_nearest(
- const KDTree *tree, const float co[3],
- KDTreeNearest *r_nearest)
-{
- const KDTreeNode *nodes = tree->nodes;
- const KDTreeNode *root, *min_node;
- uint *stack, defaultstack[KD_STACK_INIT];
- float min_dist, cur_dist;
- uint totstack, cur = 0;
-
-#ifdef DEBUG
- BLI_assert(tree->is_balanced == true);
-#endif
-
- if (UNLIKELY(tree->root == KD_NODE_UNSET))
- return -1;
-
- stack = defaultstack;
- totstack = KD_STACK_INIT;
-
- root = &nodes[tree->root];
- min_node = root;
- min_dist = len_squared_v3v3(root->co, co);
-
- if (co[root->d] < root->co[root->d]) {
- if (root->right != KD_NODE_UNSET)
- stack[cur++] = root->right;
- if (root->left != KD_NODE_UNSET)
- stack[cur++] = root->left;
- }
- else {
- if (root->left != KD_NODE_UNSET)
- stack[cur++] = root->left;
- if (root->right != KD_NODE_UNSET)
- stack[cur++] = root->right;
- }
-
- while (cur--) {
- const KDTreeNode *node = &nodes[stack[cur]];
-
- cur_dist = node->co[node->d] - co[node->d];
-
- if (cur_dist < 0.0f) {
- cur_dist = -cur_dist * cur_dist;
-
- if (-cur_dist < min_dist) {
- cur_dist = len_squared_v3v3(node->co, co);
- if (cur_dist < min_dist) {
- min_dist = cur_dist;
- min_node = node;
- }
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- }
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
- else {
- cur_dist = cur_dist * cur_dist;
-
- if (cur_dist < min_dist) {
- cur_dist = len_squared_v3v3(node->co, co);
- if (cur_dist < min_dist) {
- min_dist = cur_dist;
- min_node = node;
- }
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- }
- if (UNLIKELY(cur + 3 > totstack)) {
- stack = realloc_nodes(stack, &totstack, defaultstack != stack);
- }
- }
-
- if (r_nearest) {
- r_nearest->index = min_node->index;
- r_nearest->dist = sqrtf(min_dist);
- copy_v3_v3(r_nearest->co, min_node->co);
- }
-
- if (stack != defaultstack)
- MEM_freeN(stack);
-
- return min_node->index;
-}
-
-
-/**
- * A version of #BLI_kdtree_find_nearest which runs a callback
- * to filter out values.
- *
- * \param filter_cb: Filter find results,
- * Return codes: (1: accept, 0: skip, -1: immediate exit).
- */
-int BLI_kdtree_find_nearest_cb(
- const KDTree *tree, const float co[3],
- int (*filter_cb)(void *user_data, int index, const float co[3], float dist_sq), void *user_data,
- KDTreeNearest *r_nearest)
-{
- const KDTreeNode *nodes = tree->nodes;
- const KDTreeNode *min_node = NULL;
-
- uint *stack, defaultstack[KD_STACK_INIT];
- float min_dist = FLT_MAX, cur_dist;
- uint totstack, cur = 0;
-
-#ifdef DEBUG
- BLI_assert(tree->is_balanced == true);
-#endif
-
- if (UNLIKELY(tree->root == KD_NODE_UNSET))
- return -1;
-
- stack = defaultstack;
- totstack = KD_STACK_INIT;
-
-#define NODE_TEST_NEAREST(node) \
-{ \
- const float dist_sq = len_squared_v3v3((node)->co, co); \
- if (dist_sq < min_dist) { \
- const int result = filter_cb(user_data, (node)->index, (node)->co, dist_sq); \
- if (result == 1) { \
- min_dist = dist_sq; \
- min_node = node; \
- } \
- else if (result == 0) { \
- /* pass */ \
- } \
- else { \
- BLI_assert(result == -1); \
- goto finally; \
- } \
- } \
-} ((void)0)
-
- stack[cur++] = tree->root;
-
- while (cur--) {
- const KDTreeNode *node = &nodes[stack[cur]];
-
- cur_dist = node->co[node->d] - co[node->d];
-
- if (cur_dist < 0.0f) {
- cur_dist = -cur_dist * cur_dist;
-
- if (-cur_dist < min_dist) {
- NODE_TEST_NEAREST(node);
-
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- }
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
- else {
- cur_dist = cur_dist * cur_dist;
-
- if (cur_dist < min_dist) {
- NODE_TEST_NEAREST(node);
-
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- }
- if (UNLIKELY(cur + 3 > totstack)) {
- stack = realloc_nodes(stack, &totstack, defaultstack != stack);
- }
- }
-
-#undef NODE_TEST_NEAREST
-
-
-finally:
- if (stack != defaultstack)
- MEM_freeN(stack);
-
- if (min_node) {
- if (r_nearest) {
- r_nearest->index = min_node->index;
- r_nearest->dist = sqrtf(min_dist);
- copy_v3_v3(r_nearest->co, min_node->co);
- }
-
- return min_node->index;
- }
- else {
- return -1;
- }
-}
-
-static void add_nearest(KDTreeNearest *ptn, uint *found, uint n, int index,
- float dist, const float *co)
-{
- uint i;
-
- if (*found < n) (*found)++;
-
- for (i = *found - 1; i > 0; i--) {
- if (dist >= ptn[i - 1].dist)
- break;
- else
- ptn[i] = ptn[i - 1];
- }
-
- ptn[i].index = index;
- ptn[i].dist = dist;
- copy_v3_v3(ptn[i].co, co);
-}
-
-/**
- * Find n nearest returns number of points found, with results in nearest.
- * Normal is optional, but if given will limit results to points in normal direction from co.
- *
- * \param r_nearest: An array of nearest, sized at least \a n.
- */
-int BLI_kdtree_find_nearest_n__normal(
- const KDTree *tree, const float co[3], const float nor[3],
- KDTreeNearest r_nearest[],
- uint n)
-{
- const KDTreeNode *nodes = tree->nodes;
- const KDTreeNode *root;
- uint *stack, defaultstack[KD_STACK_INIT];
- float cur_dist;
- uint totstack, cur = 0;
- uint i, found = 0;
-
-#ifdef DEBUG
- BLI_assert(tree->is_balanced == true);
-#endif
-
- if (UNLIKELY((tree->root == KD_NODE_UNSET) || n == 0))
- return 0;
-
- stack = defaultstack;
- totstack = KD_STACK_INIT;
-
- root = &nodes[tree->root];
-
- cur_dist = squared_distance(root->co, co, nor);
- add_nearest(r_nearest, &found, n, root->index, cur_dist, root->co);
-
- if (co[root->d] < root->co[root->d]) {
- if (root->right != KD_NODE_UNSET)
- stack[cur++] = root->right;
- if (root->left != KD_NODE_UNSET)
- stack[cur++] = root->left;
- }
- else {
- if (root->left != KD_NODE_UNSET)
- stack[cur++] = root->left;
- if (root->right != KD_NODE_UNSET)
- stack[cur++] = root->right;
- }
-
- while (cur--) {
- const KDTreeNode *node = &nodes[stack[cur]];
-
- cur_dist = node->co[node->d] - co[node->d];
-
- if (cur_dist < 0.0f) {
- cur_dist = -cur_dist * cur_dist;
-
- if (found < n || -cur_dist < r_nearest[found - 1].dist) {
- cur_dist = squared_distance(node->co, co, nor);
-
- if (found < n || cur_dist < r_nearest[found - 1].dist)
- add_nearest(r_nearest, &found, n, node->index, cur_dist, node->co);
-
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- }
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
- else {
- cur_dist = cur_dist * cur_dist;
-
- if (found < n || cur_dist < r_nearest[found - 1].dist) {
- cur_dist = squared_distance(node->co, co, nor);
- if (found < n || cur_dist < r_nearest[found - 1].dist)
- add_nearest(r_nearest, &found, n, node->index, cur_dist, node->co);
-
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- }
- if (UNLIKELY(cur + 3 > totstack)) {
- stack = realloc_nodes(stack, &totstack, defaultstack != stack);
- }
- }
-
- for (i = 0; i < found; i++)
- r_nearest[i].dist = sqrtf(r_nearest[i].dist);
-
- if (stack != defaultstack)
- MEM_freeN(stack);
-
- return (int)found;
-}
-
-static int range_compare(const void *a, const void *b)
-{
- const KDTreeNearest *kda = a;
- const KDTreeNearest *kdb = b;
-
- if (kda->dist < kdb->dist)
- return -1;
- else if (kda->dist > kdb->dist)
- return 1;
- else
- return 0;
-}
-static void add_in_range(
- KDTreeNearest **r_foundstack,
- uint *r_foundstack_tot_alloc,
- uint found,
- const int index, const float dist, const float *co)
-{
- KDTreeNearest *to;
-
- if (UNLIKELY(found >= *r_foundstack_tot_alloc)) {
- *r_foundstack = MEM_reallocN_id(
- *r_foundstack,
- (*r_foundstack_tot_alloc += KD_FOUND_ALLOC_INC) * sizeof(KDTreeNode),
- __func__);
- }
-
- to = (*r_foundstack) + found;
-
- to->index = index;
- to->dist = sqrtf(dist);
- copy_v3_v3(to->co, co);
-}
-
-/**
- * Range search returns number of points found, with results in nearest
- * Normal is optional, but if given will limit results to points in normal direction from co.
- * Remember to free nearest after use!
- */
-int BLI_kdtree_range_search__normal(
- const KDTree *tree, const float co[3], const float nor[3],
- KDTreeNearest **r_nearest, float range)
-{
- const KDTreeNode *nodes = tree->nodes;
- uint *stack, defaultstack[KD_STACK_INIT];
- KDTreeNearest *foundstack = NULL;
- float range_sq = range * range, dist_sq;
- uint totstack, cur = 0, found = 0, totfoundstack = 0;
-
-#ifdef DEBUG
- BLI_assert(tree->is_balanced == true);
-#endif
-
- if (UNLIKELY(tree->root == KD_NODE_UNSET))
- return 0;
-
- stack = defaultstack;
- totstack = KD_STACK_INIT;
-
- stack[cur++] = tree->root;
-
- while (cur--) {
- const KDTreeNode *node = &nodes[stack[cur]];
-
- if (co[node->d] + range < node->co[node->d]) {
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- }
- else if (co[node->d] - range > node->co[node->d]) {
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
- else {
- dist_sq = squared_distance(node->co, co, nor);
- if (dist_sq <= range_sq) {
- add_in_range(&foundstack, &totfoundstack, found++, node->index, dist_sq, node->co);
- }
-
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
-
- if (UNLIKELY(cur + 3 > totstack)) {
- stack = realloc_nodes(stack, &totstack, defaultstack != stack);
- }
- }
-
- if (stack != defaultstack)
- MEM_freeN(stack);
-
- if (found)
- qsort(foundstack, found, sizeof(KDTreeNearest), range_compare);
-
- *r_nearest = foundstack;
-
- return (int)found;
-}
-
-/**
- * A version of #BLI_kdtree_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.
- *
- * \note the order of calls isn't sorted based on distance.
- */
-void BLI_kdtree_range_search_cb(
- const KDTree *tree, const float co[3], float range,
- bool (*search_cb)(void *user_data, int index, const float co[3], float dist_sq), void *user_data)
-{
- const KDTreeNode *nodes = tree->nodes;
-
- uint *stack, defaultstack[KD_STACK_INIT];
- float range_sq = range * range, dist_sq;
- uint totstack, cur = 0;
-
-#ifdef DEBUG
- BLI_assert(tree->is_balanced == true);
-#endif
-
- if (UNLIKELY(tree->root == KD_NODE_UNSET))
- return;
-
- stack = defaultstack;
- totstack = KD_STACK_INIT;
-
- stack[cur++] = tree->root;
-
- while (cur--) {
- const KDTreeNode *node = &nodes[stack[cur]];
-
- if (co[node->d] + range < node->co[node->d]) {
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- }
- else if (co[node->d] - range > node->co[node->d]) {
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
- else {
- dist_sq = len_squared_v3v3(node->co, co);
- if (dist_sq <= range_sq) {
- if (search_cb(user_data, node->index, node->co, dist_sq) == false) {
- goto finally;
- }
- }
-
- if (node->left != KD_NODE_UNSET)
- stack[cur++] = node->left;
- if (node->right != KD_NODE_UNSET)
- stack[cur++] = node->right;
- }
-
- if (UNLIKELY(cur + 3 > totstack)) {
- stack = realloc_nodes(stack, &totstack, defaultstack != stack);
- }
- }
-
-finally:
- if (stack != defaultstack)
- MEM_freeN(stack);
-}
-
-/**
- * Use when we want to loop over nodes ordered by index.
- * Requires indices to be aligned with nodes.
- */
-static uint *kdtree_order(const KDTree *tree)
-{
- const KDTreeNode *nodes = tree->nodes;
- uint *order = MEM_mallocN(sizeof(uint) * tree->totnode, __func__);
- for (uint i = 0; i < tree->totnode; i++) {
- order[nodes[i].index] = i;
- }
- return order;
-}
-
-/* -------------------------------------------------------------------- */
-/** \name BLI_kdtree_calc_duplicates_fast
- * \{ */
-
-struct DeDuplicateParams {
- /* Static */
- const KDTreeNode *nodes;
- float range;
- float range_sq;
- int *duplicates;
- int *duplicates_found;
-
- /* Per Search */
- float search_co[3];
- int search;
-};
-
-static void deduplicate_recursive(const struct DeDuplicateParams *p, uint i)
-{
- const KDTreeNode *node = &p->nodes[i];
- if (p->search_co[node->d] + p->range <= node->co[node->d]) {
- if (node->left != KD_NODE_UNSET) {
- deduplicate_recursive(p, node->left);
- }
- }
- else if (p->search_co[node->d] - p->range >= node->co[node->d]) {
- if (node->right != KD_NODE_UNSET) {
- deduplicate_recursive(p, node->right);
- }
- }
- else {
- if ((p->search != node->index) && (p->duplicates[node->index] == -1)) {
- if (compare_len_squared_v3v3(node->co, p->search_co, p->range_sq)) {
- p->duplicates[node->index] = (int)p->search;
- *p->duplicates_found += 1;
- }
- }
- if (node->left != KD_NODE_UNSET) {
- deduplicate_recursive(p, node->left);
- }
- if (node->right != KD_NODE_UNSET) {
- deduplicate_recursive(p, node->right);
- }
- }
-}
-
-/**
- * Find duplicate points in \a range.
- * Favors speed over quality since it doesn't find the best target vertex for merging.
- * Nodes are looped over, duplicates are added when found.
- * Nevertheless results are predictable.
- *
- * \param range: Coordinates in this range are candidates to be merged.
- * \param use_index_order: Loop over the coordinates ordered by #KDTreeNode.index
- * At the expense of some performance, this ensures the layout of the tree doesn't influence
- * the iteration order.
- * \param duplicates: An array of int's the length of #KDTree.totnode
- * Values initialized to -1 are candidates to me merged.
- * Setting the index to it's own position in the array prevents it from being touched,
- * although it can still be used as a target.
- * \returns The numebr of merges found (includes any merges already in the \a duplicates array).
- *
- * \note Merging is always a single step (target indices wont be marked for merging).
- */
-int BLI_kdtree_calc_duplicates_fast(
- const KDTree *tree, const float range, bool use_index_order,
- int *duplicates)
-{
- int found = 0;
- struct DeDuplicateParams p = {
- .nodes = tree->nodes,
- .range = range,
- .range_sq = range * range,
- .duplicates = duplicates,
- .duplicates_found = &found,
- };
-
- if (use_index_order) {
- uint *order = kdtree_order(tree);
- for (uint i = 0; i < tree->totnode; i++) {
- const uint node_index = order[i];
- const int index = (int)i;
- if (ELEM(duplicates[index], -1, index)) {
- p.search = index;
- copy_v3_v3(p.search_co, tree->nodes[node_index].co);
- int found_prev = found;
- deduplicate_recursive(&p, tree->root);
- if (found != found_prev) {
- /* Prevent chains of doubles. */
- duplicates[index] = index;
- }
- }
- }
- MEM_freeN(order);
- }
- else {
- for (uint i = 0; i < tree->totnode; i++) {
- const uint node_index = i;
- const int index = p.nodes[node_index].index;
- if (ELEM(duplicates[index], -1, index)) {
- p.search = index;
- copy_v3_v3(p.search_co, tree->nodes[node_index].co);
- int found_prev = found;
- deduplicate_recursive(&p, tree->root);
- if (found != found_prev) {
- /* Prevent chains of doubles. */
- duplicates[index] = index;
- }
- }
- }
- }
- return found;
-}
-
-/** \} */
diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c
index 46499279659..3f99f65703f 100644
--- a/source/blender/blenlib/intern/BLI_linklist.c
+++ b/source/blender/blenlib/intern/BLI_linklist.c
@@ -41,8 +41,9 @@ int BLI_linklist_count(const LinkNode *list)
{
int len;
- for (len = 0; list; list = list->next)
+ for (len = 0; list; list = list->next) {
len++;
+ }
return len;
}
@@ -51,9 +52,11 @@ int BLI_linklist_index(const LinkNode *list, void *ptr)
{
int index;
- for (index = 0; list; list = list->next, index++)
- if (list->link == ptr)
+ for (index = 0; list; list = list->next, index++) {
+ if (list->link == ptr) {
return index;
+ }
+ }
return -1;
}
@@ -62,9 +65,11 @@ LinkNode *BLI_linklist_find(LinkNode *list, int index)
{
int i;
- for (i = 0; list; list = list->next, i++)
- if (i == index)
+ for (i = 0; list; list = list->next, i++) {
+ if (i == index) {
return list;
+ }
+ }
return NULL;
}
@@ -268,8 +273,9 @@ void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc)
while (list) {
LinkNode *next = list->next;
- if (freefunc)
+ if (freefunc) {
freefunc(list->link);
+ }
MEM_freeN(list);
list = next;
@@ -281,8 +287,9 @@ void BLI_linklist_free_pool(LinkNode *list, LinkNodeFreeFP freefunc, struct BLI_
while (list) {
LinkNode *next = list->next;
- if (freefunc)
+ if (freefunc) {
freefunc(list->link);
+ }
BLI_mempool_free(mempool, list);
list = next;
@@ -303,8 +310,9 @@ void BLI_linklist_freeN(LinkNode *list)
void BLI_linklist_apply(LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata)
{
- for (; list; list = list->next)
+ for (; list; list = list->next) {
applyfunc(list->link, userdata);
+ }
}
/* -------------------------------------------------------------------- */
diff --git a/source/blender/blenlib/intern/BLI_timer.c b/source/blender/blenlib/intern/BLI_timer.c
index d361a1c563d..5fcdd85ba69 100644
--- a/source/blender/blenlib/intern/BLI_timer.c
+++ b/source/blender/blenlib/intern/BLI_timer.c
@@ -112,8 +112,12 @@ static void execute_functions_if_necessary(void)
double current_time = GET_TIME();
LISTBASE_FOREACH(TimedFunction *, timed_func, &GlobalTimer.funcs) {
- if (timed_func->tag_removal) continue;
- if (timed_func->next_time > current_time) continue;
+ if (timed_func->tag_removal) {
+ continue;
+ }
+ if (timed_func->next_time > current_time) {
+ continue;
+ }
double ret = timed_func->func(timed_func->uuid, timed_func->user_data);
diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c
index e74b1016bb1..46818c5a1b9 100644
--- a/source/blender/blenlib/intern/DLRB_tree.c
+++ b/source/blender/blenlib/intern/DLRB_tree.c
@@ -40,8 +40,9 @@ DLRBT_Tree *BLI_dlrbTree_new(void)
/* Just zero out the pointers used */
void BLI_dlrbTree_init(DLRBT_Tree *tree)
{
- if (tree == NULL)
+ if (tree == NULL) {
return;
+ }
tree->first = tree->last = tree->root = NULL;
}
@@ -50,8 +51,9 @@ void BLI_dlrbTree_init(DLRBT_Tree *tree)
static void recursive_tree_free_nodes(DLRBT_Node *node)
{
/* sanity check */
- if (node == NULL)
+ if (node == NULL) {
return;
+ }
/* free child nodes + subtrees */
recursive_tree_free_nodes(node->left);
@@ -64,8 +66,9 @@ static void recursive_tree_free_nodes(DLRBT_Node *node)
/* Free the given tree's data but not the tree itself */
void BLI_dlrbTree_free(DLRBT_Tree *tree)
{
- if (tree == NULL)
+ if (tree == NULL) {
return;
+ }
/* if the list-base stuff is set, just use that (and assume its set),
* otherwise, we'll need to traverse the tree...
@@ -89,8 +92,9 @@ void BLI_dlrbTree_free(DLRBT_Tree *tree)
static void linkedlist_sync_add_node(DLRBT_Tree *tree, DLRBT_Node *node)
{
/* sanity checks */
- if ((tree == NULL) || (node == NULL))
+ if ((tree == NULL) || (node == NULL)) {
return;
+ }
/* add left-node (and its subtree) */
linkedlist_sync_add_node(tree, node->left);
@@ -110,8 +114,9 @@ static void linkedlist_sync_add_node(DLRBT_Tree *tree, DLRBT_Node *node)
void BLI_dlrbTree_linkedlist_sync(DLRBT_Tree *tree)
{
/* sanity checks */
- if (tree == NULL)
+ if (tree == NULL) {
return;
+ }
/* clear list-base pointers so that the new list can be added properly */
tree->first = tree->last = NULL;
@@ -131,8 +136,9 @@ DLRBT_Node *BLI_dlrbTree_search(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, vo
/* check that there is a comparator to use */
/* TODO: if no comparator is supplied, try using the one supplied with the tree... */
- if (cmp_cb == NULL)
+ if (cmp_cb == NULL) {
return NULL;
+ }
/* iteratively perform this search */
while (node && found == 0) {
@@ -141,17 +147,21 @@ DLRBT_Node *BLI_dlrbTree_search(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, vo
*/
switch (cmp_cb(node, search_data)) {
case -1: /* data less than node */
- if (node->left)
+ if (node->left) {
node = node->left;
- else
+ }
+ else {
found = 1;
+ }
break;
case 1: /* data greater than node */
- if (node->right)
+ if (node->right) {
node = node->right;
- else
+ }
+ else {
found = 1;
+ }
break;
default: /* data equals node */
@@ -172,8 +182,9 @@ DLRBT_Node *BLI_dlrbTree_search_exact(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_
/* check that there is a comparator to use */
/* TODO: if no comparator is supplied, try using the one supplied with the tree... */
- if (cmp_cb == NULL)
+ if (cmp_cb == NULL) {
return NULL;
+ }
/* iteratively perform this search */
while (node && found == 0) {
@@ -182,17 +193,21 @@ DLRBT_Node *BLI_dlrbTree_search_exact(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_
*/
switch (cmp_cb(node, search_data)) {
case -1: /* data less than node */
- if (node->left)
+ if (node->left) {
node = node->left;
- else
+ }
+ else {
found = -1;
+ }
break;
case 1: /* data greater than node */
- if (node->right)
+ if (node->right) {
node = node->right;
- else
+ }
+ else {
found = -1;
+ }
break;
default: /* data equals node */
@@ -212,16 +227,18 @@ DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c
/* check that there is a comparator to use */
/* TODO: if no comparator is supplied, try using the one supplied with the tree... */
- if (cmp_cb == NULL)
+ if (cmp_cb == NULL) {
return NULL;
+ }
/* get the node which best matches this description */
node = BLI_dlrbTree_search(tree, cmp_cb, search_data);
if (node) {
/* if the item we're searching for is greater than the node found, we've found the match */
- if (cmp_cb(node, search_data) > 0)
+ if (cmp_cb(node, search_data) > 0) {
return node;
+ }
/* return the previous node otherwise */
/* NOTE: what happens if there is no previous node? */
@@ -239,16 +256,18 @@ DLRBT_Node *BLI_dlrbTree_search_next(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c
/* check that there is a comparator to use */
/* TODO: if no comparator is supplied, try using the one supplied with the tree... */
- if (cmp_cb == NULL)
+ if (cmp_cb == NULL) {
return NULL;
+ }
/* get the node which best matches this description */
node = BLI_dlrbTree_search(tree, cmp_cb, search_data);
if (node) {
/* if the item we're searching for is less than the node found, we've found the match */
- if (cmp_cb(node, search_data) < 0)
+ if (cmp_cb(node, search_data) < 0) {
return node;
+ }
/* return the previous node otherwise */
/* NOTE: what happens if there is no previous node? */
@@ -273,20 +292,24 @@ short BLI_dlrbTree_contains(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, void *
/* get the 'grandparent' - the parent of the parent - of the given node */
static DLRBT_Node *get_grandparent(DLRBT_Node *node)
{
- if (node && node->parent)
+ if (node && node->parent) {
return node->parent->parent;
- else
+ }
+ else {
return NULL;
+ }
}
/* get the sibling node (e.g. if node is left child of parent, return right child of parent) */
static DLRBT_Node *get_sibling(DLRBT_Node *node)
{
if (node && node->parent) {
- if (node == node->parent->left)
+ if (node == node->parent->left) {
return node->parent->right;
- else
+ }
+ else {
return node->parent->left;
+ }
}
/* sibling not found */
@@ -296,9 +319,10 @@ static DLRBT_Node *get_sibling(DLRBT_Node *node)
/* get the 'uncle' - the sibling of the parent - of the given node */
static DLRBT_Node *get_uncle(DLRBT_Node *node)
{
- if (node)
+ if (node) {
/* return the child of the grandparent which isn't the node's parent */
return get_sibling(node->parent);
+ }
/* uncle not found */
return NULL;
@@ -314,31 +338,38 @@ static void rotate_left(DLRBT_Tree *tree, DLRBT_Node *root)
/* pivot is simply the root's right child, to become the root's parent */
pivot = root->right;
- if (pivot == NULL)
+ if (pivot == NULL) {
return;
+ }
if (root->parent) {
- if (root == root->parent->left)
+ if (root == root->parent->left) {
root_slot = &root->parent->left;
- else
+ }
+ else {
root_slot = &root->parent->right;
+ }
}
- else
+ else {
root_slot = ((DLRBT_Node **)&tree->root); /* &((DLRBT_Node *)tree->root); */
+ }
/* - pivot's left child becomes root's right child
* - root now becomes pivot's left child
*/
root->right = pivot->left;
- if (pivot->left) pivot->left->parent = root;
+ if (pivot->left) {
+ pivot->left->parent = root;
+ }
pivot->left = root;
pivot->parent = root->parent;
root->parent = pivot;
/* make the pivot the new root */
- if (root_slot)
+ if (root_slot) {
*root_slot = pivot;
+ }
}
/* make the left child of the 'root' the new root */
@@ -348,31 +379,38 @@ static void rotate_right(DLRBT_Tree *tree, DLRBT_Node *root)
/* pivot is simply the root's left child, to become the root's parent */
pivot = root->left;
- if (pivot == NULL)
+ if (pivot == NULL) {
return;
+ }
if (root->parent) {
- if (root == root->parent->left)
+ if (root == root->parent->left) {
root_slot = &root->parent->left;
- else
+ }
+ else {
root_slot = &root->parent->right;
+ }
}
- else
+ else {
root_slot = ((DLRBT_Node **)&tree->root); /* &((DLRBT_Node *)tree->root); */
+ }
/* - pivot's right child becomes root's left child
* - root now becomes pivot's right child
*/
root->left = pivot->right;
- if (pivot->right) pivot->right->parent = root;
+ if (pivot->right) {
+ pivot->right->parent = root;
+ }
pivot->right = root;
pivot->parent = root->parent;
root->parent = pivot;
/* make the pivot the new root */
- if (root_slot)
+ if (root_slot) {
*root_slot = pivot;
+ }
}
/* *********************************************** */
@@ -390,10 +428,12 @@ static void insert_check_1(DLRBT_Tree *tree, DLRBT_Node *node)
{
if (node) {
/* if this is the root, just ensure that it is black */
- if (node->parent == NULL)
+ if (node->parent == NULL) {
node->tree_col = DLRBT_BLACK;
- else
+ }
+ else {
insert_check_2(tree, node);
+ }
}
}
@@ -468,10 +508,12 @@ static void insert_check_3(DLRBT_Tree *tree, DLRBT_Node *node)
/* if there are several nodes that all form a left chain, do a right rotation to correct
* this (or a rotation in the opposite direction if they all form a right chain) */
- if ((node == node->parent->left) && (node->parent == gp->left))
+ if ((node == node->parent->left) && (node->parent == gp->left)) {
rotate_right(tree, gp);
- else //if ((node == node->parent->right) && (node->parent == gp->right))
+ }
+ else { //if ((node == node->parent->right) && (node->parent == gp->right))
rotate_left(tree, gp);
+ }
}
}
}
@@ -484,8 +526,9 @@ static void insert_check_3(DLRBT_Tree *tree, DLRBT_Node *node)
void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node)
{
/* sanity checks */
- if ((tree == NULL) || (node == NULL))
+ if ((tree == NULL) || (node == NULL)) {
return;
+ }
/* firstly, the node we just added should be red by default */
node->tree_col = DLRBT_RED;
@@ -506,15 +549,18 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
short new_node = 0;
/* sanity checks */
- if (tree == NULL)
+ if (tree == NULL) {
return NULL;
+ }
/* TODO: if no comparator is supplied, try using the one supplied with the tree... */
- if (cmp_cb == NULL)
+ if (cmp_cb == NULL) {
return NULL;
+ }
/* TODO: if no allocator is supplied, try using the one supplied with the tree... */
- if (new_cb == NULL)
+ if (new_cb == NULL) {
return NULL;
+ }
/* TODO: if no updater is supplied, try using the one supplied with the tree... */
/* try to find the nearest node to this one */
@@ -548,8 +594,9 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb,
}
default: /* update the duplicate node as appropriate */
{
- if (update_cb)
+ if (update_cb) {
update_cb(parNode, data);
+ }
break;
}
}
diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c
index 357fa57b144..c90038b78a1 100644
--- a/source/blender/blenlib/intern/boxpack_2d.c
+++ b/source/blender/blenlib/intern/boxpack_2d.c
@@ -214,8 +214,8 @@ static int box_areasort(const void *p1, const void *p2)
const float a1 = box_area(b1);
const float a2 = box_area(b2);
- if (a1 < a2) return 1;
- else if (a1 > a2) return -1;
+ if (a1 < a2) { return 1; }
+ else if (a1 > a2) { return -1; }
return 0;
}
@@ -240,9 +240,9 @@ static int vertex_sort(const void *p1, const void *p2, void *vs_ctx_p)
#ifdef USE_FREE_STRIP
/* push free verts to the end so we can strip */
- if (UNLIKELY(v1->free == 0 && v2->free == 0)) return 0;
- else if (UNLIKELY(v1->free == 0)) return 1;
- else if (UNLIKELY(v2->free == 0)) return -1;
+ if (UNLIKELY(v1->free == 0 && v2->free == 0)) { return 0; }
+ else if (UNLIKELY(v1->free == 0)) { return 1; }
+ else if (UNLIKELY(v2->free == 0)) { return -1; }
#endif
a1 = max_ff(v1->x + vs_ctx->box_width, v1->y + vs_ctx->box_height);
@@ -254,8 +254,8 @@ static int vertex_sort(const void *p1, const void *p2, void *vs_ctx_p)
#endif
/* sort largest to smallest */
- if (a1 > a2) return 1;
- else if (a1 < a2) return -1;
+ if (a1 > a2) { return 1; }
+ else if (a1 < a2) { return -1; }
return 0;
}
/** \} */
@@ -365,8 +365,9 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r
#endif
}
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++) {
vertex_pack_indices[i] = box->v[i + 1]->index;
+ }
verts_pack_len = 3;
box++; /* next box, needed for the loop below */
/* ...done packing the first box */
diff --git a/source/blender/blenlib/intern/convexhull_2d.c b/source/blender/blenlib/intern/convexhull_2d.c
index a59d44037f1..87471ea65a5 100644
--- a/source/blender/blenlib/intern/convexhull_2d.c
+++ b/source/blender/blenlib/intern/convexhull_2d.c
@@ -83,8 +83,10 @@ int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points
minmax = i - 1;
if (minmax == n - 1) { /* degenerate case: all x-coords == xmin */
r_points[++top] = minmin;
- if (points[minmax][1] != points[minmin][1]) /* a nontrivial segment */
+ if (points[minmax][1] != points[minmin][1]) {
+ /* a nontrivial segment */
r_points[++top] = minmax;
+ }
r_points[++top] = minmin; /* add polygon endpoint */
return top + 1;
}
@@ -168,13 +170,13 @@ static int pointref_cmp_yx(const void *a_, const void *b_)
const struct PointRef *a = a_;
const struct PointRef *b = b_;
- if (a->pt[1] > b->pt[1]) return 1;
- else if (a->pt[1] < b->pt[1]) return -1;
+ if (a->pt[1] > b->pt[1]) { return 1; }
+ else if (a->pt[1] < b->pt[1]) { return -1; }
- if (a->pt[0] > b->pt[0]) return 1;
- else if (a->pt[0] < b->pt[0]) return -1;
+ if (a->pt[0] > b->pt[0]) { return 1; }
+ else if (a->pt[0] < b->pt[0]) { return -1; }
- else return 0;
+ else { return 0; }
}
/**
diff --git a/source/blender/blenlib/intern/dynlib.c b/source/blender/blenlib/intern/dynlib.c
index b172ae7a518..31f8d9d3d57 100644
--- a/source/blender/blenlib/intern/dynlib.c
+++ b/source/blender/blenlib/intern/dynlib.c
@@ -51,8 +51,9 @@ DynamicLibrary *BLI_dynlib_open(const char *name)
handle = LoadLibraryW(name_16);
UTF16_UN_ENCODE(name);
- if (!handle)
+ if (!handle) {
return NULL;
+ }
lib = MEM_callocN(sizeof(*lib), "Dynamic Library");
lib->handle = handle;
@@ -71,8 +72,9 @@ char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib)
/* if lib is NULL reset the last error code */
err = GetLastError();
- if (!lib)
+ if (!lib) {
SetLastError(ERROR_SUCCESS);
+ }
if (err) {
static char buf[1024];
@@ -103,8 +105,9 @@ DynamicLibrary *BLI_dynlib_open(const char *name)
DynamicLibrary *lib;
void *handle = dlopen(name, RTLD_LAZY);
- if (!handle)
+ if (!handle) {
return NULL;
+ }
lib = MEM_callocN(sizeof(*lib), "Dynamic Library");
lib->handle = handle;
diff --git a/source/blender/blenlib/intern/easing.c b/source/blender/blenlib/intern/easing.c
index 07765276537..99077eddc4e 100644
--- a/source/blender/blenlib/intern/easing.c
+++ b/source/blender/blenlib/intern/easing.c
@@ -91,10 +91,12 @@ float BLI_easing_bounce_ease_in(float time, float begin, float change, float dur
float BLI_easing_bounce_ease_in_out(float time, float begin, float change, float duration)
{
- if (time < duration / 2)
+ if (time < duration / 2) {
return BLI_easing_bounce_ease_in(time * 2, 0, change, duration) * 0.5f + begin;
- else
+ }
+ else {
return BLI_easing_bounce_ease_out(time * 2 - duration, 0, change, duration) * 0.5f + change * 0.5f + begin;
+ }
}
float BLI_easing_circ_ease_in(float time, float begin, float change, float duration)
@@ -111,8 +113,9 @@ float BLI_easing_circ_ease_out(float time, float begin, float change, float dura
float BLI_easing_circ_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return -change / 2 * (sqrtf(1 - time * time) - 1) + begin;
+ }
time -= 2.0f;
return change / 2 * (sqrtf(1 - time * time) + 1) + begin;
}
@@ -131,8 +134,9 @@ float BLI_easing_cubic_ease_out(float time, float begin, float change, float dur
float BLI_easing_cubic_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return change / 2 * time * time * time + begin;
+ }
time -= 2.0f;
return change / 2 * (time * time * time + 2) + begin;
}
@@ -170,14 +174,17 @@ float BLI_easing_elastic_ease_in(float time, float begin, float change, float du
float s;
float f = 1.0f;
- if (time == 0.0f)
+ if (time == 0.0f) {
return begin;
+ }
- if ((time /= duration) == 1.0f)
+ if ((time /= duration) == 1.0f) {
return begin + change;
+ }
time -= 1.0f;
- if (!period)
+ if (!period) {
period = duration * 0.3f;
+ }
if (!amplitude || amplitude < fabsf(change)) {
s = period / 4;
#ifdef USE_ELASTIC_BLEND
@@ -185,8 +192,9 @@ float BLI_easing_elastic_ease_in(float time, float begin, float change, float du
#endif
amplitude = change;
}
- else
+ else {
s = period / (2 * (float)M_PI) * asinf(change / amplitude);
+ }
return (-f * (amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period))) + begin;
}
@@ -196,13 +204,16 @@ float BLI_easing_elastic_ease_out(float time, float begin, float change, float d
float s;
float f = 1.0f;
- if (time == 0.0f)
+ if (time == 0.0f) {
return begin;
- if ((time /= duration) == 1.0f)
+ }
+ if ((time /= duration) == 1.0f) {
return begin + change;
+ }
time = -time;
- if (!period)
+ if (!period) {
period = duration * 0.3f;
+ }
if (!amplitude || amplitude < fabsf(change)) {
s = period / 4;
#ifdef USE_ELASTIC_BLEND
@@ -210,8 +221,9 @@ float BLI_easing_elastic_ease_out(float time, float begin, float change, float d
#endif
amplitude = change;
}
- else
+ else {
s = period / (2 * (float)M_PI) * asinf(change / amplitude);
+ }
return (f * (amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period))) + change + begin;
}
@@ -221,13 +233,16 @@ float BLI_easing_elastic_ease_in_out(float time, float begin, float change, floa
float s;
float f = 1.0f;
- if (time == 0.0f)
+ if (time == 0.0f) {
return begin;
- if ((time /= duration / 2) == 2.0f)
+ }
+ if ((time /= duration / 2) == 2.0f) {
return begin + change;
+ }
time -= 1.0f;
- if (!period)
+ if (!period) {
period = duration * (0.3f * 1.5f);
+ }
if (!amplitude || amplitude < fabsf(change)) {
s = period / 4;
#ifdef USE_ELASTIC_BLEND
@@ -235,8 +250,9 @@ float BLI_easing_elastic_ease_in_out(float time, float begin, float change, floa
#endif
amplitude = change;
}
- else
+ else {
s = period / (2 * (float)M_PI) * asinf(change / amplitude);
+ }
if (time < 0.0f) {
f *= -0.5f;
@@ -249,26 +265,37 @@ float BLI_easing_elastic_ease_in_out(float time, float begin, float change, floa
}
}
+static const float pow_min = 0.0009765625f; /* = 2^(-10) */
+static const float pow_scale = 1.0f / (1.0f - 0.0009765625f);
+
float BLI_easing_expo_ease_in(float time, float begin, float change, float duration)
{
- return (time == 0.0f) ? begin : change * powf(2, 10 * (time / duration - 1)) + begin;
+ if (time == 0.0) {
+ return begin;
+ }
+ return change * (powf(2, 10 * (time / duration - 1)) - pow_min) * pow_scale + begin;
}
float BLI_easing_expo_ease_out(float time, float begin, float change, float duration)
{
- return (time == duration) ? begin + change : change * (-powf(2, -10 * time / duration) + 1) + begin;
+ if (time == 0.0) {
+ return begin;
+ }
+ return change * (1 - (powf(2, -10 * time / duration) - pow_min) * pow_scale) + begin;
}
float BLI_easing_expo_ease_in_out(float time, float begin, float change, float duration)
{
- if (time == 0.0f)
- return begin;
- if (time == duration)
- return begin + change;
- if ((time /= duration / 2) < 1)
- return change / 2 * powf(2, 10 * (time - 1)) + begin;
- time -= 1.0f;
- return change / 2 * (-powf(2, -10 * time) + 2) + begin;
+ float duration_half = duration / 2.0f;
+ float change_half = change / 2.0f;
+ if (time <= duration_half) {
+ return BLI_easing_expo_ease_in(
+ time, begin, change_half, duration_half);
+ }
+ else {
+ return BLI_easing_expo_ease_out(
+ time - duration_half, begin + change_half, change_half, duration_half);
+ }
}
float BLI_easing_linear_ease(float time, float begin, float change, float duration)
@@ -290,8 +317,9 @@ float BLI_easing_quad_ease_out(float time, float begin, float change, float dura
float BLI_easing_quad_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return change / 2 * time * time + begin;
+ }
time -= 1.0f;
return -change / 2 * (time * (time - 2) - 1) + begin;
}
@@ -311,8 +339,9 @@ float BLI_easing_quart_ease_out(float time, float begin, float change, float dur
float BLI_easing_quart_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return change / 2 * time * time * time * time + begin;
+ }
time -= 2.0f;
return -change / 2 * ( time * time * time * time - 2) + begin;
}
@@ -329,8 +358,9 @@ float BLI_easing_quint_ease_out(float time, float begin, float change, float dur
}
float BLI_easing_quint_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return change / 2 * time * time * time * time * time + begin;
+ }
time -= 2.0f;
return change / 2 * (time * time * time * time * time + 2) + begin;
}
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index f3d69bc9795..55c9a189a20 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -113,7 +113,9 @@ BLI_INLINE bool edges_equal(Edge e1, Edge e2)
static uint calc_capacity_exp_for_reserve(uint reserve)
{
uint result = 1;
- while (reserve >>= 1) result++;
+ while (reserve >>= 1) {
+ result++;
+ }
return result;
}
@@ -255,7 +257,9 @@ void BLI_edgehash_print(EdgeHash *eh)
}
printf(" Entries:\n");
for (uint i = 0; i < ENTRIES_CAPACITY(eh); i++) {
- if (i == eh->length) printf(" **** below is rest capacity ****\n");
+ if (i == eh->length) {
+ printf(" **** below is rest capacity ****\n");
+ }
EdgeHashEntry entry = eh->entries[i];
printf(" %u: (%u, %u) -> %p\n", i, entry.edge.v_low, entry.edge.v_high, entry.value);
@@ -374,7 +378,9 @@ bool BLI_edgehash_remove(EdgeHash *eh, uint v0, uint v1, EdgeHashFreeFP free_val
{
uint old_length = eh->length;
void *value = BLI_edgehash_popkey(eh, v0, v1);
- if (free_value && value) free_value(value);
+ if (free_value && value) {
+ free_value(value);
+ }
return old_length > eh->length;
}
diff --git a/source/blender/blenlib/intern/expr_pylike_eval.c b/source/blender/blenlib/intern/expr_pylike_eval.c
index d0027c63c4b..51a004f846f 100644
--- a/source/blender/blenlib/intern/expr_pylike_eval.c
+++ b/source/blender/blenlib/intern/expr_pylike_eval.c
@@ -360,8 +360,8 @@ typedef struct BuiltinOpDef {
static BuiltinOpDef builtin_ops[] = {
{ "radians", OPCODE_FUNC1, op_radians },
{ "degrees", OPCODE_FUNC1, op_degrees },
- { "abs", OPCODE_FUNC1, abs },
- { "fabs", OPCODE_FUNC1, abs },
+ { "abs", OPCODE_FUNC1, fabs },
+ { "fabs", OPCODE_FUNC1, fabs },
{ "floor", OPCODE_FUNC1, floor },
{ "ceil", OPCODE_FUNC1, ceil },
{ "trunc", OPCODE_FUNC1, trunc },
@@ -554,28 +554,32 @@ static bool parse_next_token(ExprParseState *state)
char *end, *out = state->tokenbuf;
bool is_float = false;
- while (isdigit(*state->cur))
+ while (isdigit(*state->cur)) {
*out++ = *state->cur++;
+ }
if (*state->cur == '.') {
is_float = true;
*out++ = *state->cur++;
- while (isdigit(*state->cur))
+ while (isdigit(*state->cur)) {
*out++ = *state->cur++;
+ }
}
if (ELEM(*state->cur, 'e', 'E')) {
is_float = true;
*out++ = *state->cur++;
- if (ELEM(*state->cur, '+', '-'))
+ if (ELEM(*state->cur, '+', '-')) {
*out++ = *state->cur++;
+ }
CHECK_ERROR(isdigit(*state->cur));
- while (isdigit(*state->cur))
+ while (isdigit(*state->cur)) {
*out++ = *state->cur++;
+ }
}
*out = 0;
@@ -611,8 +615,9 @@ static bool parse_next_token(ExprParseState *state)
if (isalpha(*state->cur) || ELEM(*state->cur, '_')) {
char *out = state->tokenbuf;
- while (isalnum(*state->cur) || ELEM(*state->cur, '_'))
+ while (isalnum(*state->cur) || ELEM(*state->cur, '_')) {
*out++ = *state->cur++;
+ }
*out = 0;
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 2339025307e..afedd19b6d5 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -140,8 +140,9 @@ char *BLI_file_ungzip_to_mem(const char *from_file, int *r_size)
MEM_freeN(mem);
mem = NULL;
}
- else if (alloc_size != size)
+ else if (alloc_size != size) {
mem = MEM_reallocN(mem, size);
+ }
*r_size = size;
@@ -249,8 +250,9 @@ void *BLI_gzopen(const char *filename, const char *mode)
BLI_assert(!BLI_path_is_rel(filename));
/* xxx Creates file before transcribing the path */
- if (mode[0] == 'w')
+ if (mode[0] == 'w') {
fclose(ufopen(filename, "a"));
+ }
/* temporary #if until we update all libraries to 1.2.7
* for correct wide char path handling */
@@ -293,11 +295,15 @@ static bool delete_unique(const char *path, const bool dir)
if (dir) {
err = !RemoveDirectoryW(path_16);
- if (err) printf("Unable to remove directory\n");
+ if (err) {
+ printf("Unable to remove directory\n");
+ }
}
else {
err = !DeleteFileW(path_16);
- if (err) callLocalErrorCallBack("Unable to delete file");
+ if (err) {
+ callLocalErrorCallBack("Unable to delete file");
+ }
}
UTF16_UN_ENCODE(path);
@@ -487,11 +493,16 @@ bool BLI_dir_create_recursive(const char *dirname)
int BLI_rename(const char *from, const char *to)
{
- if (!BLI_exists(from)) return 0;
+ if (!BLI_exists(from)) {
+ return 0;
+ }
/* make sure the filenames are different (case insensitive) before removing */
- if (BLI_exists(to) && BLI_strcasecmp(from, to))
- if (BLI_delete(to, false, false)) return 1;
+ if (BLI_exists(to) && BLI_strcasecmp(from, to)) {
+ if (BLI_delete(to, false, false)) {
+ return 1;
+ }
+ }
return urename(from, to);
}
@@ -517,10 +528,12 @@ static void join_dirfile_alloc(char **dst, size_t *alloc_len, const char *dir, c
{
size_t len = strlen(dir) + strlen(file) + 1;
- if (*dst == NULL)
+ if (*dst == NULL) {
*dst = MEM_mallocN(len + 1, "join_dirfile_alloc path");
- else if (*alloc_len < len)
+ }
+ else if (*alloc_len < len) {
*dst = MEM_reallocN(*dst, len + 1);
+ }
*alloc_len = len;
@@ -564,21 +577,24 @@ static int recursive_operation(const char *startfrom, const char *startto,
do { /* once */
/* ensure there's no trailing slash in file path */
from = strip_last_slash(startfrom);
- if (startto)
+ if (startto) {
to = strip_last_slash(startto);
+ }
ret = lstat(from, &st);
- if (ret < 0)
+ if (ret < 0) {
/* source wasn't found, nothing to operate with */
break;
+ }
if (!S_ISDIR(st.st_mode)) {
/* source isn't a directory, can't do recursive walking for it,
* so just call file callback and leave */
if (callback_file != NULL) {
ret = callback_file(from, to);
- if (ret != RecursiveOp_Callback_OK)
+ if (ret != RecursiveOp_Callback_OK) {
ret = -1;
+ }
}
break;
}
@@ -594,11 +610,13 @@ static int recursive_operation(const char *startfrom, const char *startto,
if (callback_dir_pre != NULL) {
ret = callback_dir_pre(from, to);
if (ret != RecursiveOp_Callback_OK) {
- if (ret == RecursiveOp_Callback_StopRecurs)
+ if (ret == RecursiveOp_Callback_StopRecurs) {
/* callback requested not to perform recursive walking, not an error */
ret = 0;
- else
+ }
+ else {
ret = -1;
+ }
break;
}
}
@@ -606,12 +624,14 @@ static int recursive_operation(const char *startfrom, const char *startto,
for (i = 0; i < n; i++) {
const struct dirent * const dirent = dirlist[i];
- if (FILENAME_IS_CURRPAR(dirent->d_name))
+ if (FILENAME_IS_CURRPAR(dirent->d_name)) {
continue;
+ }
join_dirfile_alloc(&from_path, &from_alloc_len, from, dirent->d_name);
- if (to)
+ if (to) {
join_dirfile_alloc(&to_path, &to_alloc_len, to, dirent->d_name);
+ }
bool is_dir;
@@ -633,23 +653,26 @@ static int recursive_operation(const char *startfrom, const char *startto,
}
else if (callback_file != NULL) {
ret = callback_file(from_path, to_path);
- if (ret != RecursiveOp_Callback_OK)
+ if (ret != RecursiveOp_Callback_OK) {
ret = -1;
+ }
}
- if (ret != 0)
+ if (ret != 0) {
break;
+ }
}
- if (ret != 0)
+ if (ret != 0) {
break;
+ }
if (callback_dir_post != NULL) {
ret = callback_dir_post(from, to);
- if (ret != RecursiveOp_Callback_OK)
+ if (ret != RecursiveOp_Callback_OK) {
ret = -1;
+ }
}
- }
- while (false);
+ } while (false);
if (dirlist != NULL) {
for (i = 0; i < n; i++) {
@@ -657,14 +680,18 @@ static int recursive_operation(const char *startfrom, const char *startto,
}
free(dirlist);
}
- if (from_path != NULL)
+ if (from_path != NULL) {
MEM_freeN(from_path);
- if (to_path != NULL)
+ }
+ if (to_path != NULL) {
MEM_freeN(to_path);
- if (from != NULL)
+ }
+ if (from != NULL) {
MEM_freeN(from);
- if (to != NULL)
+ }
+ if (to != NULL) {
MEM_freeN(to);
+ }
return ret;
}
@@ -748,11 +775,13 @@ static bool check_the_same(const char *path_a, const char *path_b)
{
struct stat st_a, st_b;
- if (lstat(path_a, &st_a))
+ if (lstat(path_a, &st_a)) {
return false;
+ }
- if (lstat(path_b, &st_b))
+ if (lstat(path_b, &st_b)) {
return false;
+ }
return st_a.st_dev == st_b.st_dev && st_a.st_ino == st_b.st_ino;
}
@@ -843,7 +872,9 @@ static int copy_single_file(const char *from, const char *to)
if (link_len < 0) {
perror("readlink");
- if (need_free) MEM_freeN(link_buffer);
+ if (need_free) {
+ MEM_freeN(link_buffer);
+ }
return RecursiveOp_Callback_Error;
}
@@ -852,12 +883,15 @@ static int copy_single_file(const char *from, const char *to)
if (symlink(link_buffer, to)) {
perror("symlink");
- if (need_free) MEM_freeN(link_buffer);
+ if (need_free) {
+ MEM_freeN(link_buffer);
+ }
return RecursiveOp_Callback_Error;
}
- if (need_free)
+ if (need_free) {
MEM_freeN(link_buffer);
+ }
return RecursiveOp_Callback_OK;
}
@@ -872,8 +906,9 @@ static int copy_single_file(const char *from, const char *to)
return RecursiveOp_Callback_Error;
}
- if (set_permissions(to, &st))
+ if (set_permissions(to, &st)) {
return RecursiveOp_Callback_Error;
+ }
return RecursiveOp_Callback_OK;
}
@@ -902,8 +937,9 @@ static int copy_single_file(const char *from, const char *to)
fclose(to_stream);
fclose(from_stream);
- if (set_permissions(to, &st))
+ if (set_permissions(to, &st)) {
return RecursiveOp_Callback_Error;
+ }
return RecursiveOp_Callback_OK;
}
@@ -985,8 +1021,9 @@ int BLI_copy(const char *file, const char *to)
ret = recursive_operation(file, actual_to, copy_callback_pre, copy_single_file, NULL);
- if (actual_to != to)
+ if (actual_to != to) {
MEM_freeN((void *)actual_to);
+ }
return ret;
}
@@ -1057,8 +1094,11 @@ int BLI_rename(const char *from, const char *to)
return 1;
}
- if (BLI_exists(to))
- if (BLI_delete(to, false, false)) return 1;
+ if (BLI_exists(to)) {
+ if (BLI_delete(to, false, false)) {
+ return 1;
+ }
+ }
return rename(from, to);
}
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index fba3c825a1c..36051e3e7f0 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -104,10 +104,13 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
for (k = 0; k < n; k++) {
l = (j > 0) ? (k + ftoutline.contours[j - 1] + 1) : k;
- if (k == 0) l_first = l;
+ if (k == 0) {
+ l_first = l;
+ }
- if (ftoutline.tags[l] == FT_Curve_Tag_On)
+ if (ftoutline.tags[l] == FT_Curve_Tag_On) {
onpoints[j]++;
+ }
{
const int l_next = (k < n - 1) ? (l + 1) : l_first;
@@ -140,7 +143,9 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *
/* individual curve loop, start-end */
for (k = 0; k < n; k++) {
l = (j > 0) ? (k + ftoutline.contours[j - 1] + 1) : k;
- if (k == 0) l_first = l;
+ if (k == 0) {
+ l_first = l;
+ }
/* virtual conic on-curve points */
{
@@ -291,7 +296,9 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
0,
&face);
- if (err) return NULL;
+ if (err) {
+ return NULL;
+ }
/* allocate blender font */
vfd = MEM_callocN(sizeof(*vfd), "FTVFontData");
@@ -319,8 +326,9 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
err = FT_Set_Charmap(face, found);
- if (err)
+ if (err) {
return NULL;
+ }
lcode = charcode = FT_Get_First_Char(face, &glyph_index);
}
@@ -362,8 +370,9 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
charcode = FT_Get_Next_Char(face, charcode, &glyph_index);
/* Check that we won't start infinite loop */
- if (charcode <= lcode)
+ if (charcode <= lcode) {
break;
+ }
lcode = charcode;
}
@@ -460,7 +469,9 @@ VChar *BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character)
{
VChar *che = NULL;
- if (!vfont) return NULL;
+ if (!vfont) {
+ return NULL;
+ }
/* Init Freetype */
err = FT_Init_FreeType(&library);
diff --git a/source/blender/blenlib/intern/gsqueue.c b/source/blender/blenlib/intern/gsqueue.c
index 226e6cd34d5..40890222e55 100644
--- a/source/blender/blenlib/intern/gsqueue.c
+++ b/source/blender/blenlib/intern/gsqueue.c
@@ -78,8 +78,9 @@ int BLI_gsqueue_len(GSQueue *gq)
GSQueueElem *elem;
int size = 0;
- for (elem = gq->head; elem; elem = elem->next)
+ for (elem = gq->head; elem; elem = elem->next) {
size++;
+ }
return size;
}
@@ -132,8 +133,9 @@ void BLI_gsqueue_push(GSQueue *gq, const void *item)
/* compare: prevent events added double in row */
if (!BLI_gsqueue_is_empty(gq)) {
- if (0 == memcmp(item, gq->head->data, gq->elem_size))
+ if (0 == memcmp(item, gq->head->data, gq->elem_size)) {
return;
+ }
}
elem = MEM_mallocN(sizeof(*elem) + gq->elem_size, "gqueue_push");
memcpy(elem->data, item, gq->elem_size);
diff --git a/source/blender/blenlib/intern/hash_md5.c b/source/blender/blenlib/intern/hash_md5.c
index 895b558dc82..1a8e78d4227 100644
--- a/source/blender/blenlib/intern/hash_md5.c
+++ b/source/blender/blenlib/intern/hash_md5.c
@@ -316,19 +316,22 @@ int BLI_hash_md5_stream(FILE *stream, void *resblock)
sum += n;
} while (sum < BLOCKSIZE && n != 0);
- if (n == 0 && ferror(stream))
+ if (n == 0 && ferror(stream)) {
return 1;
+ }
/* RFC 1321 specifies the possible length of the file up to 2^64 bits.
* Here we only compute the number of bytes. Do a double word increment.
*/
len[0] += sum;
- if (len[0] < sum)
+ if (len[0] < sum) {
++len[1];
+ }
/* If end of file is reached, end the loop. */
- if (n == 0)
+ if (n == 0) {
break;
+ }
/* Process buffer with BLOCKSIZE bytes. Note that BLOCKSIZE % 64 == 0. */
md5_process_block(buffer, BLOCKSIZE, &ctx);
diff --git a/source/blender/blenlib/intern/jitter_2d.c b/source/blender/blenlib/intern/jitter_2d.c
index 0a1ee08776e..bbf1948be4d 100644
--- a/source/blender/blenlib/intern/jitter_2d.c
+++ b/source/blender/blenlib/intern/jitter_2d.c
@@ -104,17 +104,17 @@ void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float rad2)
vecx = jit1[j][0] - x - 1.0f;
vecy = jit1[j][1] - y - 1.0f;
- if (fabsf(vecx) < rad2) dvecx += vecx * rad2;
+ if (fabsf(vecx) < rad2) { dvecx += vecx * rad2; }
vecx += 1.0f;
- if (fabsf(vecx) < rad2) dvecx += vecx * rad2;
+ if (fabsf(vecx) < rad2) { dvecx += vecx * rad2; }
vecx += 1.0f;
- if (fabsf(vecx) < rad2) dvecx += vecx * rad2;
+ if (fabsf(vecx) < rad2) { dvecx += vecx * rad2; }
- if (fabsf(vecy) < rad2) dvecy += vecy * rad2;
+ if (fabsf(vecy) < rad2) { dvecy += vecy * rad2; }
vecy += 1.0f;
- if (fabsf(vecy) < rad2) dvecy += vecy * rad2;
+ if (fabsf(vecy) < rad2) { dvecy += vecy * rad2; }
vecy += 1.0f;
- if (fabsf(vecy) < rad2) dvecy += vecy * rad2;
+ if (fabsf(vecy) < rad2) { dvecy += vecy * rad2; }
}
}
diff --git a/source/blender/blenlib/intern/kdtree_1d.c b/source/blender/blenlib/intern/kdtree_1d.c
new file mode 100644
index 00000000000..95d440d3644
--- /dev/null
+++ b/source/blender/blenlib/intern/kdtree_1d.c
@@ -0,0 +1,25 @@
+/*
+ * 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 bli
+ */
+
+#define KD_DIMS 1
+#define KDTREE_PREFIX_ID BLI_kdtree_1d
+#define KDTree KDTree_1d
+#define KDTreeNearest KDTreeNearest_1d
+# include "kdtree_impl.h"
diff --git a/source/blender/blenlib/intern/kdtree_2d.c b/source/blender/blenlib/intern/kdtree_2d.c
new file mode 100644
index 00000000000..8ad55e2d964
--- /dev/null
+++ b/source/blender/blenlib/intern/kdtree_2d.c
@@ -0,0 +1,25 @@
+/*
+ * 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 bli
+ */
+
+#define KD_DIMS 2
+#define KDTREE_PREFIX_ID BLI_kdtree_2d
+#define KDTree KDTree_2d
+#define KDTreeNearest KDTreeNearest_2d
+# include "kdtree_impl.h"
diff --git a/source/blender/blenlib/intern/kdtree_3d.c b/source/blender/blenlib/intern/kdtree_3d.c
new file mode 100644
index 00000000000..2f85755b676
--- /dev/null
+++ b/source/blender/blenlib/intern/kdtree_3d.c
@@ -0,0 +1,25 @@
+/*
+ * 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 bli
+ */
+
+#define KD_DIMS 3
+#define KDTREE_PREFIX_ID BLI_kdtree_3d
+#define KDTree KDTree_3d
+#define KDTreeNearest KDTreeNearest_3d
+# include "kdtree_impl.h"
diff --git a/source/blender/blenlib/intern/kdtree_4d.c b/source/blender/blenlib/intern/kdtree_4d.c
new file mode 100644
index 00000000000..cdddf5e3168
--- /dev/null
+++ b/source/blender/blenlib/intern/kdtree_4d.c
@@ -0,0 +1,25 @@
+/*
+ * 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 bli
+ */
+
+#define KD_DIMS 4
+#define KDTREE_PREFIX_ID BLI_kdtree_4d
+#define KDTree KDTree_4d
+#define KDTreeNearest KDTreeNearest_4d
+#include "kdtree_impl.h"
diff --git a/source/blender/blenlib/intern/kdtree_impl.h b/source/blender/blenlib/intern/kdtree_impl.h
new file mode 100644
index 00000000000..1bce3473bde
--- /dev/null
+++ b/source/blender/blenlib/intern/kdtree_impl.h
@@ -0,0 +1,967 @@
+/*
+ * 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 bli
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_kdtree_impl.h"
+#include "BLI_utildefines.h"
+#include "BLI_strict_flags.h"
+
+#define _CONCAT_AUX(MACRO_ARG1, MACRO_ARG2) MACRO_ARG1 ## MACRO_ARG2
+#define _CONCAT(MACRO_ARG1, MACRO_ARG2) _CONCAT_AUX(MACRO_ARG1, MACRO_ARG2)
+#define BLI_kdtree_nd_(id) _CONCAT(KDTREE_PREFIX_ID, _##id)
+
+typedef struct KDTreeNode_head {
+ uint left, right;
+ float co[KD_DIMS];
+ int index;
+} KDTreeNode_head;
+
+typedef struct KDTreeNode {
+ uint left, right;
+ float co[KD_DIMS];
+ int index;
+ uint d; /* range is only (0..KD_DIMS - 1) */
+} KDTreeNode;
+
+struct KDTree {
+ KDTreeNode *nodes;
+ uint nodes_len;
+ uint root;
+#ifdef DEBUG
+ bool is_balanced; /* ensure we call balance first */
+ uint nodes_len_capacity; /* max size of the tree */
+#endif
+};
+
+#define KD_STACK_INIT 100 /* initial size for array (on the stack) */
+#define KD_NEAR_ALLOC_INC 100 /* alloc increment for collecting nearest */
+#define KD_FOUND_ALLOC_INC 50 /* alloc increment for collecting nearest */
+
+#define KD_NODE_UNSET ((uint)-1)
+
+/** When set we know all values are unbalanced, otherwise clear them when re-balancing: see T62210. */
+#define KD_NODE_ROOT_IS_INIT ((uint)-2)
+
+/* -------------------------------------------------------------------- */
+/** \name Local Math API
+ * \{ */
+
+static void copy_vn_vn(float v0[KD_DIMS], const float v1[KD_DIMS])
+{
+ for (uint j = 0; j < KD_DIMS; j++) {
+ v0[j] = v1[j];
+ }
+}
+
+static float len_squared_vnvn(const float v0[KD_DIMS], const float v1[KD_DIMS])
+{
+ float d = 0.0f;
+ for (uint j = 0; j < KD_DIMS; j++) {
+ d += SQUARE(v0[j] - v1[j]);
+ }
+ return d;
+}
+
+static float len_squared_vnvn_cb(const float co_kdtree[KD_DIMS], const float co_search[KD_DIMS], const void *UNUSED(user_data))
+{
+ return len_squared_vnvn(co_kdtree, co_search);
+}
+
+/** \} */
+
+/**
+ * Creates or free a kdtree
+ */
+KDTree *BLI_kdtree_nd_(new)(uint nodes_len_capacity)
+{
+ KDTree *tree;
+
+ tree = MEM_mallocN(sizeof(KDTree), "KDTree");
+ tree->nodes = MEM_mallocN(sizeof(KDTreeNode) * nodes_len_capacity, "KDTreeNode");
+ tree->nodes_len = 0;
+ tree->root = KD_NODE_ROOT_IS_INIT;
+
+#ifdef DEBUG
+ tree->is_balanced = false;
+ tree->nodes_len_capacity = nodes_len_capacity;
+#endif
+
+ return tree;
+}
+
+void BLI_kdtree_nd_(free)(KDTree *tree)
+{
+ if (tree) {
+ MEM_freeN(tree->nodes);
+ MEM_freeN(tree);
+ }
+}
+
+/**
+ * Construction: first insert points, then call balance. Normal is optional.
+ */
+void BLI_kdtree_nd_(insert)(KDTree *tree, int index, const float co[KD_DIMS])
+{
+ KDTreeNode *node = &tree->nodes[tree->nodes_len++];
+
+#ifdef DEBUG
+ BLI_assert(tree->nodes_len <= tree->nodes_len_capacity);
+#endif
+
+ /* note, array isn't calloc'd,
+ * need to initialize all struct members */
+
+ node->left = node->right = KD_NODE_UNSET;
+ copy_vn_vn(node->co, co);
+ node->index = index;
+ node->d = 0;
+
+#ifdef DEBUG
+ tree->is_balanced = false;
+#endif
+}
+
+static uint kdtree_balance(KDTreeNode *nodes, uint nodes_len, uint axis, const uint ofs)
+{
+ KDTreeNode *node;
+ float co;
+ uint left, right, median, i, j;
+
+ if (nodes_len <= 0) {
+ return KD_NODE_UNSET;
+ }
+ else if (nodes_len == 1) {
+ return 0 + ofs;
+ }
+
+ /* quicksort style sorting around median */
+ left = 0;
+ right = nodes_len - 1;
+ median = nodes_len / 2;
+
+ while (right > left) {
+ co = nodes[right].co[axis];
+ i = left - 1;
+ j = right;
+
+ while (1) {
+ while (nodes[++i].co[axis] < co) { /* pass */ }
+ while (nodes[--j].co[axis] > co && j > left) { /* pass */ }
+
+ if (i >= j) {
+ break;
+ }
+
+ SWAP(KDTreeNode_head, *(KDTreeNode_head *)&nodes[i], *(KDTreeNode_head *)&nodes[j]);
+ }
+
+ SWAP(KDTreeNode_head, *(KDTreeNode_head *)&nodes[i], *(KDTreeNode_head *)&nodes[right]);
+ if (i >= median) {
+ right = i - 1;
+ }
+ if (i <= median) {
+ left = i + 1;
+ }
+ }
+
+ /* set node and sort subnodes */
+ node = &nodes[median];
+ node->d = axis;
+ axis = (axis + 1) % KD_DIMS;
+ node->left = kdtree_balance(nodes, median, axis, ofs);
+ node->right = kdtree_balance(nodes + median + 1, (nodes_len - (median + 1)), axis, (median + 1) + ofs);
+
+ return median + ofs;
+}
+
+void BLI_kdtree_nd_(balance)(KDTree *tree)
+{
+ if (tree->root != KD_NODE_ROOT_IS_INIT) {
+ for (uint i = 0; i < tree->nodes_len; i++) {
+ tree->nodes[i].left = KD_NODE_UNSET;
+ tree->nodes[i].right = KD_NODE_UNSET;
+ }
+ }
+
+ tree->root = kdtree_balance(tree->nodes, tree->nodes_len, 0, 0);
+
+#ifdef DEBUG
+ tree->is_balanced = true;
+#endif
+}
+
+static uint *realloc_nodes(uint *stack, uint *stack_len_capacity, const bool is_alloc)
+{
+ uint *stack_new = MEM_mallocN((*stack_len_capacity + KD_NEAR_ALLOC_INC) * sizeof(uint), "KDTree.treestack");
+ memcpy(stack_new, stack, *stack_len_capacity * sizeof(uint));
+ // memset(stack_new + *stack_len_capacity, 0, sizeof(uint) * KD_NEAR_ALLOC_INC);
+ if (is_alloc) {
+ MEM_freeN(stack);
+ }
+ *stack_len_capacity += KD_NEAR_ALLOC_INC;
+ return stack_new;
+}
+
+/**
+ * Find nearest returns index, and -1 if no node is found.
+ */
+int BLI_kdtree_nd_(find_nearest)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest *r_nearest)
+{
+ const KDTreeNode *nodes = tree->nodes;
+ const KDTreeNode *root, *min_node;
+ uint *stack, stack_default[KD_STACK_INIT];
+ float min_dist, cur_dist;
+ uint stack_len_capacity, cur = 0;
+
+#ifdef DEBUG
+ BLI_assert(tree->is_balanced == true);
+#endif
+
+ if (UNLIKELY(tree->root == KD_NODE_UNSET)) {
+ return -1;
+ }
+
+ stack = stack_default;
+ stack_len_capacity = KD_STACK_INIT;
+
+ root = &nodes[tree->root];
+ min_node = root;
+ min_dist = len_squared_vnvn(root->co, co);
+
+ if (co[root->d] < root->co[root->d]) {
+ if (root->right != KD_NODE_UNSET) {
+ stack[cur++] = root->right;
+ }
+ if (root->left != KD_NODE_UNSET) {
+ stack[cur++] = root->left;
+ }
+ }
+ else {
+ if (root->left != KD_NODE_UNSET) {
+ stack[cur++] = root->left;
+ }
+ if (root->right != KD_NODE_UNSET) {
+ stack[cur++] = root->right;
+ }
+ }
+
+ while (cur--) {
+ const KDTreeNode *node = &nodes[stack[cur]];
+
+ cur_dist = node->co[node->d] - co[node->d];
+
+ if (cur_dist < 0.0f) {
+ cur_dist = -cur_dist * cur_dist;
+
+ if (-cur_dist < min_dist) {
+ cur_dist = len_squared_vnvn(node->co, co);
+ if (cur_dist < min_dist) {
+ min_dist = cur_dist;
+ min_node = node;
+ }
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ }
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+ else {
+ cur_dist = cur_dist * cur_dist;
+
+ if (cur_dist < min_dist) {
+ cur_dist = len_squared_vnvn(node->co, co);
+ if (cur_dist < min_dist) {
+ min_dist = cur_dist;
+ min_node = node;
+ }
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ }
+ if (UNLIKELY(cur + KD_DIMS > stack_len_capacity)) {
+ stack = realloc_nodes(stack, &stack_len_capacity, stack_default != stack);
+ }
+ }
+
+ if (r_nearest) {
+ r_nearest->index = min_node->index;
+ r_nearest->dist = sqrtf(min_dist);
+ copy_vn_vn(r_nearest->co, min_node->co);
+ }
+
+ if (stack != stack_default) {
+ MEM_freeN(stack);
+ }
+
+ return min_node->index;
+}
+
+
+/**
+ * A version of #BLI_kdtree_3d_find_nearest which runs a callback
+ * to filter out values.
+ *
+ * \param filter_cb: Filter find results,
+ * Return codes: (1: accept, 0: skip, -1: immediate exit).
+ */
+int BLI_kdtree_nd_(find_nearest_cb)(
+ const KDTree *tree, const float co[KD_DIMS],
+ int (*filter_cb)(void *user_data, int index, const float co[KD_DIMS], float dist_sq), void *user_data,
+ KDTreeNearest *r_nearest)
+{
+ const KDTreeNode *nodes = tree->nodes;
+ const KDTreeNode *min_node = NULL;
+
+ uint *stack, stack_default[KD_STACK_INIT];
+ float min_dist = FLT_MAX, cur_dist;
+ uint stack_len_capacity, cur = 0;
+
+#ifdef DEBUG
+ BLI_assert(tree->is_balanced == true);
+#endif
+
+ if (UNLIKELY(tree->root == KD_NODE_UNSET)) {
+ return -1;
+ }
+
+ stack = stack_default;
+ stack_len_capacity = ARRAY_SIZE(stack_default);
+
+#define NODE_TEST_NEAREST(node) \
+{ \
+ const float dist_sq = len_squared_vnvn((node)->co, co); \
+ if (dist_sq < min_dist) { \
+ const int result = filter_cb(user_data, (node)->index, (node)->co, dist_sq); \
+ if (result == 1) { \
+ min_dist = dist_sq; \
+ min_node = node; \
+ } \
+ else if (result == 0) { \
+ /* pass */ \
+ } \
+ else { \
+ BLI_assert(result == -1); \
+ goto finally; \
+ } \
+ } \
+} ((void)0)
+
+ stack[cur++] = tree->root;
+
+ while (cur--) {
+ const KDTreeNode *node = &nodes[stack[cur]];
+
+ cur_dist = node->co[node->d] - co[node->d];
+
+ if (cur_dist < 0.0f) {
+ cur_dist = -cur_dist * cur_dist;
+
+ if (-cur_dist < min_dist) {
+ NODE_TEST_NEAREST(node);
+
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ }
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+ else {
+ cur_dist = cur_dist * cur_dist;
+
+ if (cur_dist < min_dist) {
+ NODE_TEST_NEAREST(node);
+
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ }
+ if (UNLIKELY(cur + KD_DIMS > stack_len_capacity)) {
+ stack = realloc_nodes(stack, &stack_len_capacity, stack_default != stack);
+ }
+ }
+
+#undef NODE_TEST_NEAREST
+
+
+finally:
+ if (stack != stack_default) {
+ MEM_freeN(stack);
+ }
+
+ if (min_node) {
+ if (r_nearest) {
+ r_nearest->index = min_node->index;
+ r_nearest->dist = sqrtf(min_dist);
+ copy_vn_vn(r_nearest->co, min_node->co);
+ }
+
+ return min_node->index;
+ }
+ else {
+ return -1;
+ }
+}
+
+static void nearest_ordered_insert(
+ KDTreeNearest *nearest, uint *nearest_len, const uint nearest_len_capacity,
+ const int index, const float dist, const float co[KD_DIMS])
+{
+ uint i;
+
+ if (*nearest_len < nearest_len_capacity) {
+ (*nearest_len)++;
+ }
+
+ for (i = *nearest_len - 1; i > 0; i--) {
+ if (dist >= nearest[i - 1].dist) {
+ break;
+ }
+ else {
+ nearest[i] = nearest[i - 1];
+ }
+ }
+
+ nearest[i].index = index;
+ nearest[i].dist = dist;
+ copy_vn_vn(nearest[i].co, co);
+}
+
+/**
+ * Find \a nearest_len_capacity nearest returns number of points found, with results in nearest.
+ *
+ * \param r_nearest: An array of nearest, sized at least \a nearest_len_capacity.
+ */
+int BLI_kdtree_nd_(find_nearest_n_with_len_squared_cb)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest r_nearest[],
+ const uint nearest_len_capacity,
+ float (*len_sq_fn)(const float co_search[KD_DIMS], const float co_test[KD_DIMS], const void *user_data),
+ const void *user_data)
+{
+ const KDTreeNode *nodes = tree->nodes;
+ const KDTreeNode *root;
+ uint *stack, stack_default[KD_STACK_INIT];
+ float cur_dist;
+ uint stack_len_capacity, cur = 0;
+ uint i, nearest_len = 0;
+
+#ifdef DEBUG
+ BLI_assert(tree->is_balanced == true);
+#endif
+
+ if (UNLIKELY((tree->root == KD_NODE_UNSET) || nearest_len_capacity == 0)) {
+ return 0;
+ }
+
+ if (len_sq_fn == NULL) {
+ len_sq_fn = len_squared_vnvn_cb;
+ BLI_assert(user_data == NULL);
+ }
+
+ stack = stack_default;
+ stack_len_capacity = ARRAY_SIZE(stack_default);
+
+ root = &nodes[tree->root];
+
+ cur_dist = len_sq_fn(co, root->co, user_data);
+ nearest_ordered_insert(r_nearest, &nearest_len, nearest_len_capacity, root->index, cur_dist, root->co);
+
+ if (co[root->d] < root->co[root->d]) {
+ if (root->right != KD_NODE_UNSET) {
+ stack[cur++] = root->right;
+ }
+ if (root->left != KD_NODE_UNSET) {
+ stack[cur++] = root->left;
+ }
+ }
+ else {
+ if (root->left != KD_NODE_UNSET) {
+ stack[cur++] = root->left;
+ }
+ if (root->right != KD_NODE_UNSET) {
+ stack[cur++] = root->right;
+ }
+ }
+
+ while (cur--) {
+ const KDTreeNode *node = &nodes[stack[cur]];
+
+ cur_dist = node->co[node->d] - co[node->d];
+
+ if (cur_dist < 0.0f) {
+ cur_dist = -cur_dist * cur_dist;
+
+ if (nearest_len < nearest_len_capacity || -cur_dist < r_nearest[nearest_len - 1].dist) {
+ cur_dist = len_sq_fn(co, node->co, user_data);
+
+ if (nearest_len < nearest_len_capacity || cur_dist < r_nearest[nearest_len - 1].dist) {
+ nearest_ordered_insert(r_nearest, &nearest_len, nearest_len_capacity, node->index, cur_dist, node->co);
+ }
+
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ }
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+ else {
+ cur_dist = cur_dist * cur_dist;
+
+ if (nearest_len < nearest_len_capacity || cur_dist < r_nearest[nearest_len - 1].dist) {
+ cur_dist = len_sq_fn(co, node->co, user_data);
+ if (nearest_len < nearest_len_capacity || cur_dist < r_nearest[nearest_len - 1].dist) {
+ nearest_ordered_insert(r_nearest, &nearest_len, nearest_len_capacity, node->index, cur_dist, node->co);
+ }
+
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ }
+ if (UNLIKELY(cur + KD_DIMS > stack_len_capacity)) {
+ stack = realloc_nodes(stack, &stack_len_capacity, stack_default != stack);
+ }
+ }
+
+ for (i = 0; i < nearest_len; i++) {
+ r_nearest[i].dist = sqrtf(r_nearest[i].dist);
+ }
+
+ if (stack != stack_default) {
+ MEM_freeN(stack);
+ }
+
+ return (int)nearest_len;
+}
+
+int BLI_kdtree_nd_(find_nearest_n)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest r_nearest[],
+ const uint nearest_len_capacity)
+{
+ return BLI_kdtree_nd_(find_nearest_n_with_len_squared_cb)(
+ tree, co, r_nearest, nearest_len_capacity,
+ NULL, NULL);
+}
+
+static int nearest_cmp_dist(const void *a, const void *b)
+{
+ const KDTreeNearest *kda = a;
+ const KDTreeNearest *kdb = b;
+
+ if (kda->dist < kdb->dist) {
+ return -1;
+ }
+ else if (kda->dist > kdb->dist) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+static void nearest_add_in_range(
+ KDTreeNearest **r_nearest,
+ uint nearest_index,
+ uint *nearest_len_capacity,
+ const int index, const float dist, const float co[KD_DIMS])
+{
+ KDTreeNearest *to;
+
+ if (UNLIKELY(nearest_index >= *nearest_len_capacity)) {
+ *r_nearest = MEM_reallocN_id(
+ *r_nearest,
+ (*nearest_len_capacity += KD_FOUND_ALLOC_INC) * sizeof(KDTreeNode),
+ __func__);
+ }
+
+ to = (*r_nearest) + nearest_index;
+
+ to->index = index;
+ to->dist = sqrtf(dist);
+ copy_vn_vn(to->co, co);
+}
+
+/**
+ * Range search returns number of points nearest_len, with results in nearest
+ *
+ * \param r_nearest: Allocated array of nearest nearest_len (caller is responsible for freeing).
+ */
+int BLI_kdtree_nd_(range_search_with_len_squared_cb)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest **r_nearest, const float range,
+ float (*len_sq_fn)(const float co_search[KD_DIMS], const float co_test[KD_DIMS], const void *user_data),
+ const void *user_data)
+{
+ const KDTreeNode *nodes = tree->nodes;
+ uint *stack, stack_default[KD_STACK_INIT];
+ KDTreeNearest *nearest = NULL;
+ const float range_sq = range * range;
+ float dist_sq;
+ uint stack_len_capacity, cur = 0;
+ uint nearest_len = 0, nearest_len_capacity = 0;
+
+#ifdef DEBUG
+ BLI_assert(tree->is_balanced == true);
+#endif
+
+ if (UNLIKELY(tree->root == KD_NODE_UNSET)) {
+ return 0;
+ }
+
+ if (len_sq_fn == NULL) {
+ len_sq_fn = len_squared_vnvn_cb;
+ BLI_assert(user_data == NULL);
+ }
+
+ stack = stack_default;
+ stack_len_capacity = ARRAY_SIZE(stack_default);
+
+ stack[cur++] = tree->root;
+
+ while (cur--) {
+ const KDTreeNode *node = &nodes[stack[cur]];
+
+ if (co[node->d] + range < node->co[node->d]) {
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ }
+ else if (co[node->d] - range > node->co[node->d]) {
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+ else {
+ dist_sq = len_sq_fn(co, node->co, user_data);
+ if (dist_sq <= range_sq) {
+ nearest_add_in_range(&nearest, nearest_len++, &nearest_len_capacity, node->index, dist_sq, node->co);
+ }
+
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+
+ if (UNLIKELY(cur + KD_DIMS > stack_len_capacity)) {
+ stack = realloc_nodes(stack, &stack_len_capacity, stack_default != stack);
+ }
+ }
+
+ if (stack != stack_default) {
+ MEM_freeN(stack);
+ }
+
+ if (nearest_len) {
+ qsort(nearest, nearest_len, sizeof(KDTreeNearest), nearest_cmp_dist);
+ }
+
+ *r_nearest = nearest;
+
+ return (int)nearest_len;
+}
+
+int BLI_kdtree_nd_(range_search)(
+ const KDTree *tree, const float co[KD_DIMS],
+ KDTreeNearest **r_nearest, const float range)
+{
+ return BLI_kdtree_nd_(range_search_with_len_squared_cb)(
+ tree, co, r_nearest, range,
+ NULL, NULL);
+}
+
+/**
+ * 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.
+ *
+ * \note the order of calls isn't sorted based on distance.
+ */
+void BLI_kdtree_nd_(range_search_cb)(
+ const KDTree *tree, const float co[KD_DIMS], float range,
+ bool (*search_cb)(void *user_data, int index, const float co[KD_DIMS], float dist_sq), void *user_data)
+{
+ const KDTreeNode *nodes = tree->nodes;
+
+ uint *stack, stack_default[KD_STACK_INIT];
+ float range_sq = range * range, dist_sq;
+ uint stack_len_capacity, cur = 0;
+
+#ifdef DEBUG
+ BLI_assert(tree->is_balanced == true);
+#endif
+
+ if (UNLIKELY(tree->root == KD_NODE_UNSET)) {
+ return;
+ }
+
+ stack = stack_default;
+ stack_len_capacity = ARRAY_SIZE(stack_default);
+
+ stack[cur++] = tree->root;
+
+ while (cur--) {
+ const KDTreeNode *node = &nodes[stack[cur]];
+
+ if (co[node->d] + range < node->co[node->d]) {
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ }
+ else if (co[node->d] - range > node->co[node->d]) {
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+ else {
+ dist_sq = len_squared_vnvn(node->co, co);
+ if (dist_sq <= range_sq) {
+ if (search_cb(user_data, node->index, node->co, dist_sq) == false) {
+ goto finally;
+ }
+ }
+
+ if (node->left != KD_NODE_UNSET) {
+ stack[cur++] = node->left;
+ }
+ if (node->right != KD_NODE_UNSET) {
+ stack[cur++] = node->right;
+ }
+ }
+
+ if (UNLIKELY(cur + KD_DIMS > stack_len_capacity)) {
+ stack = realloc_nodes(stack, &stack_len_capacity, stack_default != stack);
+ }
+ }
+
+finally:
+ if (stack != stack_default) {
+ MEM_freeN(stack);
+ }
+}
+
+/**
+ * Use when we want to loop over nodes ordered by index.
+ * Requires indices to be aligned with nodes.
+ */
+static uint *kdtree_order(const KDTree *tree)
+{
+ const KDTreeNode *nodes = tree->nodes;
+ uint *order = MEM_mallocN(sizeof(uint) * tree->nodes_len, __func__);
+ for (uint i = 0; i < tree->nodes_len; i++) {
+ order[nodes[i].index] = i;
+ }
+ return order;
+}
+
+/* -------------------------------------------------------------------- */
+/** \name BLI_kdtree_3d_calc_duplicates_fast
+ * \{ */
+
+struct DeDuplicateParams {
+ /* Static */
+ const KDTreeNode *nodes;
+ float range;
+ float range_sq;
+ int *duplicates;
+ int *duplicates_found;
+
+ /* Per Search */
+ float search_co[KD_DIMS];
+ int search;
+};
+
+static void deduplicate_recursive(const struct DeDuplicateParams *p, uint i)
+{
+ const KDTreeNode *node = &p->nodes[i];
+ if (p->search_co[node->d] + p->range <= node->co[node->d]) {
+ if (node->left != KD_NODE_UNSET) {
+ deduplicate_recursive(p, node->left);
+ }
+ }
+ else if (p->search_co[node->d] - p->range >= node->co[node->d]) {
+ if (node->right != KD_NODE_UNSET) {
+ deduplicate_recursive(p, node->right);
+ }
+ }
+ else {
+ if ((p->search != node->index) && (p->duplicates[node->index] == -1)) {
+ if (len_squared_vnvn(node->co, p->search_co) <= p->range_sq) {
+ p->duplicates[node->index] = (int)p->search;
+ *p->duplicates_found += 1;
+ }
+ }
+ if (node->left != KD_NODE_UNSET) {
+ deduplicate_recursive(p, node->left);
+ }
+ if (node->right != KD_NODE_UNSET) {
+ deduplicate_recursive(p, node->right);
+ }
+ }
+}
+
+/**
+ * Find duplicate points in \a range.
+ * Favors speed over quality since it doesn't find the best target vertex for merging.
+ * Nodes are looped over, duplicates are added when found.
+ * Nevertheless results are predictable.
+ *
+ * \param range: Coordinates in this range are candidates to be merged.
+ * \param use_index_order: Loop over the coordinates ordered by #KDTreeNode.index
+ * At the expense of some performance, this ensures the layout of the tree doesn't influence
+ * the iteration order.
+ * \param duplicates: An array of int's the length of #KDTree.nodes_len
+ * Values initialized to -1 are candidates to me merged.
+ * Setting the index to it's own position in the array prevents it from being touched,
+ * although it can still be used as a target.
+ * \returns The number of merges found (includes any merges already in the \a duplicates array).
+ *
+ * \note Merging is always a single step (target indices wont be marked for merging).
+ */
+int BLI_kdtree_nd_(calc_duplicates_fast)(
+ const KDTree *tree, const float range, bool use_index_order,
+ int *duplicates)
+{
+ int found = 0;
+ struct DeDuplicateParams p = {
+ .nodes = tree->nodes,
+ .range = range,
+ .range_sq = SQUARE(range),
+ .duplicates = duplicates,
+ .duplicates_found = &found,
+ };
+
+ if (use_index_order) {
+ uint *order = kdtree_order(tree);
+ for (uint i = 0; i < tree->nodes_len; i++) {
+ const uint node_index = order[i];
+ const int index = (int)i;
+ if (ELEM(duplicates[index], -1, index)) {
+ p.search = index;
+ copy_vn_vn(p.search_co, tree->nodes[node_index].co);
+ int found_prev = found;
+ deduplicate_recursive(&p, tree->root);
+ if (found != found_prev) {
+ /* Prevent chains of doubles. */
+ duplicates[index] = index;
+ }
+ }
+ }
+ MEM_freeN(order);
+ }
+ else {
+ for (uint i = 0; i < tree->nodes_len; i++) {
+ const uint node_index = i;
+ const int index = p.nodes[node_index].index;
+ if (ELEM(duplicates[index], -1, index)) {
+ p.search = index;
+ copy_vn_vn(p.search_co, tree->nodes[node_index].co);
+ int found_prev = found;
+ deduplicate_recursive(&p, tree->root);
+ if (found != found_prev) {
+ /* Prevent chains of doubles. */
+ duplicates[index] = index;
+ }
+ }
+ }
+ }
+ return found;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name BLI_kdtree_3d_deduplicate
+ * \{ */
+
+static int kdtree_node_cmp_deduplicate(const void *n0_p, const void *n1_p)
+{
+ const KDTreeNode *n0 = n0_p;
+ const KDTreeNode *n1 = n1_p;
+ for (uint j = 0; j < KD_DIMS; j++) {
+ if (n0->co[j] < n1->co[j]) {
+ return -1;
+ }
+ else if (n0->co[j] > n1->co[j]) {
+ return 1;
+ }
+ }
+ /* Sort by pointer so the first added will be used.
+ * assignment below ignores const correctness,
+ * however the values aren't used for sorting and are to be discarded. */
+ if (n0 < n1) {
+ ((KDTreeNode *)n1)->d = KD_DIMS; /* tag invalid */
+ return -1;
+ }
+ else {
+ ((KDTreeNode *)n0)->d = KD_DIMS; /* tag invalid */
+ return 1;
+ }
+}
+
+/**
+ * Remove exact duplicates (run before before balancing).
+ *
+ * Keep the first element added when duplicates are found.
+ */
+int BLI_kdtree_nd_(deduplicate)(KDTree *tree)
+{
+#ifdef DEBUG
+ tree->is_balanced = false;
+#endif
+ qsort(tree->nodes, (size_t)tree->nodes_len, sizeof(*tree->nodes), kdtree_node_cmp_deduplicate);
+ uint j = 0;
+ for (uint i = 0; i < tree->nodes_len; i++) {
+ if (tree->nodes[i].d != KD_DIMS) {
+ if (i != j) {
+ tree->nodes[j] = tree->nodes[i];
+ }
+ j++;
+ }
+ }
+ tree->nodes_len = j;
+ return (int)tree->nodes_len;
+}
+
+/** \} */
diff --git a/source/blender/blenlib/intern/lasso_2d.c b/source/blender/blenlib/intern/lasso_2d.c
index 37d4d6e1d1f..a8eb9f09041 100644
--- a/source/blender/blenlib/intern/lasso_2d.c
+++ b/source/blender/blenlib/intern/lasso_2d.c
@@ -36,10 +36,10 @@ void BLI_lasso_boundbox(rcti *rect, const int mcords[][2], const unsigned int mo
rect->ymin = rect->ymax = mcords[0][1];
for (a = 1; a < moves; a++) {
- if (mcords[a][0] < rect->xmin) rect->xmin = mcords[a][0];
- else if (mcords[a][0] > rect->xmax) rect->xmax = mcords[a][0];
- if (mcords[a][1] < rect->ymin) rect->ymin = mcords[a][1];
- else if (mcords[a][1] > rect->ymax) rect->ymax = mcords[a][1];
+ if (mcords[a][0] < rect->xmin) { rect->xmin = mcords[a][0]; }
+ else if (mcords[a][0] > rect->xmax) { rect->xmax = mcords[a][0]; }
+ if (mcords[a][1] < rect->ymin) { rect->ymin = mcords[a][1]; }
+ else if (mcords[a][1] > rect->ymax) { rect->ymax = mcords[a][1]; }
}
}
@@ -70,14 +70,22 @@ bool BLI_lasso_is_edge_inside(const int mcords[][2], const unsigned int moves,
const int v1[2] = {x0, y0}, v2[2] = {x1, y1};
/* check points in lasso */
- if (BLI_lasso_is_point_inside(mcords, moves, v1[0], v1[1], error_value)) return true;
- if (BLI_lasso_is_point_inside(mcords, moves, v2[0], v2[1], error_value)) return true;
+ if (BLI_lasso_is_point_inside(mcords, moves, v1[0], v1[1], error_value)) {
+ return true;
+ }
+ if (BLI_lasso_is_point_inside(mcords, moves, v2[0], v2[1], error_value)) {
+ return true;
+ }
/* no points in lasso, so we have to intersect with lasso edge */
- if (isect_seg_seg_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) return true;
+ if (isect_seg_seg_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) {
+ return true;
+ }
for (unsigned int a = 0; a < moves - 1; a++) {
- if (isect_seg_seg_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) return true;
+ if (isect_seg_seg_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) {
+ return true;
+ }
}
return false;
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index 5fd75643d60..8e6de3ab141 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -44,7 +44,9 @@
*/
void BLI_movelisttolist(ListBase *dst, ListBase *src)
{
- if (src->first == NULL) return;
+ if (src->first == NULL) {
+ return;
+ }
if (dst->first == NULL) {
dst->first = src->first;
@@ -63,7 +65,9 @@ void BLI_movelisttolist(ListBase *dst, ListBase *src)
*/
void BLI_movelisttolist_reverse(ListBase *dst, ListBase *src)
{
- if (src->first == NULL) return;
+ if (src->first == NULL) {
+ return;
+ }
if (dst->first == NULL) {
dst->first = src->first;
@@ -85,13 +89,19 @@ void BLI_addhead(ListBase *listbase, void *vlink)
{
Link *link = vlink;
- if (link == NULL) return;
+ if (link == NULL) {
+ return;
+ }
link->next = listbase->first;
link->prev = NULL;
- if (listbase->first) ((Link *)listbase->first)->prev = link;
- if (listbase->last == NULL) listbase->last = link;
+ if (listbase->first) {
+ ((Link *)listbase->first)->prev = link;
+ }
+ if (listbase->last == NULL) {
+ listbase->last = link;
+ }
listbase->first = link;
}
@@ -103,13 +113,19 @@ void BLI_addtail(ListBase *listbase, void *vlink)
{
Link *link = vlink;
- if (link == NULL) return;
+ if (link == NULL) {
+ return;
+ }
link->next = NULL;
link->prev = listbase->last;
- if (listbase->last) ((Link *)listbase->last)->next = link;
- if (listbase->first == NULL) listbase->first = link;
+ if (listbase->last) {
+ ((Link *)listbase->last)->next = link;
+ }
+ if (listbase->first == NULL) {
+ listbase->first = link;
+ }
listbase->last = link;
}
@@ -121,13 +137,23 @@ void BLI_remlink(ListBase *listbase, void *vlink)
{
Link *link = vlink;
- if (link == NULL) return;
+ if (link == NULL) {
+ return;
+ }
- if (link->next) link->next->prev = link->prev;
- if (link->prev) link->prev->next = link->next;
+ if (link->next) {
+ link->next->prev = link->prev;
+ }
+ if (link->prev) {
+ link->prev->next = link->next;
+ }
- if (listbase->last == link) listbase->last = link->prev;
- if (listbase->first == link) listbase->first = link->next;
+ if (listbase->last == link) {
+ listbase->last = link->prev;
+ }
+ if (listbase->first == link) {
+ listbase->first = link->next;
+ }
}
/**
@@ -152,8 +178,9 @@ void BLI_listbase_swaplinks(ListBase *listbase, void *vlinka, void *vlinkb)
Link *linka = vlinka;
Link *linkb = vlinkb;
- if (!linka || !linkb)
+ if (!linka || !linkb) {
return;
+ }
if (linkb->next == linka) {
SWAP(Link *, linka, linkb);
@@ -171,15 +198,32 @@ void BLI_listbase_swaplinks(ListBase *listbase, void *vlinka, void *vlinkb)
}
/* Update neighbors of linka and linkb. */
- if (linka->prev) linka->prev->next = linka;
- if (linka->next) linka->next->prev = linka;
- if (linkb->prev) linkb->prev->next = linkb;
- if (linkb->next) linkb->next->prev = linkb;
+ if (linka->prev) {
+ linka->prev->next = linka;
+ }
+ if (linka->next) {
+ linka->next->prev = linka;
+ }
+ if (linkb->prev) {
+ linkb->prev->next = linkb;
+ }
+ if (linkb->next) {
+ linkb->next->prev = linkb;
+ }
- if (listbase->last == linka) listbase->last = linkb;
- else if (listbase->last == linkb) listbase->last = linka;
- if (listbase->first == linka) listbase->first = linkb;
- else if (listbase->first == linkb) listbase->first = linka;
+ if (listbase->last == linka) {
+ listbase->last = linkb;
+ }
+ else if (listbase->last == linkb) {
+ listbase->last = linka;
+ }
+
+ if (listbase->first == linka) {
+ listbase->first = linkb;
+ }
+ else if (listbase->first == linkb) {
+ listbase->first = linka;
+ }
}
/**
@@ -242,7 +286,9 @@ void BLI_freelinkN(ListBase *listbase, void *vlink)
{
Link *link = vlink;
- if (link == NULL) return;
+ if (link == NULL) {
+ return;
+ }
BLI_remlink(listbase, link);
MEM_freeN(link);
@@ -311,7 +357,9 @@ void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink)
Link *newlink = vnewlink;
/* newlink before nextlink */
- if (newlink == NULL) return;
+ if (newlink == NULL) {
+ return;
+ }
/* empty list */
if (listbase->first == NULL) {
@@ -352,7 +400,9 @@ void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink)
Link *newlink = vnewlink;
/* newlink before nextlink */
- if (newlink == NULL) return;
+ if (newlink == NULL) {
+ return;
+ }
/* empty list */
if (listbase->first == NULL) {
@@ -566,12 +616,15 @@ int BLI_findindex(const ListBase *listbase, const void *vlink)
Link *link = NULL;
int number = 0;
- if (vlink == NULL) return -1;
+ if (vlink == NULL) {
+ return -1;
+ }
link = listbase->first;
while (link) {
- if (link == vlink)
+ if (link == vlink) {
return number;
+ }
number++;
link = link->next;
@@ -589,8 +642,9 @@ void *BLI_findstring(const ListBase *listbase, const char *id, const int offset)
Link *link = NULL;
const char *id_iter;
- if (id == NULL)
+ if (id == NULL) {
return NULL;
+ }
for (link = listbase->first; link; link = link->next) {
id_iter = ((const char *)link) + offset;
@@ -761,8 +815,9 @@ int BLI_findstringindex(const ListBase *listbase, const char *id, const int offs
while (link) {
id_iter = ((const char *)link) + offset;
- if (id[0] == id_iter[0] && STREQ(id, id_iter))
+ if (id[0] == id_iter[0] && STREQ(id, id_iter)) {
return i;
+ }
i++;
link = link->next;
}
@@ -845,8 +900,9 @@ LinkData *BLI_genericNodeN(void *data)
{
LinkData *ld;
- if (data == NULL)
+ if (data == NULL) {
return NULL;
+ }
/* create new link, and make it hold the given data */
ld = MEM_callocN(sizeof(LinkData), __func__);
diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c
index c4b01729a6d..ed75cac2d0c 100644
--- a/source/blender/blenlib/intern/math_base.c
+++ b/source/blender/blenlib/intern/math_base.c
@@ -53,8 +53,9 @@ double double_round(double x, int ndigits)
pow2 = 1.0;
y = (x * pow1) * pow2;
/* if y overflows, then rounded value is exactly x */
- if (!isfinite(y))
+ if (!isfinite(y)) {
return x;
+ }
}
else {
pow1 = pow(10.0, (double)-ndigits);
@@ -63,14 +64,17 @@ double double_round(double x, int ndigits)
}
z = round(y);
- if (fabs(y - z) == 0.5)
+ if (fabs(y - z) == 0.5) {
/* halfway between two integers; use round-half-even */
z = 2.0 * round(y / 2.0);
+ }
- if (ndigits >= 0)
+ if (ndigits >= 0) {
z = (z / pow2) / pow1;
- else
+ }
+ else {
z *= pow1;
+ }
/* if computation resulted in overflow, raise OverflowError */
return z;
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 1ad0dc6a22f..b8a5a138eb4 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -65,16 +65,16 @@ MINLINE float pow7f(float x)
MINLINE float sqrt3f(float f)
{
- if (UNLIKELY(f == 0.0f)) return 0.0f;
- else if (UNLIKELY(f < 0.0f)) return -(float)(exp(log(-f) / 3.0));
- else return (float)(exp(log( f) / 3.0));
+ if (UNLIKELY(f == 0.0f)) { return 0.0f; }
+ else if (UNLIKELY(f < 0.0f)) { return -(float)(exp(log(-f) / 3.0)); }
+ else { return (float)(exp(log( f) / 3.0)); }
}
MINLINE double sqrt3d(double d)
{
- if (UNLIKELY(d == 0.0)) return 0.0;
- else if (UNLIKELY(d < 0.0)) return -exp(log(-d) / 3.0);
- else return exp(log( d) / 3.0);
+ if (UNLIKELY(d == 0.0)) { return 0.0; }
+ else if (UNLIKELY(d < 0.0)) { return -exp(log(-d) / 3.0); }
+ else { return exp(log( d) / 3.0); }
}
MINLINE float sqrtf_signed(float f)
@@ -84,42 +84,42 @@ MINLINE float sqrtf_signed(float f)
MINLINE float saacos(float fac)
{
- if (UNLIKELY(fac <= -1.0f)) return (float)M_PI;
- else if (UNLIKELY(fac >= 1.0f)) return 0.0f;
- else return acosf(fac);
+ if (UNLIKELY(fac <= -1.0f)) { return (float)M_PI; }
+ else if (UNLIKELY(fac >= 1.0f)) { return 0.0f; }
+ else { return acosf(fac); }
}
MINLINE float saasin(float fac)
{
- if (UNLIKELY(fac <= -1.0f)) return (float)-M_PI / 2.0f;
- else if (UNLIKELY(fac >= 1.0f)) return (float) M_PI / 2.0f;
- else return asinf(fac);
+ if (UNLIKELY(fac <= -1.0f)) { return (float)-M_PI / 2.0f; }
+ else if (UNLIKELY(fac >= 1.0f)) { return (float) M_PI / 2.0f; }
+ else { return asinf(fac); }
}
MINLINE float sasqrt(float fac)
{
- if (UNLIKELY(fac <= 0.0f)) return 0.0f;
- else return sqrtf(fac);
+ if (UNLIKELY(fac <= 0.0f)) { return 0.0f; }
+ else { return sqrtf(fac); }
}
MINLINE float saacosf(float fac)
{
- if (UNLIKELY(fac <= -1.0f)) return (float)M_PI;
- else if (UNLIKELY(fac >= 1.0f)) return 0.0f;
- else return acosf(fac);
+ if (UNLIKELY(fac <= -1.0f)) { return (float)M_PI; }
+ else if (UNLIKELY(fac >= 1.0f)) { return 0.0f; }
+ else { return acosf(fac); }
}
MINLINE float saasinf(float fac)
{
- if (UNLIKELY(fac <= -1.0f)) return (float)-M_PI / 2.0f;
- else if (UNLIKELY(fac >= 1.0f)) return (float) M_PI / 2.0f;
- else return asinf(fac);
+ if (UNLIKELY(fac <= -1.0f)) { return (float)-M_PI / 2.0f; }
+ else if (UNLIKELY(fac >= 1.0f)) { return (float) M_PI / 2.0f; }
+ else { return asinf(fac); }
}
MINLINE float sasqrtf(float fac)
{
- if (UNLIKELY(fac <= 0.0f)) return 0.0f;
- else return sqrtf(fac);
+ if (UNLIKELY(fac <= 0.0f)) { return 0.0f; }
+ else { return sqrtf(fac); }
}
MINLINE float interpf(float target, float origin, float fac)
@@ -140,8 +140,9 @@ MINLINE int is_power_of_2_i(int n)
MINLINE int power_of_2_max_i(int n)
{
- if (is_power_of_2_i(n))
+ if (is_power_of_2_i(n)) {
return n;
+ }
do {
n = n & (n - 1);
@@ -152,8 +153,9 @@ MINLINE int power_of_2_max_i(int n)
MINLINE int power_of_2_min_i(int n)
{
- while (!is_power_of_2_i(n))
+ while (!is_power_of_2_i(n)) {
n = n & (n - 1);
+ }
return n;
}
@@ -387,16 +389,16 @@ MINLINE float signf(float f)
MINLINE int signum_i_ex(float a, float eps)
{
- if (a > eps) return 1;
- if (a < -eps) return -1;
- else return 0;
+ if (a > eps) { return 1; }
+ if (a < -eps) { return -1; }
+ else { return 0; }
}
MINLINE int signum_i(float a)
{
- if (a > 0.0f) return 1;
- if (a < 0.0f) return -1;
- else return 0;
+ if (a > 0.0f) { return 1; }
+ if (a < 0.0f) { return -1; }
+ else { return 0; }
}
/** Returns number of (base ten) *significant* digits of integer part of given float
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index dbc5ee11663..54698ddf7ca 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -201,7 +201,9 @@ void hex_to_rgb(char *hexcol, float *r, float *g, float *b)
{
unsigned int ri, gi, bi;
- if (hexcol[0] == '#') hexcol++;
+ if (hexcol[0] == '#') {
+ hexcol++;
+ }
if (sscanf(hexcol, "%02x%02x%02x", &ri, &gi, &bi) == 3) {
/* six digit hex colors */
@@ -385,9 +387,9 @@ unsigned int rgb_to_cpack(float r, float g, float b)
ig = (unsigned int)floorf(255.0f * max_ff(g, 0.0f));
ib = (unsigned int)floorf(255.0f * max_ff(b, 0.0f));
- if (ir > 255) ir = 255;
- if (ig > 255) ig = 255;
- if (ib > 255) ib = 255;
+ if (ir > 255) { ir = 255; }
+ if (ig > 255) { ig = 255; }
+ if (ib > 255) { ib = 255; }
return (ir + (ig * 256) + (ib * 256 * 256));
}
@@ -429,28 +431,46 @@ void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
float srgb_to_linearrgb(float c)
{
- if (c < 0.04045f)
+ if (c < 0.04045f) {
return (c < 0.0f) ? 0.0f : c * (1.0f / 12.92f);
- else
+ }
+ else {
return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
+ }
}
float linearrgb_to_srgb(float c)
{
- if (c < 0.0031308f)
+ if (c < 0.0031308f) {
return (c < 0.0f) ? 0.0f : c * 12.92f;
- else
+ }
+ else {
return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
+ }
}
void minmax_rgb(short c[3])
{
- if (c[0] > 255) c[0] = 255;
- else if (c[0] < 0) c[0] = 0;
- if (c[1] > 255) c[1] = 255;
- else if (c[1] < 0) c[1] = 0;
- if (c[2] > 255) c[2] = 255;
- else if (c[2] < 0) c[2] = 0;
+ if (c[0] > 255) {
+ c[0] = 255;
+ }
+ else if (c[0] < 0) {
+ c[0] = 0;
+ }
+
+ if (c[1] > 255) {
+ c[1] = 255;
+ }
+ else if (c[1] < 0) {
+ c[1] = 0;
+ }
+
+ if (c[2] > 255) {
+ c[2] = 255;
+ }
+ else if (c[2] < 0) {
+ c[2] = 0;
+ }
}
/* If the requested RGB shade contains a negative weight for
@@ -484,10 +504,12 @@ void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *o
for (c = 0; c < 3; c++) {
offset[c] = lift[c] * gain[c];
slope[c] = gain[c] * (1.0f - lift[c]);
- if (gamma[c] == 0)
+ if (gamma[c] == 0) {
power[c] = FLT_MAX;
- else
+ }
+ else {
power[c] = 1.0f / gamma[c];
+ }
}
}
@@ -501,8 +523,12 @@ void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset)
rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
hsv[0] += hue_offset;
- if (hsv[0] > 1.0f) hsv[0] -= 1.0f;
- else if (hsv[0] < 0.0f) hsv[0] += 1.0f;
+ if (hsv[0] > 1.0f) {
+ hsv[0] -= 1.0f;
+ }
+ else if (hsv[0] < 0.0f) {
+ hsv[0] += 1.0f;
+ }
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
}
@@ -551,10 +577,16 @@ static float index_to_float(const unsigned short i)
} tmp;
/* positive and negative zeros, and all gradual underflow, turn into zero: */
- if (i < 0x80 || (i >= 0x8000 && i < 0x8080)) return 0;
+ if (i < 0x80 || (i >= 0x8000 && i < 0x8080)) {
+ return 0;
+ }
/* All NaN's and infinity turn into the largest possible legal float: */
- if (i >= 0x7f80 && i < 0x8000) return FLT_MAX;
- if (i >= 0xff80) return -FLT_MAX;
+ if (i >= 0x7f80 && i < 0x8000) {
+ return FLT_MAX;
+ }
+ if (i >= 0xff80) {
+ return -FLT_MAX;
+ }
#ifdef __BIG_ENDIAN__
tmp.us[0] = i;
@@ -572,16 +604,23 @@ void BLI_init_srgb_conversion(void)
static bool initialized = false;
unsigned int i, b;
- if (initialized)
+ if (initialized) {
return;
+ }
initialized = true;
/* Fill in the lookup table to convert floats to bytes: */
for (i = 0; i < 0x10000; i++) {
float f = linearrgb_to_srgb(index_to_float((unsigned short)i)) * 255.0f;
- if (f <= 0) BLI_color_to_srgb_table[i] = 0;
- else if (f < 255) BLI_color_to_srgb_table[i] = (unsigned short) (f * 0x100 + 0.5f);
- else BLI_color_to_srgb_table[i] = 0xff00;
+ if (f <= 0) {
+ BLI_color_to_srgb_table[i] = 0;
+ }
+ else if (f < 255) {
+ BLI_color_to_srgb_table[i] = (unsigned short) (f * 0x100 + 0.5f);
+ }
+ else {
+ BLI_color_to_srgb_table[i] = 0xff00;
+ }
}
/* Fill in the lookup table to convert bytes to float: */
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 5396f3a47f6..bfe060a8826 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -222,8 +222,9 @@ MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned
return;
}
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
fsrgb[i] = srgb[i] * (1.0f / 255.0f);
+ }
srgb_to_linearrgb_predivide_v4(linear, fsrgb);
}
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index a513aca8e46..7c9c3844843 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -133,8 +133,9 @@ float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3]
area = len_v3(n) * 0.5f;
/* negate area for flipped triangles */
- if (dot_v3v3(n, normal) < 0.0f)
+ if (dot_v3v3(n, normal) < 0.0f) {
area = -area;
+ }
return area;
}
@@ -1075,14 +1076,18 @@ int isect_seg_seg_v2_int(const int v1[2], const int v2[2], const int v3[2], cons
float div, lambda, mu;
div = (float)((v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]));
- if (div == 0.0f) return ISECT_LINE_LINE_COLINEAR;
+ if (div == 0.0f) {
+ return ISECT_LINE_LINE_COLINEAR;
+ }
lambda = (float)((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
mu = (float)((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
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 ISECT_LINE_LINE_EXACT;
+ if (lambda == 0.0f || lambda == 1.0f || mu == 0.0f || mu == 1.0f) {
+ return ISECT_LINE_LINE_EXACT;
+ }
return ISECT_LINE_LINE_CROSS;
}
return ISECT_LINE_LINE_NONE;
@@ -1118,14 +1123,18 @@ int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], co
float div, lambda, mu;
div = (v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]);
- if (div == 0.0f) return ISECT_LINE_LINE_COLINEAR;
+ if (div == 0.0f) {
+ return ISECT_LINE_LINE_COLINEAR;
+ }
lambda = ((float)(v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
mu = ((float)(v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
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 ISECT_LINE_LINE_EXACT;
+ if (lambda == 0.0f || lambda == 1.0f || mu == 0.0f || mu == 1.0f) {
+ return ISECT_LINE_LINE_EXACT;
+ }
return ISECT_LINE_LINE_CROSS;
}
return ISECT_LINE_LINE_NONE;
@@ -1293,8 +1302,9 @@ int isect_seg_seg_v2_point_ex(
u_a = dot_v2v2(s20, s10) / dot_v2v2(s10, s10);
u_b = dot_v2v2(s30, s10) / dot_v2v2(s10, s10);
- if (u_a > u_b)
+ if (u_a > u_b) {
SWAP(float, u_a, u_b);
+ }
if (u_a > endpoint_max || u_b < endpoint_min) {
/* non-overlapping segments */
@@ -1573,21 +1583,29 @@ bool isect_line_segment_tri_v3(
cross_v3_v3v3(p, d, e2);
a = dot_v3v3(e1, p);
- if (a == 0.0f) return false;
+ if (a == 0.0f) {
+ return false;
+ }
f = 1.0f / a;
sub_v3_v3v3(s, p1, v0);
u = f * dot_v3v3(s, p);
- if ((u < 0.0f) || (u > 1.0f)) return false;
+ if ((u < 0.0f) || (u > 1.0f)) {
+ return false;
+ }
cross_v3_v3v3(q, s, e1);
v = f * dot_v3v3(d, q);
- if ((v < 0.0f) || ((u + v) > 1.0f)) return false;
+ if ((v < 0.0f) || ((u + v) > 1.0f)) {
+ return false;
+ }
*r_lambda = f * dot_v3v3(e2, q);
- if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) return false;
+ if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
+ return false;
+ }
if (r_uv) {
r_uv[0] = u;
@@ -1613,21 +1631,29 @@ bool isect_line_segment_tri_epsilon_v3(
cross_v3_v3v3(p, d, e2);
a = dot_v3v3(e1, p);
- if (a == 0.0f) return false;
+ if (a == 0.0f) {
+ return false;
+ }
f = 1.0f / a;
sub_v3_v3v3(s, p1, v0);
u = f * dot_v3v3(s, p);
- if ((u < -epsilon) || (u > 1.0f + epsilon)) return false;
+ if ((u < -epsilon) || (u > 1.0f + epsilon)) {
+ return false;
+ }
cross_v3_v3v3(q, s, e1);
v = f * dot_v3v3(d, q);
- if ((v < -epsilon) || ((u + v) > 1.0f + epsilon)) return false;
+ if ((v < -epsilon) || ((u + v) > 1.0f + epsilon)) {
+ return false;
+ }
*r_lambda = f * dot_v3v3(e2, q);
- if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) return false;
+ if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
+ return false;
+ }
if (r_uv) {
r_uv[0] = u;
@@ -1657,21 +1683,29 @@ bool isect_ray_tri_v3(
cross_v3_v3v3(p, ray_direction, e2);
a = dot_v3v3(e1, p);
- if ((a > -epsilon) && (a < epsilon)) return false;
+ if ((a > -epsilon) && (a < epsilon)) {
+ return false;
+ }
f = 1.0f / a;
sub_v3_v3v3(s, ray_origin, v0);
u = f * dot_v3v3(s, p);
- if ((u < 0.0f) || (u > 1.0f)) return false;
+ if ((u < 0.0f) || (u > 1.0f)) {
+ return false;
+ }
cross_v3_v3v3(q, s, e1);
v = f * dot_v3v3(ray_direction, q);
- if ((v < 0.0f) || ((u + v) > 1.0f)) return false;
+ if ((v < 0.0f) || ((u + v) > 1.0f)) {
+ return false;
+ }
*r_lambda = f * dot_v3v3(e2, q);
- if ((*r_lambda < 0.0f)) return false;
+ if ((*r_lambda < 0.0f)) {
+ return false;
+ }
if (r_uv) {
r_uv[0] = u;
@@ -1721,21 +1755,29 @@ bool isect_ray_tri_epsilon_v3(
cross_v3_v3v3(p, ray_direction, e2);
a = dot_v3v3(e1, p);
- if (a == 0.0f) return false;
+ if (a == 0.0f) {
+ return false;
+ }
f = 1.0f / a;
sub_v3_v3v3(s, ray_origin, v0);
u = f * dot_v3v3(s, p);
- if ((u < -epsilon) || (u > 1.0f + epsilon)) return false;
+ if ((u < -epsilon) || (u > 1.0f + epsilon)) {
+ return false;
+ }
cross_v3_v3v3(q, s, e1);
v = f * dot_v3v3(ray_direction, q);
- if ((v < -epsilon) || ((u + v) > 1.0f + epsilon)) return false;
+ if ((v < -epsilon) || ((u + v) > 1.0f + epsilon)) {
+ return false;
+ }
*r_lambda = f * dot_v3v3(e2, q);
- if ((*r_lambda < 0.0f)) return false;
+ if ((*r_lambda < 0.0f)) {
+ return false;
+ }
if (r_uv) {
r_uv[0] = u;
@@ -2264,8 +2306,9 @@ static bool getLowestRoot(const float a, const float b, const float c, const flo
float r2 = (-b + sqrtD) / (2.0f * a);
/* Sort so x1 <= x2 */
- if (r1 > r2)
+ if (r1 > r2) {
SWAP(float, r1, r2);
+ }
/* Get lowest root: */
if (r1 > 0.0f && r1 < maxR) {
@@ -2335,7 +2378,9 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
normalize_v3(nor);
/* flip normal */
- if (dot_v3v3(nor, vel) > 0.0f) negate_v3(nor);
+ if (dot_v3v3(nor, vel) > 0.0f) {
+ negate_v3(nor);
+ }
a = dot_v3v3(p1, nor) - dot_v3v3(v0, nor);
nordotv = dot_v3v3(nor, vel);
@@ -2349,10 +2394,13 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
float t0 = (-a + radius) / nordotv;
float t1 = (-a - radius) / nordotv;
- if (t0 > t1)
+ if (t0 > t1) {
SWAP(float, t0, t1);
+ }
- if (t0 > 1.0f || t1 < 0.0f) return false;
+ if (t0 > 1.0f || t1 < 0.0f) {
+ return false;
+ }
/* clamp to [0, 1] */
CLAMP(t0, 0.0f, 1.0f);
@@ -2518,25 +2566,36 @@ bool isect_axial_line_segment_tri_v3(
sub_v3_v3v3(p, v0, p1);
f = (e2[a1] * e1[a2] - e2[a2] * e1[a1]);
- if ((f > -epsilon) && (f < epsilon)) return false;
+ if ((f > -epsilon) && (f < epsilon)) {
+ return false;
+ }
v = (p[a2] * e1[a1] - p[a1] * e1[a2]) / f;
- if ((v < 0.0f) || (v > 1.0f)) return false;
+ if ((v < 0.0f) || (v > 1.0f)) {
+ return false;
+ }
f = e1[a1];
if ((f > -epsilon) && (f < epsilon)) {
f = e1[a2];
- if ((f > -epsilon) && (f < epsilon)) return false;
+ if ((f > -epsilon) && (f < epsilon)) {
+ return false;
+ }
u = (-p[a2] - v * e2[a2]) / f;
}
- else
+ else {
u = (-p[a1] - v * e2[a1]) / f;
+ }
- if ((u < 0.0f) || ((u + v) > 1.0f)) return false;
+ if ((u < 0.0f) || ((u + v) > 1.0f)) {
+ return false;
+ }
*r_lambda = (p[a0] + u * e1[a0] + v * e2[a0]) / (p2[a0] - p1[a0]);
- if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) return false;
+ if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
+ return false;
+ }
return true;
}
@@ -2661,7 +2720,9 @@ bool isect_line_line_strict_v3(const float v1[3], const float v2[3],
mul_v3_fl(a, f1);
add_v3_v3v3(vi, v1, a);
- if (r_lambda) *r_lambda = f1;
+ if (r_lambda) {
+ *r_lambda = f1;
+ }
return true; /* intersection found */
}
@@ -2708,30 +2769,36 @@ bool isect_ray_aabb_v3(
const float tymin = (bbox[data->sign[1]][1] - data->ray_origin[1]) * data->ray_inv_dir[1];
const float tymax = (bbox[1 - data->sign[1]][1] - data->ray_origin[1]) * data->ray_inv_dir[1];
- if ((tmin > tymax) || (tymin > tmax))
+ if ((tmin > tymax) || (tymin > tmax)) {
return false;
+ }
- if (tymin > tmin)
+ if (tymin > tmin) {
tmin = tymin;
+ }
- if (tymax < tmax)
+ if (tymax < tmax) {
tmax = tymax;
+ }
const float tzmin = (bbox[data->sign[2]][2] - data->ray_origin[2]) * data->ray_inv_dir[2];
const float tzmax = (bbox[1 - data->sign[2]][2] - data->ray_origin[2]) * data->ray_inv_dir[2];
- if ((tmin > tzmax) || (tzmin > tmax))
+ if ((tmin > tzmax) || (tzmin > tmax)) {
return false;
+ }
- if (tzmin > tmin)
+ if (tzmin > tmin) {
tmin = tzmin;
+ }
/* Note: tmax does not need to be updated since we don't use it
* keeping this here for future reference - jwilkins */
//if (tzmax < tmax) tmax = tzmax;
- if (tmin_out)
+ if (tmin_out) {
(*tmin_out) = tmin;
+ }
return true;
}
@@ -2764,10 +2831,12 @@ bool isect_ray_aabb_v3_simple(
return false;
}
else {
- if (tmin)
+ if (tmin) {
*tmin = hit_dist[0];
- if (tmax)
+ }
+ if (tmax) {
*tmax = hit_dist[1];
+ }
return true;
}
}
@@ -2952,7 +3021,9 @@ static bool point_in_slice_as(float p[3], float origin[3], float normal[3])
float h, rp[3];
sub_v3_v3v3(rp, p, origin);
h = dot_v3v3(normal, rp) / dot_v3v3(normal, normal);
- if (h < 0.0f || h > 1.0f) return false;
+ if (h < 0.0f || h > 1.0f) {
+ return false;
+ }
return true;
}
@@ -2967,9 +3038,9 @@ bool point_in_slice_seg(float p[3], float l1[3], float l2[3])
bool isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3])
{
- if (!point_in_slice(p, v1, v2, v3)) return false;
- if (!point_in_slice(p, v2, v3, v1)) return false;
- if (!point_in_slice(p, v3, v1, v2)) return false;
+ if (!point_in_slice(p, v1, v2, v3)) { return false; }
+ if (!point_in_slice(p, v2, v3, v1)) { return false; }
+ if (!point_in_slice(p, v3, v1, v2)) { return false; }
return true;
}
@@ -3010,8 +3081,10 @@ bool clip_segment_v3_plane(
sub_v3_v3v3(dp, p2, p1);
div = dot_v3v3(dp, plane);
- if (div == 0.0f) /* parallel */
+ if (div == 0.0f) {
+ /* parallel */
return true;
+ }
float t = -plane_point_side_v3(plane, p1);
@@ -3200,14 +3273,18 @@ void interp_weights_quad_v3(float w[4], const float v1[3], const float v2[3], co
w[0] = w[1] = w[2] = w[3] = 0.0f;
/* first check for exact match */
- if (equals_v3v3(co, v1))
+ if (equals_v3v3(co, v1)) {
w[0] = 1.0f;
- else if (equals_v3v3(co, v2))
+ }
+ else if (equals_v3v3(co, v2)) {
w[1] = 1.0f;
- else if (equals_v3v3(co, v3))
+ }
+ else if (equals_v3v3(co, v3)) {
w[2] = 1.0f;
- else if (equals_v3v3(co, v4))
+ }
+ else if (equals_v3v3(co, v4)) {
w[3] = 1.0f;
+ }
else {
/* otherwise compute barycentric interpolation weights */
float n1[3], n2[3], n[3];
@@ -3487,10 +3564,12 @@ int interp_sparse_array(float *array, const int list_size, const float skipval)
int i;
for (i = 0; i < list_size; i++) {
- if (array[i] == skipval)
+ if (array[i] == skipval) {
found_invalid = 1;
- else
+ }
+ else {
found_valid = 1;
+ }
}
if (found_valid == 0) {
@@ -3898,8 +3977,9 @@ void resolve_quad_uv_v2_deriv(float r_uv[2], float r_deriv[2][2],
if (IS_ZERO(denom) != 0) {
const double fDen = a - fC;
- if (IS_ZERO(fDen) == 0)
+ if (IS_ZERO(fDen) == 0) {
r_uv[0] = (float)(a / fDen);
+ }
}
else {
const double desc_sq = b * b - a * fC;
@@ -3922,8 +4002,9 @@ void resolve_quad_uv_v2_deriv(float r_uv[2], float r_deriv[2][2],
denom = denom_t;
}
- if (IS_ZERO(denom) == 0)
+ if (IS_ZERO(denom) == 0) {
r_uv[1] = (float)((double)((1.0f - r_uv[0]) * (st0[i] - st[i]) + r_uv[0] * (st1[i] - st[i])) / denom);
+ }
}
if (r_deriv) {
@@ -3974,10 +4055,12 @@ float resolve_quad_u_v2(
if (IS_ZERO(denom) != 0) {
const double fDen = a - fC;
- if (IS_ZERO(fDen) == 0)
+ if (IS_ZERO(fDen) == 0) {
return (float)(a / fDen);
- else
+ }
+ else {
return 0.0f;
+ }
}
else {
const double desc_sq = b * b - a * fC;
@@ -4152,17 +4235,45 @@ void planes_from_projmat(float mat[4][4], float left[4], float right[4], float t
}
}
+void projmat_dimensions(const float projmat[4][4],
+ float *r_left, float *r_right,
+ float *r_bottom, float *r_top,
+ float *r_near, float *r_far)
+{
+ bool is_persp = projmat[3][3] == 0.0f;
+
+ if (is_persp) {
+ *r_left = (projmat[2][0] - 1.0f) / projmat[0][0];
+ *r_right = (projmat[2][0] + 1.0f) / projmat[0][0];
+ *r_bottom = (projmat[2][1] - 1.0f) / projmat[1][1];
+ *r_top = (projmat[2][1] + 1.0f) / projmat[1][1];
+ *r_near = projmat[3][2] / (projmat[2][2] - 1.0f);
+ *r_far = projmat[3][2] / (projmat[2][2] + 1.0f);
+ }
+ else {
+ *r_left = (-projmat[3][0] - 1.0f) / projmat[0][0];
+ *r_right = (-projmat[3][0] + 1.0f) / projmat[0][0];
+ *r_bottom = (-projmat[3][1] - 1.0f) / projmat[1][1];
+ *r_top = (-projmat[3][1] + 1.0f) / projmat[1][1];
+ *r_near = ( projmat[3][2] + 1.0f) / projmat[2][2];
+ *r_far = ( projmat[3][2] - 1.0f) / projmat[2][2];
+ }
+
+}
+
static void i_multmatrix(float icand[4][4], float Vm[4][4])
{
int row, col;
float temp[4][4];
- for (row = 0; row < 4; row++)
- for (col = 0; col < 4; col++)
+ for (row = 0; row < 4; row++) {
+ for (col = 0; col < 4; col++) {
temp[row][col] = (icand[row][0] * Vm[0][col] +
icand[row][1] * Vm[1][col] +
icand[row][2] * Vm[2][col] +
icand[row][3] * Vm[3][col]);
+ }
+ }
copy_m4_m4(Vm, temp);
}
@@ -4244,22 +4355,24 @@ int box_clip_bounds_m4(float boundbox[2][3], const float bounds[4], float winmat
fl = 0;
if (bounds) {
- if (vec[0] > bounds[1] * vec[3]) fl |= 1;
- if (vec[0] < bounds[0] * vec[3]) fl |= 2;
- if (vec[1] > bounds[3] * vec[3]) fl |= 4;
- if (vec[1] < bounds[2] * vec[3]) fl |= 8;
+ if (vec[0] > bounds[1] * vec[3]) { fl |= 1; }
+ if (vec[0] < bounds[0] * vec[3]) { fl |= 2; }
+ if (vec[1] > bounds[3] * vec[3]) { fl |= 4; }
+ if (vec[1] < bounds[2] * vec[3]) { fl |= 8; }
}
else {
- if (vec[0] < -vec[3]) fl |= 1;
- if (vec[0] > vec[3]) fl |= 2;
- if (vec[1] < -vec[3]) fl |= 4;
- if (vec[1] > vec[3]) fl |= 8;
+ if (vec[0] < -vec[3]) { fl |= 1; }
+ if (vec[0] > vec[3]) { fl |= 2; }
+ if (vec[1] < -vec[3]) { fl |= 4; }
+ if (vec[1] > vec[3]) { fl |= 8; }
}
- if (vec[2] < -vec[3]) fl |= 16;
- if (vec[2] > vec[3]) fl |= 32;
+ if (vec[2] < -vec[3]) { fl |= 16; }
+ if (vec[2] > vec[3]) { fl |= 32; }
flag &= fl;
- if (flag == 0) return 0;
+ if (flag == 0) {
+ return 0;
+ }
}
return flag;
@@ -4525,10 +4638,10 @@ void vcloud_estimate_transform_v3(
int a;
/* first set up a nice default response */
- if (lloc) zero_v3(lloc);
- if (rloc) zero_v3(rloc);
- if (lrot) unit_m3(lrot);
- if (lscale) unit_m3(lscale);
+ if (lloc) { zero_v3(lloc); }
+ if (rloc) { zero_v3(rloc); }
+ if (lrot) { unit_m3(lrot); }
+ if (lscale) { unit_m3(lscale); }
/* do com for both clouds */
if (pos && rpos && (list_size > 0)) { /* paranoya check */
/* do com for both clouds */
@@ -4561,8 +4674,12 @@ void vcloud_estimate_transform_v3(
mul_v3_fl(accu_com, 1.0f / accu_weight);
mul_v3_fl(accu_rcom, 1.0f / accu_rweight);
- if (lloc) copy_v3_v3(lloc, accu_com);
- if (rloc) copy_v3_v3(rloc, accu_rcom);
+ if (lloc) {
+ copy_v3_v3(lloc, accu_com);
+ }
+ if (rloc) {
+ copy_v3_v3(rloc, accu_rcom);
+ }
if (lrot || lscale) { /* caller does not want rot nor scale, strange but legal */
/* so now do some reverse engineering and see if we can
* split rotation from scale -> Polardecompose */
@@ -4631,12 +4748,16 @@ void vcloud_estimate_transform_v3(
if (i) {
float scale[3][3];
float irot[3][3];
- if (lrot) copy_m3_m3(lrot, q);
+ if (lrot) {
+ copy_m3_m3(lrot, q);
+ }
invert_m3_m3(irot, q);
invert_m3_m3(qi, mr);
mul_m3_m3m3(q, m, qi);
mul_m3_m3m3(scale, irot, q);
- if (lscale) copy_m3_m3(lscale, scale);
+ if (lscale) {
+ copy_m3_m3(lscale, scale);
+ }
}
}
@@ -4665,9 +4786,9 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
sd[1] = dot_v3v3(n, v1) - c;
sd[2] = dot_v3v3(n, v2) - c;
- if (fabsf(sd[0]) < epsilon) sd[0] = 0.0f;
- if (fabsf(sd[1]) < epsilon) sd[1] = 0.0f;
- if (fabsf(sd[2]) < epsilon) sd[2] = 0.0f;
+ if (fabsf(sd[0]) < epsilon) { sd[0] = 0.0f; }
+ if (fabsf(sd[1]) < epsilon) { sd[1] = 0.0f; }
+ if (fabsf(sd[2]) < epsilon) { sd[2] = 0.0f; }
if (sd[0] > 0.0f) {
if (sd[1] > 0.0f) {
@@ -5059,11 +5180,13 @@ float form_factor_hemi_poly(float p[3], float n[3], float v1[3], float v2[3], fl
* covered by a quad or triangle, cosine weighted */
float q0[3], q1[3], q2[3], q3[3], contrib = 0.0f;
- if (form_factor_visible_quad(p, n, v1, v2, v3, q0, q1, q2, q3))
+ if (form_factor_visible_quad(p, n, v1, v2, v3, q0, q1, q2, q3)) {
contrib += form_factor_quad(p, n, q0, q1, q2, q3);
+ }
- if (v4 && form_factor_visible_quad(p, n, v1, v3, v4, q0, q1, q2, q3))
+ if (v4 && form_factor_visible_quad(p, n, v1, v3, v4, q0, q1, q2, q3)) {
contrib += form_factor_quad(p, n, q0, q1, q2, q3);
+ }
return contrib;
}
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index 58262b9a364..0922c47f553 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -73,16 +73,18 @@ MINLINE void mul_sh_fl(float r[9], const float f)
{
int i;
- for (i = 0; i < 9; i++)
+ for (i = 0; i < 9; i++) {
r[i] *= f;
+ }
}
MINLINE void add_sh_shsh(float r[9], const float a[9], const float b[9])
{
int i;
- for (i = 0; i < 9; i++)
+ for (i = 0; i < 9; i++) {
r[i] = a[i] + b[i];
+ }
}
MINLINE float dot_shsh(const float a[9], const float b[9])
@@ -90,8 +92,9 @@ MINLINE float dot_shsh(const float a[9], const float b[9])
float r = 0.0f;
int i;
- for (i = 0; i < 9; i++)
+ for (i = 0; i < 9; i++) {
r += a[i] * b[i];
+ }
return r;
}
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index 5b3f6349703..ed2b48f6e62 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -273,8 +273,12 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
/* pixel value must be already wrapped, however values at boundaries may flip */
if (wrap_x) {
- if (x1 < 0) x1 = width - 1;
- if (x2 >= width) x2 = 0;
+ if (x1 < 0) {
+ x1 = width - 1;
+ }
+ if (x2 >= width) {
+ x2 = 0;
+ }
}
else if (x2 < 0 || x1 >= width) {
copy_vn_fl(float_output, components, 0.0f);
@@ -282,8 +286,12 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
}
if (wrap_y) {
- if (y1 < 0) y1 = height - 1;
- if (y2 >= height) y2 = 0;
+ if (y1 < 0) {
+ y1 = height - 1;
+ }
+ if (y2 >= height) {
+ y2 = 0;
+ }
}
else if (y2 < 0 || y1 >= height) {
copy_vn_fl(float_output, components, 0.0f);
@@ -291,17 +299,33 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
}
/* sample including outside of edges of image */
- if (x1 < 0 || y1 < 0) row1 = empty;
- else row1 = float_buffer + width * y1 * components + components * x1;
+ if (x1 < 0 || y1 < 0) {
+ row1 = empty;
+ }
+ else {
+ row1 = float_buffer + width * y1 * components + components * x1;
+ }
- if (x1 < 0 || y2 > height - 1) row2 = empty;
- else row2 = float_buffer + width * y2 * components + components * x1;
+ if (x1 < 0 || y2 > height - 1) {
+ row2 = empty;
+ }
+ else {
+ row2 = float_buffer + width * y2 * components + components * x1;
+ }
- if (x2 > width - 1 || y1 < 0) row3 = empty;
- else row3 = float_buffer + width * y1 * components + components * x2;
+ if (x2 > width - 1 || y1 < 0) {
+ row3 = empty;
+ }
+ else {
+ row3 = float_buffer + width * y1 * components + components * x2;
+ }
- if (x2 > width - 1 || y2 > height - 1) row4 = empty;
- else row4 = float_buffer + width * y2 * components + components * x2;
+ if (x2 > width - 1 || y2 > height - 1) {
+ row4 = empty;
+ }
+ else {
+ row4 = float_buffer + width * y2 * components + components * x2;
+ }
a = u - floorf(u);
b = v - floorf(v);
@@ -328,8 +352,12 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
/* pixel value must be already wrapped, however values at boundaries may flip */
if (wrap_x) {
- if (x1 < 0) x1 = width - 1;
- if (x2 >= width) x2 = 0;
+ if (x1 < 0) {
+ x1 = width - 1;
+ }
+ if (x2 >= width) {
+ x2 = 0;
+ }
}
else if (x2 < 0 || x1 >= width) {
copy_vn_uchar(byte_output, components, 0);
@@ -337,8 +365,12 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
}
if (wrap_y) {
- if (y1 < 0) y1 = height - 1;
- if (y2 >= height) y2 = 0;
+ if (y1 < 0) {
+ y1 = height - 1;
+ }
+ if (y2 >= height) {
+ y2 = 0;
+ }
}
else if (y2 < 0 || y1 >= height) {
copy_vn_uchar(byte_output, components, 0);
@@ -346,17 +378,33 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
}
/* sample including outside of edges of image */
- if (x1 < 0 || y1 < 0) row1 = empty;
- else row1 = byte_buffer + width * y1 * components + components * x1;
+ if (x1 < 0 || y1 < 0) {
+ row1 = empty;
+ }
+ else {
+ row1 = byte_buffer + width * y1 * components + components * x1;
+ }
- if (x1 < 0 || y2 > height - 1) row2 = empty;
- else row2 = byte_buffer + width * y2 * components + components * x1;
+ if (x1 < 0 || y2 > height - 1) {
+ row2 = empty;
+ }
+ else {
+ row2 = byte_buffer + width * y2 * components + components * x1;
+ }
- if (x2 > width - 1 || y1 < 0) row3 = empty;
- else row3 = byte_buffer + width * y1 * components + components * x2;
+ if (x2 > width - 1 || y1 < 0) {
+ row3 = empty;
+ }
+ else {
+ row3 = byte_buffer + width * y1 * components + components * x2;
+ }
- if (x2 > width - 1 || y2 > height - 1) row4 = empty;
- else row4 = byte_buffer + width * y2 * components + components * x2;
+ if (x2 > width - 1 || y2 > height - 1) {
+ row4 = empty;
+ }
+ else {
+ row4 = byte_buffer + width * y2 * components + components * x2;
+ }
a = u - floorf(u);
b = v - floorf(v);
@@ -548,10 +596,10 @@ void BLI_ewa_filter(const int width, const int height,
/* note: if eccentricity gets clamped (see above),
* the ue/ve limits can also be lowered accordingly
*/
- if (U0 - (float)u1 > EWA_MAXIDX) u1 = (int)U0 - EWA_MAXIDX;
- if ((float)u2 - U0 > EWA_MAXIDX) u2 = (int)U0 + EWA_MAXIDX;
- if (V0 - (float)v1 > EWA_MAXIDX) v1 = (int)V0 - EWA_MAXIDX;
- if ((float)v2 - V0 > EWA_MAXIDX) v2 = (int)V0 + EWA_MAXIDX;
+ if (U0 - (float)u1 > EWA_MAXIDX) { u1 = (int)U0 - EWA_MAXIDX; }
+ if ((float)u2 - U0 > EWA_MAXIDX) { u2 = (int)U0 + EWA_MAXIDX; }
+ if (V0 - (float)v1 > EWA_MAXIDX) { v1 = (int)V0 - EWA_MAXIDX; }
+ if ((float)v2 - V0 > EWA_MAXIDX) { v2 = (int)V0 + EWA_MAXIDX; }
/* Early output check for cases the whole region is outside of the buffer. */
if ((u2 < 0 || u1 >= width) || (v2 < 0 || v1 >= height)) {
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 747d9a1337a..68c80beb005 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -177,12 +177,15 @@ void swap_m4m4(float m1[4][4], float m2[4][4])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
{
- if (A == R)
+ if (A == R) {
mul_m4_m4_post(R, B);
- else if (B == R)
+ }
+ else if (B == R) {
mul_m4_m4_pre(R, A);
- else
+ }
+ else {
mul_m4_m4m4_uniq(R, A, B);
+ }
}
void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4])
@@ -249,12 +252,15 @@ void mul_m4_m4_post(float R[4][4], const float B[4][4])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
{
- if (A == R)
+ if (A == R) {
mul_m3_m3_post(R, B);
- else if (B == R)
+ }
+ else if (B == R) {
mul_m3_m3_pre(R, A);
- else
+ }
+ else {
mul_m3_m3m3_uniq(R, A, B);
+ }
}
void mul_m3_m3_pre(float R[3][3], const float A[3][3])
@@ -713,54 +719,66 @@ void mul_m3_fl(float m[3][3], float f)
{
int i, j;
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
m[i][j] *= f;
+ }
+ }
}
void mul_m4_fl(float m[4][4], float f)
{
int i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
m[i][j] *= f;
+ }
+ }
}
void mul_mat3_m4_fl(float m[4][4], float f)
{
int i, j;
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
m[i][j] *= f;
+ }
+ }
}
void negate_m3(float m[3][3])
{
int i, j;
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
m[i][j] *= -1.0f;
+ }
+ }
}
void negate_mat3_m4(float m[4][4])
{
int i, j;
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
m[i][j] *= -1.0f;
+ }
+ }
}
void negate_m4(float m[4][4])
{
int i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
m[i][j] *= -1.0f;
+ }
+ }
}
void mul_m3_v3_double(const float mat[3][3], double vec[3])
@@ -777,36 +795,44 @@ void add_m3_m3m3(float m1[3][3], const float m2[3][3], const float m3[3][3])
{
int i, j;
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
m1[i][j] = m2[i][j] + m3[i][j];
+ }
+ }
}
void add_m4_m4m4(float m1[4][4], const float m2[4][4], const float m3[4][4])
{
int i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
m1[i][j] = m2[i][j] + m3[i][j];
+ }
+ }
}
void sub_m3_m3m3(float m1[3][3], const float m2[3][3], const float m3[3][3])
{
int i, j;
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
m1[i][j] = m2[i][j] - m3[i][j];
+ }
+ }
}
void sub_m4_m4m4(float m1[4][4], const float m2[4][4], const float m3[4][4])
{
int i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
m1[i][j] = m2[i][j] - m3[i][j];
+ }
+ }
}
float determinant_m3_array(const float m[3][3])
@@ -1002,11 +1028,15 @@ void transpose_m4_m4(float rmat[4][4], const float mat[4][4])
/* TODO: return bool */
int compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit)
{
- if (compare_v4v4(mat1[0], mat2[0], limit))
- if (compare_v4v4(mat1[1], mat2[1], limit))
- if (compare_v4v4(mat1[2], mat2[2], limit))
- if (compare_v4v4(mat1[3], mat2[3], limit))
+ if (compare_v4v4(mat1[0], mat2[0], limit)) {
+ if (compare_v4v4(mat1[1], mat2[1], limit)) {
+ if (compare_v4v4(mat1[2], mat2[2], limit)) {
+ if (compare_v4v4(mat1[3], mat2[3], limit)) {
return 1;
+ }
+ }
+ }
+ }
return 0;
}
@@ -1194,8 +1224,9 @@ bool is_orthogonal_m3(const float m[3][3])
for (i = 0; i < 3; i++) {
for (j = 0; j < i; j++) {
- if (fabsf(dot_v3v3(m[i], m[j])) > 1e-5f)
+ if (fabsf(dot_v3v3(m[i], m[j])) > 1e-5f) {
return false;
+ }
}
}
@@ -1208,8 +1239,9 @@ bool is_orthogonal_m4(const float m[4][4])
for (i = 0; i < 4; i++) {
for (j = 0; j < i; j++) {
- if (fabsf(dot_v4v4(m[i], m[j])) > 1e-5f)
+ if (fabsf(dot_v4v4(m[i], m[j])) > 1e-5f) {
return false;
+ }
}
}
@@ -1222,9 +1254,11 @@ bool is_orthonormal_m3(const float m[3][3])
if (is_orthogonal_m3(m)) {
int i;
- for (i = 0; i < 3; i++)
- if (fabsf(dot_v3v3(m[i], m[i]) - 1) > 1e-5f)
+ for (i = 0; i < 3; i++) {
+ if (fabsf(dot_v3v3(m[i], m[i]) - 1) > 1e-5f) {
return false;
+ }
+ }
return true;
}
@@ -1238,8 +1272,9 @@ bool is_orthonormal_m4(const float m[4][4])
int i;
for (i = 0; i < 4; i++)
- if (fabsf(dot_v4v4(m[i], m[i]) - 1) > 1e-5f)
+ if (fabsf(dot_v4v4(m[i], m[i]) - 1) > 1e-5f) {
return false;
+ }
return true;
}
@@ -2071,8 +2106,9 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
/* Place the transformation in U for subsequent back
* multiplication. */
- for (i = k; i < m; i++)
+ for (i = k; i < m; i++) {
U[i][k] = A[i][k];
+ }
}
if (k < nrt) {
@@ -2120,8 +2156,9 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
/* Place the transformation in V for subsequent
* back multiplication. */
- for (i = k + 1; i < n; i++)
+ for (i = k + 1; i < n; i++) {
V[i][k] = e[i];
+ }
}
}
@@ -2205,8 +2242,9 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
int kase = 0;
/* Test for maximum iterations to avoid infinite loop */
- if (maxiter == 0)
+ if (maxiter == 0) {
break;
+ }
maxiter--;
/* This section of the program inspects for
@@ -2394,8 +2432,9 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4])
if (s[k] <= 0.0f) {
s[k] = (s[k] < 0.0f ? -s[k] : 0.0f);
- for (i = 0; i <= pp; i++)
+ for (i = 0; i <= pp; i++) {
V[i][k] = -V[i][k];
+ }
}
/* Order the singular values. */
@@ -2445,8 +2484,9 @@ void pseudoinverse_m4_m4(float Ainv[4][4], const float A_[4][4], float epsilon)
transpose_m4(V);
zero_m4(Wm);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
Wm[i][i] = (W[i] < epsilon) ? 0.0f : 1.0f / W[i];
+ }
transpose_m4(V);
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 53c7d5e6576..90eb76f19d9 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -15,10 +15,9 @@
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
-
- * The Original Code is: some of this file.
*
- * */
+ * The Original Code is: some of this file.
+ */
/** \file
* \ingroup bli
@@ -138,8 +137,9 @@ void invert_qt(float q[4])
{
const float f = dot_qtqt(q, q);
- if (f == 0.0f)
+ if (f == 0.0f) {
return;
+ }
conjugate_qt(q);
mul_qt_fl(q, 1.0f / f);
@@ -202,6 +202,29 @@ void pow_qt_fl_normalized(float q[4], const float fac)
normalize_v3_length(q + 1, si);
}
+/**
+ * Apply the rotation of \a a to \a q keeping the values compatible with \a old.
+ * Avoid axis flipping for animated f-curves for eg.
+ */
+void quat_to_compatible_quat(float q[4], const float a[4], const float old[4])
+{
+ const float eps = 1e-4f;
+ BLI_ASSERT_UNIT_QUAT(a);
+ float old_unit[4];
+ /* Skips `!finite_v4(old)` case too. */
+ if (normalize_qt_qt(old_unit, old) > eps) {
+ float delta[4];
+ rotation_between_quats_to_quat(delta, old_unit, a);
+ mul_qt_qtqt(q, old, delta);
+ if ((q[0] < 0.0f) != (old[0] < 0.0f)) {
+ negate_v4(q);
+ }
+ }
+ else {
+ copy_qt_qt(q, a);
+ }
+}
+
/* skip error check, currently only needed by mat3_to_quat_is_ok */
static void quat_to_mat3_no_error(float m[3][3], const float q[4])
{
@@ -649,8 +672,9 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
nor[1] = -tvec[2];
nor[2] = tvec[1];
- if (fabsf(tvec[1]) + fabsf(tvec[2]) < eps)
+ if (fabsf(tvec[1]) + fabsf(tvec[2]) < eps) {
nor[1] = 1.0f;
+ }
co = tvec[0];
}
@@ -659,8 +683,9 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
nor[1] = 0.0;
nor[2] = -tvec[0];
- if (fabsf(tvec[0]) + fabsf(tvec[2]) < eps)
+ if (fabsf(tvec[0]) + fabsf(tvec[2]) < eps) {
nor[2] = 1.0f;
+ }
co = tvec[1];
}
@@ -669,8 +694,9 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
nor[1] = tvec[0];
nor[2] = 0.0;
- if (fabsf(tvec[0]) + fabsf(tvec[1]) < eps)
+ if (fabsf(tvec[0]) + fabsf(tvec[1]) < eps) {
nor[0] = 1.0f;
+ }
co = tvec[2];
}
@@ -687,16 +713,16 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
quat_to_mat3(mat, q);
if (axis == 0) {
- if (upflag == 1) angle = 0.5f * atan2f(fp[2], fp[1]);
- else angle = -0.5f * atan2f(fp[1], fp[2]);
+ if (upflag == 1) { angle = 0.5f * atan2f(fp[2], fp[1]); }
+ else { angle = -0.5f * atan2f(fp[1], fp[2]); }
}
else if (axis == 1) {
- if (upflag == 0) angle = -0.5f * atan2f(fp[2], fp[0]);
- else angle = 0.5f * atan2f(fp[0], fp[2]);
+ if (upflag == 0) { angle = -0.5f * atan2f(fp[2], fp[0]); }
+ else { angle = 0.5f * atan2f(fp[0], fp[2]); }
}
else {
- if (upflag == 0) angle = 0.5f * atan2f(-fp[1], -fp[0]);
- else angle = -0.5f * atan2f(-fp[0], -fp[1]);
+ if (upflag == 0) { angle = 0.5f * atan2f(-fp[1], -fp[0]); }
+ else { angle = -0.5f * atan2f(-fp[0], -fp[1]); }
}
co = cosf(angle);
@@ -932,8 +958,9 @@ void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
*angle = ha * 2;
/* prevent division by zero for axis conversion */
- if (fabsf(si) < 0.0005f)
+ if (fabsf(si) < 0.0005f) {
si = 1.0f;
+ }
axis[0] = q[1] / si;
axis[1] = q[2] / si;
@@ -1358,9 +1385,15 @@ void rotate_eul(float beul[3], const char axis, const float ang)
assert(axis >= 'X' && axis <= 'Z');
eul[0] = eul[1] = eul[2] = 0.0f;
- if (axis == 'X') eul[0] = ang;
- else if (axis == 'Y') eul[1] = ang;
- else eul[2] = ang;
+ if (axis == 'X') {
+ eul[0] = ang;
+ }
+ else if (axis == 'Y') {
+ eul[1] = ang;
+ }
+ else {
+ eul[2] = ang;
+ }
eul_to_mat3(mat1, eul);
eul_to_mat3(mat2, beul);
@@ -1396,16 +1429,16 @@ void compatible_eul(float eul[3], const float oldrot[3])
/* is 1 of the axis rotations larger than 180 degrees and the other small? NO ELSE IF!! */
if (fabsf(deul[0]) > 3.2f && fabsf(deul[1]) < 1.6f && fabsf(deul[2]) < 1.6f) {
- if (deul[0] > 0.0f) eul[0] -= pi_x2;
- else eul[0] += pi_x2;
+ if (deul[0] > 0.0f) { eul[0] -= pi_x2; }
+ else { eul[0] += pi_x2; }
}
if (fabsf(deul[1]) > 3.2f && fabsf(deul[2]) < 1.6f && fabsf(deul[0]) < 1.6f) {
- if (deul[1] > 0.0f) eul[1] -= pi_x2;
- else eul[1] += pi_x2;
+ if (deul[1] > 0.0f) { eul[1] -= pi_x2; }
+ else { eul[1] += pi_x2; }
}
if (fabsf(deul[2]) > 3.2f && fabsf(deul[0]) < 1.6f && fabsf(deul[1]) < 1.6f) {
- if (deul[2] > 0.0f) eul[2] -= pi_x2;
- else eul[2] += pi_x2;
+ if (deul[2] > 0.0f) { eul[2] -= pi_x2; }
+ else { eul[2] += pi_x2; }
}
}
@@ -1484,12 +1517,15 @@ static const RotOrderInfo rotOrders[] = {
static const RotOrderInfo *get_rotation_order_info(const short order)
{
assert(order >= 0 && order <= 6);
- if (order < 1)
+ if (order < 1) {
return &rotOrders[0];
- else if (order < 6)
+ }
+ else if (order < 6) {
return &rotOrders[order - 1];
- else
+ }
+ else {
return &rotOrders[5];
+ }
}
/* Construct quaternion from Euler angles (in radians). */
@@ -1525,7 +1561,9 @@ void eulO_to_quat(float q[4], const float e[3], const short order)
q[2] = (float)(a[1]);
q[3] = (float)(a[2]);
- if (R->parity) q[j + 1] = -q[j + 1];
+ if (R->parity) {
+ q[j + 1] = -q[j + 1];
+ }
}
/* Convert quaternion to Euler angles (in radians). */
@@ -1739,12 +1777,15 @@ void rotate_eulO(float beul[3], const short order, char axis, float ang)
zero_v3(eul);
- if (axis == 'X')
+ if (axis == 'X') {
eul[0] = ang;
- else if (axis == 'Y')
+ }
+ else if (axis == 'Y') {
eul[1] = ang;
- else
+ }
+ else {
eul[2] = ang;
+ }
eulO_to_mat3(mat1, eul, order);
eulO_to_mat3(mat2, beul, order);
@@ -1921,8 +1962,10 @@ void add_weighted_dq_dq(DualQuat *dqsum, const DualQuat *dq, float weight)
if (dq->scale_weight) {
float wmat[4][4];
- if (flipped) /* we don't want negative weights for scaling */
+ if (flipped) {
+ /* we don't want negative weights for scaling */
weight = -weight;
+ }
copy_m4_m4(wmat, (float(*)[4])dq->scale);
mul_m4_fl(wmat, weight);
@@ -1973,8 +2016,9 @@ void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
M[2][2] = w * w + z * z - x * x - y * y;
len2 = dot_qtqt(dq->quat, dq->quat);
- if (len2 > 0.0f)
+ if (len2 > 0.0f) {
len2 = 1.0f / len2;
+ }
/* translation */
t[0] = 2 * (-t0 * x + w * t1 - t2 * z + y * t3);
@@ -1982,8 +2026,9 @@ void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
t[2] = 2 * (-t0 * z + x * t2 + w * t3 - t1 * y);
/* apply scaling */
- if (dq->scale_weight)
+ if (dq->scale_weight) {
mul_m4_v3(dq->scale, co);
+ }
/* apply rotation and translation */
mul_m3_v3(M, co);
@@ -1997,8 +2042,9 @@ void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq)
copy_m3_m4(scalemat, dq->scale);
mul_m3_m3m3(mat, M, scalemat);
}
- else
+ else {
copy_m3_m3(mat, M);
+ }
mul_m3_fl(mat, len2);
}
}
diff --git a/source/blender/blenlib/intern/math_solvers.c b/source/blender/blenlib/intern/math_solvers.c
index efaa98fc4e7..2669ac89b25 100644
--- a/source/blender/blenlib/intern/math_solvers.c
+++ b/source/blender/blenlib/intern/math_solvers.c
@@ -81,15 +81,17 @@ void BLI_svd_m3(const float m3[3][3], float r_U[3][3], float r_S[3], float r_V[3
*/
bool BLI_tridiagonal_solve(const float *a, const float *b, const float *c, const float *d, float *r_x, const int count)
{
- if (count < 1)
+ if (count < 1) {
return false;
+ }
size_t bytes = sizeof(double) * (unsigned)count;
double *c1 = (double *)MEM_mallocN(bytes * 2, "tridiagonal_c1d1");
double *d1 = c1 + count;
- if (!c1)
+ if (!c1) {
return false;
+ }
int i;
double c_prev, d_prev, x_prev;
@@ -129,8 +131,9 @@ bool BLI_tridiagonal_solve(const float *a, const float *b, const float *c, const
*/
bool BLI_tridiagonal_solve_cyclic(const float *a, const float *b, const float *c, const float *d, float *r_x, const int count)
{
- if (count < 1)
+ if (count < 1) {
return false;
+ }
float a0 = a[0], cN = c[count - 1];
@@ -143,8 +146,9 @@ bool BLI_tridiagonal_solve_cyclic(const float *a, const float *b, const float *c
float *tmp = (float *)MEM_mallocN(bytes * 2, "tridiagonal_ex");
float *b2 = tmp + count;
- if (!tmp)
+ if (!tmp) {
return false;
+ }
/* prepare the noncyclic system; relies on tridiagonal_solve ignoring values */
memcpy(b2, b, bytes);
diff --git a/source/blender/blenlib/intern/math_statistics.c b/source/blender/blenlib/intern/math_statistics.c
index e96638a4618..50fa7556134 100644
--- a/source/blender/blenlib/intern/math_statistics.c
+++ b/source/blender/blenlib/intern/math_statistics.c
@@ -67,8 +67,9 @@ static void covariance_m_vn_ex_task_cb(
*/
const int i = a / n;
const int j = a % n;
- if (j < i)
+ if (j < i) {
return;
+ }
if (center) {
for (k = 0; k < nbr_cos_vn; k++) {
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index bf4cd702ea1..0aacfd6cde1 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -925,22 +925,22 @@ void print_vn(const char *str, const float v[], const int n)
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
{
- if (min[0] > vec[0]) min[0] = vec[0];
- if (min[1] > vec[1]) min[1] = vec[1];
- if (min[2] > vec[2]) min[2] = vec[2];
+ if (min[0] > vec[0]) { min[0] = vec[0]; }
+ if (min[1] > vec[1]) { min[1] = vec[1]; }
+ if (min[2] > vec[2]) { min[2] = vec[2]; }
- if (max[0] < vec[0]) max[0] = vec[0];
- if (max[1] < vec[1]) max[1] = vec[1];
- if (max[2] < vec[2]) max[2] = vec[2];
+ if (max[0] < vec[0]) { max[0] = vec[0]; }
+ if (max[1] < vec[1]) { max[1] = vec[1]; }
+ if (max[2] < vec[2]) { max[2] = vec[2]; }
}
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
{
- if (min[0] > vec[0]) min[0] = vec[0];
- if (min[1] > vec[1]) min[1] = vec[1];
+ if (min[0] > vec[0]) { min[0] = vec[0]; }
+ if (min[1] > vec[1]) { min[1] = vec[1]; }
- if (max[0] < vec[0]) max[0] = vec[0];
- if (max[1] < vec[1]) max[1] = vec[1];
+ if (max[0] < vec[0]) { max[0] = vec[0]; }
+ if (max[1] < vec[1]) { max[1] = vec[1]; }
}
void minmax_v3v3_v3_array(float r_min[3], float r_max[3], const float (*vec_arr)[3], int nbr)
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 80bdeec5949..f22b2a7a457 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -952,6 +952,14 @@ MINLINE float len_squared_v3v3(const float a[3], const float b[3])
return dot_v3v3(d, d);
}
+MINLINE float len_squared_v4v4(const float a[4], const float b[4])
+{
+ float d[4];
+
+ sub_v4_v4v4(d, b, a);
+ return dot_v4v4(d, d);
+}
+
MINLINE float len_manhattan_v2v2(const float a[2], const float b[2])
{
float d[2];
@@ -1197,20 +1205,6 @@ MINLINE bool compare_len_v3v3(const float v1[3], const float v2[3], const float
return (dot_v3v3(d, d) <= (limit * limit));
}
-MINLINE bool compare_len_squared_v3v3(const float v1[3], const float v2[3], const float limit_sq)
-{
- float d[3];
- sub_v3_v3v3(d, v1, v2);
- return (dot_v3v3(d, d) <= limit_sq);
-}
-
-MINLINE bool compare_len_squared_v4v4(const float v1[4], const float v2[4], const float limit_sq)
-{
- float d[4];
- sub_v4_v4v4(d, v1, v2);
- return (dot_v4v4(d, d) <= limit_sq);
-}
-
/**
* <pre>
* + l1
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 8126bdfb3ef..241c5ec954c 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -281,9 +281,9 @@ static float newPerlin(float x, float y, float z)
{
int A, AA, AB, B, BA, BB;
float u = floor(x), v = floor(y), w = floor(z);
- int X = ((int)u) & 255,
- Y = ((int)v) & 255,
- Z = ((int)w) & 255; /* FIND UNIT CUBE THAT CONTAINS POINT */
+ int X = ((int)u) & 255;
+ int Y = ((int)v) & 255;
+ int Z = ((int)w) & 255; /* FIND UNIT CUBE THAT CONTAINS POINT */
x -= u; /* FIND RELATIVE X,Y,Z */
y -= v; /* OF POINT IN CUBE. */
z -= w;
@@ -388,8 +388,8 @@ static float orgBlenderNoise(float x, float y, float z)
h = hashvectf + 3 * hash[b21 + b11];
n += i * (h[0] * jx + h[1] * jy + h[2] * jz);
- if (n < 0.0f) n = 0.0f;
- else if (n > 1.0f) n = 1.0f;
+ if (n < 0.0f) { n = 0.0f; }
+ else if (n > 1.0f) { n = 1.0f; }
return n;
}
@@ -402,7 +402,9 @@ static float orgBlenderNoiseS(float x, float y, float z)
/* separated from orgBlenderNoise above, with scaling */
float BLI_hnoise(float noisesize, float x, float y, float z)
{
- if (noisesize == 0.0f) return 0.0f;
+ if (noisesize == 0.0f) {
+ return 0.0f;
+ }
x = (1.0f + x) / noisesize;
y = (1.0f + y) / noisesize;
z = (1.0f + z) / noisesize;
@@ -1294,7 +1296,9 @@ static float voronoi_F1F2(float x, float y, float z)
static float voronoi_Cr(float x, float y, float z)
{
float t = 10 * voronoi_F1F2(x, y, z);
- if (t > 1.f) return 1.f;
+ if (t > 1.f) {
+ return 1.f;
+ }
return t;
}
@@ -1341,7 +1345,9 @@ static float voronoi_F1F2S(float x, float y, float z)
static float voronoi_CrS(float x, float y, float z)
{
float t = 10 * voronoi_F1F2(x, y, z);
- if (t > 1.f) return 1.f;
+ if (t > 1.f) {
+ return 1.f;
+ }
return (2.0f * t - 1.0f);
}
@@ -1450,7 +1456,9 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise
z *= noisesize;
}
- if (hard) return fabsf(2.0f * noisefunc(x, y, z) - 1.0f);
+ if (hard) {
+ return fabsf(2.0f * noisefunc(x, y, z) - 1.0f);
+ }
return noisefunc(x, y, z);
}
@@ -1508,7 +1516,9 @@ float BLI_gTurbulence(float noisesize, float x, float y, float z, int oct, int h
sum = 0;
for (i = 0; i <= oct; i++, amp *= 0.5f, fscale *= 2.0f) {
t = noisefunc(fscale * x, fscale * y, fscale * z);
- if (hard) t = fabsf(2.0f * t - 1.0f);
+ if (hard) {
+ t = fabsf(2.0f * t - 1.0f);
+ }
sum += t * amp;
}
@@ -1583,7 +1593,9 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
}
rmd = octaves - floorf(octaves);
- if (rmd != 0.f) value += rmd * noisefunc(x, y, z) * pwr;
+ if (rmd != 0.0f) {
+ value += rmd * noisefunc(x, y, z) * pwr;
+ }
return value;
@@ -1654,7 +1666,9 @@ float mg_MultiFractal(float x, float y, float z, float H, float lacunarity, floa
z *= lacunarity;
}
rmd = octaves - floorf(octaves);
- if (rmd != 0.0f) value *= (rmd * noisefunc(x, y, z) * pwr + 1.0f);
+ if (rmd != 0.0f) {
+ value *= (rmd * noisefunc(x, y, z) * pwr + 1.0f);
+ }
return value;
@@ -1796,7 +1810,9 @@ float mg_HybridMultiFractal(float x, float y, float z, float H, float lacunarity
z *= lacunarity;
for (i = 1; (weight > 0.001f) && (i < (int)octaves); i++) {
- if (weight > 1.0f) weight = 1.0f;
+ if (weight > 1.0f) {
+ weight = 1.0f;
+ }
signal = (noisefunc(x, y, z) + offset) * pwr;
pwr *= pwHL;
result += weight * signal;
@@ -1807,7 +1823,9 @@ float mg_HybridMultiFractal(float x, float y, float z, float H, float lacunarity
}
rmd = octaves - floorf(octaves);
- if (rmd != 0.f) result += rmd * ((noisefunc(x, y, z) + offset) * pwr);
+ if (rmd != 0.f) {
+ result += rmd * ((noisefunc(x, y, z) + offset) * pwr);
+ }
return result;
@@ -1876,8 +1894,8 @@ float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity
y *= lacunarity;
z *= lacunarity;
weight = signal * gain;
- if (weight > 1.0f) weight = 1.0f;
- else if (weight < 0.0f) weight = 0.0f;
+ if (weight > 1.0f) { weight = 1.0f; }
+ else if (weight < 0.0f) { weight = 0.0f; }
signal = offset - fabsf(noisefunc(x, y, z));
signal *= signal;
signal *= weight;
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 77b137a9d6d..0bd09f0c268 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -104,7 +104,9 @@ int BLI_stringdec(const char *string, char *head, char *tail, ushort *r_num_len)
}
}
else {
- if (found_digit) break;
+ if (found_digit) {
+ break;
+ }
}
}
@@ -192,7 +194,9 @@ void BLI_cleanup_path(const char *relabase, char *path)
eind = start + strlen("\\..\\") - 1;
a = start - path - 1;
while (a > 0) {
- if (path[a] == '\\') break;
+ if (path[a] == '\\') {
+ break;
+ }
a--;
}
if (a < 0) {
@@ -308,7 +312,9 @@ bool BLI_filename_make_safe(char *fname)
}
/* Forbid only dots. */
- for (fn = fname; *fn == '.'; fn++);
+ for (fn = fname; *fn == '.'; fn++) {
+ /* pass */
+ }
if (*fn == '\0') {
*fname = '_';
changed = true;
@@ -442,7 +448,9 @@ static bool BLI_path_is_abs(const char *name)
static wchar_t *next_slash(wchar_t *path)
{
wchar_t *slash = path;
- while (*slash && *slash != L'\\') slash++;
+ while (*slash && *slash != L'\\') {
+ slash++;
+ }
return slash;
}
@@ -464,7 +472,6 @@ static void BLI_path_unc_to_short(wchar_t *unc)
wchar_t tmp[PATH_MAX];
int len = wcslen(unc);
- int copy_start = 0;
/* convert:
* \\?\UNC\server\share\folder\... to \\server\share\folder\...
* \\?\C:\ to C:\ and \\?\C:\folder\... to C:\folder\...
@@ -555,11 +562,13 @@ void BLI_path_rel(char *file, const char *relfile)
int off;
int slash = 0;
for (off = 0; temp[off] && slash < 4; off++) {
- if (temp[off] != file[off])
+ if (temp[off] != file[off]) {
return;
+ }
- if (temp[off] == '\\')
+ if (temp[off] == '\\') {
slash++;
+ }
}
}
else if (temp[1] == ':' && file[1] == ':' && temp[0] != file[0]) {
@@ -620,7 +629,9 @@ void BLI_path_rel(char *file, const char *relfile)
* We count the number of directories we need to go up in the
* hierarchy to arrive at the common 'prefix' of the path
*/
- if (p < temp) p = temp;
+ if (p < temp) {
+ p = temp;
+ }
while (p && p < lslash) {
if (*p == '/') {
r += BLI_strcpy_rlen(r, "../");
@@ -662,8 +673,9 @@ bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char
char extension[FILE_MAX];
bool has_extension = false;
- if (string_len + sep_len + suffix_len >= maxlen)
+ if (string_len + sep_len + suffix_len >= maxlen) {
return false;
+ }
for (a = string_len - 1; a >= 0; a--) {
if (string[a] == '.') {
@@ -675,8 +687,9 @@ bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char
}
}
- if (!has_extension)
+ if (!has_extension) {
a = string_len;
+ }
BLI_strncpy(extension, string + a, sizeof(extension));
sprintf(string + a, "%s%s%s", sep, suffix, extension);
@@ -750,8 +763,9 @@ static void ensure_digits(char *path, int digits)
{
char *file = (char *)BLI_last_slash(path);
- if (file == NULL)
+ if (file == NULL) {
file = path;
+ }
if (strrchr(file, '#') == NULL) {
int len = strlen(file);
@@ -771,8 +785,9 @@ bool BLI_path_frame(char *path, int frame, int digits)
{
int ch_sta, ch_end;
- if (digits)
+ if (digits) {
ensure_digits(path, digits);
+ }
if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
char tmp[FILE_MAX];
@@ -794,8 +809,9 @@ bool BLI_path_frame_range(char *path, int sta, int end, int digits)
{
int ch_sta, ch_end;
- if (digits)
+ if (digits) {
ensure_digits(path, digits);
+ }
if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
char tmp[FILE_MAX];
@@ -820,8 +836,9 @@ bool BLI_path_frame_get(char *path, int *r_frame, int *r_numdigits)
numdigits = *r_numdigits = 0;
- if (file == NULL)
+ if (file == NULL) {
file = path;
+ }
/* first get the extension part */
len = strlen(file);
@@ -862,51 +879,52 @@ bool BLI_path_frame_get(char *path, int *r_frame, int *r_numdigits)
return false;
}
-void BLI_path_frame_strip(char *path, bool set_frame_char, char *ext)
+void BLI_path_frame_strip(char *path, char *r_ext)
{
- if (*path) {
- char *file = (char *)BLI_last_slash(path);
- char *c, *suffix;
- int len;
- int numdigits = 0;
-
- if (file == NULL)
- file = path;
+ if (*path == '\0') {
+ return;
+ }
- /* first get the extension part */
- len = strlen(file);
+ char *file = (char *)BLI_last_slash(path);
+ char *c, *suffix;
+ int len;
+ int numdigits = 0;
- c = file + len;
+ if (file == NULL) {
+ file = path;
+ }
- /* isolate extension */
- while (--c != file) {
- if (*c == '.') {
- c--;
- break;
- }
- }
+ /* first get the extension part */
+ len = strlen(file);
- suffix = c + 1;
+ c = file + len;
- /* find start of number */
- while (c != (file - 1) && isdigit(*c)) {
+ /* isolate extension */
+ while (--c != file) {
+ if (*c == '.') {
c--;
- numdigits++;
+ break;
}
+ }
- c++;
+ suffix = c + 1;
- if (numdigits) {
- /* replace the number with the suffix and terminate the string */
- while (numdigits--) {
- *ext++ = *suffix;
- *c++ = set_frame_char ? '#' : *suffix;
- suffix++;
- }
- *c = '\0';
- *ext = '\0';
- }
+ /* find start of number */
+ while (c != (file - 1) && isdigit(*c)) {
+ c--;
+ numdigits++;
+ }
+
+ c++;
+
+ int suffix_length = len - (suffix - file);
+ BLI_strncpy(r_ext, suffix, suffix_length + 1);
+
+ /* replace the number with the suffix and terminate the string */
+ while (numdigits--) {
+ *c++ = '#';
}
+ *c = '\0';
}
@@ -1092,11 +1110,13 @@ bool BLI_path_cwd(char *path, const size_t maxlen)
const int filelen = strlen(path);
#ifdef WIN32
- if ((filelen >= 3 && BLI_path_is_abs(path)) || BLI_path_is_unc(path))
+ if ((filelen >= 3 && BLI_path_is_abs(path)) || BLI_path_is_unc(path)) {
wasrelative = false;
+ }
#else
- if (filelen >= 2 && path[0] == '/')
+ if (filelen >= 2 && path[0] == '/') {
wasrelative = false;
+ }
#endif
if (wasrelative) {
@@ -1239,10 +1259,12 @@ void BLI_setenv(const char *env, const char *val)
#else
/* linux/osx/bsd */
- if (val)
+ if (val) {
setenv(env, val, 1);
- else
+ }
+ else {
unsetenv(env);
+ }
#endif
}
@@ -1255,8 +1277,9 @@ void BLI_setenv(const char *env, const char *val)
*/
void BLI_setenv_if_new(const char *env, const char *val)
{
- if (BLI_getenv(env) == NULL)
+ if (BLI_getenv(env) == NULL) {
BLI_setenv(env, val);
+ }
}
/**
@@ -1266,10 +1289,12 @@ const char *BLI_getenv(const char *env)
{
#ifdef _MSC_VER
static char buffer[32767]; /* 32767 is the total size of the environment block on windows*/
- if (GetEnvironmentVariableA(env, buffer, sizeof(buffer)))
+ if (GetEnvironmentVariableA(env, buffer, sizeof(buffer))) {
return buffer;
- else
+ }
+ else {
return NULL;
+ }
#else
return getenv(env);
#endif
@@ -1285,7 +1310,9 @@ void BLI_make_exist(char *dir)
bool valid_path = true;
/* Loop as long as cur path is not a dir, and we can get a parent path. */
- while ((BLI_access(dir, R_OK) != 0) && (valid_path = BLI_parent_dir(dir)));
+ while ((BLI_access(dir, R_OK) != 0) && (valid_path = BLI_parent_dir(dir))) {
+ /* pass */
+ }
/* If we could not find an existing dir, use default root... */
if (!valid_path || !dir[0]) {
@@ -1344,7 +1371,9 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
strcpy(string, relabase);
lslash = (char *)BLI_last_slash(string);
- if (lslash) *(lslash + 1) = 0;
+ if (lslash) {
+ *(lslash + 1) = 0;
+ }
dir += 2; /* Skip over the relative reference */
}
@@ -1369,7 +1398,9 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
}
/* ignore leading slashes */
- while (*dir == '/' || *dir == '\\') dir++;
+ while (*dir == '/' || *dir == '\\') {
+ dir++;
+ }
}
}
#endif
@@ -1386,8 +1417,10 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, c
/* since we've now removed all slashes, put back one slash at the end. */
strcat(string, "/");
- while (*file && (*file == '/' || *file == '\\')) /* Trim slashes from the front of file */
+ while (*file && (*file == '/' || *file == '\\')) {
+ /* Trim slashes from the front of file */
file++;
+ }
strcat(string, file);
@@ -1537,8 +1570,9 @@ bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext)
a = path_len;
}
- if (a + ext_len >= maxlen)
+ if (a + ext_len >= maxlen) {
return false;
+ }
memcpy(path + a, ext, ext_len + 1);
return true;
@@ -1571,8 +1605,9 @@ bool BLI_path_extension_ensure(char *path, size_t maxlen, const char *ext)
}
a++;
- if (a + ext_len >= maxlen)
+ if (a + ext_len >= maxlen) {
return false;
+ }
memcpy(path + a, ext, ext_len + 1);
return true;
@@ -1869,8 +1904,12 @@ const char *BLI_first_slash(const char *string)
const char * const ffslash = strchr(string, '/');
const char * const fbslash = strchr(string, '\\');
- if (!ffslash) return fbslash;
- else if (!fbslash) return ffslash;
+ if (!ffslash) {
+ return fbslash;
+ }
+ else if (!fbslash) {
+ return ffslash;
+ }
return (ffslash < fbslash) ? ffslash : fbslash;
}
@@ -1883,8 +1922,12 @@ const char *BLI_last_slash(const char *string)
const char * const lfslash = strrchr(string, '/');
const char * const lbslash = strrchr(string, '\\');
- if (!lfslash) return lbslash;
- else if (!lbslash) return lfslash;
+ if (!lfslash) {
+ return lbslash;
+ }
+ else if (!lbslash) {
+ return lfslash;
+ }
return (lfslash > lbslash) ? lfslash : lbslash;
}
diff --git a/source/blender/blenlib/intern/polyfill_2d.c b/source/blender/blenlib/intern/polyfill_2d.c
index 5867cdee8bc..4044ebad56b 100644
--- a/source/blender/blenlib/intern/polyfill_2d.c
+++ b/source/blender/blenlib/intern/polyfill_2d.c
@@ -177,12 +177,15 @@ static void pf_ear_tip_cut(PolyFill *pf, PolyIndex *pi_ear_tip);
BLI_INLINE eSign signum_enum(float a)
{
- if (UNLIKELY(a == 0.0f))
+ if (UNLIKELY(a == 0.0f)) {
return 0;
- else if (a > 0.0f)
+ }
+ else if (a > 0.0f) {
return 1;
- else
+ }
+ else {
return -1;
+ }
}
/**
@@ -273,8 +276,8 @@ static uint kdtree2d_balance_recursive(
j = pos;
while (1) {
- while (coords[nodes[++i].index][axis] < co) ;
- while (coords[nodes[--j].index][axis] > co && j > neg) ;
+ while (coords[nodes[++i].index][axis] < co) { /* pass */ }
+ while (coords[nodes[--j].index][axis] > co && j > neg) { /* pass */ }
if (i >= j) {
break;
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index 764d0c48f0d..352bfe5dab6 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -297,8 +297,9 @@ static RNG rng_tab[BLENDER_MAX_THREADS];
void BLI_thread_srandom(int thread, unsigned int seed)
{
- if (thread >= BLENDER_MAX_THREADS)
+ if (thread >= BLENDER_MAX_THREADS) {
thread = 0;
+ }
BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
seed = BLI_rng_get_uint(&rng_tab[thread]);
@@ -369,7 +370,7 @@ BLI_INLINE double halton_ex(double invprimes, double *offset)
return *offset;
}
-void BLI_halton_1D(unsigned int prime, double offset, int n, double *r)
+void BLI_halton_1d(unsigned int prime, double offset, int n, double *r)
{
const double invprime = 1.0 / (double)prime;
@@ -380,7 +381,7 @@ void BLI_halton_1D(unsigned int prime, double offset, int n, double *r)
}
}
-void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r)
+void BLI_halton_2d(unsigned int prime[2], double offset[2], int n, double *r)
{
const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]};
@@ -393,7 +394,7 @@ void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r)
}
}
-void BLI_halton_3D(unsigned int prime[3], double offset[3], int n, double *r)
+void BLI_halton_3d(unsigned int prime[3], double offset[3], int n, double *r)
{
const double invprimes[3] = {1.0 / (double)prime[0], 1.0 / (double)prime[1], 1.0 / (double)prime[2]};
@@ -406,7 +407,7 @@ void BLI_halton_3D(unsigned int prime[3], double offset[3], int n, double *r)
}
}
-void BLI_halton_2D_sequence(unsigned int prime[2], double offset[2], int n, double *r)
+void BLI_halton_2d_sequence(unsigned int prime[2], double offset[2], int n, double *r)
{
const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]};
@@ -435,12 +436,12 @@ BLI_INLINE double radical_inverse(unsigned int n)
return u;
}
-void BLI_hammersley_1D(unsigned int n, double *r)
+void BLI_hammersley_1d(unsigned int n, double *r)
{
*r = radical_inverse(n);
}
-void BLI_hammersley_2D_sequence(unsigned int n, double *r)
+void BLI_hammersley_2d_sequence(unsigned int n, double *r)
{
for (unsigned int s = 0; s < n; s++) {
r[s * 2 + 0] = (double)(s + 0.5) / (double)n;
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index 9b26ad24230..9437380a09d 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -57,65 +57,65 @@ bool BLI_rctf_is_empty(const rctf *rect)
bool BLI_rcti_isect_x(const rcti *rect, const int x)
{
- if (x < rect->xmin) return false;
- if (x > rect->xmax) return false;
+ if (x < rect->xmin) { return false; }
+ if (x > rect->xmax) { return false; }
return true;
}
bool BLI_rcti_isect_y(const rcti *rect, const int y)
{
- if (y < rect->ymin) return false;
- if (y > rect->ymax) return false;
+ if (y < rect->ymin) { return false; }
+ if (y > rect->ymax) { return false; }
return true;
}
bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y)
{
- if (x < rect->xmin) return false;
- if (x > rect->xmax) return false;
- if (y < rect->ymin) return false;
- if (y > rect->ymax) return false;
+ if (x < rect->xmin) { return false; }
+ if (x > rect->xmax) { return false; }
+ if (y < rect->ymin) { return false; }
+ if (y > rect->ymax) { return false; }
return true;
}
bool BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2])
{
- if (xy[0] < rect->xmin) return false;
- if (xy[0] > rect->xmax) return false;
- if (xy[1] < rect->ymin) return false;
- if (xy[1] > rect->ymax) return false;
+ if (xy[0] < rect->xmin) { return false; }
+ if (xy[0] > rect->xmax) { return false; }
+ if (xy[1] < rect->ymin) { return false; }
+ if (xy[1] > rect->ymax) { return false; }
return true;
}
bool BLI_rctf_isect_x(const rctf *rect, const float x)
{
- if (x < rect->xmin) return false;
- if (x > rect->xmax) return false;
+ if (x < rect->xmin) { return false; }
+ if (x > rect->xmax) { return false; }
return true;
}
bool BLI_rctf_isect_y(const rctf *rect, const float y)
{
- if (y < rect->ymin) return false;
- if (y > rect->ymax) return false;
+ if (y < rect->ymin) { return false; }
+ if (y > rect->ymax) { return false; }
return true;
}
bool BLI_rctf_isect_pt(const rctf *rect, const float x, const float y)
{
- if (x < rect->xmin) return false;
- if (x > rect->xmax) return false;
- if (y < rect->ymin) return false;
- if (y > rect->ymax) return false;
+ if (x < rect->xmin) { return false; }
+ if (x > rect->xmax) { return false; }
+ if (y < rect->ymin) { return false; }
+ if (y > rect->ymax) { return false; }
return true;
}
bool BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
{
- if (xy[0] < rect->xmin) return false;
- if (xy[0] > rect->xmax) return false;
- if (xy[1] < rect->ymin) return false;
- if (xy[1] > rect->ymax) return false;
+ if (xy[0] < rect->xmin) { return false; }
+ if (xy[0] > rect->xmax) { return false; }
+ if (xy[1] < rect->ymin) { return false; }
+ if (xy[1] > rect->ymax) { return false; }
return true;
}
@@ -125,29 +125,29 @@ bool BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
int BLI_rcti_length_x(const rcti *rect, const int x)
{
- if (x < rect->xmin) return rect->xmin - x;
- if (x > rect->xmax) return x - rect->xmax;
+ if (x < rect->xmin) { return rect->xmin - x; }
+ if (x > rect->xmax) { return x - rect->xmax; }
return 0;
}
int BLI_rcti_length_y(const rcti *rect, const int y)
{
- if (y < rect->ymin) return rect->ymin - y;
- if (y > rect->ymax) return y - rect->ymax;
+ if (y < rect->ymin) { return rect->ymin - y; }
+ if (y > rect->ymax) { return y - rect->ymax; }
return 0;
}
float BLI_rctf_length_x(const rctf *rect, const float x)
{
- if (x < rect->xmin) return rect->xmin - x;
- if (x > rect->xmax) return x - rect->xmax;
+ if (x < rect->xmin) { return rect->xmin - x; }
+ if (x > rect->xmax) { return x - rect->xmax; }
return 0.0f;
}
float BLI_rctf_length_y(const rctf *rect, const float y)
{
- if (y < rect->ymin) return rect->ymin - y;
- if (y > rect->ymax) return y - rect->ymax;
+ if (y < rect->ymin) { return rect->ymin - y; }
+ if (y > rect->ymax) { return y - rect->ymax; }
return 0.0f;
}
@@ -200,10 +200,10 @@ static int isect_segments_fl(const float v1[2], const float v2[2], const float v
bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
{
/* first do outside-bounds check for both points of the segment */
- if (s1[0] < rect->xmin && s2[0] < rect->xmin) return false;
- if (s1[0] > rect->xmax && s2[0] > rect->xmax) return false;
- if (s1[1] < rect->ymin && s2[1] < rect->ymin) return false;
- if (s1[1] > rect->ymax && s2[1] > rect->ymax) return false;
+ if (s1[0] < rect->xmin && s2[0] < rect->xmin) { return false; }
+ if (s1[0] > rect->xmax && s2[0] > rect->xmax) { return false; }
+ if (s1[1] < rect->ymin && s2[1] < rect->ymin) { return false; }
+ if (s1[1] > rect->ymax && s2[1] > rect->ymax) { return false; }
/* if either points intersect then we definetly intersect */
if (BLI_rcti_isect_pt_v(rect, s1) || BLI_rcti_isect_pt_v(rect, s2)) {
@@ -235,10 +235,10 @@ bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2])
{
/* first do outside-bounds check for both points of the segment */
- if (s1[0] < rect->xmin && s2[0] < rect->xmin) return false;
- if (s1[0] > rect->xmax && s2[0] > rect->xmax) return false;
- if (s1[1] < rect->ymin && s2[1] < rect->ymin) return false;
- if (s1[1] > rect->ymax && s2[1] > rect->ymax) return false;
+ if (s1[0] < rect->xmin && s2[0] < rect->xmin) { return false; }
+ if (s1[0] > rect->xmax && s2[0] > rect->xmax) { return false; }
+ if (s1[1] < rect->ymin && s2[1] < rect->ymin) { return false; }
+ if (s1[1] > rect->ymax && s2[1] > rect->ymax) { return false; }
/* if either points intersect then we definetly intersect */
if (BLI_rctf_isect_pt_v(rect, s1) || BLI_rctf_isect_pt_v(rect, s2)) {
@@ -271,11 +271,19 @@ bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radi
{
float dx, dy;
- if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0;
- else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
+ if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) {
+ dx = 0;
+ }
+ else {
+ dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
+ }
- if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0;
- else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
+ if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) {
+ dy = 0;
+ }
+ else {
+ dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
+ }
return dx * dx + dy * dy <= radius * radius;
}
@@ -284,29 +292,37 @@ bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radi
{
float dx, dy;
- if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0;
- else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
+ if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) {
+ dx = 0;
+ }
+ else {
+ dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
+ }
- if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0;
- else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
+ if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) {
+ dy = 0;
+ }
+ else {
+ dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
+ }
return dx * dx + dy * dy <= radius * radius;
}
void BLI_rctf_union(rctf *rct1, const rctf *rct2)
{
- if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin;
- if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax;
- if (rct1->ymin > rct2->ymin) rct1->ymin = rct2->ymin;
- if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax;
+ if (rct1->xmin > rct2->xmin) { rct1->xmin = rct2->xmin; }
+ if (rct1->xmax < rct2->xmax) { rct1->xmax = rct2->xmax; }
+ if (rct1->ymin > rct2->ymin) { rct1->ymin = rct2->ymin; }
+ if (rct1->ymax < rct2->ymax) { rct1->ymax = rct2->ymax; }
}
void BLI_rcti_union(rcti *rct1, const rcti *rct2)
{
- if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin;
- if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax;
- if (rct1->ymin > rct2->ymin) rct1->ymin = rct2->ymin;
- if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax;
+ if (rct1->xmin > rct2->xmin) { rct1->xmin = rct2->xmin; }
+ if (rct1->xmax < rct2->xmax) { rct1->xmax = rct2->xmax; }
+ if (rct1->ymin > rct2->ymin) { rct1->ymin = rct2->ymin; }
+ if (rct1->ymax < rct2->ymax) { rct1->ymax = rct2->ymax; }
}
void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax)
@@ -379,18 +395,18 @@ void BLI_rctf_init_minmax(rctf *rect)
void BLI_rcti_do_minmax_v(rcti *rect, const int xy[2])
{
- if (xy[0] < rect->xmin) rect->xmin = xy[0];
- if (xy[0] > rect->xmax) rect->xmax = xy[0];
- if (xy[1] < rect->ymin) rect->ymin = xy[1];
- if (xy[1] > rect->ymax) rect->ymax = xy[1];
+ if (xy[0] < rect->xmin) { rect->xmin = xy[0]; }
+ if (xy[0] > rect->xmax) { rect->xmax = xy[0]; }
+ if (xy[1] < rect->ymin) { rect->ymin = xy[1]; }
+ if (xy[1] > rect->ymax) { rect->ymax = xy[1]; }
}
void BLI_rctf_do_minmax_v(rctf *rect, const float xy[2])
{
- if (xy[0] < rect->xmin) rect->xmin = xy[0];
- if (xy[0] > rect->xmax) rect->xmax = xy[0];
- if (xy[1] < rect->ymin) rect->ymin = xy[1];
- if (xy[1] > rect->ymax) rect->ymax = xy[1];
+ if (xy[0] < rect->xmin) { rect->xmin = xy[0]; }
+ if (xy[0] > rect->xmax) { rect->xmax = xy[0]; }
+ if (xy[1] < rect->ymin) { rect->ymin = xy[1]; }
+ if (xy[1] > rect->ymax) { rect->ymax = xy[1]; }
}
/* given 2 rectangles - transform a point from one to another */
@@ -620,22 +636,30 @@ bool BLI_rcti_clamp(rcti *rect, const rcti *rect_bounds, int r_xy[2])
bool BLI_rctf_compare(const rctf *rect_a, const rctf *rect_b, const float limit)
{
- if (fabsf(rect_a->xmin - rect_b->xmin) < limit)
- if (fabsf(rect_a->xmax - rect_b->xmax) < limit)
- if (fabsf(rect_a->ymin - rect_b->ymin) < limit)
- if (fabsf(rect_a->ymax - rect_b->ymax) < limit)
+ if (fabsf(rect_a->xmin - rect_b->xmin) < limit) {
+ if (fabsf(rect_a->xmax - rect_b->xmax) < limit) {
+ if (fabsf(rect_a->ymin - rect_b->ymin) < limit) {
+ if (fabsf(rect_a->ymax - rect_b->ymax) < limit) {
return true;
+ }
+ }
+ }
+ }
return false;
}
bool BLI_rcti_compare(const rcti *rect_a, const rcti *rect_b)
{
- if (rect_a->xmin == rect_b->xmin)
- if (rect_a->xmax == rect_b->xmax)
- if (rect_a->ymin == rect_b->ymin)
- if (rect_a->ymax == rect_b->ymax)
+ if (rect_a->xmin == rect_b->xmin) {
+ if (rect_a->xmax == rect_b->xmax) {
+ if (rect_a->ymin == rect_b->ymin) {
+ if (rect_a->ymax == rect_b->ymax) {
return true;
+ }
+ }
+ }
+ }
return false;
}
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 12e1425837e..80b4acc90a7 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -93,10 +93,10 @@ static int vergscdata(const void *a1, const void *a2)
{
const ScanFillVertLink *x1 = a1, *x2 = a2;
- if (x1->vert->xy[1] < x2->vert->xy[1]) return 1;
- else if (x1->vert->xy[1] > x2->vert->xy[1]) return -1;
- else if (x1->vert->xy[0] > x2->vert->xy[0]) return 1;
- else if (x1->vert->xy[0] < x2->vert->xy[0]) return -1;
+ if (x1->vert->xy[1] < x2->vert->xy[1]) { return 1; }
+ else if (x1->vert->xy[1] > x2->vert->xy[1]) { return -1; }
+ else if (x1->vert->xy[0] > x2->vert->xy[0]) { return 1; }
+ else if (x1->vert->xy[0] < x2->vert->xy[0]) { return -1; }
return 0;
}
@@ -105,10 +105,10 @@ static int vergpoly(const void *a1, const void *a2)
{
const PolyFill *x1 = a1, *x2 = a2;
- if (x1->min_xy[0] > x2->min_xy[0]) return 1;
- else if (x1->min_xy[0] < x2->min_xy[0]) return -1;
- else if (x1->min_xy[1] > x2->min_xy[1]) return 1;
- else if (x1->min_xy[1] < x2->min_xy[1]) return -1;
+ if (x1->min_xy[0] > x2->min_xy[0]) { return 1; }
+ else if (x1->min_xy[0] < x2->min_xy[0]) { return -1; }
+ else if (x1->min_xy[1] > x2->min_xy[1]) { return 1; }
+ else if (x1->min_xy[1] < x2->min_xy[1]) { return -1; }
return 0;
}
@@ -174,20 +174,20 @@ static bool boundisect(PolyFill *pf2, PolyFill *pf1)
/* has pf2 been touched (intersected) by pf1 ? with bounding box */
/* test first if polys exist */
- if (pf1->edges == 0 || pf2->edges == 0) return false;
+ if (pf1->edges == 0 || pf2->edges == 0) { return false; }
- if (pf2->max_xy[0] < pf1->min_xy[0]) return false;
- if (pf2->max_xy[1] < pf1->min_xy[1]) return false;
+ if (pf2->max_xy[0] < pf1->min_xy[0]) { return false; }
+ if (pf2->max_xy[1] < pf1->min_xy[1]) { return false; }
- if (pf2->min_xy[0] > pf1->max_xy[0]) return false;
- if (pf2->min_xy[1] > pf1->max_xy[1]) return false;
+ if (pf2->min_xy[0] > pf1->max_xy[0]) { return false; }
+ if (pf2->min_xy[1] > pf1->max_xy[1]) { return false; }
/* join */
- if (pf2->max_xy[0] < pf1->max_xy[0]) pf2->max_xy[0] = pf1->max_xy[0];
- if (pf2->max_xy[1] < pf1->max_xy[1]) pf2->max_xy[1] = pf1->max_xy[1];
+ if (pf2->max_xy[0] < pf1->max_xy[0]) { pf2->max_xy[0] = pf1->max_xy[0]; }
+ if (pf2->max_xy[1] < pf1->max_xy[1]) { pf2->max_xy[1] = pf1->max_xy[1]; }
- if (pf2->min_xy[0] > pf1->min_xy[0]) pf2->min_xy[0] = pf1->min_xy[0];
- if (pf2->min_xy[1] > pf1->min_xy[1]) pf2->min_xy[1] = pf1->min_xy[1];
+ if (pf2->min_xy[0] > pf1->min_xy[0]) { pf2->min_xy[0] = pf1->min_xy[0]; }
+ if (pf2->min_xy[1] > pf1->min_xy[1]) { pf2->min_xy[1] = pf1->min_xy[1]; }
return true;
}
@@ -230,8 +230,12 @@ static bool testedgeside(const float v1[2], const float v2[2], const float v3[2]
return false;
}
else if (inp == 0.0f) {
- if (v1[0] == v3[0] && v1[1] == v3[1]) return false;
- if (v2[0] == v3[0] && v2[1] == v3[1]) return false;
+ if (v1[0] == v3[0] && v1[1] == v3[1]) {
+ return false;
+ }
+ if (v2[0] == v3[0] && v2[1] == v3[1]) {
+ return false;
+ }
}
return true;
}
@@ -278,8 +282,12 @@ static bool addedgetoscanvert(ScanFillVertLink *sc, ScanFillEdge *eed)
break;
}
}
- if (ed) BLI_insertlinkbefore((ListBase *)&(sc->edge_first), ed, eed);
- else BLI_addtail((ListBase *)&(sc->edge_first), eed);
+ if (ed) {
+ BLI_insertlinkbefore((ListBase *)&(sc->edge_first), ed, eed);
+ }
+ else {
+ BLI_addtail((ListBase *)&(sc->edge_first), eed);
+ }
return true;
}
@@ -519,13 +527,15 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
*/
if (eed->v1->f == SF_VERT_ZERO_LEN) {
v1 = eed->v1;
- while ((eed->v1->f == SF_VERT_ZERO_LEN) && (eed->v1->tmp.v != v1) && (eed->v1 != eed->v1->tmp.v))
+ while ((eed->v1->f == SF_VERT_ZERO_LEN) && (eed->v1->tmp.v != v1) && (eed->v1 != eed->v1->tmp.v)) {
eed->v1 = eed->v1->tmp.v;
+ }
}
if (eed->v2->f == SF_VERT_ZERO_LEN) {
v2 = eed->v2;
- while ((eed->v2->f == SF_VERT_ZERO_LEN) && (eed->v2->tmp.v != v2) && (eed->v2 != eed->v2->tmp.v))
+ while ((eed->v2->f == SF_VERT_ZERO_LEN) && (eed->v2->tmp.v != v2) && (eed->v2 != eed->v2->tmp.v)) {
eed->v2 = eed->v2->tmp.v;
+ }
}
if (eed->v1 != eed->v2) {
addedgetoscanlist(scdata, eed, verts);
@@ -555,8 +565,9 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
/* STEP 2: FILL LOOP */
- if (pf->f == SF_POLY_NEW)
+ if (pf->f == SF_POLY_NEW) {
twoconnected = true;
+ }
/* (temporal) security: never much more faces than vertices */
totface = 0;
@@ -577,8 +588,12 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
if (ed1->v1->edge_tot == 1 || ed1->v2->edge_tot == 1) {
BLI_remlink((ListBase *)&(sc->edge_first), ed1);
BLI_addtail(&sf_ctx->filledgebase, ed1);
- if (ed1->v1->edge_tot > 1) ed1->v1->edge_tot--;
- if (ed1->v2->edge_tot > 1) ed1->v2->edge_tot--;
+ if (ed1->v1->edge_tot > 1) {
+ ed1->v1->edge_tot--;
+ }
+ if (ed1->v2->edge_tot > 1) {
+ ed1->v2->edge_tot--;
+ }
}
else {
ed1->v2->f = SF_VERT_AVAILABLE;
@@ -616,7 +631,9 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
v3 = ed2->v2;
/* this happens with a serial of overlapping edges */
- if (v1 == v2 || v2 == v3) break;
+ if (v1 == v2 || v2 == v3) {
+ break;
+ }
/* printf("test verts %d %d %d\n", v1->tmp.u, v2->tmp.u, v3->tmp.u); */
miny = min_ff(v1->xy[1], v3->xy[1]);
@@ -624,7 +641,9 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
for (b = a + 1; b < verts; b++, sc1++) {
if (sc1->vert->f == SF_VERT_NEW) {
- if (sc1->vert->xy[1] <= miny) break;
+ if (sc1->vert->xy[1] <= miny) {
+ break;
+ }
if (testedgeside(v1->xy, v2->xy, sc1->vert->xy)) {
if (testedgeside(v2->xy, v3->xy, sc1->vert->xy)) {
if (testedgeside(v3->xy, v1->xy, sc1->vert->xy)) {
@@ -724,8 +743,12 @@ static unsigned int scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int fl
if (ed1->v1->edge_tot < 2 || ed1->v2->edge_tot < 2) {
BLI_remlink((ListBase *)&(sc->edge_first), ed1);
BLI_addtail(&sf_ctx->filledgebase, ed1);
- if (ed1->v1->edge_tot > 1) ed1->v1->edge_tot--;
- if (ed1->v2->edge_tot > 1) ed1->v2->edge_tot--;
+ if (ed1->v1->edge_tot > 1) {
+ ed1->v1->edge_tot--;
+ }
+ if (ed1->v2->edge_tot > 1) {
+ ed1->v2->edge_tot--;
+ }
}
}
/* done with loose edges */
@@ -934,8 +957,12 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
if (flag & BLI_SCANFILL_CALC_LOOSE) {
unsigned int toggle = 0;
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
- if (eed->v1->edge_tot++ > 250) break;
- if (eed->v2->edge_tot++ > 250) break;
+ if (eed->v1->edge_tot++ > 250) {
+ break;
+ }
+ if (eed->v2->edge_tot++ > 250) {
+ break;
+ }
}
if (eed) {
/* otherwise it's impossible to be sure you can clear vertices */
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index b012ff36bf1..7da5ff114be 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -405,8 +405,9 @@ double BLI_smallhash_calc_quality(SmallHash *sh)
uint64_t sum = 0;
uint i;
- if (sh->nentries == 0)
+ if (sh->nentries == 0) {
return -1.0;
+ }
for (i = 0; i < sh->nbuckets; i++) {
if (sh->buckets[i].key != SMHASH_KEY_UNUSED) {
diff --git a/source/blender/blenlib/intern/sort.c b/source/blender/blenlib/intern/sort.c
index af206975e16..921eec5ddc4 100644
--- a/source/blender/blenlib/intern/sort.c
+++ b/source/blender/blenlib/intern/sort.c
@@ -141,8 +141,9 @@ loop:
}
pc -= es;
}
- if (pb > pc)
+ if (pb > pc) {
break;
+ }
swap(pb, pc);
swap_cnt = 1;
pb += es;
@@ -165,8 +166,9 @@ loop:
vecswap((char *)a, pb - r, r);
r = min(pd - pc, pn - pd - es);
vecswap(pb, pn - r, r);
- if ((r = pb - pa) > es)
+ if ((r = pb - pa) > es) {
BLI_qsort_r(a, r / es, es, cmp, thunk);
+ }
if ((r = pd - pc) > es) {
/* Iterate rather than recurse to save stack space */
a = pn - r;
diff --git a/source/blender/blenlib/intern/sort_utils.c b/source/blender/blenlib/intern/sort_utils.c
index 7166b7753aa..3220f753397 100644
--- a/source/blender/blenlib/intern/sort_utils.c
+++ b/source/blender/blenlib/intern/sort_utils.c
@@ -41,52 +41,52 @@ int BLI_sortutil_cmp_float(const void *a_, const void *b_)
{
const struct SortAnyByFloat *a = a_;
const struct SortAnyByFloat *b = b_;
- if (a->sort_value > b->sort_value) return 1;
- else if (a->sort_value < b->sort_value) return -1;
- else return 0;
+ if (a->sort_value > b->sort_value) { return 1; }
+ else if (a->sort_value < b->sort_value) { return -1; }
+ else { return 0; }
}
int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
{
const struct SortAnyByFloat *a = a_;
const struct SortAnyByFloat *b = b_;
- if (a->sort_value < b->sort_value) return 1;
- else if (a->sort_value > b->sort_value) return -1;
- else return 0;
+ if (a->sort_value < b->sort_value) { return 1; }
+ else if (a->sort_value > b->sort_value) { return -1; }
+ else { return 0; }
}
int BLI_sortutil_cmp_int(const void *a_, const void *b_)
{
const struct SortAnyByInt *a = a_;
const struct SortAnyByInt *b = b_;
- if (a->sort_value > b->sort_value) return 1;
- else if (a->sort_value < b->sort_value) return -1;
- else return 0;
+ if (a->sort_value > b->sort_value) { return 1; }
+ else if (a->sort_value < b->sort_value) { return -1; }
+ else { return 0; }
}
int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
{
const struct SortAnyByInt *a = a_;
const struct SortAnyByInt *b = b_;
- if (a->sort_value < b->sort_value) return 1;
- else if (a->sort_value > b->sort_value) return -1;
- else return 0;
+ if (a->sort_value < b->sort_value) { return 1; }
+ else if (a->sort_value > b->sort_value) { return -1; }
+ else { return 0; }
}
int BLI_sortutil_cmp_ptr(const void *a_, const void *b_)
{
const struct SortAnyByPtr *a = a_;
const struct SortAnyByPtr *b = b_;
- if (a->sort_value > b->sort_value) return 1;
- else if (a->sort_value < b->sort_value) return -1;
- else return 0;
+ if (a->sort_value > b->sort_value) { return 1; }
+ else if (a->sort_value < b->sort_value) { return -1; }
+ else { return 0; }
}
int BLI_sortutil_cmp_ptr_reverse(const void *a_, const void *b_)
{
const struct SortAnyByPtr *a = a_;
const struct SortAnyByPtr *b = b_;
- if (a->sort_value < b->sort_value) return 1;
- else if (a->sort_value > b->sort_value) return -1;
- else return 0;
+ if (a->sort_value < b->sort_value) { return 1; }
+ else if (a->sort_value > b->sort_value) { return -1; }
+ else { return 0; }
}
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 4fb519e7f26..7b460c77fa8 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -127,25 +127,35 @@ double BLI_dir_free_space(const char *dir)
char name[FILE_MAXDIR], *slash;
int len = strlen(dir);
- if (len >= FILE_MAXDIR) /* path too long */
+ if (len >= FILE_MAXDIR) {
+ /* path too long */
return -1;
+ }
strcpy(name, dir);
if (len) {
slash = strrchr(name, '/');
- if (slash) slash[1] = 0;
+ if (slash) {
+ slash[1] = 0;
+ }
}
else {
strcpy(name, "/");
}
#if defined(USE_STATFS_STATVFS)
- if (statvfs(name, &disk)) return -1;
+ if (statvfs(name, &disk)) {
+ return -1;
+ }
#elif defined(USE_STATFS_4ARGS)
- if (statfs(name, &disk, sizeof(struct statfs), 0)) return -1;
+ if (statfs(name, &disk, sizeof(struct statfs), 0)) {
+ return -1;
+ }
#else
- if (statfs(name, &disk)) return -1;
+ if (statfs(name, &disk)) {
+ return -1;
+ }
#endif
return ( ((double) disk.f_bsize) * ((double) disk.f_bfree));
@@ -159,8 +169,9 @@ double BLI_dir_free_space(const char *dir)
size_t BLI_file_descriptor_size(int file)
{
struct stat st;
- if ((file < 0) || (fstat(file, &st) == -1))
+ if ((file < 0) || (fstat(file, &st) == -1)) {
return -1;
+ }
return st.st_size;
}
@@ -170,8 +181,9 @@ size_t BLI_file_descriptor_size(int file)
size_t BLI_file_size(const char *path)
{
BLI_stat_t stats;
- if (BLI_stat(path, &stats) == -1)
+ if (BLI_stat(path, &stats) == -1) {
return -1;
+ }
return stats.st_size;
}
@@ -216,11 +228,15 @@ int BLI_exists(const char *name)
SetErrorMode(old_error_mode);
free(tmp_16);
- if (res == -1) return(0);
+ if (res == -1) {
+ return(0);
+ }
#else
struct stat st;
BLI_assert(!BLI_path_is_rel(name));
- if (stat(name, &st)) return(0);
+ if (stat(name, &st)) {
+ return(0);
+ }
#endif
return(st.st_mode);
}
@@ -356,7 +372,9 @@ LinkNode *BLI_file_read_as_lines(const char *name)
char *buf;
size_t size;
- if (!fp) return NULL;
+ if (!fp) {
+ return NULL;
+ }
fseek(fp, 0, SEEK_END);
size = (size_t)ftell(fp);
@@ -410,16 +428,24 @@ bool BLI_file_older(const char *file1, const char *file2)
UTF16_ENCODE(file1);
UTF16_ENCODE(file2);
- if (_wstat(file1_16, &st1)) return false;
- if (_wstat(file2_16, &st2)) return false;
+ if (_wstat(file1_16, &st1)) {
+ return false;
+ }
+ if (_wstat(file2_16, &st2)) {
+ return false;
+ }
UTF16_UN_ENCODE(file2);
UTF16_UN_ENCODE(file1);
#else
struct stat st1, st2;
- if (stat(file1, &st1)) return false;
- if (stat(file2, &st2)) return false;
+ if (stat(file1, &st1)) {
+ return false;
+ }
+ if (stat(file2, &st2)) {
+ return false;
+ }
#endif
return (st1.st_mtime < st2.st_mtime);
}
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index dbec1a3153c..dfb32e5b76c 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -423,8 +423,9 @@ char *BLI_str_replaceN(const char *__restrict str, const char *__restrict substr
*/
while ((match = strstr(str, substr_old))) {
/* the assembly buffer only gets created when we actually need to rebuild the string */
- if (ds == NULL)
+ if (ds == NULL) {
ds = BLI_dynstr_new();
+ }
/* if the match position does not match the current position in the string,
* copy the text up to this position and advance the current position in the string
@@ -508,8 +509,9 @@ char *BLI_strcasestr(const char *s, const char *find)
len = strlen(find);
do {
do {
- if ((sc = *s++) == 0)
+ if ((sc = *s++) == 0) {
return (NULL);
+ }
sc = tolower(sc);
} while (sc != c);
} while (BLI_strncasecmp(s, find, len) != 0);
@@ -530,8 +532,9 @@ char *BLI_strncasestr(const char *s, const char *find, size_t len)
if (len > 1) {
do {
do {
- if ((sc = *s++) == 0)
+ if ((sc = *s++) == 0) {
return NULL;
+ }
sc = tolower(sc);
} while (sc != c);
} while (BLI_strncasecmp(s, find, len - 1) != 0);
@@ -539,8 +542,9 @@ char *BLI_strncasestr(const char *s, const char *find, size_t len)
else {
{
do {
- if ((sc = *s++) == 0)
+ if ((sc = *s++) == 0) {
return NULL;
+ }
sc = tolower(sc);
} while (sc != c);
}
@@ -603,37 +607,46 @@ static int left_number_strcmp(const char *s1, const char *s2, int *tiebreaker)
int numdigit, numzero1, numzero2;
/* count and skip leading zeros */
- for (numzero1 = 0; *p1 && (*p1 == '0'); numzero1++)
+ for (numzero1 = 0; *p1 == '0'; numzero1++) {
p1++;
- for (numzero2 = 0; *p2 && (*p2 == '0'); numzero2++)
+ }
+ for (numzero2 = 0; *p2 == '0'; numzero2++) {
p2++;
+ }
/* find number of consecutive digits */
for (numdigit = 0; ; numdigit++) {
- if (isdigit(*(p1 + numdigit)) && isdigit(*(p2 + numdigit)))
+ if (isdigit(*(p1 + numdigit)) && isdigit(*(p2 + numdigit))) {
continue;
- else if (isdigit(*(p1 + numdigit)))
+ }
+ else if (isdigit(*(p1 + numdigit))) {
return 1; /* s2 is bigger */
- else if (isdigit(*(p2 + numdigit)))
+ }
+ else if (isdigit(*(p2 + numdigit))) {
return -1; /* s1 is bigger */
- else
+ }
+ else {
break;
+ }
}
/* same number of digits, compare size of number */
if (numdigit > 0) {
int compare = (int)strncmp(p1, p2, (size_t)numdigit);
- if (compare != 0)
+ if (compare != 0) {
return compare;
+ }
}
/* use number of leading zeros as tie breaker if still equal */
if (*tiebreaker == 0) {
- if (numzero1 > numzero2)
+ if (numzero1 > numzero2) {
*tiebreaker = 1;
- else if (numzero1 < numzero2)
+ }
+ else if (numzero1 < numzero2) {
*tiebreaker = -1;
+ }
}
return 0;
@@ -657,25 +670,30 @@ int BLI_natstrcmp(const char *s1, const char *s2)
if (isdigit(c1) && isdigit(c2)) {
int numcompare = left_number_strcmp(s1 + d1, s2 + d2, &tiebreaker);
- if (numcompare != 0)
+ if (numcompare != 0) {
return numcompare;
+ }
d1++;
- while (isdigit(s1[d1]))
+ while (isdigit(s1[d1])) {
d1++;
+ }
d2++;
- while (isdigit(s2[d2]))
+ while (isdigit(s2[d2])) {
d2++;
+ }
c1 = tolower(s1[d1]);
c2 = tolower(s2[d2]);
}
/* first check for '.' so "foo.bar" comes before "foo 1.bar" */
- if (c1 == '.' && c2 != '.')
+ if (c1 == '.' && c2 != '.') {
return -1;
- if (c1 != '.' && c2 == '.')
+ }
+ if (c1 != '.' && c2 == '.') {
return 1;
+ }
else if (c1 < c2) {
return -1;
}
@@ -689,8 +707,9 @@ int BLI_natstrcmp(const char *s1, const char *s2)
d2++;
}
- if (tiebreaker)
+ if (tiebreaker) {
return tiebreaker;
+ }
/* we might still have a different string because of lower/upper case, in
* that case fall back to regular string comparison */
@@ -747,8 +766,9 @@ size_t BLI_strnlen(const char *s, const size_t maxlen)
size_t len;
for (len = 0; len < maxlen; len++, s++) {
- if (!*s)
+ if (!*s) {
break;
+ }
}
return len;
}
@@ -757,18 +777,22 @@ void BLI_str_tolower_ascii(char *str, const size_t len)
{
size_t i;
- for (i = 0; (i < len) && str[i]; i++)
- if (str[i] >= 'A' && str[i] <= 'Z')
+ for (i = 0; (i < len) && str[i]; i++) {
+ if (str[i] >= 'A' && str[i] <= 'Z') {
str[i] += 'a' - 'A';
+ }
+ }
}
void BLI_str_toupper_ascii(char *str, const size_t len)
{
size_t i;
- for (i = 0; (i < len) && str[i]; i++)
- if (str[i] >= 'a' && str[i] <= 'z')
+ for (i = 0; (i < len) && str[i]; i++) {
+ if (str[i] >= 'a' && str[i] <= 'z') {
str[i] -= 'a' - 'A';
+ }
+ }
}
/**
@@ -939,7 +963,9 @@ size_t BLI_str_partition_ex(
if (end) {
if (from_right) {
- for (tmp = end - 1; (tmp >= str) && (*tmp != *d); tmp--);
+ for (tmp = end - 1; (tmp >= str) && (*tmp != *d); tmp--) {
+ /* pass */
+ }
if (tmp < str) {
tmp = NULL;
}
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index d4b4bba810c..0c07d1c361a 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -77,12 +77,16 @@ ptrdiff_t BLI_utf8_invalid_byte(const char *str, size_t length)
for (p = (const unsigned char *)str; p < pend; p++, length--) {
c = *p;
perr = p; /* Erroneous char is always the first of an invalid utf8 sequence... */
- if (ELEM(c, 0xfe, 0xff, 0x00)) /* Those three values are not allowed in utf8 string. */
+ if (ELEM(c, 0xfe, 0xff, 0x00)) {
+ /* Those three values are not allowed in utf8 string. */
goto utf8_error;
- if (c < 128)
+ }
+ if (c < 128) {
continue;
- if ((c & 0xc0) != 0xc0)
+ }
+ if ((c & 0xc0) != 0xc0) {
goto utf8_error;
+ }
/* Note that since we always increase p (and decrease length) by one byte in main loop,
* we only add/subtract extra utf8 bytes in code below
@@ -95,51 +99,52 @@ ptrdiff_t BLI_utf8_invalid_byte(const char *str, size_t length)
/* Check top bits in the second byte */
p++;
length--;
- if ((*p & 0xc0) != 0x80)
+ if ((*p & 0xc0) != 0x80) {
goto utf8_error;
+ }
/* Check for overlong sequences for each different length */
switch (ab) {
case 1:
/* Check for xx00 000x */
- if ((c & 0x3e) == 0) goto utf8_error;
+ if ((c & 0x3e) == 0) { goto utf8_error; }
continue; /* We know there aren't any more bytes to check */
case 2:
/* Check for 1110 0000, xx0x xxxx */
- if (c == 0xe0 && (*p & 0x20) == 0) goto utf8_error;
+ if (c == 0xe0 && (*p & 0x20) == 0) { goto utf8_error; }
/* Some special cases, see section 5 of utf-8 decoder stress-test by Markus Kuhn
* (https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt). */
/* From section 5.1 (and 5.2) */
if (c == 0xed) {
- if (*p == 0xa0 && *(p + 1) == 0x80) goto utf8_error;
- if (*p == 0xad && *(p + 1) == 0xbf) goto utf8_error;
- if (*p == 0xae && *(p + 1) == 0x80) goto utf8_error;
- if (*p == 0xaf && *(p + 1) == 0xbf) goto utf8_error;
- if (*p == 0xb0 && *(p + 1) == 0x80) goto utf8_error;
- if (*p == 0xbe && *(p + 1) == 0x80) goto utf8_error;
- if (*p == 0xbf && *(p + 1) == 0xbf) goto utf8_error;
+ if (*p == 0xa0 && *(p + 1) == 0x80) { goto utf8_error; }
+ if (*p == 0xad && *(p + 1) == 0xbf) { goto utf8_error; }
+ if (*p == 0xae && *(p + 1) == 0x80) { goto utf8_error; }
+ if (*p == 0xaf && *(p + 1) == 0xbf) { goto utf8_error; }
+ if (*p == 0xb0 && *(p + 1) == 0x80) { goto utf8_error; }
+ if (*p == 0xbe && *(p + 1) == 0x80) { goto utf8_error; }
+ if (*p == 0xbf && *(p + 1) == 0xbf) { goto utf8_error; }
}
/* From section 5.3 */
if (c == 0xef) {
- if (*p == 0xbf && *(p + 1) == 0xbe) goto utf8_error;
- if (*p == 0xbf && *(p + 1) == 0xbf) goto utf8_error;
+ if (*p == 0xbf && *(p + 1) == 0xbe) { goto utf8_error; }
+ if (*p == 0xbf && *(p + 1) == 0xbf) { goto utf8_error; }
}
break;
case 3:
/* Check for 1111 0000, xx00 xxxx */
- if (c == 0xf0 && (*p & 0x30) == 0) goto utf8_error;
+ if (c == 0xf0 && (*p & 0x30) == 0) { goto utf8_error; }
break;
case 4:
/* Check for 1111 1000, xx00 0xxx */
- if (c == 0xf8 && (*p & 0x38) == 0) goto utf8_error;
+ if (c == 0xf8 && (*p & 0x38) == 0) { goto utf8_error; }
break;
case 5:
/* Check for 1111 1100, xx00 00xx */
- if (c == 0xfc && (*p & 0x3c) == 0) goto utf8_error;
+ if (c == 0xfc && (*p & 0x3c) == 0) { goto utf8_error; }
break;
}
@@ -147,7 +152,7 @@ ptrdiff_t BLI_utf8_invalid_byte(const char *str, size_t length)
while (--ab > 0) {
p++;
length--;
- if ((*p & 0xc0) != 0x80) goto utf8_error;
+ if ((*p & 0xc0) != 0x80) { goto utf8_error; }
}
}
@@ -315,8 +320,9 @@ size_t BLI_strlen_utf8_ex(const char *strc, size_t *r_len_bytes)
size_t len;
const char *strc_orig = strc;
- for (len = 0; *strc; len++)
+ for (len = 0; *strc; len++) {
strc += BLI_str_utf8_size_safe(strc);
+ }
*r_len_bytes = (size_t)(strc - strc_orig);
return len;
@@ -326,8 +332,9 @@ size_t BLI_strlen_utf8(const char *strc)
{
size_t len;
- for (len = 0; *strc; len++)
+ for (len = 0; *strc; len++) {
strc += BLI_str_utf8_size_safe(strc);
+ }
return len;
}
@@ -412,8 +419,9 @@ int BLI_wcswidth(const wchar_t *pwcs, size_t n)
int BLI_str_utf8_char_width(const char *p)
{
uint unicode = BLI_str_utf8_as_unicode(p);
- if (unicode == BLI_UTF8_ERR)
+ if (unicode == BLI_UTF8_ERR) {
return -1;
+ }
return BLI_wcwidth((wchar_t)unicode);
}
@@ -423,8 +431,9 @@ int BLI_str_utf8_char_width_safe(const char *p)
int columns;
uint unicode = BLI_str_utf8_as_unicode(p);
- if (unicode == BLI_UTF8_ERR)
+ if (unicode == BLI_UTF8_ERR) {
return 1;
+ }
columns = BLI_wcwidth((wchar_t)unicode);
@@ -519,7 +528,7 @@ int BLI_str_utf8_size_safe(const char *p)
* instead.
*
* Return value: the resulting character
- **/
+ */
uint BLI_str_utf8_as_unicode(const char *p)
{
int i, len;
@@ -528,8 +537,9 @@ uint BLI_str_utf8_as_unicode(const char *p)
const unsigned char c = (unsigned char) *p;
UTF8_COMPUTE(c, mask, len, -1);
- if (UNLIKELY(len == -1))
+ if (UNLIKELY(len == -1)) {
return BLI_UTF8_ERR;
+ }
UTF8_GET(result, p, i, mask, len, BLI_UTF8_ERR);
return result;
@@ -544,8 +554,9 @@ uint BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t *__restri
const unsigned char c = (unsigned char) *p;
UTF8_COMPUTE(c, mask, len, -1);
- if (UNLIKELY(len == -1))
+ if (UNLIKELY(len == -1)) {
return BLI_UTF8_ERR;
+ }
UTF8_GET(result, p, i, mask, len, BLI_UTF8_ERR);
*index += (size_t)len;
return result;
@@ -625,7 +636,7 @@ uint BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict i
* Converts a single character to UTF-8.
*
* \return number of bytes written
- **/
+ */
size_t BLI_str_utf8_from_unicode(uint c, char *outbuf)
{
/* If this gets modified, also update the copy in g_string_insert_unichar() */
@@ -684,7 +695,7 @@ size_t BLI_str_utf8_from_unicode(uint c, char *outbuf)
* it starts with an appropriate byte.
*
* Return value: a pointer to the found character or %NULL.
- **/
+ */
char *BLI_str_find_prev_char_utf8(const char *str, const char *p)
{
for (--p; p >= str; --p) {
@@ -709,7 +720,7 @@ char *BLI_str_find_prev_char_utf8(const char *str, const char *p)
* it starts with an appropriate byte.
*
* Return value: a pointer to the found character or %NULL
- **/
+ */
char *BLI_str_find_next_char_utf8(const char *p, const char *end)
{
if (*p) {
@@ -740,7 +751,7 @@ char *BLI_str_find_next_char_utf8(const char *p, const char *end)
* character of the string, you must use g_utf8_find_prev_char() instead.
*
* Return value: a pointer to the found character.
- **/
+ */
char *BLI_str_prev_char_utf8(const char *p)
{
while (1) {
@@ -788,8 +799,9 @@ size_t BLI_str_partition_ex_utf8(
for (d = delim; *d != '\0'; ++d) {
if (*d == c) {
/* *suf is already correct in case from_right is true. */
- if (!from_right)
+ if (!from_right) {
*suf = (char *)(str + index);
+ }
return (size_t)(*sep - str);
}
}
diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c
index 3e13b0d3a31..46472d8125d 100644
--- a/source/blender/blenlib/intern/string_utils.c
+++ b/source/blender/blenlib/intern/string_utils.c
@@ -68,8 +68,9 @@ size_t BLI_split_name_num(char *left, int *nr, const char *name, const char deli
left[a] = '\0'; /* truncate left part here */
*nr = atol(name + a + 1);
/* casting down to an int, can overflow for large numbers */
- if (*nr < 0)
+ if (*nr < 0) {
*nr = 0;
+ }
return a;
}
else if (isdigit(name[a]) == 0) {
@@ -368,8 +369,9 @@ bool BLI_uniquename(ListBase *list, void *vlink, const char *defname, char delim
BLI_assert(name_len > 1);
/* See if we are given an empty string */
- if (ELEM(NULL, vlink, defname))
+ if (ELEM(NULL, vlink, defname)) {
return false;
+ }
return BLI_uniquename_cb(uniquename_unique_check, &data, defname, delim, GIVE_STRADDR(vlink, name_offs), name_len);
}
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index e2feef16049..3a6613b2612 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -333,8 +333,9 @@ static void task_pool_num_decrease(TaskPool *pool, size_t done)
pool->num -= done;
- if (pool->num == 0)
+ if (pool->num == 0) {
BLI_condition_notify_all(&pool->num_cond);
+ }
BLI_mutex_unlock(&pool->num_mutex);
}
@@ -354,8 +355,9 @@ static bool task_scheduler_thread_wait_pop(TaskScheduler *scheduler, Task **task
bool found_task = false;
BLI_mutex_lock(&scheduler->queue_mutex);
- while (!scheduler->queue.first && !scheduler->do_exit)
+ while (!scheduler->queue.first && !scheduler->do_exit) {
BLI_condition_wait(&scheduler->queue_cond, &scheduler->queue_mutex);
+ }
do {
Task *current_task;
@@ -391,8 +393,9 @@ static bool task_scheduler_thread_wait_pop(TaskScheduler *scheduler, Task **task
BLI_remlink(&scheduler->queue, *task);
break;
}
- if (!found_task)
+ if (!found_task) {
BLI_condition_wait(&scheduler->queue_cond, &scheduler->queue_mutex);
+ }
} while (!found_task);
BLI_mutex_unlock(&scheduler->queue_mutex);
@@ -525,8 +528,9 @@ void BLI_task_scheduler_free(TaskScheduler *scheduler)
int i;
for (i = 0; i < scheduler->num_threads; i++) {
- if (pthread_join(scheduler->threads[i], NULL) != 0)
+ if (pthread_join(scheduler->threads[i], NULL) != 0) {
fprintf(stderr, "TaskScheduler failed to join thread %d/%d\n", i, scheduler->num_threads);
+ }
}
MEM_freeN(scheduler->threads);
@@ -567,10 +571,12 @@ static void task_scheduler_push(TaskScheduler *scheduler, Task *task, TaskPriori
/* add task to queue */
BLI_mutex_lock(&scheduler->queue_mutex);
- if (priority == TASK_PRIORITY_HIGH)
+ if (priority == TASK_PRIORITY_HIGH) {
BLI_addhead(&scheduler->queue, task);
- else
+ }
+ else {
BLI_addtail(&scheduler->queue, task);
+ }
BLI_condition_notify_one(&scheduler->queue_cond);
BLI_mutex_unlock(&scheduler->queue_mutex);
@@ -908,11 +914,13 @@ void BLI_task_pool_work_and_wait(TaskPool *pool)
}
BLI_mutex_lock(&pool->num_mutex);
- if (pool->num == 0)
+ if (pool->num == 0) {
break;
+ }
- if (!found_task)
+ if (!found_task) {
BLI_condition_wait(&pool->num_cond, &pool->num_mutex);
+ }
}
BLI_mutex_unlock(&pool->num_mutex);
@@ -936,8 +944,9 @@ void BLI_task_pool_cancel(TaskPool *pool)
/* wait until all entries are cleared */
BLI_mutex_lock(&pool->num_mutex);
- while (pool->num)
+ while (pool->num) {
BLI_condition_wait(&pool->num_cond, &pool->num_mutex);
+ }
BLI_mutex_unlock(&pool->num_mutex);
pool->do_cancel = false;
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 89574dd395f..df2e50233d1 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -99,8 +99,9 @@ static TaskScheduler *task_scheduler = NULL;
* }
* // conditions to exit loop
* if (if escape loop event) {
- * if (BLI_available_threadslots(&lb) == maxthreads)
+ * if (BLI_available_threadslots(&lb) == maxthreads) {
* break;
+ * }
* }
* }
*
@@ -188,8 +189,12 @@ void BLI_threadpool_init(ListBase *threadbase, void *(*do_thread)(void *), int t
if (threadbase != NULL && tot > 0) {
BLI_listbase_clear(threadbase);
- if (tot > RE_MAX_THREAD) tot = RE_MAX_THREAD;
- else if (tot < 1) tot = 1;
+ if (tot > RE_MAX_THREAD) {
+ tot = RE_MAX_THREAD;
+ }
+ else if (tot < 1) {
+ tot = 1;
+ }
for (a = 0; a < tot; a++) {
ThreadSlot *tslot = MEM_callocN(sizeof(ThreadSlot), "threadslot");
@@ -219,8 +224,9 @@ int BLI_available_threads(ListBase *threadbase)
int counter = 0;
for (tslot = threadbase->first; tslot; tslot = tslot->next) {
- if (tslot->avail)
+ if (tslot->avail) {
counter++;
+ }
}
return counter;
}
@@ -232,8 +238,9 @@ int BLI_threadpool_available_thread_index(ListBase *threadbase)
int counter = 0;
for (tslot = threadbase->first; tslot; tslot = tslot->next, counter++) {
- if (tslot->avail)
+ if (tslot->avail) {
return counter;
+ }
}
return 0;
}
@@ -527,10 +534,12 @@ void BLI_rw_mutex_init(ThreadRWMutex *mutex)
void BLI_rw_mutex_lock(ThreadRWMutex *mutex, int mode)
{
- if (mode == THREAD_LOCK_READ)
+ if (mode == THREAD_LOCK_READ) {
pthread_rwlock_rdlock(mutex);
- else
+ }
+ else {
pthread_rwlock_wrlock(mutex);
+ }
}
void BLI_rw_mutex_unlock(ThreadRWMutex *mutex)
@@ -588,8 +597,9 @@ void BLI_ticket_mutex_lock(TicketMutex *ticket)
pthread_mutex_lock(&ticket->mutex);
queue_me = ticket->queue_tail++;
- while (queue_me != ticket->queue_head)
+ while (queue_me != ticket->queue_head) {
pthread_cond_wait(&ticket->cond, &ticket->mutex);
+ }
pthread_mutex_unlock(&ticket->mutex);
}
@@ -690,15 +700,17 @@ void *BLI_thread_queue_pop(ThreadQueue *queue)
/* wait until there is work */
pthread_mutex_lock(&queue->mutex);
- while (BLI_gsqueue_is_empty(queue->queue) && !queue->nowait)
+ while (BLI_gsqueue_is_empty(queue->queue) && !queue->nowait) {
pthread_cond_wait(&queue->push_cond, &queue->mutex);
+ }
/* if we have something, pop it */
if (!BLI_gsqueue_is_empty(queue->queue)) {
BLI_gsqueue_pop(queue->queue, &work);
- if (BLI_gsqueue_is_empty(queue->queue))
+ if (BLI_gsqueue_is_empty(queue->queue)) {
pthread_cond_broadcast(&queue->finish_cond);
+ }
}
pthread_mutex_unlock(&queue->mutex);
@@ -753,18 +765,21 @@ void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms)
/* wait until there is work */
pthread_mutex_lock(&queue->mutex);
while (BLI_gsqueue_is_empty(queue->queue) && !queue->nowait) {
- if (pthread_cond_timedwait(&queue->push_cond, &queue->mutex, &timeout) == ETIMEDOUT)
+ if (pthread_cond_timedwait(&queue->push_cond, &queue->mutex, &timeout) == ETIMEDOUT) {
break;
- else if (PIL_check_seconds_timer() - t >= ms * 0.001)
+ }
+ else if (PIL_check_seconds_timer() - t >= ms * 0.001) {
break;
+ }
}
/* if we have something, pop it */
if (!BLI_gsqueue_is_empty(queue->queue)) {
BLI_gsqueue_pop(queue->queue, &work);
- if (BLI_gsqueue_is_empty(queue->queue))
+ if (BLI_gsqueue_is_empty(queue->queue)) {
pthread_cond_broadcast(&queue->finish_cond);
+ }
}
pthread_mutex_unlock(&queue->mutex);
@@ -810,8 +825,9 @@ void BLI_thread_queue_wait_finish(ThreadQueue *queue)
/* wait for finish condition */
pthread_mutex_lock(&queue->mutex);
- while (!BLI_gsqueue_is_empty(queue->queue))
+ while (!BLI_gsqueue_is_empty(queue->queue)) {
pthread_cond_wait(&queue->finish_cond, &queue->mutex);
+ }
pthread_mutex_unlock(&queue->mutex);
}
diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c
index 5ba295cb997..c08f0d5e32b 100644
--- a/source/blender/blenlib/intern/uvproject.c
+++ b/source/blender/blenlib/intern/uvproject.c
@@ -46,8 +46,9 @@ void BLI_uvproject_from_camera(float target[2], float source[3], ProjCameraInfo
pv4[3] = 1.0;
/* rotmat is the object matrix in this case */
- if (uci->do_rotmat)
+ if (uci->do_rotmat) {
mul_m4_v4(uci->rotmat, pv4);
+ }
/* caminv is the inverse camera matrix */
mul_m4_v4(uci->caminv, pv4);
@@ -67,8 +68,9 @@ void BLI_uvproject_from_camera(float target[2], float source[3], ProjCameraInfo
}
}
else {
- if (pv4[2] == 0.0f)
+ if (pv4[2] == 0.0f) {
pv4[2] = 0.00001f; /* don't allow div by 0 */
+ }
if (uci->do_persp == false) {
target[0] = (pv4[0] / uci->camsize);
diff --git a/source/blender/blenlib/intern/voronoi_2d.c b/source/blender/blenlib/intern/voronoi_2d.c
index cf502a33774..248e07eae35 100644
--- a/source/blender/blenlib/intern/voronoi_2d.c
+++ b/source/blender/blenlib/intern/voronoi_2d.c
@@ -136,8 +136,9 @@ static VoronoiParabola *voronoiParabola_getLeftChild(VoronoiParabola *parabola)
{
VoronoiParabola *current_parabola;
- if (!parabola)
+ if (!parabola) {
return NULL;
+ }
current_parabola = parabola->left;
while (!current_parabola->is_leaf) {
@@ -152,8 +153,9 @@ static VoronoiParabola *voronoiParabola_getRightChild(VoronoiParabola *parabola)
{
VoronoiParabola *current_parabola;
- if (!parabola)
+ if (!parabola) {
return NULL;
+ }
current_parabola = parabola->right;
while (!current_parabola->is_leaf) {
@@ -170,8 +172,9 @@ static VoronoiParabola *voronoiParabola_getLeftParent(VoronoiParabola *parabola)
VoronoiParabola *last_parabola = parabola;
while (current_par->left == last_parabola) {
- if (!current_par->parent)
+ if (!current_par->parent) {
return NULL;
+ }
last_parabola = current_par;
current_par = current_par->parent;
@@ -187,8 +190,9 @@ static VoronoiParabola *voronoiParabola_getRightParent(VoronoiParabola *parabola
VoronoiParabola *last_parabola = parabola;
while (current_parabola->right == last_parabola) {
- if (!current_parabola->parent)
+ if (!current_parabola->parent) {
return NULL;
+ }
last_parabola = current_parabola;
current_parabola = current_parabola->parent;
@@ -250,10 +254,12 @@ static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, f
x1 = (-b + sqrtf(disc)) / (2 * a);
x2 = (-b - sqrtf(disc)) / (2 * a);
- if (p[1] < r[1])
+ if (p[1] < r[1]) {
ry = max_ff(x1, x2);
- else
+ }
+ else {
ry = min_ff(x1, x2);
+ }
return ry;
}
@@ -267,10 +273,12 @@ static VoronoiParabola *voronoi_getParabolaByX(VoronoiProcess *process, float xx
while (!par->is_leaf) {
x = voronoi_getXOfEdge(process, par, ly);
- if (x > xx)
+ if (x > xx) {
par = par->left;
- else
+ }
+ else {
par = par->right;
+ }
}
return par;
@@ -281,17 +289,21 @@ static int voronoi_getEdgeIntersection(VoronoiEdge *a, VoronoiEdge *b, float p[2
float x = (b->g - a->g) / (a->f - b->f);
float y = a->f * x + a->g;
- if ((x - a->start[0]) / a->direction[0] < 0)
+ if ((x - a->start[0]) / a->direction[0] < 0) {
return 0;
+ }
- if ((y - a->start[1]) / a->direction[1] < 0)
+ if ((y - a->start[1]) / a->direction[1] < 0) {
return 0;
+ }
- if ((x - b->start[0]) / b->direction[0] < 0)
+ if ((x - b->start[0]) / b->direction[0] < 0) {
return 0;
+ }
- if ((y - b->start[1]) / b->direction[1] < 0)
+ if ((y - b->start[1]) / b->direction[1] < 0) {
return 0;
+ }
p[0] = x;
p[1] = y;
@@ -312,19 +324,22 @@ static void voronoi_checkCircle(VoronoiProcess *process, VoronoiParabola *b)
float ly = process->current_y;
float s[2], dx, dy, d;
- if (!a || !c || len_squared_v2v2(a->site, c->site) < VORONOI_EPS)
+ if (!a || !c || len_squared_v2v2(a->site, c->site) < VORONOI_EPS) {
return;
+ }
- if (!voronoi_getEdgeIntersection(lp->edge, rp->edge, s))
+ if (!voronoi_getEdgeIntersection(lp->edge, rp->edge, s)) {
return;
+ }
dx = a->site[0] - s[0];
dy = a->site[1] - s[1];
d = sqrtf((dx * dx) + (dy * dy));
- if (s[1] - d >= ly)
+ if (s[1] - d >= ly) {
return;
+ }
event = MEM_callocN(sizeof(VoronoiEvent), "voronoi circle event");
@@ -363,10 +378,12 @@ static void voronoi_addParabola(VoronoiProcess *process, float site[2])
s[0] = (site[0] + fp[0]) / 2.0f;
s[1] = process->height;
- if (site[0] > fp[0])
+ if (site[0] > fp[0]) {
root->edge = voronoiEdge_new(s, fp, site);
- else
+ }
+ else {
root->edge = voronoiEdge_new(s, site, fp);
+ }
BLI_addtail(&process->edges, root->edge);
@@ -442,10 +459,12 @@ static void voronoi_removeParabola(VoronoiProcess *process, VoronoiEvent *event)
while (par != process->root) {
par = par->parent;
- if (par == xl)
+ if (par == xl) {
higher = xl;
- if (par == xr)
+ }
+ if (par == xr) {
higher = xr;
+ }
}
higher->edge = voronoiEdge_new(p, p0->site, p2->site);
@@ -453,16 +472,20 @@ static void voronoi_removeParabola(VoronoiProcess *process, VoronoiEvent *event)
gparent = p1->parent->parent;
if (p1->parent->left == p1) {
- if (gparent->left == p1->parent)
+ if (gparent->left == p1->parent) {
voronoiParabola_setLeft(gparent, p1->parent->right);
- if (gparent->right == p1->parent)
+ }
+ if (gparent->right == p1->parent) {
voronoiParabola_setRight(gparent, p1->parent->right);
+ }
}
else {
- if (gparent->left == p1->parent)
+ if (gparent->left == p1->parent) {
voronoiParabola_setLeft(gparent, p1->parent->left);
- if (gparent->right == p1->parent)
+ }
+ if (gparent->right == p1->parent) {
voronoiParabola_setRight(gparent, p1->parent->left);
+ }
}
MEM_freeN(p1->parent);
@@ -481,10 +504,12 @@ static void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabol
return;
}
- if (parabola->edge->direction[0] > 0.0f)
+ if (parabola->edge->direction[0] > 0.0f) {
mx = max_ff(process->width, parabola->edge->start[0] + 10);
- else
+ }
+ else {
mx = min_ff(0.0f, parabola->edge->start[0] - 10.0f);
+ }
parabola->edge->end[0] = mx;
parabola->edge->end[1] = mx * parabola->edge->f + parabola->edge->g;
@@ -513,20 +538,26 @@ static void voronoi_clampEdgeVertex(int width, int height, float *coord, float *
copy_v2_v2(v1, corners[i]);
- if (i == 3)
+ if (i == 3) {
copy_v2_v2(v2, corners[0]);
- else
+ }
+ else {
copy_v2_v2(v2, corners[i + 1]);
+ }
if (isect_seg_seg_v2_point(v1, v2, coord, other_coord, p) == 1) {
- if (i == 0 && coord[1] > p[1])
+ if (i == 0 && coord[1] > p[1]) {
continue;
- if (i == 1 && coord[0] < p[0])
+ }
+ if (i == 1 && coord[0] < p[0]) {
continue;
- if (i == 2 && coord[1] < p[1])
+ }
+ if (i == 2 && coord[1] < p[1]) {
continue;
- if (i == 3 && coord[0] > p[0])
+ }
+ if (i == 3 && coord[0] > p[0]) {
continue;
+ }
copy_v2_v2(coord, p);
}
@@ -630,8 +661,9 @@ static void voronoi_createBoundaryEdges(ListBase *edges, int width, int height)
}
dim = dim ? 0 : 1;
- if (i == 1)
+ if (i == 1) {
dir = -1;
+ }
}
}
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index fb16ccb36bd..483351801f4 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -52,7 +52,9 @@ int BLI_getInstallationDir(char *str)
GetModuleFileName(NULL, str, FILE_MAX);
BLI_split_dir_part(str, dir, sizeof(dir)); /* shouldn't be relative */
a = strlen(dir);
- if (dir[a - 1] == '\\') dir[a - 1] = 0;
+ if (dir[a - 1] == '\\') {
+ dir[a - 1] = 0;
+ }
strcpy(str, dir);
@@ -62,10 +64,12 @@ int BLI_getInstallationDir(char *str)
static void RegisterBlendExtension_Fail(HKEY root)
{
printf("failed\n");
- if (root)
+ if (root) {
RegCloseKey(root);
- if (!G.background)
+ }
+ if (!G.background) {
MessageBox(0, "Could not register file extension.", "Blender error", MB_OK | MB_ICONERROR);
+ }
TerminateProcess(GetCurrentProcess(), 1);
}
@@ -104,8 +108,9 @@ void RegisterBlendExtension(void)
/* try HKCU on failure */
usr_mode = true;
lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root);
- if (lresult != ERROR_SUCCESS)
+ if (lresult != ERROR_SUCCESS) {
RegisterBlendExtension_Fail(0);
+ }
}
lresult = RegCreateKeyEx(root, "blendfile", 0,
@@ -115,8 +120,9 @@ void RegisterBlendExtension(void)
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
- if (lresult != ERROR_SUCCESS)
+ if (lresult != ERROR_SUCCESS) {
RegisterBlendExtension_Fail(root);
+ }
lresult = RegCreateKeyEx(root, "blendfile\\shell\\open\\command", 0,
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
@@ -125,8 +131,9 @@ void RegisterBlendExtension(void)
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
- if (lresult != ERROR_SUCCESS)
+ if (lresult != ERROR_SUCCESS) {
RegisterBlendExtension_Fail(root);
+ }
lresult = RegCreateKeyEx(root, "blendfile\\DefaultIcon", 0,
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
@@ -135,8 +142,9 @@ void RegisterBlendExtension(void)
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
- if (lresult != ERROR_SUCCESS)
+ if (lresult != ERROR_SUCCESS) {
RegisterBlendExtension_Fail(root);
+ }
lresult = RegCreateKeyEx(root, ".blend", 0,
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
@@ -145,8 +153,9 @@ void RegisterBlendExtension(void)
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
- if (lresult != ERROR_SUCCESS)
+ if (lresult != ERROR_SUCCESS) {
RegisterBlendExtension_Fail(root);
+ }
BLI_getInstallationDir(InstallDir);
GetSystemDirectory(SysDir, FILE_MAXDIR);
@@ -154,10 +163,12 @@ void RegisterBlendExtension(void)
ThumbHandlerDLL = "BlendThumb64.dll";
#else
IsWow64Process(GetCurrentProcess(), &IsWOW64);
- if (IsWOW64 == true)
+ if (IsWOW64 == true) {
ThumbHandlerDLL = "BlendThumb64.dll";
- else
+ }
+ else {
ThumbHandlerDLL = "BlendThumb.dll";
+ }
#endif
snprintf(RegCmd, MAX_PATH * 2, "%s\\regsvr32 /s \"%s\\%s\"", SysDir, InstallDir, ThumbHandlerDLL);
system(RegCmd);
diff --git a/source/blender/blenlib/intern/winstuff_dir.c b/source/blender/blenlib/intern/winstuff_dir.c
index 0b3cf07883d..b302eaea9de 100644
--- a/source/blender/blenlib/intern/winstuff_dir.c
+++ b/source/blender/blenlib/intern/winstuff_dir.c
@@ -89,7 +89,9 @@ static char *BLI_alloc_utf_8_from_16(wchar_t *in16, size_t add)
{
size_t bsize = count_utf_8_from_16(in16);
char *out8 = NULL;
- if (!bsize) return NULL;
+ if (!bsize) {
+ return NULL;
+ }
out8 = (char *)MEM_mallocN(sizeof(char) * (bsize + add), "UTF-8 String");
conv_utf_16_to_8(in16, out8, bsize);
return out8;
@@ -99,7 +101,9 @@ static wchar_t *UNUSED_FUNCTION(BLI_alloc_utf16_from_8) (char *in8, size_t add)
{
size_t bsize = count_utf_16_from_8(in8);
wchar_t *out16 = NULL;
- if (!bsize) return NULL;
+ if (!bsize) {
+ return NULL;
+ }
out16 = (wchar_t *) MEM_mallocN(sizeof(wchar_t) * (bsize + add), "UTF-16 String");
conv_utf_8_to_16(in8, out16, bsize);
return out16;
@@ -118,8 +122,9 @@ struct dirent *readdir(DIR *dp)
wchar_t *path_16 = alloc_utf16_from_8(dp->path, 0);
dp->handle = FindFirstFileW(path_16, &(dp->data));
free(path_16);
- if (dp->handle == INVALID_HANDLE_VALUE)
+ if (dp->handle == INVALID_HANDLE_VALUE) {
return NULL;
+ }
dp->direntry.d_name = BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
@@ -137,8 +142,12 @@ struct dirent *readdir(DIR *dp)
int closedir(DIR *dp)
{
- if (dp->direntry.d_name) MEM_freeN(dp->direntry.d_name);
- if (dp->handle != INVALID_HANDLE_VALUE) FindClose(dp->handle);
+ if (dp->direntry.d_name) {
+ MEM_freeN(dp->direntry.d_name);
+ }
+ if (dp->handle != INVALID_HANDLE_VALUE) {
+ FindClose(dp->handle);
+ }
MEM_freeN(dp);
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index c3a1c0e5185..bff35167792 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -138,7 +138,7 @@ void BLO_library_link_end(
struct Main *mainl, BlendHandle **bh, int flag,
struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d);
-void BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh);
+int BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh, const unsigned int id_types_mask);
void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index f36438417ba..4d4a20adbdf 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -70,8 +70,8 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
for (Main *curmain = bmain->next; curmain != NULL; curmain = curmain->next) {
Library *curlib = curmain->curlib;
if (curlib == NULL) {
- BKE_reportf(reports, RPT_ERROR,
- "Library database with NULL library datablock!");
+ BKE_report(reports, RPT_ERROR,
+ "Library database with NULL library datablock!");
continue;
}
@@ -149,29 +149,34 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
/** Check (and fix if needed) that shape key's 'from' pointer is valid. */
bool BLO_main_validate_shapekeys(Main *bmain, ReportList *reports)
{
+ ListBase *lb;
ID *id;
bool is_valid = true;
BKE_main_lock(bmain);
- FOREACH_MAIN_ID_BEGIN(bmain, id)
+ FOREACH_MAIN_LISTBASE_BEGIN(bmain, lb)
{
- if (!BKE_key_idtype_support(GS(id->name))) {
- break;
- }
- if (id->lib == NULL) {
- /* We assume lib data is valid... */
- Key *shapekey = BKE_key_from_id(id);
- if (shapekey != NULL && shapekey->from != id) {
- is_valid = false;
- BKE_reportf(reports, RPT_ERROR,
- "ID %s uses shapekey %s, but its 'from' pointer is invalid (%p), fixing...",
- id->name, shapekey->id.name, shapekey->from);
- shapekey->from = id;
+ FOREACH_MAIN_LISTBASE_ID_BEGIN(lb, id)
+ {
+ if (!BKE_key_idtype_support(GS(id->name))) {
+ break;
+ }
+ if (id->lib == NULL) {
+ /* We assume lib data is valid... */
+ Key *shapekey = BKE_key_from_id(id);
+ if (shapekey != NULL && shapekey->from != id) {
+ is_valid = false;
+ BKE_reportf(reports, RPT_ERROR,
+ "ID %s uses shapekey %s, but its 'from' pointer is invalid (%p), fixing...",
+ id->name, shapekey->id.name, shapekey->from);
+ shapekey->from = id;
+ }
}
}
+ FOREACH_MAIN_LISTBASE_ID_END;
}
- FOREACH_MAIN_ID_END;
+ FOREACH_MAIN_LISTBASE_END;
BKE_main_unlock(bmain);
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 7fcacd8f30e..1cd63c4bdfe 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -200,13 +200,9 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
if (prv) {
memcpy(new_prv, prv, sizeof(PreviewImage));
if (prv->rect[0] && prv->w[0] && prv->h[0]) {
- uint *rect = NULL;
- size_t len = new_prv->w[0] * new_prv->h[0] * sizeof(uint);
- new_prv->rect[0] = MEM_callocN(len, __func__);
bhead = blo_bhead_next(fd, bhead);
- rect = (uint *)(bhead + 1);
- BLI_assert(len == bhead->len);
- memcpy(new_prv->rect[0], rect, len);
+ BLI_assert((new_prv->w[0] * new_prv->h[0] * sizeof(uint)) == bhead->len);
+ new_prv->rect[0] = BLO_library_read_struct(fd, bhead, "PreviewImage Icon Rect");
}
else {
/* This should not be needed, but can happen in 'broken' .blend files,
@@ -217,13 +213,9 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
}
if (prv->rect[1] && prv->w[1] && prv->h[1]) {
- uint *rect = NULL;
- size_t len = new_prv->w[1] * new_prv->h[1] * sizeof(uint);
- new_prv->rect[1] = MEM_callocN(len, __func__);
bhead = blo_bhead_next(fd, bhead);
- rect = (uint *)(bhead + 1);
- BLI_assert(len == bhead->len);
- memcpy(new_prv->rect[1], rect, len);
+ BLI_assert((new_prv->w[1] * new_prv->h[1] * sizeof(uint)) == bhead->len);
+ new_prv->rect[1] = BLO_library_read_struct(fd, bhead, "PreviewImage Image Rect");
}
else {
/* This should not be needed, but can happen in 'broken' .blend files,
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 0907b3caf32..269d91bb042 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -45,10 +45,6 @@
/* allow readfile to use deprecated functionality */
#define DNA_DEPRECATED_ALLOW
-/* Allow using DNA struct members that are marked as private for read/write.
- * Note: Each header that uses this needs to define its own way of handling
- * it. There's no generic implementation, direct use does nothing. */
-#define DNA_PRIVATE_READ_WRITE_ALLOW
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
@@ -265,7 +261,7 @@ typedef struct BHeadN {
struct BHeadN *next, *prev;
#ifdef USE_BHEAD_READ_ON_DEMAND
/** Use to read the data from the file directly into memory as needed. */
- off_t file_offset;
+ off64_t file_offset;
/** When set, the remainder of this allocation is the data, otherwise it needs to be read. */
bool has_data;
#endif
@@ -839,7 +835,7 @@ static BHeadN *get_bhead(FileData *fd)
new_bhead->file_offset = fd->file_offset;
new_bhead->has_data = false;
new_bhead->bhead = bhead;
- off_t seek_new = fd->seek(fd, bhead.len, SEEK_CUR);
+ off64_t seek_new = fd->seek(fd, bhead.len, SEEK_CUR);
if (seek_new == -1) {
fd->is_eof = true;
MEM_freeN(new_bhead);
@@ -947,7 +943,7 @@ static bool blo_bhead_read_data(FileData *fd, BHead *thisblock, void *buf)
bool success = true;
BHeadN *new_bhead = BHEADN_FROM_BHEAD(thisblock);
BLI_assert(new_bhead->has_data == false && new_bhead->file_offset != 0);
- off_t offset_backup = fd->file_offset;
+ off64_t offset_backup = fd->file_offset;
if (UNLIKELY(fd->seek(fd, new_bhead->file_offset, SEEK_SET) == -1)) {
success = false;
}
@@ -1137,7 +1133,7 @@ static int fd_read_data_from_file(FileData *filedata, void *buffer, uint size)
return (readsize);
}
-static off_t fd_seek_data_from_file(FileData *filedata, off_t offset, int whence)
+static off64_t fd_seek_data_from_file(FileData *filedata, off64_t offset, int whence)
{
filedata->file_offset = lseek(filedata->filedes, offset, whence);
return filedata->file_offset;
@@ -2619,7 +2615,16 @@ static void lib_link_brush(FileData *fd, Main *main)
/* link default grease pencil palette */
if (brush->gpencil_settings != NULL) {
- brush->gpencil_settings->material = newlibadr_us(fd, brush->id.lib, brush->gpencil_settings->material);
+ if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
+ brush->gpencil_settings->material = newlibadr_us(fd, brush->id.lib, brush->gpencil_settings->material);
+
+ if (!brush->gpencil_settings->material) {
+ brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
+ }
+ }
+ else {
+ brush->gpencil_settings->material = NULL;
+ }
}
brush->id.tag &= ~LIB_TAG_NEED_LINK;
@@ -3615,10 +3620,14 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
}
}
else if (ntree->type == NTREE_COMPOSIT) {
- if (ELEM(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT))
+ if (ELEM(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT)) {
direct_link_curvemapping(fd, node->storage);
- else if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
- ((ImageUser *)node->storage)->ok = 1;
+ }
+ else if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
+ ImageUser *iuser = node->storage;
+ iuser->ok = 1;
+ iuser->scene = NULL;
+ }
else if (node->type == CMP_NODE_CRYPTOMATTE) {
NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
nc->matte_id = newdataadr(fd, nc->matte_id);
@@ -4581,6 +4590,7 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache)
cache->edit = NULL;
cache->free_edit = NULL;
cache->cached_frames = NULL;
+ cache->cached_frames_len = 0;
}
static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointCache **ocache, int force_disk)
@@ -5454,6 +5464,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
for (md = lb->first; md; md = md->next) {
md->error = NULL;
+ md->runtime = NULL;
/* if modifiers disappear, or for upward compatibility */
if (NULL == modifierType_getInfo(md->type))
@@ -5463,7 +5474,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
SubsurfModifierData *smd = (SubsurfModifierData *)md;
smd->emCache = smd->mCache = NULL;
- smd->subdiv = NULL;
}
else if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData *)md;
@@ -5586,7 +5596,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
if (pmd->canvas) {
pmd->canvas = newdataadr(fd, pmd->canvas);
pmd->canvas->pmd = pmd;
- pmd->canvas->mesh = NULL;
pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
if (pmd->canvas->surfaces.first) {
@@ -5609,7 +5618,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
pmd->brush->psys = newdataadr(fd, pmd->brush->psys);
pmd->brush->paint_ramp = newdataadr(fd, pmd->brush->paint_ramp);
pmd->brush->vel_ramp = newdataadr(fd, pmd->brush->vel_ramp);
- pmd->brush->mesh = NULL;
}
}
else if (md->type == eModifierType_Collision) {
@@ -5779,10 +5787,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
}
}
}
- else if (md->type == eModifierType_Multires) {
- MultiresModifierData *mmd = (MultiresModifierData *)md;
- mmd->subdiv = NULL;
- }
}
}
@@ -6751,15 +6755,13 @@ static void direct_link_scene(FileData *fd, Scene *sce)
seq->strip->stripdata = NULL;
}
if (seq->flag & SEQ_USE_CROP) {
- seq->strip->crop = newdataadr(
- fd, seq->strip->crop);
+ seq->strip->crop = newdataadr(fd, seq->strip->crop);
}
else {
seq->strip->crop = NULL;
}
if (seq->flag & SEQ_USE_TRANSFORM) {
- seq->strip->transform = newdataadr(
- fd, seq->strip->transform);
+ seq->strip->transform = newdataadr(fd, seq->strip->transform);
}
else {
seq->strip->transform = NULL;
@@ -7109,7 +7111,6 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
rv3d->clipbb = newdataadr(fd, rv3d->clipbb);
rv3d->depths = NULL;
- rv3d->gpuoffscreen = NULL;
rv3d->render_engine = NULL;
rv3d->sms = NULL;
rv3d->smooth_timer = NULL;
@@ -10880,16 +10881,13 @@ static void add_loose_objects_to_scene(
base->local_view_bits |= v3d->local_view_uuid;
}
- BKE_scene_object_base_flag_sync_from_base(base);
-
if (flag & FILE_AUTOSELECT) {
- if (base->flag & BASE_SELECTABLE) {
- base->flag |= BASE_SELECTED;
- BKE_scene_object_base_flag_sync_from_base(base);
- }
+ base->flag |= BASE_SELECTED;
/* 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);
+
ob->id.tag &= ~LIB_TAG_INDIRECT;
ob->id.tag |= LIB_TAG_EXTERN;
}
@@ -10901,6 +10899,8 @@ static void add_collections_to_scene(
Main *mainvar, Main *bmain,
Scene *scene, ViewLayer *view_layer, const View3D *v3d, Library *lib, const short flag)
{
+ const bool do_append = (flag & FILE_LINK) == 0;
+
Collection *active_collection = scene->master_collection;
if (flag & FILE_ACTIVE_COLLECTION) {
LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
@@ -10938,8 +10938,11 @@ static void add_collections_to_scene(
ob->transflag |= OB_DUPLICOLLECTION;
copy_v3_v3(ob->loc, scene->cursor.location);
}
- /* We do not want to force instantiation of indirectly linked collections... */
- else if ((collection->id.tag & LIB_TAG_INDIRECT) == 0) {
+ /* 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. */
+ 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.
@@ -10951,7 +10954,7 @@ static void add_collections_to_scene(
Object *ob = coll_ob->ob;
if ((ob->id.tag & LIB_TAG_PRE_EXISTING) == 0 &&
(ob->id.tag & LIB_TAG_DOIT) == 0 &&
- (ob->id.tag & LIB_TAG_INDIRECT) == 0 &&
+ (do_append || (ob->id.tag & LIB_TAG_INDIRECT) == 0) &&
(ob->id.lib == lib) &&
(object_in_any_scene(bmain, ob) == 0))
{
@@ -10964,6 +10967,17 @@ static void add_collections_to_scene(
/* Add collection as child of active collection. */
BKE_collection_child_add(bmain, active_collection, collection);
+ if (flag & FILE_AUTOSELECT) {
+ for (CollectionObject *coll_ob = collection->gobject.first; coll_ob != NULL; coll_ob = coll_ob->next) {
+ Object *ob = coll_ob->ob;
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+ if (base) {
+ base->flag |= BASE_SELECTED;
+ BKE_scene_object_base_flag_sync_from_base(base);
+ }
+ }
+ }
+
collection->id.tag &= ~LIB_TAG_INDIRECT;
collection->id.tag |= LIB_TAG_EXTERN;
}
@@ -11044,21 +11058,25 @@ static ID *link_named_part(
/**
* Simple reader for copy/paste buffers.
*/
-void BLO_library_link_copypaste(Main *mainl, BlendHandle *bh)
+int BLO_library_link_copypaste(Main *mainl, BlendHandle *bh, const unsigned int id_types_mask)
{
FileData *fd = (FileData *)(bh);
BHead *bhead;
+ int num_directly_linked = 0;
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
ID *id = NULL;
if (bhead->code == ENDB)
break;
- if (ELEM(bhead->code, ID_OB, ID_GR)) {
+
+ if (BKE_idcode_is_valid(bhead->code) && BKE_idcode_is_linkable(bhead->code) &&
+ (id_types_mask == 0 || (BKE_idcode_to_idfilter((short)bhead->code) & id_types_mask) != 0))
+ {
read_libblock(fd, mainl, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, &id);
+ num_directly_linked++;
}
-
if (id) {
/* sort by name in list */
ListBase *lb = which_libbase(mainl, GS(id->name));
@@ -11074,6 +11092,8 @@ void BLO_library_link_copypaste(Main *mainl, BlendHandle *bh)
}
}
}
+
+ return num_directly_linked;
}
static ID *link_named_part_ex(
@@ -11137,7 +11157,8 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa
(*fd)->mainlist = MEM_callocN(sizeof(ListBase), "FileData.mainlist");
- /* clear for collection instantiating tag */
+ /* clear for objects and collections instantiating tag */
+ BKE_main_id_tag_listbase(&(mainvar->objects), LIB_TAG_DOIT, false);
BKE_main_id_tag_listbase(&(mainvar->collections), LIB_TAG_DOIT, false);
/* make mains */
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 9e970b9ae5d..42b79a4a3f9 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -48,10 +48,17 @@ enum eFileDataFlag {
FD_FLAGS_NOT_MY_LIBMAP = 1 << 5,
};
+/* Disallow since it's 32bit on ms-windows. */
+#ifdef __GNUC__
+# pragma GCC poison off_t
+#endif
+#if defined(_MSC_VER) || defined(__APPLE__)
+typedef int64_t off64_t;
+#endif
typedef int (FileDataReadFn)(struct FileData *filedata, void *buffer, unsigned int size);
-typedef off_t (FileDataSeekFn)(struct FileData *filedata, off_t offset, int whence);
+typedef off64_t (FileDataSeekFn)(struct FileData *filedata, off64_t offset, int whence);
typedef struct FileData {
/** Linked list of BHeadN's. */
@@ -59,7 +66,7 @@ typedef struct FileData {
enum eFileDataFlag flags;
bool is_eof;
int buffersize;
- off_t file_offset;
+ int64_t file_offset;
FileDataReadFn *read;
FileDataSeekFn *seek;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 3ea9c812d15..5caac97c0d1 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1709,8 +1709,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
br->falloff_angle = DEG2RADF(80);
br->flag &= ~(
- BRUSH_FLAG_DEPRECATED_1 | BRUSH_FLAG_DEPRECATED_6 |
- BRUSH_FLAG_DEPRECATED_7 | BRUSH_FLAG_DEPRECATED_17 |
+ BRUSH_FLAG_UNUSED_1 | BRUSH_FLAG_UNUSED_6 |
+ BRUSH_FLAG_UNUSED_7 | BRUSH_FLAG_UNUSED_17 |
BRUSH_FRONTFACE_FALLOFF);
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index cc4e3d93f25..20a156e99c3 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -197,12 +197,13 @@ static void do_version_workspaces_after_lib_link(Main *bmain)
WorkSpace *workspace = BLI_findstring(&bmain->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
BLI_assert(workspace != NULL);
- ListBase *layouts = BKE_workspace_layouts_get(workspace);
+ WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, win->screen);
+ BLI_assert(layout != NULL);
win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
BKE_workspace_active_set(win->workspace_hook, workspace);
- BKE_workspace_active_layout_set(win->workspace_hook, layouts->first);
+ BKE_workspace_active_layout_set(win->workspace_hook, layout);
/* Move scene and view layer to window. */
Scene *scene = screen->scene;
@@ -1433,7 +1434,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
scene->eevee.flag &= ~_flag; \
} \
} \
- }
+ } ((void)0)
#define EEVEE_GET_INT(_props, _name) \
{ \
@@ -1441,7 +1442,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (_idprop != NULL) { \
scene->eevee._name = IDP_Int(_idprop); \
} \
- }
+ } ((void)0)
#define EEVEE_GET_FLOAT(_props, _name) \
{ \
@@ -1449,7 +1450,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (_idprop != NULL) { \
scene->eevee._name = IDP_Float(_idprop); \
} \
- }
+ } ((void)0)
#define EEVEE_GET_FLOAT_ARRAY(_props, _name, _length) \
{ \
@@ -1460,7 +1461,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
scene->eevee._name [_i] = _values[_i]; \
} \
} \
- }
+ } ((void)0)
IDProperty *props = IDP_GetPropertyFromGroup(scene->layer_properties, RE_engine_id_BLENDER_EEVEE);
EEVEE_GET_BOOL(props, volumetric_enable, SCE_EEVEE_VOLUMETRIC_ENABLED);
@@ -2152,6 +2153,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 28)) {
+ for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
+ BKE_mesh_calc_edges_loose(mesh);
+ }
+ }
+
if (!MAIN_VERSION_ATLEAST(bmain, 280, 29)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
@@ -2506,44 +2513,44 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
SpaceImage *sima = (SpaceImage *)sl;
sima->flag &= ~(
- SI_FLAG_DEPRECATED_0 |
- SI_FLAG_DEPRECATED_1 |
- SI_FLAG_DEPRECATED_3 |
- SI_FLAG_DEPRECATED_6 |
- SI_FLAG_DEPRECATED_7 |
- SI_FLAG_DEPRECATED_8 |
- SI_FLAG_DEPRECATED_17 |
- SI_FLAG_DEPRECATED_18 |
- SI_FLAG_DEPRECATED_23 |
- SI_FLAG_DEPRECATED_24);
+ SI_FLAG_UNUSED_0 |
+ SI_FLAG_UNUSED_1 |
+ SI_FLAG_UNUSED_3 |
+ SI_FLAG_UNUSED_6 |
+ SI_FLAG_UNUSED_7 |
+ SI_FLAG_UNUSED_8 |
+ SI_FLAG_UNUSED_17 |
+ SI_FLAG_UNUSED_18 |
+ SI_FLAG_UNUSED_23 |
+ SI_FLAG_UNUSED_24);
break;
}
case SPACE_VIEW3D:
{
View3D *v3d = (View3D *)sl;
v3d->flag &= ~(
- V3D_FLAG_DEPRECATED_0 |
- V3D_FLAG_DEPRECATED_1 |
- V3D_FLAG_DEPRECATED_10 |
- V3D_FLAG_DEPRECATED_12);
+ V3D_FLAG_UNUSED_0 |
+ V3D_FLAG_UNUSED_1 |
+ V3D_FLAG_UNUSED_10 |
+ V3D_FLAG_UNUSED_12);
v3d->flag2 &= ~(
- V3D_FLAG2_DEPRECATED_3 |
- V3D_FLAG2_DEPRECATED_6 |
- V3D_FLAG2_DEPRECATED_12 |
- V3D_FLAG2_DEPRECATED_13 |
- V3D_FLAG2_DEPRECATED_14 |
- V3D_FLAG2_DEPRECATED_15);
+ V3D_FLAG2_UNUSED_3 |
+ V3D_FLAG2_UNUSED_6 |
+ V3D_FLAG2_UNUSED_12 |
+ V3D_FLAG2_UNUSED_13 |
+ V3D_FLAG2_UNUSED_14 |
+ V3D_FLAG2_UNUSED_15);
break;
}
case SPACE_OUTLINER:
{
SpaceOutliner *so = (SpaceOutliner *)sl;
so->filter &= ~(
- SO_FILTER_DEPRECATED_1 |
- SO_FILTER_DEPRECATED_5 |
- SO_FILTER_DEPRECATED_12);
+ SO_FILTER_UNUSED_1 |
+ SO_FILTER_UNUSED_5 |
+ SO_FILTER_UNUSED_12);
so->storeflag &= ~(
- SO_TREESTORE_DEPRECATED_1);
+ SO_TREESTORE_UNUSED_1);
break;
}
case SPACE_FILE:
@@ -2551,9 +2558,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
SpaceFile *sfile = (SpaceFile *)sl;
if (sfile->params) {
sfile->params->flag &= ~(
- FILE_PARAMS_FLAG_DEPRECATED_1 |
- FILE_PARAMS_FLAG_DEPRECATED_6 |
- FILE_PARAMS_FLAG_DEPRECATED_9);
+ FILE_PARAMS_FLAG_UNUSED_1 |
+ FILE_PARAMS_FLAG_UNUSED_6 |
+ FILE_PARAMS_FLAG_UNUSED_9);
}
break;
}
@@ -2561,26 +2568,26 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
SpaceNode *snode = (SpaceNode *)sl;
snode->flag &= ~(
- SNODE_FLAG_DEPRECATED_6 |
- SNODE_FLAG_DEPRECATED_10 |
- SNODE_FLAG_DEPRECATED_11);
+ SNODE_FLAG_UNUSED_6 |
+ SNODE_FLAG_UNUSED_10 |
+ SNODE_FLAG_UNUSED_11);
break;
}
case SPACE_PROPERTIES:
{
SpaceProperties *sbuts = (SpaceProperties *)sl;
sbuts->flag &= ~(
- SB_FLAG_DEPRECATED_2 |
- SB_FLAG_DEPRECATED_3);
+ SB_FLAG_UNUSED_2 |
+ SB_FLAG_UNUSED_3);
break;
}
case SPACE_NLA:
{
SpaceNla *snla = (SpaceNla *)sl;
snla->flag &= ~(
- SNLA_FLAG_DEPRECATED_0 |
- SNLA_FLAG_DEPRECATED_1 |
- SNLA_FLAG_DEPRECATED_3);
+ SNLA_FLAG_UNUSED_0 |
+ SNLA_FLAG_UNUSED_1 |
+ SNLA_FLAG_UNUSED_3);
break;
}
}
@@ -2590,37 +2597,37 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->r.mode &= ~(
- R_MODE_DEPRECATED_1 |
- R_MODE_DEPRECATED_2 |
- R_MODE_DEPRECATED_3 |
- R_MODE_DEPRECATED_4 |
- R_MODE_DEPRECATED_5 |
- R_MODE_DEPRECATED_6 |
- R_MODE_DEPRECATED_7 |
- R_MODE_DEPRECATED_8 |
- R_MODE_DEPRECATED_10 |
- R_MODE_DEPRECATED_13 |
- R_MODE_DEPRECATED_16 |
- R_MODE_DEPRECATED_17 |
- R_MODE_DEPRECATED_18 |
- R_MODE_DEPRECATED_19 |
- R_MODE_DEPRECATED_20 |
- R_MODE_DEPRECATED_21 |
- R_MODE_DEPRECATED_27);
+ R_MODE_UNUSED_1 |
+ R_MODE_UNUSED_2 |
+ R_MODE_UNUSED_3 |
+ R_MODE_UNUSED_4 |
+ R_MODE_UNUSED_5 |
+ R_MODE_UNUSED_6 |
+ R_MODE_UNUSED_7 |
+ R_MODE_UNUSED_8 |
+ R_MODE_UNUSED_10 |
+ R_MODE_UNUSED_13 |
+ R_MODE_UNUSED_16 |
+ R_MODE_UNUSED_17 |
+ R_MODE_UNUSED_18 |
+ R_MODE_UNUSED_19 |
+ R_MODE_UNUSED_20 |
+ R_MODE_UNUSED_21 |
+ R_MODE_UNUSED_27);
scene->r.scemode &= ~(
- R_SCEMODE_DEPRECATED_8 |
- R_SCEMODE_DEPRECATED_11 |
- R_SCEMODE_DEPRECATED_13 |
- R_SCEMODE_DEPRECATED_16 |
- R_SCEMODE_DEPRECATED_17 |
- R_SCEMODE_DEPRECATED_19);
+ R_SCEMODE_UNUSED_8 |
+ R_SCEMODE_UNUSED_11 |
+ R_SCEMODE_UNUSED_13 |
+ R_SCEMODE_UNUSED_16 |
+ R_SCEMODE_UNUSED_17 |
+ R_SCEMODE_UNUSED_19);
if (scene->toolsettings->sculpt) {
scene->toolsettings->sculpt->flags &= ~(
- SCULPT_FLAG_DEPRECATED_0 |
- SCULPT_FLAG_DEPRECATED_1 |
- SCULPT_FLAG_DEPRECATED_2);
+ SCULPT_FLAG_UNUSED_0 |
+ SCULPT_FLAG_UNUSED_1 |
+ SCULPT_FLAG_UNUSED_2);
}
if (scene->ed) {
@@ -2628,14 +2635,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
SEQ_BEGIN (scene->ed, seq)
{
seq->flag &= ~(
- SEQ_FLAG_DEPRECATED_6 |
- SEQ_FLAG_DEPRECATED_18 |
- SEQ_FLAG_DEPRECATED_19 |
- SEQ_FLAG_DEPRECATED_21);
+ SEQ_FLAG_UNUSED_6 |
+ SEQ_FLAG_UNUSED_18 |
+ SEQ_FLAG_UNUSED_19 |
+ SEQ_FLAG_UNUSED_21);
if (seq->type == SEQ_TYPE_SPEED) {
SpeedControlVars *s = (SpeedControlVars *)seq->effectdata;
s->flags &= ~(
- SEQ_SPEED_DEPRECATED_1);
+ SEQ_SPEED_UNUSED_1);
}
} SEQ_END;
}
@@ -2643,49 +2650,49 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (World *world = bmain->worlds.first; world; world = world->id.next) {
world->flag &= ~(
- WO_MODE_DEPRECATED_1 |
- WO_MODE_DEPRECATED_2 |
- WO_MODE_DEPRECATED_3 |
- WO_MODE_DEPRECATED_4 |
- WO_MODE_DEPRECATED_5 |
- WO_MODE_DEPRECATED_7);
+ WO_MODE_UNUSED_1 |
+ WO_MODE_UNUSED_2 |
+ WO_MODE_UNUSED_3 |
+ WO_MODE_UNUSED_4 |
+ WO_MODE_UNUSED_5 |
+ WO_MODE_UNUSED_7);
}
for (Image *image = bmain->images.first; image; image = image->id.next) {
image->flag &= ~(
- IMA_FLAG_DEPRECATED_0 |
- IMA_FLAG_DEPRECATED_1 |
- IMA_FLAG_DEPRECATED_4 |
- IMA_FLAG_DEPRECATED_6 |
- IMA_FLAG_DEPRECATED_8 |
- IMA_FLAG_DEPRECATED_15 |
- IMA_FLAG_DEPRECATED_16);
+ IMA_FLAG_UNUSED_0 |
+ IMA_FLAG_UNUSED_1 |
+ IMA_FLAG_UNUSED_4 |
+ IMA_FLAG_UNUSED_6 |
+ IMA_FLAG_UNUSED_8 |
+ IMA_FLAG_UNUSED_15 |
+ IMA_FLAG_UNUSED_16);
}
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
ob->flag &= ~(
- OB_FLAG_DEPRECATED_11 |
- OB_FLAG_DEPRECATED_12);
+ OB_FLAG_UNUSED_11 |
+ OB_FLAG_UNUSED_12);
ob->transflag &= ~(
- OB_TRANSFLAG_DEPRECATED_0 |
- OB_TRANSFLAG_DEPRECATED_1);
- ob->shapeflag &= ~OB_SHAPE_FLAG_DEPRECATED_1;
+ OB_TRANSFLAG_UNUSED_0 |
+ OB_TRANSFLAG_UNUSED_1);
+ ob->shapeflag &= ~OB_SHAPE_FLAG_UNUSED_1;
}
for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
me->flag &= ~(
- ME_FLAG_DEPRECATED_0 |
- ME_FLAG_DEPRECATED_1 |
- ME_FLAG_DEPRECATED_3 |
- ME_FLAG_DEPRECATED_4 |
- ME_FLAG_DEPRECATED_6 |
- ME_FLAG_DEPRECATED_7 |
- ME_FLAG_DEPRECATED_8);
+ ME_FLAG_UNUSED_0 |
+ ME_FLAG_UNUSED_1 |
+ ME_FLAG_UNUSED_3 |
+ ME_FLAG_UNUSED_4 |
+ ME_FLAG_UNUSED_6 |
+ ME_FLAG_UNUSED_7 |
+ ME_FLAG_UNUSED_8);
}
for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
mat->blend_flag &= ~(
- MA_BL_FLAG_DEPRECATED_2);
+ MA_BL_FLAG_UNUSED_2);
}
}
@@ -2798,17 +2805,17 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
R_ALPHAKEY = 2,
};
scene->r.seq_flag &= ~(
- R_SEQ_DEPRECATED_0 |
- R_SEQ_DEPRECATED_1 |
- R_SEQ_DEPRECATED_2);
- scene->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT_DEPRECATED_1;
+ R_SEQ_UNUSED_0 |
+ R_SEQ_UNUSED_1 |
+ R_SEQ_UNUSED_2);
+ scene->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT_UNUSED_1;
if (scene->r.alphamode == R_ALPHAKEY) {
scene->r.alphamode = R_ADDSKY;
}
ToolSettings *ts = scene->toolsettings;
- ts->particle.flag &= ~PE_DEPRECATED_6;
+ ts->particle.flag &= ~PE_UNUSED_6;
if (ts->sculpt != NULL) {
- ts->sculpt->flags &= ~SCULPT_FLAG_DEPRECATED_6;
+ ts->sculpt->flags &= ~SCULPT_FLAG_UNUSED_6;
}
}
}
@@ -2876,26 +2883,113 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
ob->transflag &= ~(
- OB_TRANSFLAG_DEPRECATED_0 |
- OB_TRANSFLAG_DEPRECATED_1 |
- OB_TRANSFLAG_DEPRECATED_3 |
- OB_TRANSFLAG_DEPRECATED_6 |
- OB_TRANSFLAG_DEPRECATED_12);
+ OB_TRANSFLAG_UNUSED_0 |
+ OB_TRANSFLAG_UNUSED_1 |
+ OB_TRANSFLAG_UNUSED_3 |
+ OB_TRANSFLAG_UNUSED_6 |
+ OB_TRANSFLAG_UNUSED_12);
- ob->nlaflag &= ~(OB_ADS_DEPRECATED_1 | OB_ADS_DEPRECATED_2);
+ ob->nlaflag &= ~(OB_ADS_UNUSED_1 | OB_ADS_UNUSED_2);
}
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
arm->flag &= ~(
- ARM_FLAG_DEPRECATED_1 |
- ARM_FLAG_DEPRECATED_5 |
- ARM_FLAG_DEPRECATED_7 |
- ARM_FLAG_DEPRECATED_12);
+ ARM_FLAG_UNUSED_1 |
+ ARM_FLAG_UNUSED_5 |
+ ARM_FLAG_UNUSED_7 |
+ ARM_FLAG_UNUSED_12);
}
LISTBASE_FOREACH (Text *, text, &bmain->texts) {
- enum { TXT_READONLY = 1 << 8, TXT_FOLLOW = 1 << 9};
- text->flags &= ~(TXT_READONLY | TXT_FOLLOW);
+ text->flags &= ~(TXT_FLAG_UNUSED_8 | TXT_FLAG_UNUSED_9);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 48)) {
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ /* Those are not currently used, but are accessible through RNA API and were not
+ * properly initialized previously. This is mere copy of BKE_init_scene() code. */
+ if (scene->r.im_format.view_settings.look[0] == '\0') {
+ BKE_color_managed_display_settings_init(&scene->r.im_format.display_settings);
+ BKE_color_managed_view_settings_init_render(&scene->r.im_format.view_settings,
+ &scene->r.im_format.display_settings,
+ "Filmic");
+ }
+
+ if (scene->r.bake.im_format.view_settings.look[0] == '\0') {
+ BKE_color_managed_display_settings_init(&scene->r.bake.im_format.display_settings);
+ BKE_color_managed_view_settings_init_render(&scene->r.bake.im_format.view_settings,
+ &scene->r.bake.im_format.display_settings,
+ "Filmic");
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 49)) {
+ /* All tool names changed, reset to defaults. */
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
+ while (!BLI_listbase_is_empty(&workspace->tools)) {
+ BKE_workspace_tool_remove(workspace, workspace->tools.first);
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 52)) {
+ LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
+ /* Replace deprecated PART_DRAW_BB by PART_DRAW_NOT */
+ if (part->ren_as == PART_DRAW_BB) {
+ part->ren_as = PART_DRAW_NOT;
+ }
+ if (part->draw_as == PART_DRAW_BB) {
+ part->draw_as = PART_DRAW_NOT;
+ }
+ }
+
+ if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "min_vertices")) {
+ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+ for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Triangulate) {
+ TriangulateModifierData *smd = (TriangulateModifierData *)md;
+ smd->min_vertices = 4;
+ }
+ }
+ }
+ }
+
+ FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ /* Fix missing version patching from earlier changes. */
+ if (STREQ(node->idname, "ShaderNodeOutputLamp")) {
+ STRNCPY(node->idname, "ShaderNodeOutputLight");
+ }
+ if (node->type == SH_NODE_BSDF_PRINCIPLED && node->custom2 == 0) {
+ node->custom2 = SHD_SUBSURFACE_BURLEY;
+ }
+ }
+ }
+ } FOREACH_NODETREE_END;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 53)) {
+ for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) {
+ /* Eevee: Keep material appearance consistent with previous behavior. */
+ if (!mat->use_nodes || !mat->nodetree || mat->blend_method == MA_BM_SOLID) {
+ mat->blend_shadow = MA_BS_SOLID;
+ }
+ }
+
+ /* grease pencil default animation channel color */
+ {
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ if (gpd->flag & GP_DATA_ANNOTATIONS) {
+ continue;
+ }
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* default channel color */
+ ARRAY_SET_ITEMS(gpl->color, 0.2f, 0.2f, 0.2f);
+ }
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 1f8bf3724db..973057fa362 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -69,7 +69,12 @@ void BLO_update_defaults_userpref_blend(void)
#endif
/* Clear addon preferences. */
- for (bAddon *addon = U.addons.first; addon; addon = addon->next) {
+ for (bAddon *addon = U.addons.first, *addon_next;
+ addon != NULL;
+ addon = addon_next)
+ {
+ addon_next = addon->next;
+
if (addon->prop) {
IDP_FreeProperty(addon->prop);
MEM_freeN(addon->prop);
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index ef0cd7bc7d5..025bfc55569 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -52,7 +52,7 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme)
}
#define FROM_DEFAULT_V4_UCHAR(member) \
- copy_v4_v4_char(btheme->member, U_theme_default.member);
+ copy_v4_v4_char(btheme->member, U_theme_default.member)
if (!USER_VERSION_ATLEAST(280, 25)) {
copy_v4_v4_char(btheme->space_action.anim_preview_range, btheme->space_action.anim_active);
@@ -110,6 +110,10 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme)
FROM_DEFAULT_V4_UCHAR(space_view3d.back);
}
+ if (!USER_VERSION_ATLEAST(280, 52)) {
+ FROM_DEFAULT_V4_UCHAR(space_info.info_info);
+ }
+
#undef FROM_DEFAULT_V4_UCHAR
#undef USER_VERSION_ATLEAST
@@ -356,14 +360,14 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
if (!USER_VERSION_ATLEAST(278, 6)) {
/* Clear preference flags for re-use. */
userdef->flag &= ~(
- USER_FLAG_NUMINPUT_ADVANCED | USER_FLAG_DEPRECATED_2 | USER_FLAG_DEPRECATED_3 |
- USER_FLAG_DEPRECATED_6 | USER_FLAG_DEPRECATED_7 |
- USER_FLAG_DEPRECATED_9 | USER_DEVELOPER_UI);
+ USER_FLAG_NUMINPUT_ADVANCED | USER_FLAG_UNUSED_2 | USER_FLAG_UNUSED_3 |
+ USER_FLAG_UNUSED_6 | USER_FLAG_UNUSED_7 |
+ USER_FLAG_UNUSED_9 | USER_DEVELOPER_UI);
userdef->uiflag &= ~(
USER_HEADER_BOTTOM);
userdef->transopts &= ~(
- USER_TR_DEPRECATED_2 | USER_TR_DEPRECATED_3 | USER_TR_DEPRECATED_4 |
- USER_TR_DEPRECATED_6 | USER_TR_DEPRECATED_7);
+ USER_TR_UNUSED_2 | USER_TR_UNUSED_3 | USER_TR_UNUSED_4 |
+ USER_TR_UNUSED_6 | USER_TR_UNUSED_7);
userdef->uiflag |= USER_LOCK_CURSOR_ADJUST;
}
@@ -448,15 +452,15 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
userdef->light_param[3].flag = 1;
userdef->light_param[3].smooth = 0.7;
- copy_v4_fl4(userdef->light_ambient, 0.025000, 0.025000, 0.025000, 1.000000);
+ copy_v3_fl3(userdef->light_ambient, 0.025000, 0.025000, 0.025000);
userdef->flag &= ~(
- USER_FLAG_DEPRECATED_4);
+ USER_FLAG_UNUSED_4);
userdef->uiflag &= ~(
USER_HEADER_FROM_PREF |
- USER_UIFLAG_DEPRECATED_12 |
- USER_UIFLAG_DEPRECATED_22);
+ USER_UIFLAG_UNUSED_12 |
+ USER_UIFLAG_UNUSED_22);
}
if (!USER_VERSION_ATLEAST(280, 41)) {
@@ -469,15 +473,20 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
if (!USER_VERSION_ATLEAST(280, 44)) {
userdef->uiflag &= ~(
- USER_UIFLAG_DEPRECATED_0 | USER_UIFLAG_DEPRECATED_1);
+ USER_UIFLAG_UNUSED_0 | USER_UIFLAG_UNUSED_1);
userdef->uiflag2 &= ~(
- USER_UIFLAG2_DEPRECATED_0);
+ USER_UIFLAG2_UNUSED_0);
userdef->gp_settings &= ~(
- GP_PAINT_DEPRECATED_0);
+ GP_PAINT_UNUSED_0);
}
- if (!USER_VERSION_ATLEAST(280, 46)) {
- userdef->uiflag2 |= USER_EDIT_MODE_SMOOTH_WIRE;
+ if (!USER_VERSION_ATLEAST(280, 50)) {
+ /* 3ds is no longer enabled by default and not ported yet. */
+ BKE_addon_remove_safe(&userdef->addons, "io_scene_3ds");
+ }
+
+ if (!USER_VERSION_ATLEAST(280, 51)) {
+ userdef->move_threshold = 2;
}
/**
@@ -493,9 +502,6 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
if (userdef->image_draw_method == 0)
userdef->image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
- // we default to the first audio device
- userdef->audiodevice = 0;
-
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 5c038d698b4..374085571ea 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -93,10 +93,6 @@
/* allow writefile to use deprecated functionality (for forward compatibility code) */
#define DNA_DEPRECATED_ALLOW
-/* Allow using DNA struct members that are marked as private for read/write.
- * Note: Each header that uses this needs to define its own way of handling
- * it. There's no generic implementation, direct use does nothing. */
-#define DNA_PRIVATE_READ_WRITE_ALLOW
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
@@ -1423,9 +1419,10 @@ static void write_particlesettings(WriteData *wd, ParticleSettings *part)
if (part->instance_collection) { /* can be NULL if lining fails or set to None */
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(part->instance_collection, object)
{
- if (object != dw->ob) {
- dw->index++;
+ if (object == dw->ob) {
+ break;
}
+ dw->index++;
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index fba71b20e7c..c24a5b21b6c 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -737,7 +737,9 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
ftable[i] = f_new;
- if (f == bm_old->act_face) bm_new->act_face = f_new;
+ if (f == bm_old->act_face) {
+ bm_new->act_face = f_new;
+ }
}
bm_old->elem_index_dirty &= ~BM_FACE;
bm_new->elem_index_dirty &= ~BM_FACE;
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index eead30bcd24..58b83cd0586 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -152,8 +152,9 @@ BMEdge *BM_edge_create(
BLI_assert((e_example == NULL) || (e_example->head.htype == BM_EDGE));
BLI_assert(!(create_flag & 1));
- if ((create_flag & BM_CREATE_NO_DOUBLE) && (e = BM_edge_exists(v1, v2)))
+ if ((create_flag & BM_CREATE_NO_DOUBLE) && (e = BM_edge_exists(v1, v2))) {
return e;
+ }
e = BLI_mempool_alloc(bm->epool);
@@ -554,11 +555,13 @@ int bmesh_elem_check(void *element, const char htype)
IS_FACE_WRONG_LENGTH = (1 << 26),
} err = 0;
- if (!element)
+ if (!element) {
return IS_NULL;
+ }
- if (head->htype != htype)
+ if (head->htype != htype) {
return IS_WRONG_TYPE;
+ }
switch (htype) {
case BM_VERT:
@@ -748,8 +751,9 @@ static void bm_kill_only_vert(BMesh *bm, BMVert *v)
BM_select_history_remove(bm, v);
- if (v->head.data)
+ if (v->head.data) {
CustomData_bmesh_free_block(&bm->vdata, &v->head.data);
+ }
if (bm->vtoolflagpool) {
BLI_mempool_free(bm->vtoolflagpool, ((BMVert_OFlag *)v)->oflags);
@@ -769,8 +773,9 @@ static void bm_kill_only_edge(BMesh *bm, BMEdge *e)
BM_select_history_remove(bm, (BMElem *)e);
- if (e->head.data)
+ if (e->head.data) {
CustomData_bmesh_free_block(&bm->edata, &e->head.data);
+ }
if (bm->etoolflagpool) {
BLI_mempool_free(bm->etoolflagpool, ((BMEdge_OFlag *)e)->oflags);
@@ -784,8 +789,9 @@ static void bm_kill_only_edge(BMesh *bm, BMEdge *e)
*/
static void bm_kill_only_face(BMesh *bm, BMFace *f)
{
- if (bm->act_face == f)
+ if (bm->act_face == f) {
bm->act_face = NULL;
+ }
bm->totface--;
bm->elem_index_dirty |= BM_FACE;
@@ -793,8 +799,9 @@ static void bm_kill_only_face(BMesh *bm, BMFace *f)
BM_select_history_remove(bm, (BMElem *)f);
- if (f->head.data)
+ if (f->head.data) {
CustomData_bmesh_free_block(&bm->pdata, &f->head.data);
+ }
if (bm->ftoolflagpool) {
BLI_mempool_free(bm->ftoolflagpool, ((BMFace_OFlag *)f)->oflags);
@@ -810,8 +817,9 @@ static void bm_kill_only_loop(BMesh *bm, BMLoop *l)
{
bm->totloop--;
bm->elem_index_dirty |= BM_LOOP;
- if (l->head.data)
+ if (l->head.data) {
CustomData_bmesh_free_block(&bm->ldata, &l->head.data);
+ }
BLI_mempool_free(bm->lpool, l);
}
@@ -1128,8 +1136,9 @@ static int UNUSED_FUNCTION(bm_vert_systag_count_disk)(BMVert *v, const char api_
BMEdge *e = v->e;
int i = 0;
- if (!e)
+ if (!e) {
return 0;
+ }
do {
i += BM_ELEM_API_FLAG_TEST(e, api_flag) ? 1 : 0;
@@ -1146,8 +1155,9 @@ static bool bm_vert_is_manifold_flagged(BMVert *v, const char api_flag)
{
BMEdge *e = v->e;
- if (!e)
+ if (!e) {
return false;
+ }
do {
BMLoop *l = e->l;
@@ -1161,8 +1171,9 @@ static bool bm_vert_is_manifold_flagged(BMVert *v, const char api_flag)
}
do {
- if (!BM_ELEM_API_FLAG_TEST(l->f, api_flag))
+ if (!BM_ELEM_API_FLAG_TEST(l->f, api_flag)) {
return false;
+ }
} while ((l = l->radial_next) != e->l);
} while ((e = bmesh_disk_edge_next(e, v)) != v->e);
@@ -1209,8 +1220,9 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const bool do_del)
return NULL;
}
- if (totface == 1)
+ if (totface == 1) {
return faces[0];
+ }
bm_elements_systag_enable(faces, totface, _FLAG_JF);
@@ -1291,8 +1303,9 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const bool do_del)
BMLoop *l2 = l_iter->radial_next;
do {
- if (BM_ELEM_API_FLAG_TEST(l2->f, _FLAG_JF))
+ if (BM_ELEM_API_FLAG_TEST(l2->f, _FLAG_JF)) {
break;
+ }
l2 = l2->radial_next;
} while (l2 != l_iter);
@@ -1486,31 +1499,38 @@ BMFace *bmesh_kernel_split_face_make_edge(
l_iter = l_first = l_f1;
first_loop_f1 = 0;
do {
- if (l_iter == f->l_first)
+ if (l_iter == f->l_first) {
first_loop_f1 = 1;
+ }
} while ((l_iter = l_iter->next) != l_first);
if (first_loop_f1) {
/* original first loop was in f1, find a suitable first loop for f2
* which is as similar as possible to f1. the order matters for tools
* such as duplifaces. */
- if (f->l_first->prev == l_f1)
+ if (f->l_first->prev == l_f1) {
f2->l_first = l_f2->prev;
- else if (f->l_first->next == l_f1)
+ }
+ else if (f->l_first->next == l_f1) {
f2->l_first = l_f2->next;
- else
+ }
+ else {
f2->l_first = l_f2;
+ }
}
else {
/* original first loop was in f2, further do same as above */
f2->l_first = f->l_first;
- if (f->l_first->prev == l_f2)
+ if (f->l_first->prev == l_f2) {
f->l_first = l_f1->prev;
- else if (f->l_first->next == l_f2)
+ }
+ else if (f->l_first->next == l_f2) {
f->l_first = l_f1->next;
- else
+ }
+ else {
f->l_first = l_f1;
+ }
}
#endif
@@ -1539,7 +1559,9 @@ BMFace *bmesh_kernel_split_face_make_edge(
f->len = f1len;
- if (r_l) *r_l = l_f2;
+ if (r_l) {
+ *r_l = l_f2;
+ }
#ifdef USE_BMESH_HOLES
if (holes) {
@@ -1728,7 +1750,9 @@ BMVert *bmesh_kernel_split_edge_make_vert(BMesh *bm, BMVert *tv, BMEdge *e, BMEd
BM_CHECK_ELEMENT(e);
BM_CHECK_ELEMENT(tv);
- if (r_e) *r_e = e_new;
+ if (r_e) {
+ *r_e = e_new;
+ }
return v_new;
}
@@ -2123,16 +2147,18 @@ BMFace *bmesh_kernel_join_face_kill_edge(BMesh *bm, BMFace *f1, BMFace *f2, BMEd
l_f2->prev->next = l_f1->next;
/* if l_f1 was baseloop, make l_f1->next the base. */
- if (BM_FACE_FIRST_LOOP(f1) == l_f1)
+ if (BM_FACE_FIRST_LOOP(f1) == l_f1) {
BM_FACE_FIRST_LOOP(f1) = l_f1->next;
+ }
/* increase length of f1 */
f1->len += (f2->len - 2);
/* make sure each loop points to the proper face */
newlen = f1->len;
- for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f1); i < newlen; i++, l_iter = l_iter->next)
+ for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f1); i < newlen; i++, l_iter = l_iter->next) {
l_iter->f = f1;
+ }
/* remove edge from the disk cycle of its two vertices */
bmesh_disk_edge_remove(l_f1->e, l_f1->e->v1);
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index 7bd86922df2..1f8661c3e04 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -471,8 +471,9 @@ void BM_mesh_edgeloops_calc_order(BMesh *UNUSED(bm), ListBase *eloops, const boo
const float *no = ((BMEdgeLoopStore *)eloops_ordered.last)->no;
float len_best_sq = FLT_MAX;
- if (use_normals)
+ if (use_normals) {
BLI_ASSERT_UNIT_V3(no);
+ }
for (el_store = eloops->first; el_store; el_store = el_store->next) {
float len_sq;
@@ -619,8 +620,9 @@ void BM_edgeloop_calc_center(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store)
v_next = NODE_AS_CO(node_next);
} while (1);
- if (totw != 0.0f)
+ if (totw != 0.0f) {
mul_v3_fl(el_store->co, 1.0f / (float) totw);
+ }
}
diff --git a/source/blender/bmesh/intern/bmesh_inline.h b/source/blender/bmesh/intern/bmesh_inline.h
index 39657f1c32e..549fc90fe40 100644
--- a/source/blender/bmesh/intern/bmesh_inline.h
+++ b/source/blender/bmesh/intern/bmesh_inline.h
@@ -58,8 +58,8 @@ BLI_INLINE void _bm_elem_flag_disable(BMHeader *head, const char hflag)
BLI_INLINE void _bm_elem_flag_set(BMHeader *head, const char hflag, const int val)
{
- if (val) _bm_elem_flag_enable(head, hflag);
- else _bm_elem_flag_disable(head, hflag);
+ if (val) { _bm_elem_flag_enable(head, hflag); }
+ else { _bm_elem_flag_disable(head, hflag); }
}
BLI_INLINE void _bm_elem_flag_toggle(BMHeader *head, const char hflag)
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index 655772b49ac..11d6df430c3 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -177,8 +177,9 @@ void BM_face_interp_from_face_ex(
float co[2];
int i;
- if (f_src != f_dst)
+ if (f_src != f_dst) {
BM_elem_attrs_copy(bm, bm, f_src, f_dst);
+ }
/* interpolate */
i = 0;
@@ -213,7 +214,9 @@ void BM_face_interp_from_face(BMesh *bm, BMFace *f_dst, const BMFace *f_src, con
do {
mul_v2_m3v3(cos_2d[i], axis_mat, l_iter->v->co);
blocks_l[i] = l_iter->head.data;
- if (do_vertex) blocks_v[i] = l_iter->v->head.data;
+ if (do_vertex) {
+ blocks_v[i] = l_iter->v->head.data;
+ }
} while ((void)i++, (l_iter = l_iter->next) != l_first);
BM_face_interp_from_face_ex(bm, f_dst, f_src, do_vertex,
@@ -324,10 +327,12 @@ static bool mdisp_in_mdispquad(
float v1[3], v2[3], c[3], v3[3], v4[3], e1[3], e2[3];
float eps = FLT_EPSILON * 4000;
- if (is_zero_v3(l_src->v->no))
+ if (is_zero_v3(l_src->v->no)) {
BM_vert_normal_update_all(l_src->v);
- if (is_zero_v3(l_dst->v->no))
+ }
+ if (is_zero_v3(l_dst->v->no)) {
BM_vert_normal_update_all(l_dst->v);
+ }
compute_mdisp_quad(l_dst, l_dst_f_center, v1, v2, v3, v4, e1, e2);
@@ -341,8 +346,9 @@ static bool mdisp_in_mdispquad(
add_v3_v3(v1, c); add_v3_v3(v2, c);
add_v3_v3(v3, c); add_v3_v3(v4, c);
- if (!quad_co(v1, v2, v3, v4, p, l_src->v->no, r_uv))
+ if (!quad_co(v1, v2, v3, v4, p, l_src->v->no, r_uv)) {
return 0;
+ }
mul_v2_fl(r_uv, (float)(res - 1));
@@ -386,8 +392,9 @@ static void bm_loop_flip_disp(
if (fabsf(d) < 1e-4f) {
d = bm_loop_flip_equotion(mat, b, target_axis_x, target_axis_y, coord, 0, 2);
- if (fabsf(d) < 1e-4f)
+ if (fabsf(d) < 1e-4f) {
d = bm_loop_flip_equotion(mat, b, target_axis_x, target_axis_y, coord, 1, 2);
+ }
}
disp[0] = (b[0] * mat[1][1] - mat[0][1] * b[1]) / d;
@@ -472,8 +479,9 @@ void BM_loop_interp_multires_ex(
float axis_x[3], axis_y[3];
/* ignore 2-edged faces */
- if (UNLIKELY(l_dst->f->len < 3))
+ if (UNLIKELY(l_dst->f->len < 3)) {
return;
+ }
md_dst = BM_ELEM_CD_GET_VOID_P(l_dst, cd_loop_mdisp_offset);
compute_mdisp_quad(l_dst, f_dst_center, v1, v2, v3, v4, e1, e2);
@@ -564,8 +572,9 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
BMLoop *l;
BMIter liter;
- if (cd_loop_mdisp_offset == -1)
+ if (cd_loop_mdisp_offset == -1) {
return;
+ }
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
MDisps *mdp = BM_ELEM_CD_GET_VOID_P(l->prev, cd_loop_mdisp_offset);
@@ -621,13 +630,16 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
* </pre>
*/
- if (l->radial_next == l)
+ if (l->radial_next == l) {
continue;
+ }
- if (l->radial_next->v == l->v)
+ if (l->radial_next->v == l->v) {
mdl2 = BM_ELEM_CD_GET_VOID_P(l->radial_next, cd_loop_mdisp_offset);
- else
+ }
+ else {
mdl2 = BM_ELEM_CD_GET_VOID_P(l->radial_next->next, cd_loop_mdisp_offset);
+ }
sides = (int)sqrt(mdl1->totdisp);
for (y = 0; y < sides; y++) {
@@ -826,7 +838,9 @@ void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
CustomData_add_layer(data, type, CD_DEFAULT, NULL, 0);
update_data_blocks(bm, &olddata, data);
- if (olddata.layers) MEM_freeN(olddata.layers);
+ if (olddata.layers) {
+ MEM_freeN(olddata.layers);
+ }
}
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name)
@@ -842,7 +856,9 @@ void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *
CustomData_add_layer_named(data, type, CD_DEFAULT, NULL, 0, name);
update_data_blocks(bm, &olddata, data);
- if (olddata.layers) MEM_freeN(olddata.layers);
+ if (olddata.layers) {
+ MEM_freeN(olddata.layers);
+ }
}
void BM_data_layer_free(BMesh *bm, CustomData *data, int type)
@@ -862,7 +878,9 @@ void BM_data_layer_free(BMesh *bm, CustomData *data, int type)
UNUSED_VARS_NDEBUG(has_layer);
update_data_blocks(bm, &olddata, data);
- if (olddata.layers) MEM_freeN(olddata.layers);
+ if (olddata.layers) {
+ MEM_freeN(olddata.layers);
+ }
}
void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n)
@@ -882,7 +900,9 @@ void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n)
UNUSED_VARS_NDEBUG(has_layer);
update_data_blocks(bm, &olddata, data);
- if (olddata.layers) MEM_freeN(olddata.layers);
+ if (olddata.layers) {
+ MEM_freeN(olddata.layers);
+ }
}
void BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int dst_n)
@@ -940,7 +960,9 @@ float BM_elem_float_data_get(CustomData *cd, void *element, int type)
void BM_elem_float_data_set(CustomData *cd, void *element, int type, const float val)
{
float *f = CustomData_bmesh_get(cd, ((BMHeader *)element)->data, type);
- if (f) *f = val;
+ if (f) {
+ *f = val;
+ }
}
/** \name Loop interpolation functions: BM_vert_loop_groups_data_layer_***
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c
index ce275342557..2f9eeac83e9 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.c
+++ b/source/blender/bmesh/intern/bmesh_iterators.c
@@ -584,8 +584,9 @@ void bmiter__loop_of_loop_begin(struct BMIter__loop_of_loop *iter)
iter->l_first = iter->ldata;
iter->l_next = iter->l_first->radial_next;
- if (iter->l_next == iter->l_first)
+ if (iter->l_next == iter->l_first) {
iter->l_next = NULL;
+ }
}
void *bmiter__loop_of_loop_step(struct BMIter__loop_of_loop *iter)
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index ec7c2237edb..3b2e43b89ad 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -523,10 +523,12 @@ BMLog *BM_log_from_existing_entries_create(BMesh *bm, BMLogEntry *entry)
{
BMLog *log = BM_log_create(bm);
- if (entry->prev)
+ if (entry->prev) {
log->current_entry = entry;
- else
+ }
+ else {
log->current_entry = NULL;
+ }
/* Let BMLog manage the entry list again */
log->entries.first = log->entries.last = entry;
@@ -563,19 +565,23 @@ void BM_log_free(BMLog *log)
{
BMLogEntry *entry;
- if (log->unused_ids)
+ if (log->unused_ids) {
range_tree_uint_free(log->unused_ids);
+ }
- if (log->id_to_elem)
+ if (log->id_to_elem) {
BLI_ghash_free(log->id_to_elem, NULL, NULL);
+ }
- if (log->elem_to_id)
+ if (log->elem_to_id) {
BLI_ghash_free(log->elem_to_id, NULL, NULL);
+ }
/* Clear the BMLog references within each entry, but do not free
* the entries themselves */
- for (entry = log->entries.first; entry; entry = entry->next)
+ for (entry = log->entries.first; entry; entry = entry->next) {
entry->log = NULL;
+ }
MEM_freeN(log);
}
@@ -691,10 +697,12 @@ void BM_log_entry_drop(BMLogEntry *entry)
if (!log) {
/* Unlink */
BLI_assert(!(entry->prev && entry->next));
- if (entry->prev)
+ if (entry->prev) {
entry->prev->next = NULL;
- else if (entry->next)
+ }
+ else if (entry->next) {
entry->next->prev = NULL;
+ }
bm_log_entry_free(entry);
MEM_freeN(entry);
@@ -740,8 +748,9 @@ void BM_log_entry_drop(BMLogEntry *entry)
BLI_assert(!"Cannot drop BMLogEntry from middle");
}
- if (log->current_entry == entry)
+ if (log->current_entry == entry) {
log->current_entry = entry->prev;
+ }
bm_log_entry_free(entry);
BLI_freelinkN(&log->entries, entry);
@@ -1126,10 +1135,10 @@ void bm_log_print(const BMLog *log, const char *description)
printf("%s:\n", description);
printf(" % 2d: [ initial ]%s\n", 0,
- (!log->current_entry) ? current : "");
+ (!log->current_entry) ? current : "");
for (entry = log->entries.first, i = 1; entry; entry = entry->next, i++) {
printf(" % 2d: [%p]%s\n", i, entry,
- (entry == log->current_entry) ? current : "");
+ (entry == log->current_entry) ? current : "");
}
}
#endif
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index 0c18625924d..53d9b4b1b56 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -60,7 +60,9 @@ static void recount_totsels(BMesh *bm)
int count = 0;
BM_ITER_MESH (ele, &iter, bm, iter_types[i]) {
- if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) count += 1;
+ if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
+ count += 1;
+ }
}
*tots[i] = count;
}
@@ -667,20 +669,32 @@ static int bm_mesh_flag_count(
if (htype & BM_VERT) {
BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
- if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue;
- if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++;
+ if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
+ continue;
+ }
+ if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) {
+ tot++;
+ }
}
}
if (htype & BM_EDGE) {
BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
- if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue;
- if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++;
+ if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
+ continue;
+ }
+ if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) {
+ tot++;
+ }
}
}
if (htype & BM_FACE) {
BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
- if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue;
- if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++;
+ if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
+ continue;
+ }
+ if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) {
+ tot++;
+ }
}
}
@@ -876,9 +890,9 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3])
* we cant make a crossvec from a vec thats the same as the vec
* unlikely but possible, so make sure if the normal is (0, 0, 1)
* that vec isn't the same or in the same direction even. */
- if (eve->no[0] < 0.5f) vec[0] = 1.0f;
- else if (eve->no[1] < 0.5f) vec[1] = 1.0f;
- else vec[2] = 1.0f;
+ if (eve->no[0] < 0.5f) { vec[0] = 1.0f; }
+ else if (eve->no[1] < 0.5f) { vec[1] = 1.0f; }
+ else { vec[2] = 1.0f; }
cross_v3_v3v3(r_plane, eve->no, vec);
}
normalize_v3(r_plane);
@@ -1371,15 +1385,21 @@ void _bm_elem_hide_set(BMesh *bm, BMHeader *head, const bool hide)
* hiding an element */
switch (head->htype) {
case BM_VERT:
- if (hide) BM_vert_select_set(bm, (BMVert *)head, false);
+ if (hide) {
+ BM_vert_select_set(bm, (BMVert *)head, false);
+ }
BM_vert_hide_set((BMVert *)head, hide);
break;
case BM_EDGE:
- if (hide) BM_edge_select_set(bm, (BMEdge *)head, false);
+ if (hide) {
+ BM_edge_select_set(bm, (BMEdge *)head, false);
+ }
BM_edge_hide_set((BMEdge *)head, hide);
break;
case BM_FACE:
- if (hide) BM_face_select_set(bm, (BMFace *)head, false);
+ if (hide) {
+ BM_face_select_set(bm, (BMFace *)head, false);
+ }
BM_face_hide_set((BMFace *)head, hide);
break;
default:
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 1e2612dd843..460b7ce8dae 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -213,8 +213,9 @@ void BM_mesh_data_free(BMesh *bm)
if (is_ldata_free || is_pdata_free) {
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (is_pdata_free)
+ if (is_pdata_free) {
CustomData_bmesh_free_block(&(bm->pdata), &(f->head.data));
+ }
if (is_ldata_free) {
BM_ITER_ELEM (l, &itersub, f, BM_LOOPS_OF_FACE) {
CustomData_bmesh_free_block(&(bm->ldata), &(l->head.data));
@@ -224,10 +225,10 @@ void BM_mesh_data_free(BMesh *bm)
}
/* Free custom data pools, This should probably go in CustomData_free? */
- if (bm->vdata.totlayer) BLI_mempool_destroy(bm->vdata.pool);
- if (bm->edata.totlayer) BLI_mempool_destroy(bm->edata.pool);
- if (bm->ldata.totlayer) BLI_mempool_destroy(bm->ldata.pool);
- if (bm->pdata.totlayer) BLI_mempool_destroy(bm->pdata.pool);
+ if (bm->vdata.totlayer) { BLI_mempool_destroy(bm->vdata.pool); }
+ if (bm->edata.totlayer) { BLI_mempool_destroy(bm->edata.pool); }
+ if (bm->ldata.totlayer) { BLI_mempool_destroy(bm->ldata.pool); }
+ if (bm->pdata.totlayer) { BLI_mempool_destroy(bm->pdata.pool); }
/* free custom data */
CustomData_free(&bm->vdata, 0);
@@ -241,9 +242,9 @@ void BM_mesh_data_free(BMesh *bm)
BLI_mempool_destroy(bm->lpool);
BLI_mempool_destroy(bm->fpool);
- if (bm->vtable) MEM_freeN(bm->vtable);
- if (bm->etable) MEM_freeN(bm->etable);
- if (bm->ftable) MEM_freeN(bm->ftable);
+ if (bm->vtable) { MEM_freeN(bm->vtable); }
+ if (bm->etable) { MEM_freeN(bm->etable); }
+ if (bm->ftable) { MEM_freeN(bm->ftable); }
/* destroy flag pool */
BM_mesh_elem_toolflags_clear(bm);
@@ -924,7 +925,9 @@ static void bm_mesh_loops_calc_normals(
}
else {
/* We still have to consume the stack! */
- while (BLI_SMALLSTACK_POP(clnors));
+ while (BLI_SMALLSTACK_POP(clnors)) {
+ /* pass */
+ }
}
BKE_lnor_space_custom_data_to_normal(lnor_space, *clnor_ref, lnor);
}
@@ -941,7 +944,9 @@ static void bm_mesh_loops_calc_normals(
}
else {
/* We still have to consume the stack! */
- while (BLI_SMALLSTACK_POP(normal));
+ while (BLI_SMALLSTACK_POP(normal)) {
+ /* pass */
+ }
}
}
@@ -1074,7 +1079,7 @@ void BM_lnorspacearr_store(BMesh *bm, float(*r_lnors)[3])
int cd_loop_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
BM_loops_calc_normal_vcos(
- bm, NULL, NULL, NULL, true, M_PI, r_lnors, bm->lnor_spacearr, NULL, cd_loop_clnors_offset, false);
+ bm, NULL, NULL, NULL, true, M_PI, r_lnors, bm->lnor_spacearr, NULL, cd_loop_clnors_offset, false);
bm->spacearr_dirty &= ~(BM_SPACEARR_DIRTY | BM_SPACEARR_DIRTY_ALL);
}
@@ -1188,7 +1193,7 @@ void BM_lnorspace_rebuild(BMesh *bm, bool preserve_clnor)
BKE_lnor_spacearr_clear(bm->lnor_spacearr);
}
BM_loops_calc_normal_vcos(
- bm, NULL, NULL, NULL, true, M_PI, r_lnors, bm->lnor_spacearr, NULL, cd_loop_clnors_offset, true);
+ bm, NULL, NULL, NULL, true, M_PI, r_lnors, bm->lnor_spacearr, NULL, cd_loop_clnors_offset, true);
MEM_freeN(r_lnors);
BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
@@ -1339,30 +1344,94 @@ static int bm_loop_normal_mark_indiv(BMesh *bm, BLI_bitmap *loops)
BMEditSelection *ese, *ese_prev;
int totloopsel = 0;
+ const bool sel_verts = (bm->selectmode & SCE_SELECT_VERTEX) != 0;
+ const bool sel_edges = (bm->selectmode & SCE_SELECT_EDGE) != 0;
+ const bool sel_faces = (bm->selectmode & SCE_SELECT_FACE) != 0;
+ const bool use_sel_face_history = sel_faces && (sel_edges || sel_verts);
+
BM_mesh_elem_index_ensure(bm, BM_LOOP);
BLI_assert(bm->lnor_spacearr != NULL);
BLI_assert(bm->lnor_spacearr->data_type == MLNOR_SPACEARR_BMLOOP_PTR);
- /* Goes from last selected to the first selected element. */
- for (ese = bm->selected.last; ese; ese = ese->prev) {
- if (ese->htype == BM_FACE) {
- ese_prev = ese;
- /* If current face is selected, then any verts to be edited must have been selected before it. */
- while ((ese_prev = ese_prev->prev)) {
- if (ese_prev->htype == BM_VERT) {
- bm_loop_normal_mark_indiv_do_loop(
- BM_face_vert_share_loop((BMFace *)ese->ele, (BMVert *)ese_prev->ele),
- loops, bm->lnor_spacearr, &totloopsel);
+ if (use_sel_face_history) {
+ /* Using face history allows to select a single loop from a single face...
+ * Note that this is On² piece of code, but it is not designed to be used with huge selection sets,
+ * rather with only a few items selected at most.*/
+ printf("using face history selection\n");
+ /* Goes from last selected to the first selected element. */
+ for (ese = bm->selected.last; ese; ese = ese->prev) {
+ if (ese->htype == BM_FACE) {
+ /* If current face is selected, then any verts to be edited must have been selected before it. */
+ for (ese_prev = ese->prev; ese_prev; ese_prev = ese_prev->prev) {
+ if (ese_prev->htype == BM_VERT) {
+ bm_loop_normal_mark_indiv_do_loop(
+ BM_face_vert_share_loop((BMFace *)ese->ele, (BMVert *)ese_prev->ele),
+ loops, bm->lnor_spacearr, &totloopsel);
+ }
+ else if (ese_prev->htype == BM_EDGE) {
+ BMEdge *e = (BMEdge *)ese_prev->ele;
+ bm_loop_normal_mark_indiv_do_loop(
+ BM_face_vert_share_loop((BMFace *)ese->ele, e->v1),
+ loops, bm->lnor_spacearr, &totloopsel);
+
+ bm_loop_normal_mark_indiv_do_loop(
+ BM_face_vert_share_loop((BMFace *)ese->ele, e->v2),
+ loops, bm->lnor_spacearr, &totloopsel);
+ }
+ }
+ }
+ }
+ }
+ else {
+ if (sel_faces) {
+ /* Only select all loops of selected faces. */
+ printf("using face selection\n");
+ BMLoop *l;
+ BMFace *f;
+ BMIter liter, fiter;
+ BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
+ if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+ BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) {
+ bm_loop_normal_mark_indiv_do_loop(l, loops, bm->lnor_spacearr, &totloopsel);
+ }
}
- else if (ese_prev->htype == BM_EDGE) {
- bm_loop_normal_mark_indiv_do_loop(
- BM_face_vert_share_loop((BMFace *)ese->ele, ((BMEdge *)ese_prev->ele)->v1),
- loops, bm->lnor_spacearr, &totloopsel);
-
- bm_loop_normal_mark_indiv_do_loop(
- BM_face_vert_share_loop((BMFace *)ese->ele, ((BMEdge *)ese_prev->ele)->v2),
- loops, bm->lnor_spacearr, &totloopsel);
+ }
+ }
+ if (sel_edges) {
+ /* Only select all loops of selected edges. */
+ printf("using edge selection\n");
+ BMLoop *l;
+ BMEdge *e;
+ BMIter liter, eiter;
+ BM_ITER_MESH(e, &eiter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
+ BM_ITER_ELEM(l, &liter, e, BM_LOOPS_OF_EDGE) {
+ bm_loop_normal_mark_indiv_do_loop(l, loops, bm->lnor_spacearr, &totloopsel);
+ /* Loops actually 'have' two edges, or said otherwise, a selected edge actually selects
+ * *two* loops in each of its faces. We have to find the other one too. */
+ if (BM_vert_in_edge(e, l->next->v)) {
+ bm_loop_normal_mark_indiv_do_loop(l->next, loops, bm->lnor_spacearr, &totloopsel);
+ }
+ else {
+ BLI_assert(BM_vert_in_edge(e, l->prev->v));
+ bm_loop_normal_mark_indiv_do_loop(l->prev, loops, bm->lnor_spacearr, &totloopsel);
+ }
+ }
+ }
+ }
+ }
+ if (sel_verts) {
+ /* Select all loops of selected verts. */
+ printf("using vert selection\n");
+ BMLoop *l;
+ BMVert *v;
+ BMIter liter, viter;
+ BM_ITER_MESH(v, &viter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
+ BM_ITER_ELEM(l, &liter, v, BM_LOOPS_OF_VERT) {
+ bm_loop_normal_mark_indiv_do_loop(l, loops, bm->lnor_spacearr, &totloopsel);
+ }
}
}
}
@@ -1398,17 +1467,13 @@ BMLoopNorEditDataArray *BM_loop_normal_editdata_array_init(BMesh *bm)
BMVert *v;
BMIter liter, viter;
- bool verts = (bm->selectmode & SCE_SELECT_VERTEX) != 0;
- bool edges = (bm->selectmode & SCE_SELECT_EDGE) != 0;
- bool faces = (bm->selectmode & SCE_SELECT_FACE) != 0;
int totloopsel = 0;
BLI_assert(bm->spacearr_dirty == 0);
- BMLoopNorEditDataArray *lnors_ed_arr = MEM_mallocN(
- sizeof(*lnors_ed_arr), __func__);
+ BMLoopNorEditDataArray *lnors_ed_arr = MEM_mallocN(sizeof(*lnors_ed_arr), __func__);
lnors_ed_arr->lidx_to_lnor_editdata = MEM_callocN(
- sizeof(*lnors_ed_arr->lidx_to_lnor_editdata) * bm->totloop, __func__);
+ sizeof(*lnors_ed_arr->lidx_to_lnor_editdata) * bm->totloop, __func__);
if (!CustomData_has_layer(&bm->ldata, CD_CUSTOMLOOPNORMAL)) {
BM_data_layer_add(bm, &bm->ldata, CD_CUSTOMLOOPNORMAL);
@@ -1418,10 +1483,9 @@ BMLoopNorEditDataArray *BM_loop_normal_editdata_array_init(BMesh *bm)
BM_mesh_elem_index_ensure(bm, BM_LOOP);
BLI_bitmap *loops = BLI_BITMAP_NEW(bm->totloop, __func__);
- if (faces && (verts || edges)) {
- /* More than one selection mode, check for individual normals to edit. */
- totloopsel = bm_loop_normal_mark_indiv(bm, loops);
- }
+
+ /* This function define loop normals to edit, based on selection modes and history. */
+ totloopsel = bm_loop_normal_mark_indiv(bm, loops);
if (totloopsel) {
BMLoopNorEditData *lnor_ed = lnors_ed_arr->lnor_editdata = MEM_mallocN(sizeof(*lnor_ed) * totloopsel, __func__);
@@ -1437,21 +1501,6 @@ BMLoopNorEditDataArray *BM_loop_normal_editdata_array_init(BMesh *bm)
}
lnors_ed_arr->totloop = totloopsel;
}
- else { /* If multiple selection modes are inactive OR no such loop is found, fall back to editing all loops. */
- totloopsel = BM_total_loop_select(bm);
- BMLoopNorEditData *lnor_ed = lnors_ed_arr->lnor_editdata = MEM_mallocN(sizeof(*lnor_ed) * totloopsel, __func__);
-
- BM_ITER_MESH(v, &viter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
- BM_ITER_ELEM(l, &liter, v, BM_LOOPS_OF_VERT) {
- loop_normal_editdata_init(bm, lnor_ed, v, l, cd_custom_normal_offset);
- lnors_ed_arr->lidx_to_lnor_editdata[BM_elem_index_get(l)] = lnor_ed;
- lnor_ed++;
- }
- }
- }
- lnors_ed_arr->totloop = totloopsel;
- }
MEM_freeN(loops);
lnors_ed_arr->cd_custom_normal_offset = cd_custom_normal_offset;
@@ -1805,8 +1854,9 @@ void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
/* pass (re-use the array) */
}
else {
- if (bm->vtable)
+ if (bm->vtable) {
MEM_freeN(bm->vtable);
+ }
bm->vtable = MEM_mallocN(sizeof(void **) * bm->totvert, "bm->vtable");
bm->vtable_tot = bm->totvert;
}
@@ -1816,8 +1866,9 @@ void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
/* pass (re-use the array) */
}
else {
- if (bm->etable)
+ if (bm->etable) {
MEM_freeN(bm->etable);
+ }
bm->etable = MEM_mallocN(sizeof(void **) * bm->totedge, "bm->etable");
bm->etable_tot = bm->totedge;
}
@@ -1827,8 +1878,9 @@ void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
/* pass (re-use the array) */
}
else {
- if (bm->ftable)
+ if (bm->ftable) {
MEM_freeN(bm->ftable);
+ }
bm->ftable = MEM_mallocN(sizeof(void **) * bm->totface, "bm->ftable");
bm->ftable_tot = bm->totface;
}
@@ -1976,8 +2028,9 @@ void BM_mesh_remap(
BMFace *fa;
BMLoop *lo;
- if (!(vert_idx || edge_idx || face_idx))
+ if (!(vert_idx || edge_idx || face_idx)) {
return;
+ }
BM_mesh_elem_table_ensure(
bm,
@@ -2227,12 +2280,15 @@ void BM_mesh_remap(
}
}
- if (vptr_map)
+ if (vptr_map) {
BLI_ghash_free(vptr_map, NULL, NULL);
- if (eptr_map)
+ }
+ if (eptr_map) {
BLI_ghash_free(eptr_map, NULL, NULL);
- if (fptr_map)
+ }
+ if (fptr_map) {
BLI_ghash_free(fptr_map, NULL, NULL);
+ }
}
/**
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index 8254b8a2202..66cd3a0b30c 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -219,6 +219,12 @@ void BM_mesh_bm_from_me(
CustomData_copy(&me->ldata, &bm->ldata, mask.lmask, CD_CALLOC, 0);
CustomData_copy(&me->pdata, &bm->pdata, mask.pmask, CD_CALLOC, 0);
}
+ else {
+ CustomData_bmesh_merge(&me->vdata, &bm->vdata, mask.vmask, CD_CALLOC, bm, BM_VERT);
+ CustomData_bmesh_merge(&me->edata, &bm->edata, mask.emask, CD_CALLOC, bm, BM_EDGE);
+ CustomData_bmesh_merge(&me->ldata, &bm->ldata, mask.lmask, CD_CALLOC, bm, BM_LOOP);
+ CustomData_bmesh_merge(&me->pdata, &bm->pdata, mask.pmask, CD_CALLOC, bm, BM_FACE);
+ }
/* -------------------------------------------------------------------- */
/* Shape Key */
@@ -312,10 +318,14 @@ void BM_mesh_bm_from_me(
/* Copy Custom Data */
CustomData_to_bmesh_block(&me->vdata, &bm->vdata, i, &v->head.data, true);
- if (cd_vert_bweight_offset != -1) BM_ELEM_CD_SET_FLOAT(v, cd_vert_bweight_offset, (float)mvert->bweight / 255.0f);
+ if (cd_vert_bweight_offset != -1) {
+ BM_ELEM_CD_SET_FLOAT(v, cd_vert_bweight_offset, (float)mvert->bweight / 255.0f);
+ }
/* set shape key original index */
- if (cd_shape_keyindex_offset != -1) BM_ELEM_CD_SET_INT(v, cd_shape_keyindex_offset, i);
+ if (cd_shape_keyindex_offset != -1) {
+ BM_ELEM_CD_SET_INT(v, cd_shape_keyindex_offset, i);
+ }
/* set shapekey data */
if (tot_shape_keys) {
@@ -347,8 +357,12 @@ void BM_mesh_bm_from_me(
/* Copy Custom Data */
CustomData_to_bmesh_block(&me->edata, &bm->edata, i, &e->head.data, true);
- if (cd_edge_bweight_offset != -1) BM_ELEM_CD_SET_FLOAT(e, cd_edge_bweight_offset, (float)medge->bweight / 255.0f);
- if (cd_edge_crease_offset != -1) BM_ELEM_CD_SET_FLOAT(e, cd_edge_crease_offset, (float)medge->crease / 255.0f);
+ if (cd_edge_bweight_offset != -1) {
+ BM_ELEM_CD_SET_FLOAT(e, cd_edge_bweight_offset, (float)medge->bweight / 255.0f);
+ }
+ if (cd_edge_crease_offset != -1) {
+ BM_ELEM_CD_SET_FLOAT(e, cd_edge_crease_offset, (float)medge->crease / 255.0f);
+ }
}
if (is_new) {
@@ -391,7 +405,9 @@ void BM_mesh_bm_from_me(
}
f->mat_nr = mp->mat_nr;
- if (i == me->act_face) bm->act_face = f;
+ if (i == me->act_face) {
+ bm->act_face = f;
+ }
int j = mp->loopstart;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
@@ -561,20 +577,36 @@ void BM_mesh_bm_to_me(
ototvert = me->totvert;
/* new vertex block */
- if (bm->totvert == 0) mvert = NULL;
- else mvert = MEM_callocN(bm->totvert * sizeof(MVert), "loadeditbMesh vert");
+ if (bm->totvert == 0) {
+ mvert = NULL;
+ }
+ else {
+ mvert = MEM_callocN(bm->totvert * sizeof(MVert), "loadeditbMesh vert");
+ }
/* new edge block */
- if (bm->totedge == 0) medge = NULL;
- else medge = MEM_callocN(bm->totedge * sizeof(MEdge), "loadeditbMesh edge");
+ if (bm->totedge == 0) {
+ medge = NULL;
+ }
+ else {
+ medge = MEM_callocN(bm->totedge * sizeof(MEdge), "loadeditbMesh edge");
+ }
/* new ngon face block */
- if (bm->totface == 0) mpoly = NULL;
- else mpoly = MEM_callocN(bm->totface * sizeof(MPoly), "loadeditbMesh poly");
+ if (bm->totface == 0) {
+ mpoly = NULL;
+ }
+ else {
+ mpoly = MEM_callocN(bm->totface * sizeof(MPoly), "loadeditbMesh poly");
+ }
/* new loop block */
- if (bm->totloop == 0) mloop = NULL;
- else mloop = MEM_callocN(bm->totloop * sizeof(MLoop), "loadeditbMesh loop");
+ if (bm->totloop == 0) {
+ mloop = NULL;
+ }
+ else {
+ mloop = MEM_callocN(bm->totloop * sizeof(MLoop), "loadeditbMesh loop");
+ }
/* lets save the old verts just in case we are actually working on
* a key ... we now do processing of the keys at the end */
@@ -634,7 +666,9 @@ void BM_mesh_bm_to_me(
/* copy over customdat */
CustomData_from_bmesh_block(&bm->vdata, &me->vdata, v->head.data, i);
- if (cd_vert_bweight_offset != -1) mvert->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(v, cd_vert_bweight_offset);
+ if (cd_vert_bweight_offset != -1) {
+ mvert->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(v, cd_vert_bweight_offset);
+ }
i++;
mvert++;
@@ -658,8 +692,12 @@ void BM_mesh_bm_to_me(
bmesh_quick_edgedraw_flag(med, e);
- if (cd_edge_crease_offset != -1) med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_crease_offset);
- if (cd_edge_bweight_offset != -1) med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_bweight_offset);
+ if (cd_edge_crease_offset != -1) {
+ med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_crease_offset);
+ }
+ if (cd_edge_bweight_offset != -1) {
+ med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_bweight_offset);
+ }
i++;
med++;
@@ -691,7 +729,9 @@ void BM_mesh_bm_to_me(
BM_CHECK_ELEMENT(l_iter->v);
} while ((l_iter = l_iter->next) != l_first);
- if (f == bm->act_face) me->act_face = i;
+ if (f == bm->act_face) {
+ me->act_face = i;
+ }
/* copy over customdata */
CustomData_from_bmesh_block(&bm->pdata, &me->pdata, f->head.data, i);
@@ -717,15 +757,21 @@ void BM_mesh_bm_to_me(
if (ob->par1 < ototvert) {
eve = vertMap[ob->par1];
- if (eve) ob->par1 = BM_elem_index_get(eve);
+ if (eve) {
+ ob->par1 = BM_elem_index_get(eve);
+ }
}
if (ob->par2 < ototvert) {
eve = vertMap[ob->par2];
- if (eve) ob->par2 = BM_elem_index_get(eve);
+ if (eve) {
+ ob->par2 = BM_elem_index_get(eve);
+ }
}
if (ob->par3 < ototvert) {
eve = vertMap[ob->par3];
- if (eve) ob->par3 = BM_elem_index_get(eve);
+ if (eve) {
+ ob->par3 = BM_elem_index_get(eve);
+ }
}
}
@@ -757,7 +803,9 @@ void BM_mesh_bm_to_me(
}
}
- if (vertMap) MEM_freeN(vertMap);
+ if (vertMap) {
+ MEM_freeN(vertMap);
+ }
}
BKE_mesh_update_customdata_pointers(me, false);
@@ -803,12 +851,14 @@ void BM_mesh_bm_to_me(
* necessary */
j = 0;
for (i = 0; i < bm->vdata.totlayer; i++) {
- if (bm->vdata.layers[i].type != CD_SHAPEKEY)
+ if (bm->vdata.layers[i].type != CD_SHAPEKEY) {
continue;
+ }
for (currkey = me->key->block.first; currkey; currkey = currkey->next) {
- if (currkey->uid == bm->vdata.layers[i].uid)
+ if (currkey->uid == bm->vdata.layers[i].uid) {
break;
+ }
}
if (!currkey) {
@@ -924,10 +974,14 @@ void BM_mesh_bm_to_me(
currkey->data = newkey;
}
- if (ofs) MEM_freeN(ofs);
+ if (ofs) {
+ MEM_freeN(ofs);
+ }
}
- if (oldverts) MEM_freeN(oldverts);
+ if (oldverts) {
+ MEM_freeN(oldverts);
+ }
/* topology could be changed, ensure mdisps are ok */
multires_topology_changed(me);
@@ -1019,9 +1073,13 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
mv->flag = BM_vert_flag_to_mflag(eve);
- if (cd_vert_bweight_offset != -1) mv->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eve, cd_vert_bweight_offset);
+ if (cd_vert_bweight_offset != -1) {
+ mv->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eve, cd_vert_bweight_offset);
+ }
- if (add_orig) *index++ = i;
+ if (add_orig) {
+ *index++ = i;
+ }
CustomData_from_bmesh_block(&bm->vdata, &me->vdata, eve->head.data, i);
}
@@ -1046,11 +1104,17 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
}
}
- 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) med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_bweight_offset);
+ 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) {
+ med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_bweight_offset);
+ }
CustomData_from_bmesh_block(&bm->edata, &me->edata, eed->head.data, i);
- if (add_orig) *index++ = i;
+ if (add_orig) {
+ *index++ = i;
+ }
}
bm->elem_index_dirty &= ~BM_EDGE;
@@ -1082,7 +1146,9 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
CustomData_from_bmesh_block(&bm->pdata, &me->pdata, efa->head.data, i);
- if (add_orig) *index++ = i;
+ if (add_orig) {
+ *index++ = i;
+ }
}
bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index bc0a09636f7..e1aa5fcfee1 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -716,6 +716,17 @@ BMVert *BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts, BMVert **r_varr)
return v_new;
}
+/**
+ * Swap v1 & v2
+ *
+ * \note Typically we shouldn't care about this, however it's used when extruding wire edges.
+ */
+void BM_edge_verts_swap(BMEdge *e)
+{
+ SWAP(BMVert *, e->v1, e->v2);
+ SWAP(BMDiskLink, e->v1_disk_link, e->v2_disk_link);
+}
+
#if 0
/**
* Checks if a face is valid in the data structure
diff --git a/source/blender/bmesh/intern/bmesh_mods.h b/source/blender/bmesh/intern/bmesh_mods.h
index 87893727192..ce0234ed61f 100644
--- a/source/blender/bmesh/intern/bmesh_mods.h
+++ b/source/blender/bmesh/intern/bmesh_mods.h
@@ -57,6 +57,8 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float perce
BMVert *BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts, BMVert **r_varr);
+void BM_edge_verts_swap(BMEdge *e);
+
bool BM_face_validate(BMFace *face, FILE *err);
void BM_edge_calc_rotate(
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index e7585cc1836..0ed1338e62f 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1391,6 +1391,7 @@ static BMOpDefine bmo_duplicate_def = {
/* destination bmesh, if NULL will use current on */
{"dest", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_BMESH}},
{"use_select_history", BMO_OP_SLOT_BOOL},
+ {"use_edge_flip_from_face", BMO_OP_SLOT_BOOL},
{{'\0'}},
},
/* slots_out */
@@ -1764,11 +1765,11 @@ static BMOpDefine bmo_bevel_def = {
{"mark_sharp", BMO_OP_SLOT_BOOL}, /* extend edge data to allow sharp edges to run across bevels */
{"harden_normals", BMO_OP_SLOT_BOOL}, /* harden normals */
{"face_strength_mode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
- bmo_enum_bevel_face_strength_type}, /* whether to set face strength, and which faces to set if so */
+ bmo_enum_bevel_face_strength_type}, /* whether to set face strength, and which faces to set if so */
{"miter_outer", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
- bmo_enum_bevel_miter_type}, /* outer miter kind */
+ bmo_enum_bevel_miter_type}, /* outer miter kind */
{"miter_inner", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
- bmo_enum_bevel_miter_type}, /* outer miter kind */
+ bmo_enum_bevel_miter_type}, /* outer miter kind */
{"spread", BMO_OP_SLOT_FLT}, /* amount to offset beveled edge */
{"smoothresh", BMO_OP_SLOT_FLT}, /* for passing mesh's smoothresh, used in hardening */
{{'\0'}},
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
index 030b9480e4f..78e75cf3d30 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
@@ -64,8 +64,8 @@ ATTR_NONNULL(1, 2)
BLI_INLINE void _bmo_elem_flag_set(BMesh *bm, BMFlagLayer *oflags, const short oflag, int val)
{
BLI_assert(bm->use_toolflags);
- if (val) oflags[bm->toolflag_index].f |= oflag;
- else oflags[bm->toolflag_index].f &= (short)~oflag;
+ if (val) { oflags[bm->toolflag_index].f |= oflag; }
+ else { oflags[bm->toolflag_index].f &= (short)~oflag; }
}
ATTR_NONNULL(1, 2)
@@ -204,7 +204,9 @@ BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot *slot, const void *element)
{
void **val = BMO_slot_map_data_get(slot, element);
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL);
- if (val) return *val;
+ if (val) {
+ return *val;
+ }
return NULL;
}
@@ -214,7 +216,9 @@ BLI_INLINE void *BMO_slot_map_elem_get(BMOpSlot *slot, const void *element)
{
void **val = (void **) BMO_slot_map_data_get(slot, element);
BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_ELEM);
- if (val) return *val;
+ if (val) {
+ return *val;
+ }
return NULL;
}
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 2ce03cf5a7d..5586db26664 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -96,10 +96,12 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op))
BLI_assert(bm->totflags > 0);
/* add flag layer, if appropriate */
- if (bm->toolflag_index > 0)
+ if (bm->toolflag_index > 0) {
bmo_flag_layer_alloc(bm);
- else
+ }
+ else {
bmo_flag_layer_clear(bm);
+ }
}
/**
@@ -111,8 +113,9 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op))
*/
void BMO_pop(BMesh *bm)
{
- if (bm->toolflag_index > 0)
+ if (bm->toolflag_index > 0) {
bmo_flag_layer_free(bm);
+ }
bm->toolflag_index--;
}
@@ -212,12 +215,14 @@ void BMO_op_exec(BMesh *bm, BMOperator *op)
BMO_push(bm, op);
- if (bm->toolflag_index == 1)
+ if (bm->toolflag_index == 1) {
bmesh_edit_begin(bm, op->type_flag);
+ }
op->exec(bm, op);
- if (bm->toolflag_index == 1)
+ if (bm->toolflag_index == 1) {
bmesh_edit_end(bm, op->type_flag);
+ }
BMO_pop(bm);
}
@@ -287,8 +292,9 @@ void _bmo_slot_copy(
BMOpSlot *slot_src = BMO_slot_get(slot_args_src, slot_name_src);
BMOpSlot *slot_dst = BMO_slot_get(slot_args_dst, slot_name_dst);
- if (slot_src == slot_dst)
+ if (slot_src == slot_dst) {
return;
+ }
BLI_assert(slot_src->slot_type == slot_dst->slot_type);
if (slot_src->slot_type != slot_dst->slot_type) {
@@ -368,8 +374,9 @@ void BMO_slot_float_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_n
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT);
- if (!(slot->slot_type == BMO_OP_SLOT_FLT))
+ if (!(slot->slot_type == BMO_OP_SLOT_FLT)) {
return;
+ }
slot->data.f = f;
}
@@ -378,8 +385,9 @@ void BMO_slot_int_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_INT);
- if (!(slot->slot_type == BMO_OP_SLOT_INT))
+ if (!(slot->slot_type == BMO_OP_SLOT_INT)) {
return;
+ }
slot->data.i = i;
}
@@ -388,8 +396,9 @@ void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL);
- if (!(slot->slot_type == BMO_OP_SLOT_BOOL))
+ if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) {
return;
+ }
slot->data.i = i;
}
@@ -399,8 +408,9 @@ void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], cons
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT);
- if (!(slot->slot_type == BMO_OP_SLOT_MAT))
+ if (!(slot->slot_type == BMO_OP_SLOT_MAT)) {
return;
+ }
slot->len = 4;
slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float) * 4 * 4);
@@ -422,8 +432,9 @@ void BMO_slot_mat4_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT);
- if (!(slot->slot_type == BMO_OP_SLOT_MAT))
+ if (!(slot->slot_type == BMO_OP_SLOT_MAT)) {
return;
+ }
if (slot->data.p) {
copy_m4_m4(r_mat, BMO_SLOT_AS_MATRIX(slot));
@@ -437,8 +448,9 @@ void BMO_slot_mat3_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT);
- if (!(slot->slot_type == BMO_OP_SLOT_MAT))
+ if (!(slot->slot_type == BMO_OP_SLOT_MAT)) {
return;
+ }
if (slot->data.p) {
copy_m3_m4(r_mat, BMO_SLOT_AS_MATRIX(slot));
@@ -452,8 +464,9 @@ void BMO_slot_ptr_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR);
- if (!(slot->slot_type == BMO_OP_SLOT_PTR))
+ if (!(slot->slot_type == BMO_OP_SLOT_PTR)) {
return;
+ }
slot->data.p = p;
}
@@ -462,8 +475,9 @@ void BMO_slot_vec_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC);
- if (!(slot->slot_type == BMO_OP_SLOT_VEC))
+ if (!(slot->slot_type == BMO_OP_SLOT_VEC)) {
return;
+ }
copy_v3_v3(slot->data.vec, vec);
}
@@ -473,8 +487,9 @@ float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT);
- if (!(slot->slot_type == BMO_OP_SLOT_FLT))
+ if (!(slot->slot_type == BMO_OP_SLOT_FLT)) {
return 0.0f;
+ }
return slot->data.f;
}
@@ -483,8 +498,9 @@ int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_INT);
- if (!(slot->slot_type == BMO_OP_SLOT_INT))
+ if (!(slot->slot_type == BMO_OP_SLOT_INT)) {
return 0;
+ }
return slot->data.i;
}
@@ -493,8 +509,9 @@ bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL);
- if (!(slot->slot_type == BMO_OP_SLOT_BOOL))
+ if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) {
return 0;
+ }
return slot->data.i;
}
@@ -518,8 +535,9 @@ void *BMO_slot_ptr_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR);
- if (!(slot->slot_type == BMO_OP_SLOT_PTR))
+ if (!(slot->slot_type == BMO_OP_SLOT_PTR)) {
return NULL;
+ }
return slot->data.p;
}
@@ -528,8 +546,9 @@ void BMO_slot_vec_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC);
- if (!(slot->slot_type == BMO_OP_SLOT_VEC))
+ if (!(slot->slot_type == BMO_OP_SLOT_VEC)) {
return;
+ }
copy_v3_v3(r_vec, slot->data.vec);
}
@@ -660,8 +679,9 @@ int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot
BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
/* check if its actually a buffer */
- if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF)
+ if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) {
return 0;
+ }
return slot->len;
}
@@ -755,8 +775,9 @@ void *BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS]
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
/* check if its actually a buffer */
- if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF)
+ if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) {
return NULL;
+ }
slot->len = len;
if (len) {
@@ -784,9 +805,9 @@ void BMO_slot_buffer_from_all(
BLI_assert(output->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
BLI_assert(((output->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype);
- if (htype & BM_VERT) totelement += bm->totvert;
- if (htype & BM_EDGE) totelement += bm->totedge;
- if (htype & BM_FACE) totelement += bm->totface;
+ if (htype & BM_VERT) { totelement += bm->totvert; }
+ if (htype & BM_EDGE) { totelement += bm->totedge; }
+ if (htype & BM_FACE) { totelement += bm->totface; }
if (totelement) {
BMIter iter;
@@ -838,10 +859,12 @@ static void bmo_slot_buffer_from_hflag(
BLI_assert(((output->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype);
BLI_assert((output->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) == 0);
- if (test_for_enabled)
+ if (test_for_enabled) {
totelement = BM_mesh_elem_hflag_count_enabled(bm, htype, hflag, respecthide);
- else
+ }
+ else {
totelement = BM_mesh_elem_hflag_count_disabled(bm, htype, hflag, respecthide);
+ }
if (totelement) {
BMIter iter;
@@ -999,10 +1022,12 @@ static void bmo_slot_buffer_from_flag(
BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype);
BLI_assert((slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) == 0);
- if (test_for_enabled)
+ if (test_for_enabled) {
totelement = BMO_mesh_enabled_flag_count(bm, htype, oflag);
- else
+ }
+ else {
totelement = BMO_mesh_disabled_flag_count(bm, htype, oflag);
+ }
if (totelement) {
BMIter iter;
@@ -1085,8 +1110,9 @@ void BMO_slot_buffer_hflag_enable(
BLI_assert((slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) == 0);
for (i = 0; i < slot->len; i++, data++) {
- if (!(htype & (*data)->head.htype))
+ if (!(htype & (*data)->head.htype)) {
continue;
+ }
if (do_flush_select) {
BM_elem_select_set(bm, *data, true);
@@ -1121,8 +1147,9 @@ void BMO_slot_buffer_hflag_disable(
BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype);
for (i = 0; i < slot->len; i++, data++) {
- if (!(htype & (*data)->head.htype))
+ if (!(htype & (*data)->head.htype)) {
continue;
+ }
if (do_flush_select) {
BM_elem_select_set(bm, *data, false);
@@ -1154,8 +1181,9 @@ void BMO_slot_buffer_flag_enable(
BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype);
for (i = 0; i < slot->len; i++) {
- if (!(htype & data[i]->htype))
+ if (!(htype & data[i]->htype)) {
continue;
+ }
BMO_elem_flag_enable(bm, (BMElemF *)data[i], oflag);
}
@@ -1179,8 +1207,9 @@ void BMO_slot_buffer_flag_disable(
BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype);
for (i = 0; i < slot->len; i++) {
- if (!(htype & data[i]->htype))
+ if (!(htype & data[i]->htype)) {
continue;
+ }
BMO_elem_flag_disable(bm, (BMElemF *)data[i], oflag);
}
@@ -1363,8 +1392,9 @@ void *BMO_slot_buffer_get_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
- if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF)
+ if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) {
return NULL;
+ }
return slot->data.buf ? *slot->data.buf : NULL;
}
@@ -1496,7 +1526,9 @@ typedef struct BMOpError {
void BMO_error_clear(BMesh *bm)
{
- while (BMO_error_pop(bm, NULL, NULL));
+ while (BMO_error_pop(bm, NULL, NULL)) {
+ /* pass */
+ }
}
void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg)
@@ -1526,8 +1558,12 @@ int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op)
return 0;
}
- if (msg) *msg = err->msg;
- if (op) *op = err->op;
+ if (msg) {
+ *msg = err->msg;
+ }
+ if (op) {
+ *op = err->op;
+ }
return err->errorcode;
}
@@ -1590,8 +1626,9 @@ int BMO_opcode_from_opname(const char *opname)
static int BMO_opcode_from_opname_check(const char *opname)
{
int i = BMO_opcode_from_opname(opname);
- if (i == -1)
+ if (i == -1) {
fprintf(stderr, "%s: could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname);
+ }
return i;
}
@@ -1702,8 +1739,9 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
fmt += i;
/* ignore trailing whitespace */
- if (!fmt[i])
+ if (!fmt[i]) {
break;
+ }
/* find end of slot name, only "slot=%f", can be used */
i = strcspn(fmt, "=");
@@ -1734,9 +1772,9 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
const char c = NEXT_CHAR(fmt);
fmt++;
- if (c == '3') size = 3;
- else if (c == '4') size = 4;
- else GOTO_ERROR("matrix size was not 3 or 4");
+ if (c == '3') { size = 3; }
+ else if (c == '4') { size = 4; }
+ else { GOTO_ERROR("matrix size was not 3 or 4"); }
BMO_slot_mat_set(op, op->slots_in, slot_name, va_arg(vlist, void *), size);
state = true;
@@ -1816,9 +1854,9 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt,
while (1) {
char htype_set;
const char c = NEXT_CHAR(fmt);
- if (c == 'f') htype_set = BM_FACE;
- else if (c == 'e') htype_set = BM_EDGE;
- else if (c == 'v') htype_set = BM_VERT;
+ if (c == 'f') { htype_set = BM_FACE; }
+ else if (c == 'e') { htype_set = BM_EDGE; }
+ else if (c == 'v') { htype_set = BM_VERT; }
else {
break;
}
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 4b5b75d919b..9a67c998e4e 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -635,8 +635,9 @@ void BM_face_calc_center_median_weighted(const BMFace *f, float r_cent[3])
w_prev = w_curr;
} while ((l_iter = l_iter->next) != l_first);
- if (totw != 0.0f)
+ if (totw != 0.0f) {
mul_v3_fl(r_cent, 1.0f / (float) totw);
+ }
}
/**
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index 7a0d1c7ec5a..4b34e1fe07d 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -1179,8 +1179,9 @@ int BM_face_share_face_count(BMFace *f1, BMFace *f2)
BM_ITER_ELEM (e, &iter1, f1, BM_EDGES_OF_FACE) {
BM_ITER_ELEM (f, &iter2, e, BM_FACES_OF_EDGE) {
- if (f != f1 && f != f2 && BM_face_share_edge_check(f, f2))
+ if (f != f1 && f != f2 && BM_face_share_edge_check(f, f2)) {
count++;
+ }
}
}
@@ -1198,8 +1199,9 @@ bool BM_face_share_face_check(BMFace *f1, BMFace *f2)
BM_ITER_ELEM (e, &iter1, f1, BM_EDGES_OF_FACE) {
BM_ITER_ELEM (f, &iter2, e, BM_FACES_OF_EDGE) {
- if (f != f1 && f != f2 && BM_face_share_edge_check(f, f2))
+ if (f != f1 && f != f2 && BM_face_share_edge_check(f, f2)) {
return true;
+ }
}
}
diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c
index e4bad715b29..a90d0d245d0 100644
--- a/source/blender/bmesh/intern/bmesh_structure.c
+++ b/source/blender/bmesh/intern/bmesh_structure.c
@@ -172,8 +172,9 @@ void bmesh_disk_edge_append(BMEdge *e, BMVert *v)
dl1->prev = dl2->prev;
dl2->prev = e;
- if (dl3)
+ if (dl3) {
dl3->next = e;
+ }
}
}
@@ -192,8 +193,9 @@ void bmesh_disk_edge_remove(BMEdge *e, BMVert *v)
dl2->prev = dl1->prev;
}
- if (v->e == e)
+ if (v->e == e) {
v->e = (e != dl1->next) ? dl1->next : NULL;
+ }
dl1->next = dl1->prev = NULL;
}
@@ -387,8 +389,9 @@ bool bmesh_radial_validate(int radlen, BMLoop *l)
BMLoop *l_iter = l;
int i = 0;
- if (bmesh_radial_length(l) != radlen)
+ if (bmesh_radial_length(l) != radlen) {
return false;
+ }
do {
if (UNLIKELY(!l_iter)) {
@@ -396,10 +399,12 @@ bool bmesh_radial_validate(int radlen, BMLoop *l)
return false;
}
- if (l_iter->e != l->e)
+ if (l_iter->e != l->e) {
return false;
- if (l_iter->v != l->e->v1 && l_iter->v != l->e->v2)
+ }
+ if (l_iter->v != l->e->v1 && l_iter->v != l->e->v2) {
return false;
+ }
if (UNLIKELY(i > BM_LOOP_RADIAL_MAX)) {
BMESH_ASSERT(0);
@@ -526,8 +531,9 @@ int bmesh_radial_length(const BMLoop *l)
const BMLoop *l_iter = l;
int i = 0;
- if (!l)
+ if (!l) {
return 0;
+ }
do {
if (UNLIKELY(!l_iter)) {
diff --git a/source/blender/bmesh/intern/bmesh_structure_inline.h b/source/blender/bmesh/intern/bmesh_structure_inline.h
index 31c1e6500c9..0998d9bd907 100644
--- a/source/blender/bmesh/intern/bmesh_structure_inline.h
+++ b/source/blender/bmesh/intern/bmesh_structure_inline.h
@@ -40,20 +40,24 @@ BLI_INLINE BMDiskLink *bmesh_disk_edge_link_from_vert(const BMEdge *e, const BMV
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_INLINE BMEdge *bmesh_disk_edge_next_safe(const BMEdge *e, const BMVert *v)
{
- if (v == e->v1)
+ if (v == e->v1) {
return e->v1_disk_link.next;
- if (v == e->v2)
+ }
+ if (v == e->v2) {
return e->v2_disk_link.next;
+ }
return NULL;
}
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_INLINE BMEdge *bmesh_disk_edge_prev_safe(const BMEdge *e, const BMVert *v)
{
- if (v == e->v1)
+ if (v == e->v1) {
return e->v1_disk_link.prev;
- if (v == e->v2)
+ }
+ if (v == e->v2) {
return e->v2_disk_link.prev;
+ }
return NULL;
}
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index 67e3a86fbe3..0ac9b958c11 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -1170,8 +1170,9 @@ static void bmw_FaceLoopWalker_begin(BMWalker *walker, void *data)
/* BMesh *bm = walker->bm; */ /* UNUSED */
/* int fcount = BM_edge_face_count(e); */ /* UNUSED */
- if (!bmw_FaceLoopWalker_edge_begins_loop(walker, e))
+ if (!bmw_FaceLoopWalker_edge_begins_loop(walker, e)) {
return;
+ }
lwalk = BMW_state_add(walker);
lwalk->l = e->l;
@@ -1334,8 +1335,9 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker)
lwalk = &owalk;
l = lwalk->l;
- if (!l)
+ if (!l) {
return lwalk->wireedge;
+ }
e = l->e;
if (!EDGE_CHECK(e)) {
@@ -1368,7 +1370,6 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker)
/* only walk to manifold edge */
if ((l->f->len % 2 == 0) && EDGE_CHECK(l->e) &&
!BLI_gset_haskey(walker->visit_set, l->e))
-
#else
l = l->radial_next;
@@ -1407,8 +1408,9 @@ static void bmw_EdgeboundaryWalker_begin(BMWalker *walker, void *data)
BLI_assert(BM_edge_is_boundary(e));
- if (BLI_gset_haskey(walker->visit_set, e))
+ if (BLI_gset_haskey(walker->visit_set, e)) {
return;
+ }
lwalk = BMW_state_add(walker);
lwalk->e = e;
@@ -1483,8 +1485,9 @@ static void bmw_UVEdgeWalker_begin(BMWalker *walker, void *data)
BMwUVEdgeWalker *lwalk;
BMLoop *l = data;
- if (BLI_gset_haskey(walker->visit_set, l))
+ if (BLI_gset_haskey(walker->visit_set, l)) {
return;
+ }
lwalk = BMW_state_add(walker);
lwalk->l = l;
@@ -1548,8 +1551,9 @@ static void *bmw_UVEdgeWalker_step(BMWalker *walker)
l_other = (l_radial->v != l_pivot->v) ? l_radial->next : l_radial;
data_other = BM_ELEM_CD_GET_VOID_P(l_other, offset);
- if (!CustomData_data_equals(type, data_pivot, data_other))
+ if (!CustomData_data_equals(type, data_pivot, data_other)) {
continue;
+ }
lwalk = BMW_state_add(walker);
BLI_gset_insert(walker->visit_set, l_radial);
diff --git a/source/blender/bmesh/operators/bmo_bridge.c b/source/blender/bmesh/operators/bmo_bridge.c
index 896c28dd743..84b5f44a43f 100644
--- a/source/blender/bmesh/operators/bmo_bridge.c
+++ b/source/blender/bmesh/operators/bmo_bridge.c
@@ -384,10 +384,10 @@ static void bridge_loop_pair(
l_b = l_b_next = BM_iter_at_index(bm, BM_LOOPS_OF_VERT, v_b, 0);
}
- if (l_a && l_a_next == NULL) l_a_next = l_a;
- if (l_a_next && l_a == NULL) l_a = l_a_next;
- if (l_b && l_b_next == NULL) l_b_next = l_b;
- if (l_b_next && l_b == NULL) l_b = l_b_next;
+ if (l_a && l_a_next == NULL) { l_a_next = l_a; }
+ if (l_a_next && l_a == NULL) { l_a = l_a_next; }
+ if (l_b && l_b_next == NULL) { l_b_next = l_b; }
+ if (l_b_next && l_b == NULL) { l_b = l_b_next; }
f_example = l_a ? l_a->f : (l_b ? l_b->f : NULL);
if (v_b != v_b_next) {
diff --git a/source/blender/bmesh/operators/bmo_connect_concave.c b/source/blender/bmesh/operators/bmo_connect_concave.c
index 7e3278853ce..98527482f52 100644
--- a/source/blender/bmesh/operators/bmo_connect_concave.c
+++ b/source/blender/bmesh/operators/bmo_connect_concave.c
@@ -56,15 +56,15 @@ static int bm_edge_length_cmp(const void *a_, const void *b_)
/* merge edges between concave edges last since these
* are most likely to remain and be the main dividers */
- if (e_a_concave < e_b_concave) return -1;
- else if (e_a_concave > e_b_concave) return 1;
+ if (e_a_concave < e_b_concave) { return -1; }
+ else if (e_a_concave > e_b_concave) { return 1; }
else {
/* otherwise shortest edges last */
const float e_a_len = BM_edge_calc_length_squared(e_a);
const float e_b_len = BM_edge_calc_length_squared(e_b);
- if (e_a_len < e_b_len) return 1;
- else if (e_a_len > e_b_len) return -1;
- else return 0;
+ if (e_a_len < e_b_len) { return 1; }
+ else if (e_a_len > e_b_len) { return -1; }
+ else { return 0; }
}
}
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index ff4b671784d..001c3004ec9 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -108,13 +108,13 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
const int tot_edges = BMO_iter_elem_count_flag(bm, BM_EDGES_OF_VERT, v, ELE_NEW, true);
if (tot_edges == 0) {
/* only accept 1 free vert */
- if (v_free == NULL) v_free = v;
- else ok = false; /* only ever want one of these */
+ if (v_free == NULL) { v_free = v; }
+ else { ok = false; } /* only ever want one of these */
}
else if (tot_edges == 1) {
- if (v_a == NULL) v_a = v;
- else if (v_b == NULL) v_b = v;
- else ok = false; /* only ever want 2 of these */
+ if (v_a == NULL) { v_a = v; }
+ else if (v_b == NULL) { v_b = v; }
+ else { ok = false; } /* only ever want 2 of these */
}
else if (tot_edges == 2) {
/* do nothing, regular case */
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index 0c249f84cb2..d04fe2b7146 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -203,8 +203,9 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
goto cleanup;
}
- while (faces[tot])
+ while (faces[tot]) {
tot++;
+ }
f_new = BM_faces_join(bm, faces, tot, true);
@@ -254,7 +255,9 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
cleanup:
/* free/cleanup */
for (i = 0; i < BLI_array_len(regions); i++) {
- if (regions[i]) MEM_freeN(regions[i]);
+ if (regions[i]) {
+ MEM_freeN(regions[i]);
+ }
}
BLI_array_free(regions);
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index c5a6a582b96..5c7c78eb654 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -75,7 +75,8 @@ static BMEdge *bmo_edge_copy(
BMOpSlot *slot_boundarymap_out,
BMesh *bm_dst, BMesh *bm_src,
BMEdge *e_src,
- GHash *vhash, GHash *ehash)
+ GHash *vhash, GHash *ehash,
+ const bool use_edge_flip_from_face)
{
BMEdge *e_dst;
BMVert *e_dst_v1, *e_dst_v2;
@@ -121,6 +122,14 @@ static BMEdge *bmo_edge_copy(
/* Mark the edge for output */
BMO_edge_flag_enable(bm_dst, e_dst, DUPE_NEW);
+ if (use_edge_flip_from_face) {
+ /* Take winding from previous face (if we had one),
+ * otherwise extruding a duplicated edges gives bad normals, see: T62487. */
+ if (BM_edge_is_boundary(e_src) && (e_src->l->v == e_src->v1)) {
+ BM_edge_verts_swap(e_dst);
+ }
+ }
+
return e_dst;
}
@@ -184,6 +193,7 @@ static BMFace *bmo_face_copy(
static void bmo_mesh_copy(BMOperator *op, BMesh *bm_dst, BMesh *bm_src)
{
const bool use_select_history = BMO_slot_bool_get(op->slots_in, "use_select_history");
+ const bool use_edge_flip_from_face = BMO_slot_bool_get(op->slots_in, "use_edge_flip_from_face");
BMVert *v = NULL, *v2;
BMEdge *e = NULL;
@@ -253,7 +263,7 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *bm_dst, BMesh *bm_src)
}
/* now copy the actual edge */
bmo_edge_copy(op, slot_edge_map_out, slot_boundary_map_out,
- bm_dst, bm_src, e, vhash, ehash);
+ bm_dst, bm_src, e, vhash, ehash, use_edge_flip_from_face);
BMO_edge_flag_enable(bm_src, e, DUPE_DONE);
}
}
@@ -273,7 +283,7 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *bm_dst, BMesh *bm_src)
BM_ITER_ELEM (e, &eiter, f, BM_EDGES_OF_FACE) {
if (!BMO_edge_flag_test(bm_src, e, DUPE_DONE)) {
bmo_edge_copy(op, slot_edge_map_out, slot_boundary_map_out,
- bm_dst, bm_src, e, vhash, ehash);
+ bm_dst, bm_src, e, vhash, ehash, use_edge_flip_from_face);
BMO_edge_flag_enable(bm_src, e, DUPE_DONE);
}
}
@@ -323,8 +333,9 @@ void bmo_duplicate_exec(BMesh *bm, BMOperator *op)
BMOperator *dupeop = op;
BMesh *bm_dst = BMO_slot_ptr_get(op->slots_in, "dest");
- if (!bm_dst)
+ if (!bm_dst) {
bm_dst = bm;
+ }
/* flag input */
BMO_slot_buffer_flag_enable(bm, dupeop->slots_in, "geom", BM_ALL_NOLOOP, DUPE_INPUT);
diff --git a/source/blender/bmesh/operators/bmo_edgenet.c b/source/blender/bmesh/operators/bmo_edgenet.c
index b974c2aeb79..4334c7bcdcc 100644
--- a/source/blender/bmesh/operators/bmo_edgenet.c
+++ b/source/blender/bmesh/operators/bmo_edgenet.c
@@ -44,8 +44,9 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
const bool use_smooth = BMO_slot_bool_get(op->slots_in, "use_smooth");
// const int sides = BMO_slot_int_get(op->slots_in, "sides");
- if (!bm->totvert || !bm->totedge)
+ if (!bm->totvert || !bm->totedge) {
return;
+ }
BM_mesh_elem_hflag_disable_all(bm, BM_EDGE, BM_ELEM_TAG, false);
BMO_slot_buffer_hflag_enable(bm, op->slots_in, "edges", BM_EDGE, BM_ELEM_TAG, false);
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index d4c49ae2347..eaf059c7e03 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -258,8 +258,9 @@ void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op)
dupev = BM_vert_create(bm, v->co, v, BM_CREATE_NOP);
BMO_vert_flag_enable(bm, dupev, EXT_KEEP);
- if (has_vskin)
+ if (has_vskin) {
bm_extrude_disable_skin_root(bm, v);
+ }
if (select_history_map) {
BMEditSelection *ese;
@@ -464,10 +465,12 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
BM_edge_kill(bm, e);
/* kill standalone vertices from this edge - see [#32341] */
- if (!v1->e)
+ if (!v1->e) {
BM_vert_kill(bm, v1);
- if (!v2->e)
+ }
+ if (!v2->e) {
BM_vert_kill(bm, v2);
+ }
continue;
}
@@ -563,7 +566,9 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
}
/* cleanup */
- if (delorig) BMO_op_finish(bm, &delop);
+ if (delorig) {
+ BMO_op_finish(bm, &delop);
+ }
BMO_op_finish(bm, &dupeop);
}
diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c
index ff9ad5135dd..09c174586f8 100644
--- a/source/blender/bmesh/operators/bmo_fill_grid.c
+++ b/source/blender/bmesh/operators/bmo_fill_grid.c
@@ -89,7 +89,9 @@ static void quad_verts_to_barycentric_tri(
normalize_v3(no);
}
- if (is_flip) negate_v3(no);
+ if (is_flip) {
+ negate_v3(no);
+ }
mul_v3_fl(no, len_v3v3(tri[0], tri[1]));
mid_v3_v3v3(tri[2], tri[0], tri[1]);
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index 1979cddfa17..664c4b3f615 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -74,8 +74,9 @@ static void hull_add_triangle(
t->v[2] = v3;
/* Mark triangles vertices as not interior */
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++) {
BMO_vert_flag_disable(bm, t->v[i], HULL_FLAG_INTERIOR_ELE);
+ }
BLI_gset_insert(hull_triangles, t);
normal_tri_v3(t->no, v1->co, v2->co, v3->co);
@@ -126,8 +127,9 @@ static void hull_output_triangles(BMesh *bm, GSet *hull_triangles)
else {
/* Look for an adjacent face that existed before the hull */
for (i = 0; i < 3; i++) {
- if (!example)
+ if (!example) {
example = hull_find_example_face(bm, edges[i]);
+ }
}
/* Create new hull face */
@@ -178,8 +180,9 @@ static LinkData *final_edges_find_link(ListBase *adj, BMVert *v)
LinkData *link;
for (link = adj->first; link; link = link->next) {
- if (link->data == v)
+ if (link->data == v) {
return link;
+ }
}
return NULL;
@@ -192,12 +195,14 @@ static int hull_final_edges_lookup(
ListBase *adj;
/* Use lower vertex pointer for hash key */
- if (v1 > v2)
+ if (v1 > v2) {
SWAP(BMVert *, v1, v2);
+ }
adj = BLI_ghash_lookup(final_edges->edges, v1);
- if (!adj)
+ if (!adj) {
return false;
+ }
return !!final_edges_find_link(adj, v2);
}
@@ -224,8 +229,9 @@ static HullFinalEdges *hull_final_edges(GSet *hull_triangles)
ListBase *adj;
/* Use lower vertex pointer for hash key */
- if (v1 > v2)
+ if (v1 > v2) {
SWAP(BMVert *, v1, v2);
+ }
adj = BLI_ghash_lookup(final_edges->edges, v1);
if (!adj) {
@@ -304,8 +310,9 @@ static void hull_mark_interior_elements(
/* Check for interior edges too */
BMO_ITER (e, &oiter, op->slots_in, "input", BM_EDGE) {
- if (!hull_final_edges_lookup(final_edges, e->v1, e->v2))
+ if (!hull_final_edges_lookup(final_edges, e->v1, e->v2)) {
BMO_edge_flag_enable(bm, e, HULL_FLAG_INTERIOR_ELE);
+ }
}
/* Mark all input faces as interior, some may be unmarked in
@@ -409,8 +416,9 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op)
}
}
- if (hole && any_faces)
+ if (hole && any_faces) {
BMO_edge_flag_enable(bm, e, HULL_FLAG_HOLE);
+ }
}
}
@@ -476,8 +484,9 @@ static BMVert **hull_verts_from_bullet(
if (original_index >= 0 && original_index < num_input_verts) {
hull_verts[i] = input_verts[original_index];
}
- else
+ else {
BLI_assert(!"Unexpected new vertex in hull output");
+ }
}
return hull_verts;
@@ -552,8 +561,9 @@ static bool hull_num_input_verts_is_ok(BMOperator *op)
BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) {
partial_num_verts++;
- if (partial_num_verts >= 3)
+ if (partial_num_verts >= 3) {
break;
+ }
}
return (partial_num_verts >= 3);
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index 72fce49f41f..3534d798b02 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -174,8 +174,9 @@ static void bm_loop_customdata_merge(
for (layer_n = 0; layer_n < bm->ldata.totlayer; layer_n++) {
const int type = bm->ldata.layers[layer_n].type;
const int offset = bm->ldata.layers[layer_n].offset;
- if (!CustomData_layer_has_math(&bm->ldata, layer_n))
+ if (!CustomData_layer_has_math(&bm->ldata, layer_n)) {
continue;
+ }
/* check we begin with merged data */
if ((CustomData_data_equals(
diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c
index 7ff7cbbe1ac..19d01cb2e08 100644
--- a/source/blender/bmesh/operators/bmo_join_triangles.c
+++ b/source/blender/bmesh/operators/bmo_join_triangles.c
@@ -339,8 +339,9 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
const BMVert *verts[4];
float error;
- if (!BMO_edge_flag_test(bm, e, EDGE_MARK))
+ if (!BMO_edge_flag_test(bm, e, EDGE_MARK)) {
continue;
+ }
bm_edge_to_quad_verts(e, verts);
diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c
index e3bf4b00968..2ef96d1df03 100644
--- a/source/blender/bmesh/operators/bmo_mirror.c
+++ b/source/blender/bmesh/operators/bmo_mirror.c
@@ -93,10 +93,12 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
for (i = 0; i < totlayer; i++) {
luv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i);
- if (mirror_u)
+ if (mirror_u) {
luv->uv[0] = 1.0f - luv->uv[0];
- if (mirror_v)
+ }
+ if (mirror_v) {
luv->uv[1] = 1.0f - luv->uv[1];
+ }
}
}
}
@@ -109,6 +111,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL_NOLOOP, ELE_NEW);
- if (vmap)
+ if (vmap) {
MEM_freeN(vmap);
+ }
}
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index 12962dd281c..ae9adfbcbba 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -840,8 +840,9 @@ void BM_mesh_calc_uvs_grid(
BLI_assert(cd_loop_uv_offset != -1);
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (!BMO_face_flag_test(bm, f, oflag))
+ if (!BMO_face_flag_test(bm, f, oflag)) {
continue;
+ }
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);
@@ -938,8 +939,9 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
prevop = bmop;
}
- if (a)
+ if (a) {
BMO_op_finish(bm, &bmop);
+ }
{
float len, len2, vec2[3];
@@ -1166,8 +1168,9 @@ void BM_mesh_calc_uvs_sphere(
BLI_assert(cd_loop_uv_offset != -1); /* caller is responsible for giving us UVs */
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (!BMO_face_flag_test(bm, f, oflag))
+ if (!BMO_face_flag_test(bm, f, oflag)) {
continue;
+ }
bm_mesh_calc_uvs_sphere_face(f, cd_loop_uv_offset);
}
@@ -1178,8 +1181,9 @@ void BM_mesh_calc_uvs_sphere(
float minx = 1.0f;
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (!BMO_face_flag_test(bm, f, oflag))
+ if (!BMO_face_flag_test(bm, f, oflag)) {
continue;
+ }
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) {
@@ -1189,8 +1193,9 @@ void BM_mesh_calc_uvs_sphere(
}
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (!BMO_face_flag_test(bm, f, oflag))
+ if (!BMO_face_flag_test(bm, f, oflag)) {
continue;
+ }
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;
@@ -1291,8 +1296,9 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
float vec[3], mat[4][4], phi, phid;
int a;
- if (!segs)
+ if (!segs) {
return;
+ }
BMO_slot_mat4_get(op->slots_in, "matrix", mat);
@@ -1317,8 +1323,9 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
BMO_vert_flag_enable(bm, v1, VERT_MARK);
- if (lastv1)
+ if (lastv1) {
BM_edge_create(bm, v1, lastv1, NULL, BM_CREATE_NOP);
+ }
if (a && cap_ends) {
BMFace *f;
@@ -1327,14 +1334,16 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
BMO_face_flag_enable(bm, f, FACE_NEW);
}
- if (!firstv1)
+ if (!firstv1) {
firstv1 = v1;
+ }
lastv1 = v1;
}
- if (!a)
+ if (!a) {
return;
+ }
BM_edge_create(bm, firstv1, lastv1, NULL, 0);
@@ -1382,8 +1391,9 @@ void BM_mesh_calc_uvs_circle(
invert_m4_m4(inv_mat, mat);
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
- if (!BMO_face_flag_test(bm, f, oflag))
+ if (!BMO_face_flag_test(bm, f, oflag)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1416,8 +1426,9 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs");
int a;
- if (!segs)
+ if (!segs) {
return;
+ }
BMO_slot_mat4_get(op->slots_in, "matrix", mat);
@@ -1487,8 +1498,9 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
lastv2 = v2;
}
- if (!a)
+ if (!a) {
return;
+ }
if (cap_ends) {
f = BM_face_create_quad_tri(bm, cent1, v1, firstv1, NULL, NULL, BM_CREATE_NOP);
@@ -1574,8 +1586,9 @@ void BM_mesh_calc_uvs_cone(
y = 1.0f - uv_height;
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
- if (!BMO_face_flag_test(bm, f, oflag))
+ if (!BMO_face_flag_test(bm, f, oflag)) {
continue;
+ }
if (f->len == 4 && radius_top && radius_bottom) {
/* side face - so unwrap it in a rectangle */
@@ -1647,7 +1660,9 @@ void bmo_create_cube_exec(BMesh *bm, BMOperator *op)
BMO_slot_mat4_get(op->slots_in, "matrix", mat);
- if (!off) off = 0.5f;
+ if (!off) {
+ off = 0.5f;
+ }
int i = 0;
for (int x = -1; x < 2; x += 2) {
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index 1432e15185e..e59bad0d682 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -230,10 +230,12 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
const bool is_del_v2 = BMO_vert_flag_test_bool(bm, (v2 = e->v2), ELE_DEL);
if (is_del_v1 || is_del_v2) {
- if (is_del_v1)
+ if (is_del_v1) {
v1 = BMO_slot_map_elem_get(slot_targetmap, v1);
- if (is_del_v2)
+ }
+ if (is_del_v2) {
v2 = BMO_slot_map_elem_get(slot_targetmap, v2);
+ }
if (v1 == v2) {
BMO_edge_flag_enable(bm, e, EDGE_COL);
@@ -337,8 +339,9 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op)
vert_snap = BMO_slot_buffer_get_single(BMO_slot_get(op->slots_in, "vert_snap"));
tot = BM_vert_face_count(vert_snap);
- if (!tot)
+ if (!tot) {
return;
+ }
fac = 1.0f / tot;
BM_ITER_ELEM (l, &iter, vert_snap, BM_LOOPS_OF_VERT) {
@@ -388,8 +391,9 @@ void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op)
const int type = bm->ldata.layers[i].type;
const int offset = bm->ldata.layers[i].offset;
- if (!CustomData_layer_has_math(&bm->ldata, i))
+ if (!CustomData_layer_has_math(&bm->ldata, i)) {
continue;
+ }
CustomData_data_initminmax(type, &min, &max);
@@ -474,8 +478,9 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
zero_v3(center);
- if (!BMO_edge_flag_test(bm, e, EDGE_MARK))
+ if (!BMO_edge_flag_test(bm, e, EDGE_MARK)) {
continue;
+ }
BLI_assert(BLI_stack_is_empty(edge_stack));
@@ -598,8 +603,9 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op)
#endif
for (i = 0; i < bm->ldata.totlayer; i++) {
- if (CustomData_layer_has_math(&bm->ldata, i))
+ if (CustomData_layer_has_math(&bm->ldata, i)) {
bmo_collapsecon_do_layer(bm, i, oflag);
+ }
}
#ifndef NDEBUG
@@ -634,9 +640,9 @@ static void bmesh_find_doubles_common(
int *duplicates = MEM_mallocN(sizeof(int) * verts_len, __func__);
{
- KDTree *tree = BLI_kdtree_new(verts_len);
+ KDTree_3d *tree = BLI_kdtree_3d_new(verts_len);
for (int i = 0; i < verts_len; i++) {
- BLI_kdtree_insert(tree, i, verts[i]->co);
+ BLI_kdtree_3d_insert(tree, i, verts[i]->co);
if (has_keep_vert && BMO_vert_flag_test(bm, verts[i], VERT_KEEP)) {
duplicates[i] = i;
}
@@ -645,9 +651,9 @@ static void bmesh_find_doubles_common(
}
}
- BLI_kdtree_balance(tree);
- found_duplicates = BLI_kdtree_calc_duplicates_fast(tree, dist, false, duplicates) != 0;
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_balance(tree);
+ found_duplicates = BLI_kdtree_3d_calc_duplicates_fast(tree, dist, false, duplicates) != 0;
+ BLI_kdtree_3d_free(tree);
}
if (found_duplicates) {
diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
index acdb49e94e1..bf376a757ef 100644
--- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c
+++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
@@ -229,13 +229,17 @@ static void init_laplacian_matrix(LaplacianSystem *sys)
sys->zerola[idv1] = 1;
sys->zerola[idv2] = 1;
sys->zerola[idv3] = 1;
- if (has_4_vert) sys->zerola[idv4] = 1;
+ if (has_4_vert) {
+ sys->zerola[idv4] = 1;
+ }
}
sys->ring_areas[idv1] += areaf;
sys->ring_areas[idv2] += areaf;
sys->ring_areas[idv3] += areaf;
- if (has_4_vert) sys->ring_areas[idv4] += areaf;
+ if (has_4_vert) {
+ sys->ring_areas[idv4] += areaf;
+ }
if (has_4_vert) {
@@ -478,9 +482,13 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
BMVert *v;
LaplacianSystem *sys;
- if (bm->totface == 0) return;
+ if (bm->totface == 0) {
+ return;
+ }
sys = init_laplacian_system(bm->totedge, bm->totface, bm->totvert);
- if (!sys) return;
+ if (!sys) {
+ return;
+ }
sys->bm = bm;
sys->op = op;
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 360b1fea4d2..6b7f81aabb6 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -151,7 +151,9 @@ static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v_a, BMVert *v_b, BMFace
f_new = BM_face_split(bm, f, l_a, l_b, &l_new, NULL, false);
- if (r_f_new) *r_f_new = f_new;
+ if (r_f_new) {
+ *r_f_new = f_new;
+ }
return l_new ? l_new->e : NULL;
}
@@ -448,8 +450,12 @@ static void bm_subdivide_multicut(
BMO_edge_flag_enable(bm, e_new, SUBD_SPLIT | ELE_SPLIT);
BM_CHECK_ELEMENT(v);
- if (v->e) BM_CHECK_ELEMENT(v->e);
- if (v->e && v->e->l) BM_CHECK_ELEMENT(v->e->l->f);
+ if (v->e) {
+ BM_CHECK_ELEMENT(v->e);
+ }
+ if (v->e && v->e->l) {
+ BM_CHECK_ELEMENT(v->e->l->f);
+ }
}
alter_co(v1, &e_tmp, params, 0, &v1_tmp, &v2_tmp);
@@ -689,8 +695,9 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts
b = numcuts + 1 + numcuts + 1 + (numcuts - i - 1);
e = connect_smallest_face(bm, verts[a], verts[b], &f_new);
- if (!e)
+ if (!e) {
continue;
+ }
BMO_edge_flag_enable(bm, e, ELE_INNER);
BMO_face_flag_enable(bm, f_new, ELE_INNER);
@@ -715,8 +722,9 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts
a = i * s + j;
b = (i - 1) * s + j;
e = connect_smallest_face(bm, lines[a], lines[b], &f_new);
- if (!e)
+ if (!e) {
continue;
+ }
BMO_edge_flag_enable(bm, e, ELE_INNER);
BMO_face_flag_enable(bm, f_new, ELE_INNER);
@@ -794,7 +802,9 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts,
a = numcuts * 2 + 2 + i;
b = numcuts + numcuts - i;
e = connect_smallest_face(bm, verts[a], verts[b], &f_new);
- if (!e) goto cleanup;
+ if (!e) {
+ goto cleanup;
+ }
BMO_edge_flag_enable(bm, e, ELE_INNER);
BMO_face_flag_enable(bm, f_new, ELE_INNER);
@@ -843,7 +853,9 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts,
cleanup:
for (i = 1; i < numcuts + 2; i++) {
- if (lines[i]) MEM_freeN(lines[i]);
+ if (lines[i]) {
+ MEM_freeN(lines[i]);
+ }
}
MEM_freeN(lines);
@@ -1001,8 +1013,9 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
bool matched = false;
/* skip non-quads if requested */
- if (use_only_quads && face->len != 4)
+ if (use_only_quads && face->len != 4) {
continue;
+ }
/* figure out which pattern to use */
@@ -1018,8 +1031,8 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
verts[i] = l_new->v;
if (BMO_edge_flag_test(bm, edges[i], SUBD_SPLIT)) {
- if (!e1) e1 = edges[i];
- else e2 = edges[i];
+ if (!e1) { e1 = edges[i]; }
+ else { e2 = edges[i]; }
totesel++;
}
@@ -1278,8 +1291,12 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
BM_data_layer_free_n(bm, &bm->vdata, CD_SHAPEKEY, params.shape_info.tmpkey);
BLI_stack_free(facedata);
- if (edges) BLI_array_free(edges);
- if (verts) BLI_array_free(verts);
+ if (edges) {
+ BLI_array_free(edges);
+ }
+ if (verts) {
+ BLI_array_free(verts);
+ }
BLI_array_free(loops_split);
BLI_array_free(loops);
diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
index 04a5cf316be..8c5ee4ede3d 100644
--- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c
+++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
@@ -249,8 +249,9 @@ static GSet *bm_edgering_pair_calc(BMesh *bm, ListBase *eloops_rim)
pair_test.first = el_store;
pair_test.second = el_store_other;
- if (pair_test.first > pair_test.second)
+ if (pair_test.first > pair_test.second) {
SWAP(const void *, pair_test.first, pair_test.second);
+ }
void **pair_key_p;
if (!BLI_gset_ensure_p_ex(eloop_pair_gs, &pair_test, &pair_key_p)) {
@@ -693,8 +694,8 @@ static void bm_edgering_pair_interpolate(
/* create the triangle and transform */
for (j = 0; j < 3; j++) {
zero_v3(tri_tmp[j]);
- if (j == 1) tri_tmp[j][0] = shape_size;
- else if (j == 2) tri_tmp[j][1] = shape_size;
+ if (j == 1) { tri_tmp[j][0] = shape_size; }
+ else if (j == 2) { tri_tmp[j][1] = shape_size; }
mul_qt_v3(quat_array[i], tri_tmp[j]);
add_v3_v3(tri_tmp[j], coord_array_main[i]);
}
diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c
index 747b1769137..35f5c40a213 100644
--- a/source/blender/bmesh/operators/bmo_triangulate.c
+++ b/source/blender/bmesh/operators/bmo_triangulate.c
@@ -47,7 +47,7 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op)
BM_mesh_elem_hflag_disable_all(bm, BM_FACE | BM_EDGE, BM_ELEM_TAG, false);
BMO_slot_buffer_hflag_enable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, false);
- BM_mesh_triangulate(bm, quad_method, ngon_method, true, op, slot_facemap_out, slot_facemap_double_out);
+ BM_mesh_triangulate(bm, quad_method, ngon_method, 4, true, op, slot_facemap_out, slot_facemap_double_out);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index 3e99d5fb814..2439b5fe2b2 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -399,24 +399,30 @@ void bmo_smooth_vert_exec(BMesh *UNUSED(bm), BMOperator *op)
mul_v3_fl(co, 1.0f / (float)j);
interp_v3_v3v3(co, v->co, co, fac);
- if (clipx && fabsf(v->co[0]) <= clip_dist)
+ if (clipx && fabsf(v->co[0]) <= clip_dist) {
co[0] = 0.0f;
- if (clipy && fabsf(v->co[1]) <= clip_dist)
+ }
+ if (clipy && fabsf(v->co[1]) <= clip_dist) {
co[1] = 0.0f;
- if (clipz && fabsf(v->co[2]) <= clip_dist)
+ }
+ if (clipz && fabsf(v->co[2]) <= clip_dist) {
co[2] = 0.0f;
+ }
i++;
}
i = 0;
BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
- if (xaxis)
+ if (xaxis) {
v->co[0] = cos[i][0];
- if (yaxis)
+ }
+ if (yaxis) {
v->co[1] = cos[i][1];
- if (zaxis)
+ }
+ if (zaxis) {
v->co[2] = cos[i][2];
+ }
i++;
}
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 803a55bf9a8..1c77220c03c 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -240,26 +240,30 @@ static int bev_debug_flags = 0;
/* If we're called from the modifier, tool flags aren't available, but don't need output geometry */
static void flag_out_edge(BMesh *bm, BMEdge *bme)
{
- if (bm->use_toolflags)
+ if (bm->use_toolflags) {
BMO_edge_flag_enable(bm, bme, EDGE_OUT);
+ }
}
static void flag_out_vert(BMesh *bm, BMVert *bmv)
{
- if (bm->use_toolflags)
+ if (bm->use_toolflags) {
BMO_vert_flag_enable(bm, bmv, VERT_OUT);
+ }
}
static void disable_flag_out_edge(BMesh *bm, BMEdge *bme)
{
- if (bm->use_toolflags)
+ if (bm->use_toolflags) {
BMO_edge_flag_disable(bm, bme, EDGE_OUT);
+ }
}
static void record_face_kind(BevelParams *bp, BMFace *f, FKind fkind)
{
- if (bp->face_hash)
+ if (bp->face_hash) {
BLI_ghash_insert(bp->face_hash, f, POINTER_FROM_INT(fkind));
+ }
}
static FKind get_face_kind(BevelParams *bp, BMFace *f)
@@ -352,8 +356,9 @@ static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme)
int i;
for (i = 0; i < bv->edgecount; i++) {
- if (bv->edges[i].e == bme)
+ if (bv->edges[i].e == bme) {
return &bv->edges[i];
+ }
}
return NULL;
}
@@ -374,8 +379,9 @@ static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e, BevVert
bvo = find_bevvert(bp, e->is_rev ? e->e->v1 : e->e->v2);
if (bvo) {
- if (r_bvother)
+ if (r_bvother) {
*r_bvother = bvo;
+ }
eother = find_edge_half(bvo, e->e);
BLI_assert(eother != NULL);
return eother;
@@ -392,8 +398,9 @@ static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e)
{
EdgeHalf *e;
- if (from_e == NULL)
+ if (from_e == NULL) {
from_e = &bv->edges[bv->edgecount - 1];
+ }
e = from_e;
do {
if (e->is_bev) {
@@ -410,8 +417,9 @@ static int count_ccw_edges_between(EdgeHalf *e1, EdgeHalf *e2)
EdgeHalf *e = e1;
do {
- if (e == e2)
+ if (e == e2) {
break;
+ }
e = e->next;
cnt++;
} while (e != e1);
@@ -427,8 +435,9 @@ static bool edges_face_connected_at_vert(BMEdge *bme1, BMEdge *bme2)
BMIter iter;
BM_ITER_ELEM(l, &iter, bme1, BM_LOOPS_OF_EDGE) {
- if (l->prev->e == bme2 || l->next->e == bme2)
+ if (l->prev->e == bme2 || l->next->e == bme2) {
return true;
+ }
}
return false;
}
@@ -445,23 +454,28 @@ static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother)
frep2 = NULL;
if (v->ebev) {
frep = v->ebev->fprev;
- if (v->efirst->fprev != frep)
+ if (v->efirst->fprev != frep) {
frep2 = v->efirst->fprev;
+ }
}
else if (v->efirst) {
frep = v->efirst->fprev;
if (frep) {
- if (v->elast->fnext != frep)
+ if (v->elast->fnext != frep) {
frep2 = v->elast->fnext;
- else if (v->efirst->fnext != frep)
+ }
+ else if (v->efirst->fnext != frep) {
frep2 = v->efirst->fnext;
- else if (v->elast->fprev != frep)
+ }
+ else if (v->elast->fprev != frep) {
frep2 = v->efirst->fprev;
+ }
}
else if (v->efirst->fnext) {
frep = v->efirst->fnext;
- if (v->elast->fnext != frep)
+ if (v->elast->fnext != frep) {
frep2 = v->elast->fnext;
+ }
}
else if (v->elast->fprev) {
frep = v->elast->fprev;
@@ -470,17 +484,20 @@ static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother)
else if (v->prev->elast) {
frep = v->prev->elast->fnext;
if (v->next->efirst) {
- if (frep)
+ if (frep) {
frep2 = v->next->efirst->fprev;
- else
+ }
+ else {
frep = v->next->efirst->fprev;
+ }
}
}
else {
frep = NULL;
}
- if (r_fother)
+ if (r_fother) {
*r_fother = frep2;
+ }
return frep;
}
@@ -523,8 +540,9 @@ static BMFace *bev_create_ngon(
}
if (interp_f) {
bme = NULL;
- if (edge_arr)
+ if (edge_arr) {
bme = edge_arr[i];
+ }
if (bme) {
copy_v3_v3(save_co, l->v->co);
closest_to_line_segment_v3(l->v->co, save_co, bme->v1->co, bme->v2->co);
@@ -548,8 +566,9 @@ static BMFace *bev_create_ngon(
}
}
- if (mat_nr >= 0)
+ if (mat_nr >= 0) {
f->mat_nr = mat_nr;
+ }
return f;
}
@@ -596,13 +615,15 @@ static bool contig_ldata_across_edge(BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f
BMVert *v1, *v2;
int i;
- if (bm->ldata.totlayer == 0)
+ if (bm->ldata.totlayer == 0) {
return true;
+ }
v1 = e->v1;
v2 = e->v2;
- if (!BM_edge_loop_pair(e, &lef1, &lef2))
+ if (!BM_edge_loop_pair(e, &lef1, &lef2)) {
return false;
+ }
if (lef1->f == f2) {
SWAP(BMLoop *, lef1, lef2);
}
@@ -651,8 +672,9 @@ static void bev_merge_uvs(BMesh *bm, BMVert *v)
for (i = 0; i < num_of_uv_layers; i++) {
int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i);
- if (cd_loop_uv_offset == -1)
+ if (cd_loop_uv_offset == -1) {
return;
+ }
n = 0;
zero_v2(uv);
@@ -685,19 +707,23 @@ static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v)
l1 = NULL;
l2 = NULL;
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
- if (l->e == bme)
+ if (l->e == bme) {
l1 = l;
- else if (l->prev->e == bme)
+ }
+ else if (l->prev->e == bme) {
l2 = l;
+ }
}
- if (l1 == NULL || l2 == NULL)
+ if (l1 == NULL || l2 == NULL) {
return;
+ }
for (i = 0; i < num_of_uv_layers; i++) {
int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i);
- if (cd_loop_uv_offset == -1)
+ if (cd_loop_uv_offset == -1) {
return;
+ }
zero_v2(uv);
luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset);
@@ -719,8 +745,9 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3])
sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co);
len = normalize_v3(dir);
- if (d > len)
+ if (d > len) {
d = len - (float)(50.0 * BEVEL_EPSILON_D);
+ }
copy_v3_v3(slideco, v->co);
madd_v3_v3fl(slideco, dir, -d);
}
@@ -762,19 +789,25 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v)
/* angles are in [0,pi]. need to compare cross product with normal to see if they are reflex */
cross_v3_v3v3(cross, dir1, dir2);
normalize_v3(cross);
- if (e1->fnext)
+ if (e1->fnext) {
no = e1->fnext->no;
- else if (e2->fprev)
+ }
+ else if (e2->fprev) {
no = e2->fprev->no;
- else
+ }
+ else {
no = v->no;
+ }
dot = dot_v3v3(cross, no);
- if (fabsf(dot) < BEVEL_EPSILON_BIG)
+ if (fabsf(dot) < BEVEL_EPSILON_BIG) {
return 0;
- else if (dot < 0.0f)
+ }
+ else if (dot < 0.0f) {
return 1;
- else
+ }
+ else {
return -1;
+ }
}
/* co should be approximately on the plane between e1 and e2, which share common vert v
@@ -798,11 +831,13 @@ static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1,
ang1co = angle_normalized_v3v3(dir1, dirco);
/* angles are in [0,pi]. need to compare cross product with normal to see if they are reflex */
cross_v3_v3v3(no, dir1, dir2);
- if (dot_v3v3(no, f->no) < 0.0f)
+ if (dot_v3v3(no, f->no) < 0.0f) {
ang11 = (float)(M_PI * 2.0) - ang11;
+ }
cross_v3_v3v3(no, dir1, dirco);
- if (dot_v3v3(no, f->no) < 0.0f)
+ if (dot_v3v3(no, f->no) < 0.0f) {
ang1co = (float)(M_PI * 2.0) - ang1co;
+ }
return (ang11 - ang1co > -BEVEL_EPSILON_ANG);
}
@@ -823,9 +858,10 @@ static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1,
*/
static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool edges_between, float meetco[3])
{
- float dir1[3], dir2[3], dir1n[3], dir2p[3], norm_v[3], norm_v1[3], norm_v2[3],
- norm_perp1[3], norm_perp2[3], off1a[3], off1b[3], off2a[3], off2b[3],
- isect2[3], dropco[3], plane[4], ang, d;
+ float dir1[3], dir2[3], dir1n[3], dir2p[3], norm_v[3], norm_v1[3], norm_v2[3];
+ float norm_perp1[3], norm_perp2[3], off1a[3], off1b[3], off2a[3], off2b[3];
+ float isect2[3], dropco[3], plane[4];
+ float ang, d;
BMVert *closer_v;
EdgeHalf *e, *e1next, *e2prev;
BMFace *ff;
@@ -857,10 +893,12 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool e
* if offsets are different, we're out of luck:
* use the max of the two (so get consistent looking results if the same situation
* arises elsewhere in the object but with opposite roles for e1 and e2 */
- if (f)
+ if (f) {
copy_v3_v3(norm_v, f->no);
- else
+ }
+ else {
copy_v3_v3(norm_v, v->no);
+ }
add_v3_v3(dir1, dir2);
cross_v3_v3v3(norm_perp1, dir1, norm_v);
normalize_v3(norm_perp1);
@@ -895,8 +933,9 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool e
else if (!edges_between) {
cross_v3_v3v3(norm_v1, dir2, dir1);
normalize_v3(norm_v1);
- if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f)
+ if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) {
negate_v3(norm_v1);
+ }
copy_v3_v3(norm_v2, norm_v1);
}
else {
@@ -904,13 +943,15 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool e
cross_v3_v3v3(norm_v1, dir1n, dir1);
normalize_v3(norm_v1);
f = e1->fnext;
- if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f)
+ if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) {
negate_v3(norm_v1);
+ }
cross_v3_v3v3(norm_v2, dir2, dir2p);
normalize_v3(norm_v2);
f = e2->fprev;
- if (dot_v3v3(norm_v2, f ? f->no : v->no) < 0.0f)
+ if (dot_v3v3(norm_v2, f ? f->no : v->no) < 0.0f) {
negate_v3(norm_v2);
+ }
}
/* get vectors perp to each edge, perp to norm_v, and pointing into face */
@@ -953,8 +994,9 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool e
}
for (e = e1; e != e2; e = e->next) {
ff = e->fnext;
- if (!ff)
+ if (!ff) {
continue;
+ }
plane_from_point_normal_v3(plane, v->co, ff->no);
closest_to_plane_normalized_v3(dropco, plane, meetco);
if (point_between_edges(dropco, v, ff, e, e->next)) {
@@ -987,30 +1029,36 @@ static bool offset_meet_edge(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetc
/* find angle from dir1 to dir2 as viewed from vertex normal side */
ang = angle_normalized_v3v3(dir1, dir2);
if (fabsf(ang) < BEVEL_GOOD_ANGLE) {
- if (r_angle)
+ if (r_angle) {
*r_angle = 0.0f;
+ }
return false;
}
cross_v3_v3v3(fno, dir1, dir2);
if (dot_v3v3(fno, v->no) < 0.0f) {
ang = 2.0f * (float)M_PI - ang; /* angle is reflex */
- if (r_angle)
+ if (r_angle) {
*r_angle = ang;
+ }
return false;
}
- if (r_angle)
+ if (r_angle) {
*r_angle = ang;
+ }
- if (fabsf(ang - (float)M_PI) < BEVEL_GOOD_ANGLE)
+ if (fabsf(ang - (float)M_PI) < BEVEL_GOOD_ANGLE) {
return false;
+ }
sinang = sinf(ang);
copy_v3_v3(meetco, v->co);
- if (e1->offset_r == 0.0f)
+ if (e1->offset_r == 0.0f) {
madd_v3_v3fl(meetco, dir1, e2->offset_l / sinang);
- else
+ }
+ else {
madd_v3_v3fl(meetco, dir2, e1->offset_r / sinang);
+ }
return true;
}
@@ -1045,9 +1093,10 @@ static bool offset_on_edge_between(
ok2 = offset_meet_edge(emid, e2, v, meet2, &ang2);
if (ok1 && ok2) {
mid_v3_v3v3(meetco, meet1, meet2);
- if (r_sinratio)
+ if (r_sinratio) {
/* ang1 should not be 0, but be paranoid */
*r_sinratio = (ang1 == 0.0f) ? 1.0f : sinf(ang2) / sinf(ang1);
+ }
retval = true;
}
else if (ok1 && !ok2) {
@@ -1082,15 +1131,19 @@ static void offset_in_plane(EdgeHalf *e, const float plane_no[3], bool left, flo
}
else {
zero_v3(no);
- if (fabsf(dir[0]) < fabsf(dir[1]))
+ if (fabsf(dir[0]) < fabsf(dir[1])) {
no[0] = 1.0f;
- else
+ }
+ else {
no[1] = 1.0f;
+ }
}
- if (left)
+ if (left) {
cross_v3_v3v3(fdir, dir, no);
- else
+ }
+ else {
cross_v3_v3v3(fdir, no, dir);
+ }
normalize_v3(fdir);
copy_v3_v3(r, v->co);
madd_v3_v3fl(r, fdir, left ? e->offset_l : e->offset_r);
@@ -1254,16 +1307,18 @@ static void move_profile_plane(BoundVert *bndv, EdgeHalf *e1, EdgeHalf *e2)
float d1[3], d2[3], no[3], no2[3], dot;
/* only do this if projecting, and e1, e2, and proj_dir are not coplanar */
- if (is_zero_v3(bndv->profile.proj_dir))
+ if (is_zero_v3(bndv->profile.proj_dir)) {
return;
+ }
sub_v3_v3v3(d1, e1->e->v1->co, e1->e->v2->co);
sub_v3_v3v3(d2, e2->e->v1->co, e2->e->v2->co);
cross_v3_v3v3(no, d1, d2);
cross_v3_v3v3(no2, d1, bndv->profile.proj_dir);
if (normalize_v3(no) > BEVEL_EPSILON_BIG && normalize_v3(no2) > BEVEL_EPSILON_BIG) {
dot = fabsf(dot_v3v3(no, no2));
- if (fabsf(dot - 1.0f) > BEVEL_EPSILON_BIG)
+ if (fabsf(dot - 1.0f) > BEVEL_EPSILON_BIG) {
copy_v3_v3(bndv->profile.plane_no, no);
+ }
}
}
@@ -1277,8 +1332,9 @@ static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *b
float d1[3], d2[3], no[3], no2[3], no3[3], dot1, dot2, l1, l2, l3;
/* only do this if projecting, and d1, d2, and proj_dir are not coplanar */
- if (is_zero_v3(bndv1->profile.proj_dir) || is_zero_v3(bndv2->profile.proj_dir))
+ if (is_zero_v3(bndv1->profile.proj_dir) || is_zero_v3(bndv2->profile.proj_dir)) {
return;
+ }
sub_v3_v3v3(d1, bv->v->co, bndv1->nv.co);
sub_v3_v3v3(d2, bv->v->co, bndv2->nv.co);
cross_v3_v3v3(no, d1, d2);
@@ -1292,10 +1348,12 @@ static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *b
if (l1 > BEVEL_EPSILON && (l2 > BEVEL_EPSILON || l3 > BEVEL_EPSILON)) {
dot1 = fabsf(dot_v3v3(no, no2));
dot2 = fabsf(dot_v3v3(no, no3));
- if (fabsf(dot1 - 1.0f) > BEVEL_EPSILON)
+ if (fabsf(dot1 - 1.0f) > BEVEL_EPSILON) {
copy_v3_v3(bndv1->profile.plane_no, no);
- if (fabsf(dot2 - 1.0f) > BEVEL_EPSILON)
+ }
+ if (fabsf(dot2 - 1.0f) > BEVEL_EPSILON) {
copy_v3_v3(bndv2->profile.plane_no, no);
+ }
}
}
@@ -1305,12 +1363,14 @@ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f)
{
BMLoop *la, *lb;
- if (!f)
+ if (!f) {
return 0;
+ }
la = BM_face_edge_share_loop(f, a);
lb = BM_face_edge_share_loop(f, b);
- if (!la || !lb)
+ if (!la || !lb) {
return 0;
+ }
return lb->next == la ? 1 : -1;
}
@@ -1449,10 +1509,12 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n,
int d;
if (bp->seg == 1) {
- if (i == 0)
+ if (i == 0) {
copy_v3_v3(r_co, pro->coa);
- else
+ }
+ else {
copy_v3_v3(r_co, pro->cob);
+ }
}
else {
@@ -1486,22 +1548,27 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv)
bool need_2, map_ok;
Profile *pro = &bndv->profile;
- if (bp->seg == 1)
+ if (bp->seg == 1) {
return;
+ }
need_2 = bp->seg != bp->pro_spacing.seg_2;
if (!pro->prof_co) {
pro->prof_co = (float *)BLI_memarena_alloc(bp->mem_arena, (bp->seg + 1) * 3 * sizeof(float));
- if (need_2)
+ if (need_2) {
pro->prof_co_2 = (float *)BLI_memarena_alloc(bp->mem_arena, (bp->pro_spacing.seg_2 + 1) * 3 *sizeof(float));
- else
+ }
+ else {
pro->prof_co_2 = pro->prof_co;
+ }
}
r = pro->super_r;
- if (r == PRO_LINE_R)
+ if (r == PRO_LINE_R) {
map_ok = false;
- else
+ }
+ else {
map_ok = make_unit_square_map(pro->coa, pro->midco, pro->cob, m);
+ }
for (i = 0; i < 2; i++) {
if (i == 0) {
ns = bp->seg;
@@ -1510,8 +1577,9 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv)
prof_co = pro->prof_co;
}
else {
- if (!need_2)
+ if (!need_2) {
break; /* shares coords with pro->prof_co */
+ }
ns = bp->pro_spacing.seg_2;
xvals = bp->pro_spacing.xvals_2;
yvals = bp->pro_spacing.yvals_2;
@@ -1519,10 +1587,12 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv)
}
BLI_assert((r == PRO_LINE_R || (xvals != NULL && yvals != NULL)) && prof_co != NULL);
for (k = 0; k <= ns; k++) {
- if (k == 0)
+ if (k == 0) {
copy_v3_v3(co, pro->coa);
- else if (k == ns)
+ }
+ else if (k == ns) {
copy_v3_v3(co, pro->cob);
+ }
else {
if (map_ok) {
p[0] = xvals[k];
@@ -1630,13 +1700,15 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg)
/* First first edge with seam or sharp edge data */
while ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) {
e = e->next;
- if (e == efirst)
+ if (e == efirst) {
break;
+ }
}
/* If no such edge found, return */
- if ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag)))
+ if ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) {
return;
+ }
/* Set efirst to this first encountered edge. */
efirst = e;
@@ -1648,8 +1720,9 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg)
while (((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(ne, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(ne, flag))) &&
ne != efirst)
{
- if (ne->is_bev)
+ if (ne->is_bev) {
flag_count++;
+ }
ne = ne->next;
}
if (ne == e || (ne == efirst && ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(efirst, flag)) ||
@@ -1677,8 +1750,9 @@ static void bevel_extend_edge_data(BevVert *bv)
do {
/* If current boundvert has a seam length > 0 then it has a seam running along its edges */
if (bcur->seam_len) {
- if (!bv->vmesh->boundstart->seam_len && start == bv->vmesh->boundstart)
+ if (!bv->vmesh->boundstart->seam_len && start == bv->vmesh->boundstart) {
start = bcur; /* set start to first boundvert with seam_len > 0 */
+ }
/* Now for all the mesh_verts starting at current index and ending at idxlen
* We go through outermost ring and through all its segments and add seams
@@ -1693,10 +1767,12 @@ static void bevel_extend_edge_data(BevVert *bv)
/* Here v1 & v2 are current and next BMverts, we find common edge and set its edge data */
e = v1->e;
while (e->v1 != v2 && e->v2 != v2) {
- if (e->v1 == v1)
+ if (e->v1 == v1) {
e = e->v1_disk_link.next;
- else
+ }
+ else {
e = e->v2_disk_link.next;
+ }
}
BM_elem_flag_set(e, BM_ELEM_SEAM, true);
v1 = v2;
@@ -1704,17 +1780,20 @@ static void bevel_extend_edge_data(BevVert *bv)
BMVert *v3 = mesh_vert(vm, (i + 1) % vm->count, 0, 0)->v;
e = v1->e; //Do same as above for first and last vert
while (e->v1 != v3 && e->v2 != v3) {
- if (e->v1 == v1)
+ if (e->v1 == v1) {
e = e->v1_disk_link.next;
- else
+ }
+ else {
e = e->v2_disk_link.next;
+ }
}
BM_elem_flag_set(e, BM_ELEM_SEAM, true);
bcur = bcur->next;
}
}
- else
+ else {
bcur = bcur->next;
+ }
} while (bcur != start);
@@ -1722,8 +1801,9 @@ static void bevel_extend_edge_data(BevVert *bv)
start = bcur;
do {
if (bcur->sharp_len) {
- if (!bv->vmesh->boundstart->sharp_len && start == bv->vmesh->boundstart)
+ if (!bv->vmesh->boundstart->sharp_len && start == bv->vmesh->boundstart) {
start = bcur;
+ }
int idxlen = bcur->index + bcur->sharp_len;
for (int i = bcur->index; i < idxlen; i++) {
@@ -1734,10 +1814,12 @@ static void bevel_extend_edge_data(BevVert *bv)
e = v1->e;
while (e->v1 != v2 && e->v2 != v2) {
- if (e->v1 == v1)
+ if (e->v1 == v1) {
e = e->v1_disk_link.next;
- else
+ }
+ else {
e = e->v2_disk_link.next;
+ }
}
BM_elem_flag_set(e, BM_ELEM_SMOOTH, false);
v1 = v2;
@@ -1745,17 +1827,20 @@ static void bevel_extend_edge_data(BevVert *bv)
BMVert *v3 = mesh_vert(vm, (i + 1) % vm->count, 0, 0)->v;
e = v1->e;
while (e->v1 != v3 && e->v2 != v3) {
- if (e->v1 == v1)
+ if (e->v1 == v1) {
e = e->v1_disk_link.next;
- else
+ }
+ else {
e = e->v2_disk_link.next;
+ }
}
BM_elem_flag_set(e, BM_ELEM_SMOOTH, false);
bcur = bcur->next;
}
}
- else
+ else {
bcur = bcur->next;
+ }
} while (bcur != start);
}
@@ -1768,10 +1853,12 @@ static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp)
FKind fkind;
BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(f, BM_ELEM_SMOOTH))
+ if (!BM_elem_flag_test(f, BM_ELEM_SMOOTH)) {
continue;
- if (get_face_kind(bp, f) != F_RECON)
+ }
+ if (get_face_kind(bp, f) != F_RECON) {
continue;
+ }
BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) {
/* cases we care about will have exactly one adjacent face */
lother = l->radial_next;
@@ -1804,8 +1891,9 @@ static void bevel_harden_normals(BMesh *bm, BevelParams *bp)
short *clnors;
float *pnorm, norm[3];
- if (bp->offset == 0.0 || !bp->harden_normals)
+ if (bp->offset == 0.0 || !bp->harden_normals) {
return;
+ }
/* recalculate all face and vertex normals; side effect: ensures vertex, edge, face indices */
/* I suspect this is not necessary: TODO: test that guess */
@@ -1825,13 +1913,15 @@ static void bevel_harden_normals(BMesh *bm, BevelParams *bp)
/* ensure that bm->lnor_spacearr has properly stored loop normals; side effect: ensures loop indices */
BM_lnorspace_update(bm);
- if (cd_clnors_offset == -1)
+ if (cd_clnors_offset == -1) {
cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
+ }
BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
fkind = get_face_kind(bp, f);
- if (fkind == F_ORIG || fkind == F_RECON)
+ if (fkind == F_ORIG || fkind == F_RECON) {
continue;
+ }
BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) {
estep = l->prev->e; /* causes CW walk around l->v fan */
lprev = BM_vert_step_fan_loop(l, &estep);
@@ -1903,12 +1993,13 @@ static void bevel_harden_normals(BMesh *bm, BevelParams *bp)
}
}
if (pnorm) {
- if (pnorm == norm)
+ if (pnorm == norm) {
normalize_v3(norm);
+ }
l_index = BM_elem_index_get(l);
clnors = BM_ELEM_CD_GET_VOID_P(l, cd_clnors_offset);
BKE_lnor_space_custom_normal_to_data(
- bm->lnor_spacearr->lspacearr[l_index], pnorm, clnors);
+ bm->lnor_spacearr->lspacearr[l_index], pnorm, clnors);
}
}
}
@@ -1974,8 +2065,9 @@ static void set_bound_vert_seams(BevVert *bv, bool mark_seam, bool mark_sharp)
v->any_seam = false;
for (e = v->efirst; e; e = e->next) {
v->any_seam |= e->is_seam;
- if (e == v->elast)
+ if (e == v->elast) {
break;
+ }
}
bv->any_seam |= v->any_seam;
} while ((v = v->next) != bv->vmesh->boundstart);
@@ -1992,13 +2084,15 @@ static int count_bound_vert_seams(BevVert *bv)
{
int ans, i;
- if (!bv->any_seam)
+ if (!bv->any_seam) {
return 0;
+ }
ans = 0;
for (i = 0; i < bv->edgecount; i++)
- if (bv->edges[i].is_seam)
+ if (bv->edges[i].is_seam) {
ans++;
+ }
return ans;
}
@@ -2057,12 +2151,15 @@ static void build_boundary_vertex_only(BevelParams *bp, BevVert *bv, bool constr
if (construct) {
set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp);
- if (vm->count == 2)
+ if (vm->count == 2) {
vm->mesh_kind = M_NONE;
- else if (bp->seg == 1)
+ }
+ else if (bp->seg == 1) {
vm->mesh_kind = M_POLY;
- else
+ }
+ else {
vm->mesh_kind = M_ADJ;
+ }
}
}
@@ -2206,8 +2303,9 @@ static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
v1prev = v1->prev;
v3next = v3->next;
copy_v3_v3(co2, v1->nv.co);
- if (v1->is_arc_start)
+ if (v1->is_arc_start) {
copy_v3_v3(v1->profile.midco, co2);
+ }
/* co1 is intersection of line through co2 in dir of emiter->e
* and plane with normal the dir of emiter->e and through v1prev */
@@ -2288,8 +2386,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
int ang_kind;
/* Current bevel does nothing if only one edge into a vertex */
- if (bv->edgecount <= 1)
+ if (bv->edgecount <= 1) {
return;
+ }
if (bp->vertex_only) {
build_boundary_vertex_only(bp, bv, construct);
@@ -2345,8 +2444,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
}
else if (nnip > 0) {
if (bp->loop_slide && nnip == 1 && good_offset_on_edge_between(e, e2, enip, bv->v)) {
- if (offset_on_edge_between(e, e2, enip, bv->v, co, &r))
+ if (offset_on_edge_between(e, e2, enip, bv->v, co, &r)) {
eon = enip;
+ }
}
else {
offset_meet(e, e2, bv->v, NULL, true, co);
@@ -2355,8 +2455,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
else {
/* nip > 0 and nnip == 0 */
if (bp->loop_slide && nip == 1 && good_offset_on_edge_between(e, e2, eip, bv->v)) {
- if (offset_on_edge_between(e, e2, eip, bv->v, co, &r))
+ if (offset_on_edge_between(e, e2, eip, bv->v, co, &r)) {
eon = eip;
+ }
}
else {
offset_meet(e, e2, bv->v, e->fnext, true, co);
@@ -2368,8 +2469,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
v->elast = e2;
v->ebev = e2;
v->eon = eon;
- if (eon)
+ if (eon) {
v->sinratio = r;
+ }
e->rightv = v;
e2->leftv = v;
for (e3 = e->next; e3 != e2; e3 = e3->next) {
@@ -2386,15 +2488,18 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == 1) ||
(miter_inner != BEVEL_MITER_SHARP && ang_kind == -1))
{
- if (ang_kind == 1)
+ if (ang_kind == 1) {
emiter = e;
+ }
/* make one or two more boundverts; for now all will have same co */
v1 = v;
v1->ebev = NULL;
- if (ang_kind == 1 && miter_outer == BEVEL_MITER_PATCH)
+ if (ang_kind == 1 && miter_outer == BEVEL_MITER_PATCH) {
v2 = add_new_bound_vert(mem_arena, vm, co);
- else
+ }
+ else {
v2 = NULL;
+ }
v3 = add_new_bound_vert(mem_arena, vm, co);
v3->ebev = e2;
v3->efirst = e2;
@@ -2437,12 +2542,15 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
* If between is odd, put middle one at midindex */
for (e3 = e->next; e3 != e2; e3 = e3->next) {
v1->elast = e3;
- if (i < bet2)
+ if (i < bet2) {
e3->profile_index = 0;
- else if (betodd && i == bet2)
+ }
+ else if (betodd && i == bet2) {
e3->profile_index = bp->seg / 2;
- else
+ }
+ else {
e3->profile_index = bp->seg;
+ }
i++;
}
}
@@ -2454,8 +2562,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == 1) ||
(miter_inner != BEVEL_MITER_SHARP && ang_kind == -1))
{
- if (ang_kind == 1)
+ if (ang_kind == 1) {
emiter = e;
+ }
v1 = e->rightv;
if (ang_kind == 1 && miter_outer == BEVEL_MITER_PATCH) {
v2 = v1->next;
@@ -2466,8 +2575,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
v3 = v1->next;
}
adjust_bound_vert(v1, co);
- if (v2)
+ if (v2) {
adjust_bound_vert(v2, co);
+ }
adjust_bound_vert(v3, co);
}
else {
@@ -2527,12 +2637,14 @@ static void print_adjust_stats(BoundVert *vstart)
delta = fabs(eright->offset_r - eleft->offset_l);
delta_pct = 100.0 * delta / eright->offset_r_spec;
printf("e%d r(%f) vs l(%f): abs(delta)=%f, delta_pct=%f\n",
- BM_elem_index_get(eright->e), eright->offset_r, eleft->offset_l, delta, delta_pct);
+ BM_elem_index_get(eright->e), eright->offset_r, eleft->offset_l, delta, delta_pct);
even_residual2 += delta * delta;
- if (delta > max_even_r)
+ if (delta > max_even_r) {
max_even_r = delta;
- if (delta_pct > max_even_r_pct)
+ }
+ if (delta_pct > max_even_r_pct) {
max_even_r_pct = delta_pct;
+ }
}
v = v->adjchain;
} while (v && v != vstart);
@@ -2546,26 +2658,30 @@ static void print_adjust_stats(BoundVert *vstart)
delta = eright->offset_r - eright->offset_r_spec;
delta_pct = 100.0 * delta / eright->offset_r_spec;
printf("e%d r(%f) vs r spec(%f): delta=%f, delta_pct=%f\n",
- BM_elem_index_get(eright->e), eright->offset_r, eright->offset_r_spec, delta, delta_pct);
+ BM_elem_index_get(eright->e), eright->offset_r, eright->offset_r_spec, delta, delta_pct);
spec_residual2 += delta * delta;
delta = fabs(delta);
delta_pct = fabs(delta_pct);
- if (delta > max_spec_r)
+ if (delta > max_spec_r) {
max_spec_r = delta;
- if (delta_pct > max_spec_r_pct)
+ }
+ if (delta_pct > max_spec_r_pct) {
max_spec_r_pct = delta_pct;
+ }
delta = eleft->offset_l - eleft->offset_l_spec;
delta_pct = 100.0 * delta / eright->offset_l_spec;
printf("e%d l(%f) vs l spec(%f): delta=%f, delta_pct=%f\n",
- BM_elem_index_get(eright->e), eleft->offset_l, eleft->offset_l_spec, delta, delta_pct);
+ BM_elem_index_get(eright->e), eleft->offset_l, eleft->offset_l_spec, delta, delta_pct);
spec_residual2 += delta * delta;
delta = fabs(delta);
delta_pct = fabs(delta_pct);
- if (delta > max_spec_r)
+ if (delta > max_spec_r) {
max_spec_r = delta;
- if (delta_pct > max_spec_r_pct)
+ }
+ if (delta_pct > max_spec_r_pct) {
max_spec_r_pct = delta_pct;
+ }
}
v = v->adjchain;
} while (v && v != vstart);
@@ -2694,12 +2810,13 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
v = v->adjchain;
} while (v && v != vstart);
#ifdef DEBUG_ADJUST
- printf(" -> %d parms\n", np);
+ printf(" -> %d parms\n", np);
#endif
#ifdef FAST_ADJUST_CODE
- if (adjust_the_cycle_or_chain_fast(vstart, np, iscycle))
+ if (adjust_the_cycle_or_chain_fast(vstart, np, iscycle)) {
return;
+ }
#endif
nrows = iscycle ? 3 * np : 3 * np - 3;
@@ -2717,8 +2834,9 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
enextleft = v->adjchain->elast;
#ifdef DEBUG_ADJUST
printf("p%d: e%d->offset_r = %f\n", i, BM_elem_index_get(eright->e), eright->offset_r);
- if (iscycle || v != vstart)
+ if (iscycle || v != vstart) {
printf(" dependent: e%d->offset_l = %f * p%d\n", BM_elem_index_get(eleft->e), v->sinratio, i);
+ }
#endif
/* residue i: width difference between eright and eleft of next */
@@ -2749,7 +2867,7 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
EIG_linear_solver_right_hand_side_add(solver, 0, row, weight * enextleft->offset_l);
#ifdef DEBUG_ADJUST
printf("b[%d]=%f * %f, for e%d->offset_l\n", row, weight, enextleft->offset_l,
- BM_elem_index_get(enextleft->e));
+ BM_elem_index_get(enextleft->e));
#endif
}
else {
@@ -2769,8 +2887,9 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
/* Note: this print only works after solve, but by that time b has been cleared */
EIG_linear_solver_print_matrix(solver);
printf("\nSolution:\n");
- for (i = 0; i < np; i++)
+ for (i = 0; i < np; i++) {
printf("p%d = %f\n", i, EIG_linear_solver_variable_get(solver, 0, i));
+ }
#endif
/* Use the solution to set new widths */
@@ -2822,22 +2941,29 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
* It turns out that the dependent offsets either form chains or
* cycles, and we can process each of those separatey.
*/
-static void adjust_offsets(BevelParams *bp)
+static void adjust_offsets(BevelParams *bp, BMesh *bm)
{
+ BMVert *bmv;
BevVert *bv, *bvcur;
BoundVert *v, *vanchor, *vchainstart, *vchainend, *vnext;
EdgeHalf *enext;
- GHashIterator giter;
+ BMIter iter;
bool iscycle;
int chainlen;
/* find and process chains and cycles of unvisited BoundVerts that have eon set */
- GHASH_ITER(giter, bp->vert_hash) {
- bv = bvcur = BLI_ghashIterator_getValue(&giter);
+ /* 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))
+ continue;
+ bv = bvcur = find_bevvert(bp, bmv);
+ if (!bv)
+ continue;
vanchor = bv->vmesh->boundstart;
do {
- if (vanchor->visited || !vanchor->eon)
+ if (vanchor->visited || !vanchor->eon) {
continue;
+ }
/* Find one of (1) a cycle that starts and ends at v
* where each v has v->eon set and had not been visited before;
@@ -2855,11 +2981,13 @@ static void adjust_offsets(BevelParams *bp)
chainlen = 1;
while (v->eon && !v->visited && !iscycle) {
v->visited = true;
- if (!v->efirst)
+ if (!v->efirst) {
break;
+ }
enext = find_other_end_edge_half(bp, v->efirst, &bvcur);
- if (!enext)
+ if (!enext) {
break;
+ }
BLI_assert(enext != NULL);
vnext = enext->leftv;
v->adjchain = vnext;
@@ -2880,27 +3008,33 @@ static void adjust_offsets(BevelParams *bp)
bvcur = bv;
do {
v->visited = true;
- if (!v->elast)
+ if (!v->elast) {
break;
+ }
enext = find_other_end_edge_half(bp, v->elast, &bvcur);
- if (!enext)
+ if (!enext) {
break;
+ }
vnext = enext->rightv;
vnext->adjchain = v;
chainlen++;
vchainstart = vnext;
v = vnext;
} while (!v->visited && v->eon);
- if (chainlen >= 3 && !vchainstart->eon && !vchainend->eon)
+ if (chainlen >= 3 && !vchainstart->eon && !vchainend->eon) {
adjust_the_cycle_or_chain(vchainstart, false);
+ }
}
} while ((vanchor = vanchor->next) != bv->vmesh->boundstart);
}
/* Rebuild boundaries with new width specs */
- GHASH_ITER(giter, bp->vert_hash) {
- bv = BLI_ghashIterator_getValue(&giter);
- build_boundary(bp, bv, false);
+ 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)
+ build_boundary(bp, bv, false);
+ }
}
}
@@ -2919,8 +3053,9 @@ static BoundVert *pipe_test(BevVert *bv)
float dir1[3], dir3[3];
vm = bv->vmesh;
- if (vm->count < 3 || vm->count > 4 || bv->selcount < 3 || bv->selcount > 4)
+ if (vm->count < 3 || vm->count > 4 || bv->selcount < 3 || bv->selcount > 4) {
return NULL;
+ }
/* find v1, v2, v3 all with beveled edges, where v1 and v3 have collinear edges */
epipe = NULL;
@@ -2940,14 +3075,16 @@ static BoundVert *pipe_test(BevVert *bv)
}
} while ((v1 = v1->next) != vm->boundstart);
- if (!epipe)
+ if (!epipe) {
return NULL;
+ }
/* check face planes: all should have normals perpendicular to epipe */
for (e = &bv->edges[0]; e != &bv->edges[bv->edgecount]; e++) {
if (e->fnext) {
- if (dot_v3v3(dir1, e->fnext->no) > BEVEL_EPSILON_BIG)
+ if (dot_v3v3(dir1, e->fnext->no) > BEVEL_EPSILON_BIG) {
return NULL;
+ }
}
}
return v1;
@@ -2984,24 +3121,30 @@ static NewVert *mesh_vert_canon(VMesh *vm, int i, int j, int k)
odd = ns % 2;
BLI_assert(0 <= i && i <= n && 0 <= j && j <= ns && 0 <= k && k <= ns);
- if (!odd && j == ns2 && k == ns2)
+ if (!odd && j == ns2 && k == ns2) {
ans = mesh_vert(vm, 0, j, k);
- else if (j <= ns2 - 1 + odd && k <= ns2)
+ }
+ else if (j <= ns2 - 1 + odd && k <= ns2) {
ans = mesh_vert(vm, i, j, k);
- else if (k <= ns2)
+ }
+ else if (k <= ns2) {
ans = mesh_vert(vm, (i + n - 1) % n, k, ns - j);
- else
+ }
+ else {
ans = mesh_vert(vm, (i + 1) % n, ns - k, j);
+ }
return ans;
}
static bool is_canon(VMesh *vm, int i, int j, int k)
{
int ns2 = vm->seg / 2;
- if (vm->seg % 2 == 1)
+ if (vm->seg % 2 == 1) {
return (j <= ns2 && k <= ns2);
- else
+ }
+ else {
return ((j < ns2 && k <= ns2) || (j == ns2 && k == ns2 && i == 0));
+ }
}
/* Copy the vertex data to all of vm verts from canonical ones */
@@ -3016,8 +3159,9 @@ static void vmesh_copy_equiv_verts(VMesh *vm)
for (i = 0; i < n; i++) {
for (j = 0; j <= ns2; j++) {
for (k = 0; k <= ns; k++) {
- if (is_canon(vm, i, j, k))
+ if (is_canon(vm, i, j, k)) {
continue;
+ }
v1 = mesh_vert(vm, i, j, k);
v0 = mesh_vert_canon(vm, i, j, k);
copy_v3_v3(v1->co, v0->co);
@@ -3063,16 +3207,21 @@ static float sabin_gamma(int n)
double ans, k, k2, k4, k6, x, y;
/* precalculated for common cases of n */
- if (n < 3)
+ if (n < 3) {
return 0.0f;
- else if (n == 3)
+ }
+ else if (n == 3) {
ans = 0.065247584f;
- else if (n == 4)
+ }
+ else if (n == 4) {
ans = 0.25f;
- else if (n == 5)
+ }
+ else if (n == 5) {
ans = 0.401983447f;
- else if (n == 6)
+ }
+ else if (n == 6) {
ans = 0.523423277f;
+ }
else {
k = cos(M_PI / (double)n);
/* need x, real root of x^3 + (4k^2 - 3)x - 2k = 0.
@@ -3101,8 +3250,9 @@ static void fill_vmesh_fracs(VMesh *vm, float *frac, int i)
frac[k + 1] = total;
}
if (total > 0.0f) {
- for (k = 1; k <= ns; k++)
+ for (k = 1; k <= ns; k++) {
frac[k] /= total;
+ }
}
else {
frac[ns] = 1.0f;
@@ -3145,10 +3295,12 @@ static int interp_range(const float *frac, int n, const float f, float *r_rest)
for (i = 0; i < n; i++) {
if (f <= frac[i + 1]) {
rest = f - frac[i];
- if (rest == 0)
+ if (rest == 0) {
*r_rest = 0.0f;
- else
+ }
+ else {
*r_rest = rest / (frac[i + 1] - frac[i]);
+ }
if (i == n - 1 && *r_rest == 1.0f) {
i = n;
*r_rest = 0.0f;
@@ -3382,8 +3534,9 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm0)
mul_v3_fl(co, 1.0f / (float)n);
madd_v3_v3fl(co, co2, beta / (2.0f * (float)n));
madd_v3_v3fl(co, mesh_vert(vm0, 0, ns20, ns20)->co, gamma);
- for (i = 0; i < n; i++)
+ for (i = 0; i < n; i++) {
copy_v3_v3(mesh_vert(vm1, i, ns0, ns0)->co, co);
+ }
/* Final step: sample the boundary vertices at even parameter spacing */
bndv = vm1->boundstart;
@@ -3420,8 +3573,9 @@ static VMesh *make_cube_corner_square(MemArena *mem_arena, int nseg)
for (i = 0; i < 3; i++) {
for (j = 0; j <= ns2; j++) {
for (k = 0; k <= ns2; k++) {
- if (!is_canon(vm, i, j, k))
+ if (!is_canon(vm, i, j, k)) {
continue;
+ }
co[i] = 1.0f;
co[(i + 1) % 3] = (float)k * 2.0f / (float)nseg;
co[(i + 2) % 3] = (float)j * 2.0f / (float)nseg;
@@ -3453,10 +3607,12 @@ static VMesh *make_cube_corner_square_in(MemArena *mem_arena, int nseg)
co[i] = 1.0f;
add_new_bound_vert(mem_arena, vm, co);
}
- if (odd)
+ if (odd) {
b = 2.0f / (2.0f * (float)ns2 + (float)M_SQRT2);
- else
+ }
+ else {
b = 2.0f / (float)nseg;
+ }
for (i = 0; i < 3; i++) {
for (k = 0; k <= ns2; k++) {
co[i] = 1.0f - (float)k * b;
@@ -3488,10 +3644,12 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
int i, j, k, ns2;
float co[3], coc[3];
- if (r == PRO_SQUARE_R)
+ if (r == PRO_SQUARE_R) {
return make_cube_corner_square(mem_arena, nseg);
- else if (r == PRO_SQUARE_IN_R)
+ }
+ else if (r == PRO_SQUARE_IN_R) {
return make_cube_corner_square_in(mem_arena, nseg);
+ }
/* initial mesh has 3 sides, 2 segments */
vm0 = new_adj_vmesh(mem_arena, 3, 2, NULL);
@@ -3524,10 +3682,12 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
copy_v3_fl(co, M_SQRT1_3);
if (nseg > 2) {
- if (r > 1.5f)
+ if (r > 1.5f) {
mul_v3_fl(co, 1.4f);
- else if (r < 0.75f)
+ }
+ else if (r < 0.75f) {
mul_v3_fl(co, 0.6f);
+ }
}
copy_v3_v3(mesh_vert(vm0, 0, 1, 1)->co, co);
@@ -3537,8 +3697,9 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
while (vm1->seg < nseg) {
vm1 = cubic_subdiv(bp, vm1);
}
- if (vm1->seg != nseg)
+ if (vm1->seg != nseg) {
vm1 = interp_vmesh(bp, vm1, nseg);
+ }
/* Now snap each vertex to the superellipsoid */
ns2 = nseg / 2;
@@ -3561,30 +3722,36 @@ static int tri_corner_test(BevelParams *bp, BevVert *bv)
int i;
int in_plane_e = 0;
- if (bp->vertex_only)
+ if (bp->vertex_only) {
return -1;
- if (bv->vmesh->count != 3)
+ }
+ if (bv->vmesh->count != 3) {
return 0;
+ }
totang = 0.0f;
for (i = 0; i < bv->edgecount; i++) {
e = &bv->edges[i];
ang = BM_edge_calc_face_angle_signed_ex(e->e, 0.0f);
- if (ang <= M_PI_4)
+ if (ang <= M_PI_4) {
in_plane_e++;
- else if (ang >= 3.0f * (float) M_PI_4)
+ }
+ else if (ang >= 3.0f * (float) M_PI_4) {
return -1;
+ }
totang += ang;
}
- if (in_plane_e != bv->edgecount - 3)
+ if (in_plane_e != bv->edgecount - 3) {
return -1;
+ }
angdiff = fabsf(totang - 3.0f * (float)M_PI_2);
if ((bp->pro_super_r == PRO_SQUARE_R && angdiff > (float)M_PI / 16.0f) ||
(angdiff > (float)M_PI_4))
{
return -1;
}
- if (bv->edgecount != 3 || bv->selcount != 3)
+ if (bv->edgecount != 3 || bv->selcount != 3) {
return 0;
+ }
return 1;
}
@@ -3697,8 +3864,9 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv)
}
}
sub_v3_v3v3(dir, coa, co);
- if (len_squared_v3(dir) > BEVEL_EPSILON_SQ)
+ if (len_squared_v3(dir) > BEVEL_EPSILON_SQ) {
madd_v3_v3fl(co, dir, fullness);
+ }
copy_v3_v3(mesh_vert(vm0, 0, 1, 1)->co, co);
vmesh_copy_equiv_verts(vm0);
@@ -3706,8 +3874,9 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv)
do {
vm1 = cubic_subdiv(bp, vm1);
} while (vm1->seg < ns);
- if (vm1->seg != ns)
+ if (vm1->seg != ns) {
vm1 = interp_vmesh(bp, vm1, ns);
+ }
return vm1;
}
@@ -3773,8 +3942,9 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
for (i = 0; i < n; i++) {
for (j = 1; j <= ns2; j++) {
for (k = 0; k <= ns2; k++) {
- if (!is_canon(vm, i, j, k))
+ if (!is_canon(vm, i, j, k)) {
continue;
+ }
midline = even && k == ns2 &&
((i == 0 && j == ns2) || (i == ipipe1 || i == ipipe2));
snap_to_pipe_profile(vpipe, midline, mesh_vert(vm, i, j, k)->co);
@@ -3792,14 +3962,17 @@ static void get_incident_edges(BMFace *f, BMVert *v, BMEdge **r_e1, BMEdge **r_e
*r_e1 = NULL;
*r_e2 = NULL;
- if (!f)
+ if (!f) {
return;
+ }
BM_ITER_ELEM (e, &iter, f, BM_EDGES_OF_FACE) {
if (e->v1 == v || e->v2 == v) {
- if (*r_e1 == NULL)
+ if (*r_e1 == NULL) {
*r_e1 = e;
- else if (*r_e2 == NULL)
+ }
+ else if (*r_e2 == NULL) {
*r_e2 = e;
+ }
}
}
}
@@ -3811,10 +3984,12 @@ static BMEdge *find_closer_edge(float *co, BMEdge *e1, BMEdge *e2)
BLI_assert(e1 != NULL && e2 != NULL);
dsq1 = dist_squared_to_line_segment_v3(co, e1->v1->co, e1->v2->co);
dsq2 = dist_squared_to_line_segment_v3(co, e2->v1->co, e2->v2->co);
- if (dsq1 < dsq2)
+ if (dsq1 < dsq2) {
return e1;
- else
+ }
+ else {
return e2;
+ }
}
/* Snap co to the closest edge of face f. Return the edge in *r_snap_e,
@@ -3927,10 +4102,12 @@ static void build_square_in_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv, VMesh
/* copy whichever of a and b is closer to v into r */
static void closer_v3_v3v3v3(float r[3], float a[3], float b[3], float v[3])
{
- if (len_squared_v3v3(a, v) <= len_squared_v3v3(b, v))
+ if (len_squared_v3v3(a, v) <= len_squared_v3v3(b, v)) {
copy_v3_v3(r, a);
- else
+ }
+ else {
copy_v3_v3(r, b);
+ }
}
/* Special case of VMesh when profile == 1 and there are 3 or more beveled edges.
@@ -3972,8 +4149,9 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
e1 = bndv->efirst;
e2 = bndv->elast;
akind = 0;
- if (e1 && e2)
+ if (e1 && e2) {
akind = edges_angle_kind(e1, e2, bv->v);
+ }
if (bndv->is_patch_start) {
mid_v3_v3v3(centerline + clstride * i, bndv->nv.co, bndv->next->nv.co);
cset[i] = true;
@@ -4090,8 +4268,9 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
* This is used in interpolation along centerline in odd case.
* To avoid too big a drop from bv, cap finalfrac a 0.8 arbitrarily */
finalfrac = 0.5f / sin(ang);
- if (finalfrac > 0.8f)
+ if (finalfrac > 0.8f) {
finalfrac = 0.8f;
+ }
}
else {
finalfrac = 0.8f;
@@ -4123,8 +4302,9 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
}
bndv = bndv->next;
}
- if (!odd)
+ if (!odd) {
copy_v3_v3(mesh_vert(vm, 0, ns2, ns2)->co, bv->v->co);
+ }
vmesh_copy_equiv_verts(vm);
/* fill in interior points by interpolation from edges to centerlines */
@@ -4134,13 +4314,14 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
for (j = 1; j < ns2 + odd; j++) {
for (k = 1; k <= ns2; k++) {
ikind = isect_line_line_v3(
- mesh_vert(vm, i, 0, k)->co, centerline + clstride * im1 + 3 * k,
- mesh_vert(vm, i, j, 0)->co, centerline + clstride * i + 3 * j,
- meet1, meet2);
+ mesh_vert(vm, i, 0, k)->co, centerline + clstride * im1 + 3 * k,
+ mesh_vert(vm, i, j, 0)->co, centerline + clstride * i + 3 * j,
+ meet1, meet2);
if (ikind == 0) {
/* how can this happen? fall back on interpolation in one direction if it does */
- interp_v3_v3v3(mesh_vert(vm, i, j, k)->co,
- mesh_vert(vm, i, 0, k)->co, centerline + clstride * im1 + 3 * k, j * ns2inv);
+ interp_v3_v3v3(
+ mesh_vert(vm, i, j, k)->co,
+ mesh_vert(vm, i, 0, k)->co, centerline + clstride * im1 + 3 * k, j * ns2inv);
}
else if (ikind == 1) {
copy_v3_v3(mesh_vert(vm, i, j, k)->co, meet1);
@@ -4220,10 +4401,12 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv)
for (i = 0; i < n; i++) {
for (j = 0; j <= ns2; j++) {
for (k = 0; k <= ns; k++) {
- if (j == 0 && (k == 0 || k == ns))
+ if (j == 0 && (k == 0 || k == ns)) {
continue; /* boundary corners already made */
- if (!is_canon(vm, i, j, k))
+ }
+ if (!is_canon(vm, i, j, k)) {
continue;
+ }
copy_v3_v3(mesh_vert(vm, i, j, k)->co, mesh_vert(vm1, i, j, k)->co);
create_mesh_bmvert(bm, vm, i, j, k, bv->v);
}
@@ -4236,10 +4419,12 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv)
i = v->index;
f = boundvert_rep_face(v, NULL);
f2 = boundvert_rep_face(v->next, NULL);
- if (bp->vertex_only)
+ if (bp->vertex_only) {
e = v->efirst;
- else
+ }
+ else {
e = v->ebev;
+ }
bme = e ? e->e : NULL;
/* For odd ns, make polys with lower left corner at (i,j,k) for
* j in [0, ns2-1], k in [0, ns2]. And then the center ngon.
@@ -4295,8 +4480,9 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv)
else {
bme1 = k == ns2 - 1 ? bme : NULL;
bme3 = NULL;
- if (j == ns2 - 1 && v->prev->ebev)
+ if (j == ns2 - 1 && v->prev->ebev) {
bme3 = v->prev->ebev->e;
+ }
bme2 = bme1 != NULL ? bme1 : bme3;
r_f = bev_create_quad_ex(bm, bmv1, bmv2, bmv3, bmv4, f, f, f, f,
NULL, bme1, bme2, bme3, mat_nr);
@@ -4322,8 +4508,9 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv)
}
} while ((v = v->next) != vm->boundstart);
bmv1 = mesh_vert(vm, 0, ns2, ns2)->v;
- if (bp->vertex_only || count_bound_vert_seams(bv) <= 1)
+ if (bp->vertex_only || count_bound_vert_seams(bv) <= 1) {
bev_merge_uvs(bm, bmv1);
+ }
}
/* center ngon */
@@ -4347,15 +4534,17 @@ static bool is_bad_uv_poly(BevVert *bv, BMFace *frep)
v = vm->boundstart;
d2 = snap_face_dist_squared(v->nv.v->co, frep, &firste, co);
- if (d2 > BEVEL_EPSILON_BIG_SQ || firste == NULL)
+ if (d2 > BEVEL_EPSILON_BIG_SQ || firste == NULL) {
return false;
+ }
for (v = v->next; v != vm->boundstart; v = v->next) {
snap_face_dist_squared(v->nv.v->co, frep, &snape, co);
if (snape != firste) {
d2 = dist_to_line_v3(co, firste->v1->co, firste->v2->co);
- if (d2 > BEVEL_EPSILON_BIG_SQ)
+ if (d2 > BEVEL_EPSILON_BIG_SQ) {
return false;
+ }
}
}
return true;
@@ -4508,8 +4697,9 @@ static void bevel_vert_two_edges(BevelParams *bp, BMesh *bm, BevVert *bv)
create_mesh_bmvert(bm, vm, 0, 0, k, bv->v);
}
copy_v3_v3(mesh_vert(vm, 0, 0, ns)->co, v2->co);
- for (k = 1; k < ns; k++)
+ for (k = 1; k < ns; k++) {
copy_mesh_vert(vm, 1, 0, ns - k, 0, 0, k);
+ }
}
if (BM_vert_face_check(bv->v) == false) {
@@ -4520,8 +4710,9 @@ static void bevel_vert_two_edges(BevelParams *bp, BMesh *bm, BevVert *bv)
v2 = mesh_vert(vm, 0, 0, k + 1)->v;
BLI_assert(v1 != NULL && v2 != NULL);
bme = BM_edge_create(bm, v1, v2, e_eg, BM_CREATE_NO_DOUBLE);
- if (bme)
+ if (bme) {
flag_out_edge(bm, bme);
+ }
}
}
}
@@ -4554,8 +4745,9 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv)
create_mesh_bmvert(bm, vm, i, 0, 0, bv->v);
v->nv.v = mesh_vert(vm, i, 0, 0)->v;
if (weld && v->ebev) {
- if (!weld1)
+ if (!weld1) {
weld1 = v;
+ }
else {
weld2 = v;
move_weld_profile_planes(bv, weld1, weld2);
@@ -4574,8 +4766,9 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv)
if (v->ebev && vm->mesh_kind != M_ADJ) {
get_profile_point(bp, &v->profile, k, ns, co);
copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co);
- if (!weld)
+ if (!weld) {
create_mesh_bmvert(bm, vm, i, 0, k, bv->v);
+ }
}
else if (n == 2 && !v->ebev && vm->mesh_kind != M_ADJ) {
/* case of one edge beveled and this is the v without ebev */
@@ -4608,14 +4801,16 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv)
copy_v3_v3(mesh_vert(vm, weld1->index, 0, k)->co, co);
create_mesh_bmvert(bm, vm, weld1->index, 0, k, bv->v);
}
- for (k = 1; k < ns; k++)
+ for (k = 1; k < ns; k++) {
copy_mesh_vert(vm, weld2->index, 0, ns - k, weld1->index, 0, k);
+ }
}
switch (vm->mesh_kind) {
case M_NONE:
- if (n == 2 && bp->vertex_only)
+ if (n == 2 && bp->vertex_only) {
bevel_vert_two_edges(bp, bm, bv);
+ }
break;
case M_POLY:
bevel_build_poly(bp, bm, bv);
@@ -4738,8 +4933,9 @@ static bool fast_bevel_edge_order(BevVert *bv)
bme2 = (l->v == bv->v) ? l->prev->e : l->next->e;
if (!BM_BEVEL_EDGE_TAG_TEST(bme2)) {
nsucs++;
- if (bmenext == NULL)
+ if (bmenext == NULL) {
bmenext = bme2;
+ }
}
}
if (nsucs == 0 || (nsucs == 2 && j != 1) || nsucs > 2 ||
@@ -4771,24 +4967,28 @@ static bool fast_bevel_edge_order(BevVert *bv)
* a unique face, if possible */
e = &bv->edges[0];
bme = e->e;
- if (!bme->l)
+ if (!bme->l) {
return false;
+ }
for (i = 1; i < ntot; i++) {
/* find an unflagged edge bme2 that shares a face f with previous bme */
num_shared_face = 0;
first_suc = NULL; /* keep track of first successor to match legacy behavior */
BM_ITER_ELEM (bme2, &iter, bv->v, BM_EDGES_OF_VERT) {
- if (BM_BEVEL_EDGE_TAG_TEST(bme2))
+ if (BM_BEVEL_EDGE_TAG_TEST(bme2)) {
continue;
+ }
BM_ITER_ELEM (f, &iter2, bme2, BM_FACES_OF_EDGE) {
if (BM_face_edge_share_loop(f, bme)) {
num_shared_face++;
- if (first_suc == NULL)
+ if (first_suc == NULL) {
first_suc = bme2;
+ }
}
}
- if (num_shared_face >= 3)
+ if (num_shared_face >= 3) {
break;
+ }
}
if (num_shared_face == 1 || (i == 1 && num_shared_face == 2)) {
e = &bv->edges[i];
@@ -4827,19 +5027,23 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme)
BLI_assert(first_bme != NULL);
bv->edges[i].e = first_bme;
BM_BEVEL_EDGE_TAG_ENABLE(first_bme);
- if (i == 0 && fast_bevel_edge_order(bv))
+ if (i == 0 && fast_bevel_edge_order(bv)) {
break;
+ }
i = bevel_edge_order_extend(bm, bv, i);
i++;
- if (i >= bv->edgecount)
+ if (i >= bv->edgecount) {
break;
+ }
/* Not done yet: find a new first_bme */
first_bme = NULL;
BM_ITER_ELEM(bme, &iter, bv->v, BM_EDGES_OF_VERT) {
- if (BM_BEVEL_EDGE_TAG_TEST(bme))
+ if (BM_BEVEL_EDGE_TAG_TEST(bme)) {
continue;
- if (!first_bme)
+ }
+ if (!first_bme) {
first_bme = bme;
+ }
if (BM_edge_face_count(bme) == 1) {
first_bme = bme;
break;
@@ -4853,8 +5057,9 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme)
bme = e->e;
bme2 = e2->e;
BLI_assert(bme != NULL);
- if (e->fnext != NULL || e2->fprev != NULL)
+ if (e->fnext != NULL || e2->fprev != NULL) {
continue;
+ }
/* Which faces have successive loops that are for bme and bme2?
* There could be more than one. E.g., in manifold ntot==2 case.
* Prefer one that has loop in same direction as e. */
@@ -4862,8 +5067,9 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme)
BM_ITER_ELEM(l, &iter, bme, BM_LOOPS_OF_EDGE) {
f = l->f;
if ((l->prev->e == bme2 || l->next->e == bme2)) {
- if (!bestf || l->v == bv->v)
+ if (!bestf || l->v == bv->v) {
bestf = f;
+ }
}
if (bestf) {
e->fnext = e2->fprev = bestf;
@@ -4906,15 +5112,17 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) {
BLI_assert(fcnt == 2);
nsel++;
- if (!first_bme)
+ if (!first_bme) {
first_bme = bme;
+ }
}
if (fcnt == 1) {
/* good to start face chain from this edge */
first_bme = bme;
}
- if (fcnt > 0 || bp->vertex_only)
+ if (fcnt > 0 || bp->vertex_only) {
ntot++;
+ }
if (BM_edge_is_wire(bme)) {
nwire++;
/* If edge beveling, exclude wire edges from edges array.
@@ -4924,8 +5132,9 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
}
}
}
- if (!first_bme)
+ if (!first_bme) {
first_bme = v->e;
+ }
if ((nsel == 0 && !bp->vertex_only) || (ntot < 2 && bp->vertex_only)) {
/* signal this vert isn't being beveled */
@@ -4940,10 +5149,12 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
bv->wirecount = nwire;
bv->offset = bp->offset;
bv->edges = (EdgeHalf *)BLI_memarena_alloc(bp->mem_arena, ntot * sizeof(EdgeHalf));
- if (nwire)
+ if (nwire) {
bv->wire_edges = (BMEdge **)BLI_memarena_alloc(bp->mem_arena, nwire * sizeof(BMEdge *));
- else
+ }
+ else {
bv->wire_edges = NULL;
+ }
bv->vmesh = (VMesh *)BLI_memarena_alloc(bp->mem_arena, sizeof(VMesh));
bv->vmesh->seg = bp->seg;
@@ -4992,9 +5203,10 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
* reverse the array, being careful to reverse face pointers too */
if (ntot > 1) {
ccw_test_sum = 0;
- for (i = 0; i < ntot; i++)
+ for (i = 0; i < ntot; i++) {
ccw_test_sum += bev_ccw_test(bv->edges[i].e, bv->edges[(i + 1) % ntot].e,
bv->edges[i].fnext);
+ }
if (ccw_test_sum < 0) {
for (i = 0; i <= (ntot / 2) - 1; i++) {
SWAP(EdgeHalf, bv->edges[i], bv->edges[ntot - i - 1]);
@@ -5024,17 +5236,21 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
break;
case BEVEL_AMT_WIDTH:
z = fabsf(2.0f * sinf(edge_face_angle(e) / 2.0f));
- if (z < BEVEL_EPSILON)
+ if (z < BEVEL_EPSILON) {
e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */
- else
+ }
+ else {
e->offset_l_spec = bp->offset / z;
+ }
break;
case BEVEL_AMT_DEPTH:
z = fabsf(cosf(edge_face_angle(e) / 2.0f));
- if (z < BEVEL_EPSILON)
+ if (z < BEVEL_EPSILON) {
e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */
- else
+ }
+ else {
e->offset_l_spec = bp->offset / z;
+ }
break;
case BEVEL_AMT_PERCENT:
/* offset needs to be such that it meets adjacent edges at percentage of their lengths */
@@ -5052,8 +5268,9 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
e->offset_l_spec = bp->offset;
break;
}
- if (bp->offset_type != BEVEL_AMT_PERCENT)
+ if (bp->offset_type != BEVEL_AMT_PERCENT) {
e->offset_r_spec = e->offset_l_spec;
+ }
if (bp->use_weights) {
weight = BM_elem_float_data_get(&bm->edata, e->e, CD_BWEIGHT);
e->offset_l_spec *= weight;
@@ -5078,10 +5295,12 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
e->offset_l = e->offset_l_spec;
e->offset_r = e->offset_r_spec;
- if (e->fprev && e->fnext)
+ if (e->fprev && e->fnext) {
e->is_seam = !contig_ldata_across_edge(bm, e->e, e->fprev, e->fnext);
- else
+ }
+ else {
e->is_seam = true;
+ }
}
if (nwire) {
@@ -5202,8 +5421,9 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
if (bmv) {
BLI_array_append(vv, bmv);
BLI_array_append(ee, bme); /* TODO: maybe better edge here */
- if (corner3special && v->ebev && !v->ebev->is_seam && k != vm->seg)
+ if (corner3special && v->ebev && !v->ebev->is_seam && k != vm->seg) {
BLI_array_append(vv_fix, bmv);
+ }
}
}
v = v->next;
@@ -5229,8 +5449,9 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
if (bmv) {
BLI_array_append(vv, bmv);
BLI_array_append(ee, bme);
- if (corner3special && v->ebev && !v->ebev->is_seam && k != 0)
+ if (corner3special && v->ebev && !v->ebev->is_seam && k != 0) {
BLI_array_append(vv_fix, bmv);
+ }
}
}
v = v->prev;
@@ -5274,8 +5495,9 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
BM_elem_flag_enable(bme_new, BM_ELEM_SMOOTH);
}
}
- else
+ else {
bme_prev = ee[k];
+ }
}
}
@@ -5292,8 +5514,9 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
break;
}
}
- if (!keep)
+ if (!keep) {
disable_flag_out_edge(bm, bme);
+ }
}
}
}
@@ -5337,8 +5560,9 @@ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v)
int i;
bv = find_bevvert(bp, v);
- if (!bv || bv->wirecount == 0 || !bv->vmesh)
+ if (!bv || bv->wirecount == 0 || !bv->vmesh) {
return;
+ }
for (i = 0; i < bv->wirecount; i++) {
e = bv->wire_edges[i];
@@ -5350,8 +5574,9 @@ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v)
bvother = NULL;
if (BM_elem_flag_test(vother, BM_ELEM_TAG)) {
bvother = find_bevvert(bp, vother);
- if (!bvother || !bvother->vmesh)
+ if (!bvother || !bvother->vmesh) {
return; /* shouldn't happen */
+ }
}
bndv = bv->vmesh->boundstart;
do {
@@ -5450,10 +5675,12 @@ static void weld_cross_attrs_copy(BMesh *bm, BevVert *bv, VMesh *vm, int vmindex
mesh_vert(vm, vmindex, 0, i + 1)->v);
BLI_assert(bme);
BM_elem_attrs_copy(bm, bm, bme_prev, bme);
- if (disable_seam)
+ if (disable_seam) {
BM_elem_flag_disable(bme, BM_ELEM_SEAM);
- if (enable_smooth)
+ }
+ if (enable_smooth) {
BM_elem_flag_enable(bme, BM_ELEM_SMOOTH);
+ }
}
}
@@ -5476,8 +5703,9 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
int k, nseg, i1, i2, odd, mid;
int mat_nr = bp->mat_nr;
- if (!BM_edge_is_manifold(bme))
+ if (!BM_edge_is_manifold(bme)) {
return;
+ }
bv1 = find_bevvert(bp, bme->v1);
bv2 = find_bevvert(bp, bme->v2);
@@ -5560,25 +5788,30 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
record_face_kind(bp, r_f, F_EDGE);
/* tag the long edges: those out of verts[0] and verts[2] */
BM_ITER_ELEM(l, &iter, r_f, BM_LOOPS_OF_FACE) {
- if (l->v == verts[0] || l->v == verts[2])
+ if (l->v == verts[0] || l->v == verts[2]) {
BM_elem_flag_enable(l, BM_ELEM_LONG_TAG);
+ }
}
verts[0] = verts[3];
verts[1] = verts[2];
}
if (!odd) {
- if (!e1->is_seam)
+ if (!e1->is_seam) {
bev_merge_edge_uvs(bm, center_bme, mesh_vert(vm1, i1, 0, mid)->v);
- if (!e2->is_seam)
+ }
+ if (!e2->is_seam) {
bev_merge_edge_uvs(bm, center_bme, mesh_vert(vm2, i2, 0, mid)->v);
+ }
}
/* Fix UVs along end edge joints. A nop unless other side built already. */
/* TODO: if some seam, may want to do selective merge */
- if (!bv1->any_seam && bv1->vmesh->mesh_kind == M_NONE)
+ if (!bv1->any_seam && bv1->vmesh->mesh_kind == M_NONE) {
bev_merge_end_uvs(bm, bv1, e1);
- if (!bv2->any_seam && bv2->vmesh->mesh_kind == M_NONE)
+ }
+ if (!bv2->any_seam && bv2->vmesh->mesh_kind == M_NONE) {
bev_merge_end_uvs(bm, bv2, e2);
+ }
/* Copy edge data to first and last edge */
bme1 = BM_edge_exists(bmv1, bmv2);
@@ -5612,11 +5845,13 @@ static double find_superellipse_chord_endpoint(double x0, double dtarget, float
/* For gradient between -1 and 1, xnew can only be in
* [x0 + sqrt(2)/2*dtarget, x0 + dtarget]. */
xmin = x0 + M_SQRT2 / 2.0 * dtarget;
- if (xmin > 1.0)
+ if (xmin > 1.0) {
xmin = 1.0;
+ }
xmax = x0 + dtarget;
- if (xmax > 1.0)
+ if (xmax > 1.0) {
xmax = 1.0;
+ }
ymin = superellipse_co(xmin, r, rbig);
ymax = superellipse_co(xmax, r, rbig);
@@ -5661,14 +5896,15 @@ static double find_superellipse_chord_endpoint(double x0, double dtarget, float
return xnew;
}
- /* This search procedure to find equidistant points (x,y) in the first
- * superellipse quadrant works for every superellipse exponent but is more
- * expensive than known solutions for special cases.
- * Call the point on superellipse that intersects x=y line mx.
- * For r>=1 use only the range x in [0,mx] and mirror the rest along x=y line,
- * for r<1 use only x in [mx,1]. Points are initially spaced and iteratively
- * repositioned to have the same distance. */
-
+/**
+ * This search procedure to find equidistant points (x,y) in the first
+ * superellipse quadrant works for every superellipse exponent but is more
+ * expensive than known solutions for special cases.
+ * Call the point on superellipse that intersects x=y line mx.
+ * For r>=1 use only the range x in [0,mx] and mirror the rest along x=y line,
+ * for r<1 use only x in [mx,1]. Points are initially spaced and iteratively
+ * repositioned to have the same distance.
+ */
static void find_even_superellipse_chords_general(int seg, float r, double *xvals, double *yvals)
{
const int smoothitermax = 10;
@@ -5767,13 +6003,14 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval
}
}
- /* Find equidistant points (x0,y0), (x1,y1)... (xn,yn) on the superellipse
- * function in the first quadrant. For special profiles (linear, arc,
- * rectangle) the point can be calculated easily, for any other profile a more
- * expensive search procedure must be used because there is no known closed
- * form for equidistant parametrization
- * xvals and yvals should be size n+1 */
-
+/**
+ * Find equidistant points (x0,y0), (x1,y1)... (xn,yn) on the superellipse
+ * function in the first quadrant. For special profiles (linear, arc,
+ * rectangle) the point can be calculated easily, for any other profile a more
+ * expensive search procedure must be used because there is no known closed
+ * form for equidistant parametrization
+ * xvals and yvals should be size n+1
+ */
static void find_even_superellipse_chords(int n, float r, double *xvals, double *yvals)
{
int i, n2;
@@ -5867,8 +6104,9 @@ static void set_profile_spacing(BevelParams *bp)
bp->pro_spacing.yvals = (double *)BLI_memarena_alloc(bp->mem_arena, (seg + 1) * sizeof(double));
find_even_superellipse_chords(seg, bp->pro_super_r, bp->pro_spacing.xvals, bp->pro_spacing.yvals);
seg_2 = power_of_2_max_i(bp->seg);
- if (seg_2 == 2)
+ if (seg_2 == 2) {
seg_2 = 4;
+ }
bp->pro_spacing.seg_2 = seg_2;
if (seg_2 == seg) {
bp->pro_spacing.xvals_2 = bp->pro_spacing.xvals;
@@ -5921,8 +6159,9 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
float ka, kb, kc, g, h, t, den, no_collide_offset, th1, th2, sin1, sin2, tan1, tan2, limit;
limit = no_collide_offset = bp->offset + 1e6;
- if (bp->offset == 0.0f)
+ if (bp->offset == 0.0f) {
return no_collide_offset;
+ }
kb = eb->offset_l_spec;
ea = eb->next; /* note: this is in direction b --> a */
ka = ea->offset_r_spec;
@@ -5952,16 +6191,19 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
if (!lb) {
return no_collide_offset;
}
- if (lb->next->v == vc)
+ if (lb->next->v == vc) {
vd = lb->next->next->v;
- else if (lb->v == vc)
+ }
+ else if (lb->v == vc) {
vd = lb->prev->v;
+ }
else {
return no_collide_offset;
}
}
- if (ea->e == eb->e || (ec && ec->e == eb->e))
+ if (ea->e == eb->e || (ec && ec->e == eb->e)) {
return no_collide_offset;
+ }
ka = ka / bp->offset;
kb = kb / bp->offset;
kc = kc / bp->offset;
@@ -5982,8 +6224,9 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
if (den != 0.0f) {
t = BM_edge_calc_length(eb->e);
t *= g * h / den;
- if (t >= 0.0f)
+ if (t >= 0.0f) {
limit = t;
+ }
}
}
@@ -5991,14 +6234,16 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb)
if (kb > 0.0f && ka == 0.0f /*&& bvb->selcount == 1 && bvb->edgecount > 2*/) {
t = BM_edge_calc_length(ea->e);
t *= sin1 / kb;
- if (t >= 0.0f && t < limit)
+ if (t >= 0.0f && t < limit) {
limit = t;
+ }
}
if (kb > 0.0f && kc == 0.0f /* && bvc && ec && bvc->selcount == 1 && bvc->edgecount > 2 */) {
t = BM_edge_calc_length(ec->e);
t *= sin2 / kb;
- if (t >= 0.0f && t < limit)
+ if (t >= 0.0f && t < limit) {
limit = t;
+ }
}
return limit;
}
@@ -6016,15 +6261,17 @@ static float vertex_collide_offset(BevelParams *bp, EdgeHalf *ea)
EdgeHalf *eb;
limit = no_collide_offset = bp->offset + 1e6;
- if (bp->offset == 0.0f)
+ if (bp->offset == 0.0f) {
return no_collide_offset;
+ }
ka = ea->offset_l_spec / bp->offset;
eb = find_other_end_edge_half(bp, ea, NULL);
kb = eb ? eb->offset_l_spec / bp->offset : 0.0f;
kab = ka + kb;
la = BM_edge_calc_length(ea->e);
- if (kab <= 0.0f)
+ if (kab <= 0.0f) {
return no_collide_offset;
+ }
limit = la / kab;
return limit;
}
@@ -6037,28 +6284,35 @@ static float vertex_collide_offset(BevelParams *bp, EdgeHalf *ea)
* current edge offset specs to reflect this clamping,
* and store the new offset in bp.offset.
*/
-static void bevel_limit_offset(BevelParams *bp)
+static void bevel_limit_offset(BevelParams *bp, BMesh *bm)
{
BevVert *bv;
EdgeHalf *eh;
- GHashIterator giter;
+ BMIter iter;
+ BMVert *bmv;
float limited_offset, offset_factor, collision_offset;
int i;
limited_offset = bp->offset;
- GHASH_ITER(giter, bp->vert_hash) {
- bv = BLI_ghashIterator_getValue(&giter);
+ BM_ITER_MESH(bmv, &iter, bm, BM_VERTS_OF_MESH) {
+ if (!BM_elem_flag_test(bmv, BM_ELEM_TAG))
+ continue;
+ bv = find_bevvert(bp, bmv);
+ if (!bv)
+ continue;
for (i = 0; i < bv->edgecount; i++) {
eh = &bv->edges[i];
if (bp->vertex_only) {
collision_offset = vertex_collide_offset(bp, eh);
- if (collision_offset < limited_offset)
+ if (collision_offset < limited_offset) {
limited_offset = collision_offset;
+ }
}
else {
collision_offset = geometry_collide_offset(bp, eh);
- if (collision_offset < limited_offset)
+ if (collision_offset < limited_offset) {
limited_offset = collision_offset;
+ }
}
}
}
@@ -6070,8 +6324,12 @@ static void bevel_limit_offset(BevelParams *bp)
* with the new limited_offset.
*/
offset_factor = limited_offset / bp->offset;
- GHASH_ITER(giter, bp->vert_hash) {
- bv = BLI_ghashIterator_getValue(&giter);
+ BM_ITER_MESH(bmv, &iter, bm, BM_VERTS_OF_MESH) {
+ if (!BM_elem_flag_test(bmv, BM_ELEM_TAG))
+ continue;
+ bv = find_bevvert(bp, bmv);
+ if (!bv)
+ continue;
for (i = 0; i < bv->edgecount; i++) {
eh = &bv->edges[i];
eh->offset_l_spec *= offset_factor;
@@ -6113,7 +6371,6 @@ void BM_mesh_bevel(
BMLoop *l;
BevVert *bv;
BevelParams bp = {NULL};
- GHashIterator giter;
bp.offset = offset;
bp.offset_type = offset_type;
@@ -6156,34 +6413,38 @@ void BM_mesh_bevel(
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
bv = bevel_vert_construct(bm, &bp, v);
- if (!limit_offset && bv)
+ if (!limit_offset && bv) {
build_boundary(&bp, bv, true);
+ }
}
}
/* Perhaps clamp offset to avoid geometry colliisions */
if (limit_offset) {
- bevel_limit_offset(&bp);
+ bevel_limit_offset(&bp, bm);
/* Assign initial new vertex positions */
- GHASH_ITER(giter, bp.vert_hash) {
- bv = BLI_ghashIterator_getValue(&giter);
- build_boundary(&bp, bv, true);
+ 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)
+ build_boundary(&bp, bv, true);
+ }
}
}
/* Perhaps do a pass to try to even out widths */
if (!bp.vertex_only && bp.offset_adjust && bp.offset_type != BEVEL_AMT_PERCENT) {
- adjust_offsets(&bp);
+ adjust_offsets(&bp, bm);
}
/* Build the meshes around vertices, now that positions are final */
- /* Note: could use GHASH_ITER over bp.vert_hash when backward compatibility no longer matters */
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_vmesh(&bp, bm, bv);
+ }
}
}
@@ -6197,9 +6458,12 @@ void BM_mesh_bevel(
}
/* Extend edge data like sharp edges and precompute normals for harden */
- GHASH_ITER(giter, bp.vert_hash) {
- bv = BLI_ghashIterator_getValue(&giter);
- bevel_extend_edge_data(bv);
+ 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)
+ bevel_extend_edge_data(bv);
+ }
}
/* Rebuild face polygons around affected vertices */
@@ -6228,8 +6492,9 @@ void BM_mesh_bevel(
* will be set, and we to transfer the oflags to BM_ELEM_TAGs */
if (bm->use_toolflags) {
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BMO_vert_flag_test(bm, v, VERT_OUT))
+ if (BMO_vert_flag_test(bm, v, VERT_OUT)) {
BM_elem_flag_enable(v, BM_ELEM_TAG);
+ }
}
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BMO_edge_flag_test(bm, e, EDGE_OUT)) {
@@ -6240,8 +6505,9 @@ void BM_mesh_bevel(
/* clear the BM_ELEM_LONG_TAG tags, which were only set on some edges in F_EDGE faces */
BM_ITER_MESH(f, &iter, bm, BM_FACES_OF_MESH) {
- if (get_face_kind(&bp, f) != F_EDGE)
+ if (get_face_kind(&bp, f) != F_EDGE) {
continue;
+ }
BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) {
BM_elem_flag_disable(l, BM_ELEM_LONG_TAG);
}
diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c
index 83f5edb01ea..da7feff70e6 100644
--- a/source/blender/bmesh/tools/bmesh_bisect_plane.c
+++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c
@@ -52,9 +52,9 @@ static short plane_point_test_v3(const float plane[4], const float co[3], const
const float f = plane_point_side_v3(plane, co);
*r_depth = f;
- if (f <= -eps) return -1;
- else if (f >= eps) return 1;
- else return 0;
+ if (f <= -eps) { return -1; }
+ else if (f >= eps) { return 1; }
+ else { return 0; }
}
@@ -98,9 +98,9 @@ static int bm_vert_sortval_cb(const void *v_a_v, const void *v_b_v)
const float val_a = BM_VERT_SORTVAL(*((BMVert **)v_a_v));
const float val_b = BM_VERT_SORTVAL(*((BMVert **)v_b_v));
- if (val_a > val_b) return 1;
- else if (val_a < val_b) return -1;
- else return 0;
+ if (val_a > val_b) { return 1; }
+ else if (val_a < val_b) { return -1; }
+ else { return 0; }
}
diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index 7f6bcf12f84..c60dd04fbb5 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -424,9 +424,9 @@ static int *bm_edge_symmetry_map(BMesh *bm, uint symmetry_axis, float limit)
uint i;
int *edge_symmetry_map;
const float limit_sq = SQUARE(limit);
- KDTree *tree;
+ KDTree_3d *tree;
- tree = BLI_kdtree_new(bm->totedge);
+ tree = BLI_kdtree_3d_new(bm->totedge);
etable = MEM_mallocN(sizeof(*etable) * bm->totedge, __func__);
edge_symmetry_map = MEM_mallocN(sizeof(*edge_symmetry_map) * bm->totedge, __func__);
@@ -434,12 +434,12 @@ static int *bm_edge_symmetry_map(BMesh *bm, uint symmetry_axis, float limit)
BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) {
float co[3];
mid_v3_v3v3(co, e->v1->co, e->v2->co);
- BLI_kdtree_insert(tree, i, co);
+ BLI_kdtree_3d_insert(tree, i, co);
etable[i] = e;
edge_symmetry_map[i] = -1;
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
sym_data.etable = etable;
sym_data.limit_sq = limit_sq;
@@ -457,7 +457,7 @@ static int *bm_edge_symmetry_map(BMesh *bm, uint symmetry_axis, float limit)
sub_v3_v3v3(sym_data.e_dir, sym_data.e_v2_co, sym_data.e_v1_co);
sym_data.e_found_index = -1;
- BLI_kdtree_range_search_cb(tree, co, limit, bm_edge_symmetry_check_cb, &sym_data);
+ BLI_kdtree_3d_range_search_cb(tree, co, limit, bm_edge_symmetry_check_cb, &sym_data);
if (sym_data.e_found_index != -1) {
const int i_other = sym_data.e_found_index;
@@ -468,7 +468,7 @@ static int *bm_edge_symmetry_map(BMesh *bm, uint symmetry_axis, float limit)
}
MEM_freeN(etable);
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
return edge_symmetry_map;
}
@@ -1257,10 +1257,12 @@ static bool bm_decim_edge_collapse(
BM_ITER_ELEM (l, &liter, v_other, BM_LOOPS_OF_VERT) {
if (l->f->len == 3) {
BMEdge *e_outer;
- if (BM_vert_in_edge(l->prev->e, l->v))
+ if (BM_vert_in_edge(l->prev->e, l->v)) {
e_outer = l->next->e;
- else
+ }
+ else {
e_outer = l->prev->e;
+ }
BLI_assert(BM_vert_in_edge(e_outer, l->v) == false);
@@ -1348,9 +1350,9 @@ void BM_mesh_decimate_collapse(
#ifdef USE_CUSTOMDATA
/* initialize customdata flag, we only need math for loops */
- if (CustomData_has_interp(&bm->vdata)) customdata_flag |= CD_DO_VERT;
- if (CustomData_has_interp(&bm->edata)) customdata_flag |= CD_DO_EDGE;
- if (CustomData_has_math(&bm->ldata)) customdata_flag |= CD_DO_LOOP;
+ if (CustomData_has_interp(&bm->vdata)) { customdata_flag |= CD_DO_VERT; }
+ if (CustomData_has_interp(&bm->edata)) { customdata_flag |= CD_DO_EDGE; }
+ if (CustomData_has_math(&bm->ldata)) { customdata_flag |= CD_DO_LOOP; }
#endif
/* iterative edge collapse and maintain the eheap */
diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
index b61a499cffc..6069175348c 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
@@ -376,12 +376,16 @@ void BM_mesh_decimate_dissolve_ex(
BM_edge_kill(bm, e_iter);
if (v1->e == NULL) {
vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v1)];
- if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL;
+ if (vidx_reverse != -1) {
+ vinput_arr[vidx_reverse] = NULL;
+ }
BM_vert_kill(bm, v1);
}
if (v2->e == NULL) {
vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v2)];
- if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL;
+ if (vidx_reverse != -1) {
+ vinput_arr[vidx_reverse] = NULL;
+ }
BM_vert_kill(bm, v2);
}
}
diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c
index 4068562d077..2445978e294 100644
--- a/source/blender/bmesh/tools/bmesh_intersect.c
+++ b/source/blender/bmesh/tools/bmesh_intersect.c
@@ -797,14 +797,16 @@ static void bm_isect_tri_tri(
BMEdge *ie;
if (i == 0) {
- if (STACK_SIZE(iv_ls_a) != 2)
+ if (STACK_SIZE(iv_ls_a) != 2) {
continue;
+ }
ie_vs = iv_ls_a;
f = f_a;
}
else {
- if (STACK_SIZE(iv_ls_b) != 2)
+ if (STACK_SIZE(iv_ls_b) != 2) {
continue;
+ }
ie_vs = iv_ls_b;
f = f_b;
}
diff --git a/source/blender/bmesh/tools/bmesh_path.c b/source/blender/bmesh/tools/bmesh_path.c
index 0ae1f4a57f1..4710c3929c4 100644
--- a/source/blender/bmesh/tools/bmesh_path.c
+++ b/source/blender/bmesh/tools/bmesh_path.c
@@ -171,8 +171,9 @@ LinkNode *BM_mesh_calc_path_vert(
while (!BLI_heapsimple_is_empty(heap)) {
v = BLI_heapsimple_pop_min(heap);
- if (v == v_dst)
+ if (v == v_dst) {
break;
+ }
if (!BM_elem_flag_test(v, BM_ELEM_TAG)) {
BM_elem_flag_enable(v, BM_ELEM_TAG);
@@ -343,8 +344,9 @@ LinkNode *BM_mesh_calc_path_edge(
while (!BLI_heapsimple_is_empty(heap)) {
e = BLI_heapsimple_pop_min(heap);
- if (e == e_dst)
+ if (e == e_dst) {
break;
+ }
if (!BM_elem_flag_test(e, BM_ELEM_TAG)) {
BM_elem_flag_enable(e, BM_ELEM_TAG);
@@ -529,8 +531,9 @@ LinkNode *BM_mesh_calc_path_face(
while (!BLI_heapsimple_is_empty(heap)) {
f = BLI_heapsimple_pop_min(heap);
- if (f == f_dst)
+ if (f == f_dst) {
break;
+ }
if (!BM_elem_flag_test(f, BM_ELEM_TAG)) {
BM_elem_flag_enable(f, BM_ELEM_TAG);
diff --git a/source/blender/bmesh/tools/bmesh_region_match.c b/source/blender/bmesh/tools/bmesh_region_match.c
index 8a69dd05a06..a89c41eecc0 100644
--- a/source/blender/bmesh/tools/bmesh_region_match.c
+++ b/source/blender/bmesh/tools/bmesh_region_match.c
@@ -579,9 +579,9 @@ static int bm_face_len_cmp(const void *v1, const void *v2)
{
const BMFace *f1 = v1, *f2 = v2;
- if (f1->len > f2->len) return 1;
- else if (f1->len < f2->len) return -1;
- else return 0;
+ if (f1->len > f2->len) { return 1; }
+ else if (f1->len < f2->len) { return -1; }
+ else { return 0; }
}
static uint bm_uuidwalk_init_from_edge(
diff --git a/source/blender/bmesh/tools/bmesh_triangulate.c b/source/blender/bmesh/tools/bmesh_triangulate.c
index 034151fa584..3209732ba66 100644
--- a/source/blender/bmesh/tools/bmesh_triangulate.c
+++ b/source/blender/bmesh/tools/bmesh_triangulate.c
@@ -83,8 +83,9 @@ static void bm_face_triangulate_mapping(
void BM_mesh_triangulate(
- BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only,
- BMOperator *op, BMOpSlot *slot_facemap_out, BMOpSlot *slot_facemap_double_out)
+ BMesh *bm, const int quad_method, const int ngon_method, const int min_vertices,
+ const bool tag_only, BMOperator *op, BMOpSlot *slot_facemap_out,
+ BMOpSlot *slot_facemap_double_out)
{
BMIter iter;
BMFace *face;
@@ -103,7 +104,7 @@ void BM_mesh_triangulate(
if (slot_facemap_out) {
/* same as below but call: bm_face_triangulate_mapping() */
BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) {
- if (face->len > 3) {
+ if (face->len >= min_vertices) {
if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) {
bm_face_triangulate_mapping(
bm, face,
@@ -118,7 +119,7 @@ void BM_mesh_triangulate(
LinkNode *faces_double = NULL;
BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) {
- if (face->len > 3) {
+ if (face->len >= min_vertices) {
if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) {
BM_face_triangulate(
bm, face,
diff --git a/source/blender/bmesh/tools/bmesh_triangulate.h b/source/blender/bmesh/tools/bmesh_triangulate.h
index 1b312ebadbf..b254246720c 100644
--- a/source/blender/bmesh/tools/bmesh_triangulate.h
+++ b/source/blender/bmesh/tools/bmesh_triangulate.h
@@ -24,7 +24,8 @@
#define __BMESH_TRIANGULATE_H__
void BM_mesh_triangulate(
- BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only,
+ BMesh *bm, const int quad_method, const int ngon_method,
+ const int min_vertices, const bool tag_only,
BMOperator *op, BMOpSlot *slot_facemap_out, BMOpSlot *slot_doubles_out);
#endif /* __BMESH_TRIANGULATE_H__ */
diff --git a/source/blender/bmesh/tools/bmesh_wireframe.c b/source/blender/bmesh/tools/bmesh_wireframe.c
index e7fbed76e4c..10db05fad98 100644
--- a/source/blender/bmesh/tools/bmesh_wireframe.c
+++ b/source/blender/bmesh/tools/bmesh_wireframe.c
@@ -437,7 +437,9 @@ void BM_mesh_wireframe(
BMVert *v_pos2 = verts_pos[i_2];
f_new = BM_face_create_quad_tri(bm, v_l1, v_l2, v_neg2, v_neg1, f_src, BM_CREATE_NOP);
- if (mat_offset) f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
+ if (mat_offset) {
+ f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
+ }
BM_elem_flag_enable(f_new, BM_ELEM_TAG);
l_new = BM_FACE_FIRST_LOOP(f_new);
@@ -448,7 +450,9 @@ void BM_mesh_wireframe(
f_new = BM_face_create_quad_tri(bm, v_l2, v_l1, v_pos1, v_pos2, f_src, BM_CREATE_NOP);
- if (mat_offset) f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
+ if (mat_offset) {
+ f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
+ }
BM_elem_flag_enable(f_new, BM_ELEM_TAG);
l_new = BM_FACE_FIRST_LOOP(f_new);
@@ -465,7 +469,9 @@ void BM_mesh_wireframe(
BMVert *v_b2 = verts_boundary[i_2];
f_new = BM_face_create_quad_tri(bm, v_b2, v_b1, v_neg1, v_neg2, f_src, BM_CREATE_NOP);
- if (mat_offset) f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
+ if (mat_offset) {
+ f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
+ }
BM_elem_flag_enable(f_new, BM_ELEM_TAG);
l_new = BM_FACE_FIRST_LOOP(f_new);
@@ -475,7 +481,9 @@ void BM_mesh_wireframe(
BM_elem_attrs_copy(bm, bm, l, l_new->next->next);
f_new = BM_face_create_quad_tri(bm, v_b1, v_b2, v_pos2, v_pos1, f_src, BM_CREATE_NOP);
- if (mat_offset) f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
+ if (mat_offset) {
+ f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max);
+ }
BM_elem_flag_enable(f_new, BM_ELEM_TAG);
l_new = BM_FACE_FIRST_LOOP(f_new);
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index ebb2a9da10c..e9babea7b3d 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -92,11 +92,11 @@ bool AnimationExporter::exportAnimations()
try {
animation_sampler.sample_scene(
- export_settings->sampling_rate,
- /*keyframe_at_end = */ true,
- export_settings->open_sim,
- export_settings->keep_keyframes,
- export_settings->export_animation_type
+ export_settings->sampling_rate,
+ /*keyframe_at_end = */ true,
+ export_settings->open_sim,
+ export_settings->keep_keyframes,
+ export_settings->export_animation_type
);
openLibrary();
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index 295ec66a4e8..7af4777331d 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -145,48 +145,48 @@ protected:
/* export animation as separate trans/rot/scale curves */
void export_curve_animation_set(
- Object *ob,
- BCAnimationSampler &sampler,
- bool export_tm_curves);
+ Object *ob,
+ BCAnimationSampler &sampler,
+ bool export_tm_curves);
/* export one single curve */
void export_curve_animation(
- Object *ob,
- BCAnimationCurve &curve);
+ Object *ob,
+ BCAnimationCurve &curve);
/* export animation as matrix data */
void export_matrix_animation(
- Object *ob,
- BCAnimationSampler &sampler);
+ Object *ob,
+ BCAnimationSampler &sampler);
/* step through the bone hierarchy */
void export_bone_animations_recursive(
- Object *ob_arm,
- Bone *bone,
- BCAnimationSampler &sampler);
+ Object *ob_arm,
+ Bone *bone,
+ BCAnimationSampler &sampler);
/* Export for one bone */
void export_bone_animation(
- Object *ob,
- Bone *bone,
- BCFrames &frames,
- BCMatrixSampleMap &outmats);
+ Object *ob,
+ Bone *bone,
+ BCFrames &frames,
+ BCMatrixSampleMap &outmats);
/* call to the low level collada exporter */
void export_collada_curve_animation(
- std::string id,
- std::string name,
- std::string target,
- std::string axis,
- BCAnimationCurve &curve);
+ std::string id,
+ std::string name,
+ std::string target,
+ std::string axis,
+ BCAnimationCurve &curve);
/* call to the low level collada exporter */
void export_collada_matrix_animation(
- std::string id,
- std::string name,
- std::string target,
- BCFrames &frames,
- BCMatrixSampleMap &outmats);
+ std::string id,
+ std::string name,
+ std::string target,
+ BCFrames &frames,
+ BCMatrixSampleMap &outmats);
BCAnimationCurve *get_modified_export_curve(Object *ob, BCAnimationCurve &curve, BCAnimationCurveMap &curves);
@@ -197,40 +197,41 @@ protected:
/* Input and Output sources (single valued) */
std::string collada_source_from_values(
- BC_animation_source_type tm_channel,
- COLLADASW::InputSemantic::Semantics semantic,
- std::vector<float> &values,
- const std::string& anim_id,
- const std::string axis_name);
+ BC_animation_source_type tm_channel,
+ COLLADASW::InputSemantic::Semantics semantic,
+ std::vector<float> &values,
+ const std::string& anim_id,
+ const std::string axis_name);
/* Output sources (matrix data) */
std::string collada_source_from_values(
- BCMatrixSampleMap &samples,
- const std::string& anim_id);
+ BCMatrixSampleMap &samples,
+ const std::string& anim_id);
/* Interpolation sources */
std::string collada_linear_interpolation_source(
- int tot,
- const std::string& anim_id);
+ int tot,
+ const std::string& anim_id);
/* source ID = animation_name + semantic_suffix */
std::string get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic);
- void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param,
- COLLADASW::InputSemantic::Semantics semantic,
- bool is_rot,
- const std::string axis,
- bool transform);
+ void add_source_parameters(
+ COLLADASW::SourceBase::ParameterNameList& param,
+ COLLADASW::InputSemantic::Semantics semantic,
+ bool is_rot,
+ const std::string axis,
+ bool transform);
int get_point_in_curve(BCBezTriple &bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_angle, float *values);
int get_point_in_curve(const BCAnimationCurve &curve, float sample_frame, COLLADASW::InputSemantic::Semantics semantic, bool is_angle, float *values);
std::string collada_tangent_from_curve(
- COLLADASW::InputSemantic::Semantics semantic,
- BCAnimationCurve &curve,
- const std::string& anim_id,
- const std::string axis_name);
+ COLLADASW::InputSemantic::Semantics semantic,
+ BCAnimationCurve &curve,
+ const std::string& anim_id,
+ const std::string axis_name);
std::string collada_interpolation_source(const BCAnimationCurve &curve, const std::string& anim_id, std::string axis_name, bool *has_tangents);
@@ -251,8 +252,8 @@ protected:
#ifdef WITH_MORPH_ANIMATION
void export_morph_animation(
- Object *ob,
- BCAnimationSampler &sampler);
+ Object *ob,
+ BCAnimationSampler &sampler);
#endif
};
diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h
index e5d431a05c0..dfb3f5cfe33 100644
--- a/source/blender/collada/AnimationImporter.h
+++ b/source/blender/collada/AnimationImporter.h
@@ -180,11 +180,12 @@ public:
// prerequisites:
// animlist_map - map animlist id -> animlist
// curve_map - map anim id -> curve(s)
- Object *translate_animation_OLD(COLLADAFW::Node *node,
- std::map<COLLADAFW::UniqueId, Object *>& object_map,
- std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
- COLLADAFW::Transformation::TransformationType tm_type,
- Object *par_job = NULL);
+ Object *translate_animation_OLD(
+ COLLADAFW::Node *node,
+ std::map<COLLADAFW::UniqueId, Object *>& object_map,
+ std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
+ COLLADAFW::Transformation::TransformationType tm_type,
+ Object *par_job = NULL);
void find_frames( std::vector<float>* frames, std::vector<FCurve*>* curves );
void find_frames_old( std::vector<float>* frames, COLLADAFW::Node * node, COLLADAFW::Transformation::TransformationType tm_type );
diff --git a/source/blender/collada/ArmatureExporter.h b/source/blender/collada/ArmatureExporter.h
index d5f808155f4..11f853621a0 100644
--- a/source/blender/collada/ArmatureExporter.h
+++ b/source/blender/collada/ArmatureExporter.h
@@ -61,10 +61,10 @@ public:
{}
void add_armature_bones(
- Object *ob_arm,
- ViewLayer *view_layer,
- SceneExporter *se,
- std::vector<Object *>& child_objects);
+ Object *ob_arm,
+ ViewLayer *view_layer,
+ SceneExporter *se,
+ std::vector<Object *>& child_objects);
bool add_instance_controller(Object *ob);
@@ -85,10 +85,10 @@ private:
// Scene, SceneExporter and the list of child_objects
// are required for writing bone parented objects
void add_bone_node(
- Bone *bone,
- Object *ob_arm,
- SceneExporter *se,
- std::vector<Object *>& child_objects);
+ Bone *bone,
+ Object *ob_arm,
+ SceneExporter *se,
+ std::vector<Object *>& child_objects);
void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node);
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 018367c81ff..bd06a8e5319 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -208,11 +208,11 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
}
/**
- * Collada only knows Joints, hence bones at the end of a bone chain
- * don't have a defined length. This function guesses reasonable
- * tail locations for the affected bones (nodes which don't have any connected child)
- * Hint: The extended_bones set gets populated in ArmatureImporter::create_bone
-**/
+ * Collada only knows Joints, hence bones at the end of a bone chain
+ * don't have a defined length. This function guesses reasonable
+ * tail locations for the affected bones (nodes which don't have any connected child)
+ * Hint: The extended_bones set gets populated in ArmatureImporter::create_bone
+ */
void ArmatureImporter::fix_leaf_bone_hierarchy(bArmature *armature, Bone *bone, bool fix_orientation)
{
if (bone == NULL)
@@ -674,10 +674,10 @@ void ArmatureImporter::set_pose(Object *ob_arm, COLLADAFW::Node *root_node, con
}
/**
- * root - if this joint is the top joint in hierarchy, if a joint
- * is a child of a node (not joint), root should be true since
- * this is where we build armature bones from
- **/
+ * root - if this joint is the top joint in hierarchy, if a joint
+ * is a child of a node (not joint), root should be true since
+ * this is where we build armature bones from
+ */
void ArmatureImporter::add_root_joint(COLLADAFW::Node *node, Object *parent)
{
root_joints.push_back(node);
diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h
index 4715b31fe62..4c82b1e55e3 100644
--- a/source/blender/collada/ArmatureImporter.h
+++ b/source/blender/collada/ArmatureImporter.h
@@ -100,8 +100,9 @@ private:
JointData *get_joint_data(COLLADAFW::Node *node);
#endif
- int create_bone(SkinInfo* skin, COLLADAFW::Node *node, EditBone *parent, int totchild,
- float parent_mat[4][4], bArmature *arm, std::vector<std::string> &layer_labels);
+ int create_bone(
+ SkinInfo* skin, COLLADAFW::Node *node, EditBone *parent, int totchild,
+ float parent_mat[4][4], bArmature *arm, std::vector<std::string> &layer_labels);
BoneExtended &add_bone_extended(EditBone *bone, COLLADAFW::Node * node, int sibcount, std::vector<std::string> &layer_labels, BoneExtensionMap &extended_bones);
diff --git a/source/blender/collada/BCAnimationSampler.h b/source/blender/collada/BCAnimationSampler.h
index 19ccb88fa9e..95ec642ef33 100644
--- a/source/blender/collada/BCAnimationSampler.h
+++ b/source/blender/collada/BCAnimationSampler.h
@@ -175,11 +175,11 @@ public:
void add_object(Object *ob);
void sample_scene(
- int sampling_rate,
- int keyframe_at_end,
- bool for_opensim,
- bool keep_keyframes,
- BC_export_animation_type export_animation_type);
+ int sampling_rate,
+ int keyframe_at_end,
+ bool for_opensim,
+ bool keep_keyframes,
+ BC_export_animation_type export_animation_type);
BCAnimationCurveMap *get_curves(Object *ob);
void get_object_frames(BCFrames &frames, Object *ob);
diff --git a/source/blender/collada/BCSampleData.cpp b/source/blender/collada/BCSampleData.cpp
index 936d48ccaca..812ac3c2a5a 100644
--- a/source/blender/collada/BCSampleData.cpp
+++ b/source/blender/collada/BCSampleData.cpp
@@ -95,9 +95,9 @@ const bool BCSample::get_value(std::string channel_target, const int array_index
else if (channel_target == "scale") {
*val = obmat.scale()[array_index];
}
- else if (
- channel_target == "rotation" ||
- channel_target == "rotation_euler") {
+ else if (channel_target == "rotation" ||
+ channel_target == "rotation_euler")
+ {
*val = obmat.rotation()[array_index];
}
else if (channel_target == "rotation_quat") {
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 97d4f056d0b..f784c811c26 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -474,10 +474,10 @@ void DocumentImporter::report_unknown_reference(const COLLADAFW::Node &node, con
std::string id = node.getOriginalId();
std::string name = node.getName();
fprintf(stderr,
- "error: node id=\"%s\", name=\"%s\" refers to an undefined %s.\n",
- id.c_str(),
- name.c_str(),
- object_type.c_str());
+ "error: node id=\"%s\", name=\"%s\" refers to an undefined %s.\n",
+ id.c_str(),
+ name.c_str(),
+ object_type.c_str());
}
std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node)
@@ -496,10 +496,10 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
std::vector<Object *> *root_objects = new std::vector<Object *>();
fprintf(stderr,
- "| %s id='%s', name='%s'\n",
- is_joint ? "JOINT" : "NODE ",
- id.c_str(),
- name.c_str() );
+ "| %s id='%s', name='%s'\n",
+ is_joint ? "JOINT" : "NODE ",
+ id.c_str(),
+ name.c_str() );
if (is_joint) {
if (parent_node == NULL && !is_library_node) {
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index 3494cdbada4..94e86af521f 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -156,9 +156,10 @@ void EffectsExporter::create_image_samplers(COLLADASW::EffectProfile &ep, KeyIma
std::string uid(id_name(image));
std::string key = translate_id(uid);
- COLLADASW::Sampler *sampler = new COLLADASW::Sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
- key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
- key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
+ COLLADASW::Sampler *sampler = new COLLADASW::Sampler(
+ COLLADASW::Sampler::SAMPLER_TYPE_2D,
+ key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
+ key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
sampler->setImageId(key);
@@ -203,9 +204,10 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
// create only one <sampler>/<surface> pair for each unique image
if (im_samp_map.find(key) == im_samp_map.end()) {
//<newparam> <sampler> <source>
- COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
- key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
- key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
+ COLLADASW::Sampler sampler(
+ COLLADASW::Sampler::SAMPLER_TYPE_2D,
+ key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
+ key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
sampler.setImageId(key);
// copy values to arrays since they will live longer
samplers[a] = sampler;
diff --git a/source/blender/collada/EffectExporter.h b/source/blender/collada/EffectExporter.h
index 3ba642088a1..6d42a3d69ba 100644
--- a/source/blender/collada/EffectExporter.h
+++ b/source/blender/collada/EffectExporter.h
@@ -60,11 +60,12 @@ private:
void get_images(Material *ma, KeyImageMap &uid_image_map);
void create_image_samplers(COLLADASW::EffectProfile &ep, KeyImageMap &uid_image_map, std::string &active_uv);
- void writeTextures(COLLADASW::EffectProfile &ep,
- std::string &key,
- COLLADASW::Sampler *sampler,
- MTex *t, Image *ima,
- std::string &uvname );
+ void writeTextures(
+ COLLADASW::EffectProfile &ep,
+ std::string &key,
+ COLLADASW::Sampler *sampler,
+ MTex *t, Image *ima,
+ std::string &uvname );
bool hasEffects(Scene *sce);
diff --git a/source/blender/collada/ExtraHandler.h b/source/blender/collada/ExtraHandler.h
index 4e1e0415714..fef1d5c9b7f 100644
--- a/source/blender/collada/ExtraHandler.h
+++ b/source/blender/collada/ExtraHandler.h
@@ -53,16 +53,16 @@ public:
/** Method to ask, if the current callback handler want to read the data of the given extra element. */
bool parseElement (
- const char* profileName,
- const unsigned long& elementHash,
- const COLLADAFW::UniqueId& uniqueId,
- COLLADAFW::Object* object);
+ const char* profileName,
+ const unsigned long& elementHash,
+ const COLLADAFW::UniqueId& uniqueId,
+ COLLADAFW::Object* object);
/** For backwards compatibility with older OpenCollada, new version added object parameter */
bool parseElement (
- const char* profileName,
- const unsigned long& elementHash,
- const COLLADAFW::UniqueId& uniqueId);
+ const char* profileName,
+ const unsigned long& elementHash,
+ const COLLADAFW::UniqueId& uniqueId);
private:
/** Disable default copy constructor. */
ExtraHandler(const ExtraHandler& pre);
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index ba9ba7998e0..f589e99f84b 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -519,10 +519,10 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
MLoopCol *mlc = mloopcol + mpoly->loopstart;
for (int j = 0; j < mpoly->totloop; j++, mlc++) {
source.appendValues(
- mlc->r / 255.0f,
- mlc->g / 255.0f,
- mlc->b / 255.0f,
- mlc->a / 255.0f
+ mlc->r / 255.0f,
+ mlc->g / 255.0f,
+ mlc->b / 255.0f,
+ mlc->a / 255.0f
);
}
}
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 306120e464f..6f87b6613b7 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -876,7 +876,7 @@ std::string *MeshImporter::get_geometry_name(const std::string &mesh_name)
* this function checks if both objects have the same
* materials assigned to Object (in the same order)
* returns true if condition matches, otherwise false;
- **/
+ */
static bool bc_has_same_material_configuration(Object *ob1, Object *ob2)
{
if (ob1->totcol != ob2->totcol) return false; // not same number of materials
@@ -897,7 +897,7 @@ static bool bc_has_same_material_configuration(Object *ob1, Object *ob2)
* and no material is assigned to Data.
* That is true right after the objects have been imported.
*
- **/
+ */
static void bc_copy_materials_to_data(Object *ob, Mesh *me)
{
for (int index = 0; index < ob->totcol; index++) {
@@ -910,7 +910,7 @@ static void bc_copy_materials_to_data(Object *ob, Mesh *me)
*
* Remove all references to materials from the object
*
- **/
+ */
static void bc_remove_materials_from_object(Object *ob, Mesh *me)
{
for (int index = 0; index < ob->totcol; index++) {
@@ -923,7 +923,7 @@ static void bc_remove_materials_from_object(Object *ob, Mesh *me)
* Returns the list of Users of the given Mesh object.
* Note: This function uses the object user flag to control
* which objects have already been processed.
- **/
+ */
std::vector<Object *> MeshImporter::get_all_users_of(Mesh *reference_mesh)
{
std::vector<Object *> mesh_users;
@@ -958,7 +958,7 @@ std::vector<Object *> MeshImporter::get_all_users_of(Mesh *reference_mesh)
* Add the materials of the first user to the geometry
* adjust all other users accordingly.
*
- **/
+ */
void MeshImporter::optimize_material_assignements()
{
for (std::vector<Object *>::iterator it = imported_objects.begin();
diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h
index 163ecfce9ea..08b7edd2a3b 100644
--- a/source/blender/collada/MeshImporter.h
+++ b/source/blender/collada/MeshImporter.h
@@ -105,23 +105,26 @@ private:
std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap> geom_uid_mat_mapping_map; // crazy name!
std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId> materials_mapped_to_geom; //< materials that have already been mapped to a geometry. A pair of geom uid and mat uid, one geometry can have several materials
- bool set_poly_indices(MPoly *mpoly,
- MLoop *mloop,
- int loop_index,
- unsigned int *indices,
- int loop_count);
-
- void set_face_uv(MLoopUV *mloopuv,
- UVDataWrapper &uvs,
- int loop_index,
- COLLADAFW::IndexList& index_list,
- int count);
-
- void set_vcol(MLoopCol *mloopcol,
- VCOLDataWrapper &vob,
- int loop_index,
- COLLADAFW::IndexList& index_list,
- int count);
+ bool set_poly_indices(
+ MPoly *mpoly,
+ MLoop *mloop,
+ int loop_index,
+ unsigned int *indices,
+ int loop_count);
+
+ void set_face_uv(
+ MLoopUV *mloopuv,
+ UVDataWrapper &uvs,
+ int loop_index,
+ COLLADAFW::IndexList& index_list,
+ int count);
+
+ void set_vcol(
+ MLoopCol *mloopcol,
+ VCOLDataWrapper &vob,
+ int loop_index,
+ COLLADAFW::IndexList& index_list,
+ int count);
#ifdef COLLADA_DEBUG
void print_index_list(COLLADAFW::IndexList& index_list);
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index f09fae73efd..9031aa1ed9f 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -131,10 +131,10 @@ void SceneExporter::writeNodes(Object *ob)
}
else {
TransformWriter::add_node_transform_ob(
- colladaNode,
- ob,
- this->export_settings->export_transformation_type,
- this->export_settings->limit_precision
+ colladaNode,
+ ob,
+ this->export_settings->export_transformation_type,
+ this->export_settings->limit_precision
);
}
@@ -148,9 +148,10 @@ void SceneExporter::writeNodes(Object *ob)
COLLADASW::InstanceGeometry instGeom(mSW);
instGeom.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, this->export_settings->use_object_instantiation)));
instGeom.setName(encode_xml(id_name(ob)));
- InstanceWriter::add_material_bindings(instGeom.getBindMaterial(),
- ob,
- this->export_settings->active_uv_only);
+ InstanceWriter::add_material_bindings(
+ instGeom.getBindMaterial(),
+ ob,
+ this->export_settings->active_uv_only);
instGeom.add();
}
}
diff --git a/source/blender/collada/TransformWriter.h b/source/blender/collada/TransformWriter.h
index 49ed22ef3f8..3792ce840ee 100644
--- a/source/blender/collada/TransformWriter.h
+++ b/source/blender/collada/TransformWriter.h
@@ -33,16 +33,16 @@ class TransformWriter
{
protected:
void add_node_transform(
- COLLADASW::Node& node,
- float mat[4][4],
- float parent_mat[4][4],
- bool limit_precision=false);
+ COLLADASW::Node& node,
+ float mat[4][4],
+ float parent_mat[4][4],
+ bool limit_precision=false);
void add_node_transform_ob(
- COLLADASW::Node& node,
- Object *ob,
- BC_export_transformation_type transformation_type,
- bool limit_precision = false);
+ COLLADASW::Node& node,
+ Object *ob,
+ BC_export_transformation_type transformation_type,
+ bool limit_precision = false);
void add_node_transform_identity(COLLADASW::Node& node);
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 79ad79f6735..0084ff84e4d 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -236,7 +236,6 @@ Object *bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type
Object *ob = BKE_object_add_only_object(bmain, type, name);
ob->data = BKE_object_obdata_add_from_type(bmain, type, name);
- ob->lay = scene->lay;
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
LayerCollection *layer_collection = BKE_layer_collection_get_active(view_layer);
@@ -547,7 +546,7 @@ void bc_triangulate_mesh(Mesh *me)
BMeshFromMeshParams bm_from_me_params = {0};
bm_from_me_params.calc_face_normal = true;
BM_mesh_bm_from_me(bm, me, &bm_from_me_params);
- BM_mesh_triangulate(bm, quad_method, use_beauty, tag_only, NULL, NULL, NULL);
+ BM_mesh_triangulate(bm, quad_method, use_beauty, 4, tag_only, NULL, NULL, NULL);
BMeshToMeshParams bm_to_me_params = {0};
bm_to_me_params.calc_object_remap = false;
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp
index ba0d225fdd7..f23b186416d 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.cpp
+++ b/source/blender/compositor/intern/COM_NodeGraph.cpp
@@ -128,7 +128,7 @@ void NodeGraph::add_bNode(const CompositorContext &context, bNodeTree *b_ntree,
}
/* special node types */
- if (b_node->type == NODE_GROUP) {
+ if (ELEM(b_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
add_proxies_group(context, b_node, key);
}
else if (b_node->type == NODE_REROUTE) {
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
index 6adf4f6207d..beed19a0b95 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
@@ -55,8 +55,8 @@ void OutputFileNode::convertToOperations(NodeConverter &converter, const Composi
}
else {
outputOperation = new OutputOpenExrMultiLayerOperation(
- context.getRenderData(), context.getbNodeTree(), storage->base_path,
- storage->format.exr_codec, use_half_float, context.getViewName());
+ context.getRenderData(), context.getbNodeTree(), storage->base_path,
+ storage->format.exr_codec, use_half_float, context.getViewName());
}
converter.addOperation(outputOperation);
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
index f213bdff51d..a3bcaac2835 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
@@ -51,7 +51,6 @@ public:
void deinitExecution();
};
-/**/
class OutputStereoOperation : public OutputSingleLayerOperation {
private:
char m_name[FILE_MAX];
diff --git a/source/blender/datatoc/datatoc.c b/source/blender/datatoc/datatoc.c
index 454c0a5d0e7..d54fa898968 100644
--- a/source/blender/datatoc/datatoc.c
+++ b/source/blender/datatoc/datatoc.c
@@ -36,8 +36,12 @@ static char *basename(char *string)
lfslash = strrchr(string, '/');
lbslash = strrchr(string, '\\');
- if (lbslash) lbslash++;
- if (lfslash) lfslash++;
+ if (lbslash) {
+ lbslash++;
+ }
+ if (lfslash) {
+ lfslash++;
+ }
return MAX3(string, lfslash, lbslash);
}
@@ -66,15 +70,18 @@ int main(int argc, char **argv)
size = ftell(fpin);
fseek(fpin, 0L, SEEK_SET);
- if (argv[1][0] == '.') argv[1]++;
+ if (argv[1][0] == '.') {
+ argv[1]++;
+ }
#ifdef VERBOSE
printf("Making C file <%s>\n", argv[2]);
#endif
argv_len = (int)strlen(argv[1]);
- for (i = 0; i < argv_len; i++)
+ for (i = 0; i < argv_len; i++) {
if (argv[1][i] == '.') argv[1][i] = '_';
+ }
fpout = fopen(argv[2], "w");
if (!fpout) {
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index 11732c55a99..ce4508461ef 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -158,11 +158,11 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
#define DEG_OBJECT_ITER_END \
ITER_END; \
- }
+ } ((void)0)
/**
- * Depsgraph objects iterator for draw manager and final render
- */
+ * Depsgraph objects iterator for draw manager and final render
+ */
#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(graph_, instance_) \
DEG_OBJECT_ITER_BEGIN(graph_, instance_, \
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | \
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index dbf6b1d1451..0cc1c2aa211 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -496,6 +496,13 @@ void DepsgraphNodeBuilder::build_collection(
* objects are poked with the new visibility flag, since they
* might become visible too. */
}
+ else if (from_layer_collection == NULL &&
+ !id_node->is_collection_fully_expanded)
+ {
+ /* Initially collection was built from layer now, and was requested
+ * to not recurs into object. But nw it's asked to recurs into all
+ * objects. */
+ }
else {
return;
}
@@ -771,6 +778,11 @@ void DepsgraphNodeBuilder::build_object_transform(Object *object)
function_bind(BKE_object_eval_uber_transform,
_1,
ob_cow));
+ /* Operation to take of rigid body simulation. soft bodies and other firends
+ * in the context of point cache invalidation. */
+ add_operation_node(&object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_SIMULATION_INIT);
/* Object transform is done. */
op_node = add_operation_node(&object->id, NodeType::TRANSFORM,
OperationCode::TRANSFORM_FINAL,
@@ -1015,6 +1027,7 @@ void DepsgraphNodeBuilder::build_world(World *world)
function_bind(BKE_world_eval, _1, world_cow));
/* Animation. */
build_animdata(&world->id);
+ build_parameters(&world->id);
/* World's nodetree. */
build_nodetree(world->nodetree);
}
@@ -1047,8 +1060,8 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
/* Init/rebuild operation. */
add_operation_node(&scene->id, NodeType::TRANSFORM,
- OperationCode::RIGIDBODY_REBUILD,
- function_bind(BKE_rigidbody_rebuild_sim, _1, scene_cow));
+ OperationCode::RIGIDBODY_REBUILD,
+ function_bind(BKE_rigidbody_rebuild_sim, _1, scene_cow));
/* Do-sim operation. */
OperationNode *sim_node = add_operation_node(
&scene->id, NodeType::TRANSFORM,
@@ -1065,8 +1078,8 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
if (object->type != OB_MESH) {
continue;
}
- /* 2) create operation for flushing results */
- /* object's transform component - where the rigidbody operation
+ /* Create operation for flushing results. */
+ /* Object's transform component - where the rigidbody operation
* lives. */
add_operation_node(&object->id,
NodeType::TRANSFORM,
@@ -1184,6 +1197,7 @@ void DepsgraphNodeBuilder::build_particle_settings(
get_cow_datablock(particle_settings);
/* Animation data. */
build_animdata(&particle_settings->id);
+ build_parameters(&particle_settings->id);
/* Parameters change. */
OperationNode *op_node;
op_node = add_operation_node(&particle_settings->id,
@@ -1217,6 +1231,7 @@ void DepsgraphNodeBuilder::build_shapekeys(Key *key)
return;
}
build_animdata(&key->id);
+ build_parameters(&key->id);
/* This is an exit operation for the entire key datablock, is what is used
* as dependency for modifiers evaluation. */
add_operation_node(
@@ -1382,8 +1397,7 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(
obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_DONE);
op_node->set_as_exit();
/* Parameters for driver sources. */
- add_operation_node(
- obdata, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL);
+ build_parameters(obdata);
/* Batch cache. */
add_operation_node(obdata,
NodeType::BATCH_CACHE,
@@ -1399,6 +1413,7 @@ void DepsgraphNodeBuilder::build_armature(bArmature *armature)
return;
}
build_animdata(&armature->id);
+ build_parameters(&armature->id);
/* Make sure pose is up-to-date with armature updates. */
add_operation_node(
&armature->id, NodeType::PARAMETERS, OperationCode::ARMATURE_EVAL);
@@ -1409,11 +1424,8 @@ void DepsgraphNodeBuilder::build_camera(Camera *camera)
if (built_map_.checkIsBuiltAndTag(camera)) {
return;
}
- OperationNode *op_node;
build_animdata(&camera->id);
- op_node = add_operation_node(
- &camera->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL);
- op_node->set_as_exit();
+ build_parameters(&camera->id);
}
void DepsgraphNodeBuilder::build_light(Light *lamp)
@@ -1421,16 +1433,8 @@ void DepsgraphNodeBuilder::build_light(Light *lamp)
if (built_map_.checkIsBuiltAndTag(lamp)) {
return;
}
- OperationNode *op_node;
build_animdata(&lamp->id);
- op_node = add_operation_node(
- &lamp->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL);
- /* NOTE: We mark this node as both entry and exit. This way we have a
- * node to link all dependencies for shading (which includes relation to the
- * light object, and incldues relation from node tree) without adding a
- * dedicated component type. */
- op_node->set_as_entry();
- op_node->set_as_exit();
+ build_parameters(&lamp->id);
/* light's nodetree */
build_nodetree(lamp->nodetree);
}
@@ -1446,6 +1450,8 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
/* nodetree itself */
add_id_node(&ntree->id);
bNodeTree *ntree_cow = get_cow_datablock(ntree);
+ /* General parameters. */
+ build_parameters(&ntree->id);
/* Animation, */
build_animdata(&ntree->id);
/* Shading update. */
@@ -1493,7 +1499,7 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree)
else if (id_type == ID_MC) {
build_movieclip((MovieClip *)id);
}
- else if (bnode->type == NODE_GROUP) {
+ else if (ELEM(bnode->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
bNodeTree *group_ntree = (bNodeTree *)id;
build_nodetree(group_ntree);
}
@@ -1523,6 +1529,7 @@ void DepsgraphNodeBuilder::build_material(Material *material)
material_cow));
/* Material animation. */
build_animdata(&material->id);
+ build_parameters(&material->id);
/* Material's nodetree. */
build_nodetree(material->nodetree);
}
@@ -1535,6 +1542,7 @@ void DepsgraphNodeBuilder::build_texture(Tex *texture)
}
/* Texture itself. */
build_animdata(&texture->id);
+ build_parameters(&texture->id);
/* Texture's nodetree. */
build_nodetree(texture->nodetree);
/* Special cases for different IDs which texture uses. */
@@ -1552,6 +1560,7 @@ void DepsgraphNodeBuilder::build_image(Image *image) {
if (built_map_.checkIsBuiltAndTag(image)) {
return;
}
+ build_parameters(&image->id);
add_operation_node(&image->id,
NodeType::GENERIC_DATABLOCK,
OperationCode::GENERIC_DATABLOCK_UPDATE);
@@ -1583,6 +1592,7 @@ void DepsgraphNodeBuilder::build_gpencil(bGPdata *gpd)
/* The main reason Grease Pencil is included here is because the animation
* (and drivers) need to be hosted somewhere. */
build_animdata(gpd_id);
+ build_parameters(gpd_id);
}
void DepsgraphNodeBuilder::build_cachefile(CacheFile *cache_file)
@@ -1593,6 +1603,7 @@ void DepsgraphNodeBuilder::build_cachefile(CacheFile *cache_file)
ID *cache_file_id = &cache_file->id;
/* Animation, */
build_animdata(cache_file_id);
+ build_parameters(cache_file_id);
/* Cache evaluation itself. */
add_operation_node(
cache_file_id, NodeType::CACHE, OperationCode::FILE_CACHE_UPDATE);
@@ -1607,6 +1618,7 @@ void DepsgraphNodeBuilder::build_mask(Mask *mask)
Mask *mask_cow = get_cow_datablock(mask);
/* F-Curve based animation. */
build_animdata(mask_id);
+ build_parameters(mask_id);
/* Animation based on mask's shapes. */
add_operation_node(mask_id,
NodeType::ANIMATION,
@@ -1628,6 +1640,7 @@ void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip)
MovieClip *clip_cow = (MovieClip *)ensure_cow_id(clip_id);
/* Animation. */
build_animdata(clip_id);
+ build_parameters(clip_id);
/* Movie clip evaluation. */
add_operation_node(clip_id,
NodeType::PARAMETERS,
@@ -1649,6 +1662,7 @@ void DepsgraphNodeBuilder::build_lightprobe(LightProbe *probe)
add_operation_node(
&probe->id, NodeType::PARAMETERS, OperationCode::LIGHT_PROBE_EVAL);
build_animdata(&probe->id);
+ build_parameters(&probe->id);
}
void DepsgraphNodeBuilder::build_speaker(Speaker *speaker)
@@ -1660,6 +1674,7 @@ void DepsgraphNodeBuilder::build_speaker(Speaker *speaker)
add_operation_node(
&speaker->id, NodeType::PARAMETERS, OperationCode::SPEAKER_EVAL);
build_animdata(&speaker->id);
+ build_parameters(&speaker->id);
}
/* **** ID traversal callbacks functions **** */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 161d0a9cd9f..489b688eaaa 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -284,29 +284,11 @@ void DepsgraphRelationBuilder::add_modifier_to_transform_relation(
const DepsNodeHandle *handle,
const char *description)
{
- /* Geometry operation, this is where relation will be wired to. */
- OperationNode *geometry_operation_node =
- handle->node->get_entry_operation();
- ComponentNode *geometry_component = geometry_operation_node->owner;
- BLI_assert(geometry_component->type == NodeType::GEOMETRY);
- IDNode *id_node = geometry_component->owner;
- /* Transform operation, the source of the relation. */
- ComponentNode *transform_component =
- id_node->find_component(NodeType::TRANSFORM);
- ID *id = geometry_operation_node->owner->owner->id_orig;
- BLI_assert(GS(id->name) == ID_OB);
- Object *object = reinterpret_cast<Object *>(id);
- OperationNode *transform_operation_node = NULL;
- if (object->rigidbody_object == NULL) {
- transform_operation_node = transform_component->get_exit_operation();
- }
- else {
- transform_operation_node = transform_component->get_operation(
- OperationCode::TRANSFORM_EVAL);
- }
+ IDNode *id_node = handle->node->owner->owner;
+ ID *id = id_node->id_orig;
+ ComponentKey geometry_key(id, NodeType::GEOMETRY);
/* Wire up the actual relation. */
- add_operation_relation(
- transform_operation_node, geometry_operation_node, description);
+ add_depends_on_transform_relation(id, geometry_key, description);
}
void DepsgraphRelationBuilder::add_customdata_mask(
@@ -510,6 +492,9 @@ void DepsgraphRelationBuilder::build_id(ID *id)
case ID_TE:
build_texture((Tex *)id);
break;
+ case ID_IM:
+ build_image((Image *)id);
+ break;
case ID_WO:
build_world((World *)id);
break;
@@ -654,6 +639,10 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object)
BKE_constraints_id_loop(&object->constraints, constraint_walk, &data);
}
/* Object constraints. */
+ OperationKey object_transform_simulation_init_key(
+ &object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_SIMULATION_INIT);
if (object->constraints.first != NULL) {
OperationKey constraint_key(&object->id,
NodeType::TRANSFORM,
@@ -667,12 +656,22 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object)
/* operation order */
add_relation(base_op_key, constraint_key, "ObBase-> Constraint Stack");
add_relation(constraint_key, final_transform_key, "ObConstraints -> Done");
- add_relation(constraint_key, ob_eval_key, "Eval");
- add_relation(ob_eval_key, final_transform_key, "Eval");
+ add_relation(constraint_key, ob_eval_key, "Constraint -> Transform Eval");
+ add_relation(ob_eval_key,
+ object_transform_simulation_init_key,
+ "Transform Eval -> Simulation Init");
+ add_relation(object_transform_simulation_init_key,
+ final_transform_key,
+ "Simulation -> Final Transform");
}
else {
add_relation(base_op_key, ob_eval_key, "Eval");
- add_relation(ob_eval_key, final_transform_key, "Eval");
+ add_relation(ob_eval_key,
+ object_transform_simulation_init_key,
+ "Transform Eval -> Simulation Init");
+ add_relation(object_transform_simulation_init_key,
+ final_transform_key,
+ "Simulation -> Final Transform");
}
/* Animation data */
build_animdata(&object->id);
@@ -932,6 +931,11 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object)
* so we onl;y hook up to transform channel here. */
add_relation(parent_geometry_key, ob_key, "Parent");
}
+
+ /* Dupliverts uses original vertex index. */
+ if (parent->transflag & OB_DUPLIVERTS) {
+ add_customdata_mask(parent, DEGCustomDataMeshMasks::MaskVert(CD_MASK_ORIGINDEX));
+ }
}
void DepsgraphRelationBuilder::build_object_pointcache(Object *object)
@@ -952,9 +956,10 @@ void DepsgraphRelationBuilder::build_object_pointcache(Object *object)
int flag = -1;
if (ptcache_id->type == PTCACHE_TYPE_RIGIDBODY) {
flag = FLAG_TRANSFORM;
- OperationKey transform_key(&object->id,
- NodeType::TRANSFORM,
- OperationCode::TRANSFORM_LOCAL);
+ OperationKey transform_key(
+ &object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_SIMULATION_INIT);
add_relation(point_cache_key,
transform_key,
"Point Cache -> Rigid Body");
@@ -976,15 +981,16 @@ void DepsgraphRelationBuilder::build_object_pointcache(Object *object)
}
/* Manual edits to any dependency (or self) should reset the point cache. */
if (!BLI_listbase_is_empty(&ptcache_id_list)) {
- OperationKey transform_init_key(&object->id,
- NodeType::TRANSFORM,
- OperationCode::TRANSFORM_INIT);
+ OperationKey transform_eval_key(
+ &object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_EVAL);
OperationKey geometry_init_key(&object->id,
NodeType::GEOMETRY,
OperationCode::GEOMETRY_EVAL_INIT);
- add_relation(transform_init_key,
+ add_relation(transform_eval_key,
point_cache_key,
- "Transform Local -> Point Cache",
+ "Transform Simulation -> Point Cache",
RELATION_FLAG_FLUSH_USER_EDIT_ONLY);
add_relation(geometry_init_key,
point_cache_key,
@@ -1688,6 +1694,7 @@ void DepsgraphRelationBuilder::build_world(World *world)
}
/* animation */
build_animdata(&world->id);
+ build_parameters(&world->id);
/* world's nodetree */
if (world->nodetree != NULL) {
build_nodetree(world->nodetree);
@@ -1725,11 +1732,21 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
* initialized.
* TODO(sergey): Verify that it indeed goes to initialization and not to a
* simulation. */
- ListBase *relations = build_effector_relations(graph_, rbw->effector_weights->group);
- LISTBASE_FOREACH (EffectorRelation *, relation, relations) {
+ ListBase *effector_relations =
+ build_effector_relations(graph_, rbw->effector_weights->group);
+ LISTBASE_FOREACH (EffectorRelation *, effector_relation, effector_relations) {
ComponentKey effector_transform_key(
- &relation->ob->id, NodeType::TRANSFORM);
+ &effector_relation->ob->id, NodeType::TRANSFORM);
add_relation(effector_transform_key, rb_init_key, "RigidBody Field");
+ if (effector_relation->pd != NULL) {
+ const short shape = effector_relation->pd->shape;
+ if (ELEM(shape, PFIELD_SHAPE_SURFACE, PFIELD_SHAPE_POINTS)) {
+ ComponentKey effector_geometry_key(
+ &effector_relation->ob->id, NodeType::GEOMETRY);
+ add_relation(
+ effector_geometry_key, rb_init_key, "RigidBody Field");
+ }
+ }
}
/* Objects. */
if (rbw->group != NULL) {
@@ -1749,11 +1766,15 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
"Rigidbody Sim Eval -> RBO Sync");
/* Simulation uses object transformation after parenting and solving
* contraints. */
+ OperationKey object_transform_simulation_init_key(
+ &object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_SIMULATION_INIT);
OperationKey object_transform_eval_key(
&object->id,
NodeType::TRANSFORM,
OperationCode::TRANSFORM_EVAL);
- add_relation(object_transform_eval_key,
+ add_relation(object_transform_simulation_init_key,
rb_simulate_key,
"Object Transform -> Rigidbody Sim Eval");
/* Geometry must be known to create the rigid body. RBO_MESH_BASE
@@ -1945,12 +1966,9 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object)
}
}
/* Particle depends on the object transform, so that channel is to be ready
- * first.
- *
- * TODO(sergey): This relation should be altered once real granular update
- * is implemented. */
- ComponentKey transform_key(&object->id, NodeType::TRANSFORM);
- add_relation(transform_key, obdata_ubereval_key, "Particle Eval");
+ * first. */
+ add_depends_on_transform_relation(
+ &object->id, obdata_ubereval_key, "Particle Eval");
}
void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part)
@@ -1960,6 +1978,7 @@ void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part)
}
/* Animation data relations. */
build_animdata(&part->id);
+ build_parameters(&part->id);
OperationKey particle_settings_init_key(&part->id,
NodeType::PARTICLE_SETTINGS,
OperationCode::PARTICLE_SETTINGS_INIT);
@@ -2036,14 +2055,19 @@ void DepsgraphRelationBuilder::build_shapekeys(Key *key)
}
/* Attach animdata to geometry. */
build_animdata(&key->id);
+ build_parameters(&key->id);
/* Connect all blocks properties to the final result evaluation. */
ComponentKey geometry_key(&key->id, NodeType::GEOMETRY);
+ OperationKey parameters_eval_key(&key->id,
+ NodeType::PARAMETERS,
+ OperationCode::PARAMETERS_EVAL);
LISTBASE_FOREACH (KeyBlock *, key_block, &key->block) {
OperationKey key_block_key(&key->id,
NodeType::PARAMETERS,
OperationCode::PARAMETERS_EVAL,
key_block->name);
add_relation(key_block_key, geometry_key, "Key Block Properties");
+ add_relation(key_block_key, parameters_eval_key, "Key Block Properties");
}
}
@@ -2244,6 +2268,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
}
/* Animation. */
build_animdata(obdata);
+ build_parameters(obdata);
/* ShapeKeys. */
Key *key = BKE_key_from_id(obdata);
if (key != NULL) {
@@ -2269,30 +2294,37 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
{
Curve *cu = (Curve *)obdata;
if (cu->bevobj != NULL) {
- ComponentKey bevob_geom_key(&cu->bevobj->id,
- NodeType::GEOMETRY);
- add_relation(bevob_geom_key,
- obdata_geom_eval_key,
- "Curve Bevel Geometry");
- ComponentKey bevob_key(&cu->bevobj->id,
- NodeType::TRANSFORM);
- add_relation(bevob_key,
- obdata_geom_eval_key,
- "Curve Bevel Transform");
+ ComponentKey bevob_geom_key(
+ &cu->bevobj->id,
+ NodeType::GEOMETRY);
+ add_relation(
+ bevob_geom_key,
+ obdata_geom_eval_key,
+ "Curve Bevel Geometry");
+ ComponentKey bevob_key(
+ &cu->bevobj->id,
+ NodeType::TRANSFORM);
+ add_relation(
+ bevob_key,
+ obdata_geom_eval_key,
+ "Curve Bevel Transform");
build_object(NULL, cu->bevobj);
}
if (cu->taperobj != NULL) {
- ComponentKey taperob_key(&cu->taperobj->id,
- NodeType::GEOMETRY);
+ ComponentKey taperob_key(
+ &cu->taperobj->id,
+ NodeType::GEOMETRY);
add_relation(taperob_key, obdata_geom_eval_key, "Curve Taper");
build_object(NULL, cu->taperobj);
}
if (cu->textoncurve != NULL) {
- ComponentKey textoncurve_key(&cu->textoncurve->id,
- NodeType::GEOMETRY);
- add_relation(textoncurve_key,
- obdata_geom_eval_key,
- "Text on Curve");
+ ComponentKey textoncurve_key(
+ &cu->textoncurve->id,
+ NodeType::GEOMETRY);
+ add_relation(
+ textoncurve_key,
+ obdata_geom_eval_key,
+ "Text on Curve");
build_object(NULL, cu->textoncurve);
}
break;
@@ -2341,6 +2373,7 @@ void DepsgraphRelationBuilder::build_armature(bArmature *armature)
return;
}
build_animdata(&armature->id);
+ build_parameters(&armature->id);
}
void DepsgraphRelationBuilder::build_camera(Camera *camera)
@@ -2348,6 +2381,7 @@ void DepsgraphRelationBuilder::build_camera(Camera *camera)
if (built_map_.checkIsBuiltAndTag(camera)) {
return;
}
+ build_parameters(&camera->id);
if (camera->dof_ob != NULL) {
ComponentKey camera_parameters_key(&camera->id, NodeType::PARAMETERS);
ComponentKey dof_ob_key(&camera->dof_ob->id, NodeType::TRANSFORM);
@@ -2361,6 +2395,7 @@ void DepsgraphRelationBuilder::build_light(Light *lamp)
if (built_map_.checkIsBuiltAndTag(lamp)) {
return;
}
+ build_parameters(&lamp->id);
/* light's nodetree */
if (lamp->nodetree != NULL) {
build_nodetree(lamp->nodetree);
@@ -2380,6 +2415,7 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
return;
}
build_animdata(&ntree->id);
+ build_parameters(&ntree->id);
ComponentKey shading_key(&ntree->id, NodeType::SHADING);
/* nodetree's nodes... */
LISTBASE_FOREACH (bNode *, bnode, &ntree->nodes) {
@@ -2395,7 +2431,7 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
build_texture((Tex *)bnode->id);
}
else if (id_type == ID_IM) {
- /* nothing for now. */
+ build_image((Image *)bnode->id);
}
else if (id_type == ID_OB) {
build_object(NULL, (Object *)id);
@@ -2413,7 +2449,7 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
else if (id_type == ID_MC) {
build_movieclip((MovieClip *)id);
}
- else if (bnode->type == NODE_GROUP) {
+ else if (ELEM(bnode->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
bNodeTree *group_ntree = (bNodeTree *)id;
build_nodetree(group_ntree);
ComponentKey group_shading_key(&group_ntree->id,
@@ -2437,6 +2473,8 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
ComponentKey animation_key(&ntree->id, NodeType::ANIMATION);
add_relation(animation_key, shading_parameters_key, "NTree Shading Parameters");
}
+ ComponentKey parameters_key(&ntree->id, NodeType::PARAMETERS);
+ add_relation(parameters_key, shading_parameters_key, "NTree Shading Parameters");
}
/* Recursively build graph for material */
@@ -2447,6 +2485,7 @@ void DepsgraphRelationBuilder::build_material(Material *material)
}
/* animation */
build_animdata(&material->id);
+ build_parameters(&material->id);
/* material's nodetree */
if (material->nodetree != NULL) {
build_nodetree(material->nodetree);
@@ -2469,8 +2508,15 @@ void DepsgraphRelationBuilder::build_texture(Tex *texture)
}
/* texture itself */
build_animdata(&texture->id);
+ build_parameters(&texture->id);
/* texture's nodetree */
build_nodetree(texture->nodetree);
+ /* Special cases for different IDs which texture uses. */
+ if (texture->type == TEX_IMAGE) {
+ if (texture->ima != NULL) {
+ build_image(texture->ima);
+ }
+ }
build_nested_nodetree(&texture->id, texture->nodetree);
if (check_id_has_anim_component(&texture->id)) {
ComponentKey animation_key(&texture->id, NodeType::ANIMATION);
@@ -2480,6 +2526,14 @@ void DepsgraphRelationBuilder::build_texture(Tex *texture)
}
}
+void DepsgraphRelationBuilder::build_image(Image *image)
+{
+ if (built_map_.checkIsBuiltAndTag(image)) {
+ return;
+ }
+ build_parameters(&image->id);
+}
+
void DepsgraphRelationBuilder::build_compositor(Scene *scene)
{
/* For now, just a plain wrapper? */
@@ -2493,6 +2547,7 @@ void DepsgraphRelationBuilder::build_gpencil(bGPdata *gpd)
}
/* animation */
build_animdata(&gpd->id);
+ build_parameters(&gpd->id);
// TODO: parent object (when that feature is implemented)
}
@@ -2504,6 +2559,13 @@ void DepsgraphRelationBuilder::build_cachefile(CacheFile *cache_file)
}
/* Animation. */
build_animdata(&cache_file->id);
+ build_parameters(&cache_file->id);
+ if (check_id_has_anim_component(&cache_file->id)) {
+ ComponentKey animation_key(&cache_file->id, NodeType::ANIMATION);
+ ComponentKey datablock_key(&cache_file->id,
+ NodeType::CACHE);
+ add_relation(animation_key, datablock_key, "Datablock Animation");
+ }
}
void DepsgraphRelationBuilder::build_mask(Mask *mask)
@@ -2514,6 +2576,7 @@ void DepsgraphRelationBuilder::build_mask(Mask *mask)
ID *mask_id = &mask->id;
/* F-Curve animation. */
build_animdata(mask_id);
+ build_parameters(mask_id);
/* Own mask animation. */
OperationKey mask_animation_key(mask_id,
NodeType::ANIMATION,
@@ -2532,6 +2595,7 @@ void DepsgraphRelationBuilder::build_movieclip(MovieClip *clip)
}
/* Animation. */
build_animdata(&clip->id);
+ build_parameters(&clip->id);
}
void DepsgraphRelationBuilder::build_lightprobe(LightProbe *probe)
@@ -2540,6 +2604,7 @@ void DepsgraphRelationBuilder::build_lightprobe(LightProbe *probe)
return;
}
build_animdata(&probe->id);
+ build_parameters(&probe->id);
}
void DepsgraphRelationBuilder::build_speaker(Speaker *speaker)
@@ -2548,6 +2613,7 @@ void DepsgraphRelationBuilder::build_speaker(Speaker *speaker)
return;
}
build_animdata(&speaker->id);
+ build_parameters(&speaker->id);
}
void DepsgraphRelationBuilder::build_copy_on_write_relations()
@@ -2621,10 +2687,6 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node)
if (id_type == ID_ME && comp_node->type == NodeType::GEOMETRY) {
rel_flag &= ~RELATION_FLAG_NO_FLUSH;
}
- /* materials need update grease pencil objects */
- if (id_type == ID_MA) {
- rel_flag &= ~RELATION_FLAG_NO_FLUSH;
- }
/* Notes on exceptions:
* - Parameters component is where drivers are living. Changing any
* of the (custom) properties in the original datablock (even the
@@ -2637,30 +2699,12 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node)
* copied by copy-on-write, and not preserved. PROBABLY it is better
* to preserve that cache in copy-on-write, but for the time being
* we allow flush to layer collections component which will ensure
- * that cached array fo bases exists and is up-to-date.
- *
- * - Action is allowed to flush as well, this way it's possible to
- * keep current tagging in animation editors (which tags action for
- * CoW update when it's changed) but yet guarantee evaluation order
- * with objects which are using that action. */
+ * that cached array fo bases exists and is up-to-date. */
if (comp_node->type == NodeType::PARAMETERS ||
comp_node->type == NodeType::LAYER_COLLECTIONS)
{
rel_flag &= ~RELATION_FLAG_NO_FLUSH;
}
- if (comp_node->type == NodeType::ANIMATION && id_type == ID_AC) {
- rel_flag &= ~RELATION_FLAG_NO_FLUSH;
- /* NOTE: We only allow flush on user edits. If the action block is
- * just brought into the dependency graph it is either due to
- * initial graph construction or due to some property got animated.
- * In first case all the related datablocks will be tagged for an
- * update as well. In the second case it is up to the editing
- * function to tag changed datablock.
- *
- * This logic allows to preserve unkeyed changes on file load and on
- * undo. */
- rel_flag |= RELATION_FLAG_FLUSH_USER_EDIT_ONLY;
- }
/* All entry operations of each component should wait for a proper
* copy of ID. */
OperationNode *op_entry = comp_node->get_entry_operation();
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 250593eeda0..0a0f0e99865 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -52,6 +52,7 @@ struct EffectorWeights;
struct FCurve;
struct GHash;
struct ID;
+struct Image;
struct Key;
struct LayerCollection;
struct Light;
@@ -198,6 +199,12 @@ public:
const char *description,
int flags = 0);
+ template <typename KeyTo>
+ Relation *add_depends_on_transform_relation(ID *id,
+ const KeyTo& key_to,
+ const char *description,
+ int flags = 0);
+
/* Adds relation from proper transformation opertation to the modifier.
* Takes care of checking for possible physics solvers modifying position
* of this object. */
@@ -272,6 +279,7 @@ public:
void build_nodetree(bNodeTree *ntree);
void build_material(Material *ma);
void build_texture(Tex *tex);
+ void build_image(Image *image);
void build_compositor(Scene *scene);
void build_gpencil(bGPdata *gpd);
void build_cachefile(CacheFile *cache_file);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
index 613e8f86baf..86a17ae4a47 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
@@ -27,6 +27,7 @@
extern "C" {
#include "DNA_ID.h"
+#include "DNA_object_types.h"
}
namespace DEG {
@@ -117,6 +118,26 @@ Relation *DepsgraphRelationBuilder::add_node_handle_relation(
return NULL;
}
+template <typename KeyTo>
+Relation *DepsgraphRelationBuilder::add_depends_on_transform_relation(
+ ID *id,
+ const KeyTo& key_to,
+ const char *description,
+ int flags)
+{
+ if (GS(id->name) == ID_OB) {
+ Object *object = reinterpret_cast<Object *>(id);
+ if (object->rigidbody_object != NULL) {
+ OperationKey transform_key(&object->id,
+ NodeType::TRANSFORM,
+ OperationCode::TRANSFORM_EVAL);
+ return add_relation(transform_key, key_to, description, flags);
+ }
+ }
+ ComponentKey transform_key(id, NodeType::TRANSFORM);
+ return add_relation(transform_key, key_to, description, flags);
+}
+
template <typename KeyType>
DepsNodeHandle DepsgraphRelationBuilder::create_node_handle(
const KeyType &key,
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 fe88b532dca..35652ebb53e 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -260,14 +260,8 @@ void DepsgraphRelationBuilder::build_splineik_pose(Object *object,
RELATION_FLAG_GODMODE);
/* Attach path dependency to solver. */
if (data->tar != NULL) {
- /* TODO(sergey): For until we'll store partial matricies in the
- * depsgraph, we create dependency between target object and pose eval
- * component. See IK pose for a bit more information. */
- /* TODO: the bigggest point here is that we need the curve PATH and not
- * just the general geometry. */
ComponentKey target_key(&data->tar->id, NodeType::GEOMETRY);
- ComponentKey pose_key(&object->id, NodeType::EVAL_POSE);
- add_relation(target_key, pose_key, "Curve.Path -> Spline IK");
+ add_relation(target_key, init_ik_key, "Curve.Path -> Spline IK");
}
pchan->flag |= POSE_DONE;
OperationKey final_transforms_key(
@@ -343,6 +337,8 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
NodeType::PARAMETERS,
OperationCode::ARMATURE_EVAL);
add_relation(armature_key, pose_init_key, "Data dependency");
+ /* Run cleanup even when there are no bones. */
+ add_relation(pose_init_key, pose_cleanup_key, "Init -> Cleanup");
/* IK Solvers.
*
* - These require separate processing steps are pose-level to be executed
@@ -456,7 +452,8 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
NodeType::BONE,
pchan->name,
OperationCode::BONE_CONSTRAINTS);
- add_relation(bone_pose_key, constraints_key, "Constraints Stack");
+ add_relation(bone_pose_key, constraints_key, "Pose -> Constraints Stack");
+ add_relation(bone_local_key, constraints_key, "Local -> Constraints Stack");
/* Constraints -> ready/ */
/* TODO(sergey): When constraint stack is exploded, this step should
* occur before the first IK solver. */
@@ -518,9 +515,15 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
add_relation(bone_done_key,
pose_done_key,
"PoseEval Result-Bone Link");
+
+ /* Bones must be traversed before cleanup. */
add_relation(bone_done_key,
pose_cleanup_key,
- "Cleanup dependency");
+ "Done -> Cleanup");
+
+ add_relation(bone_ready_key,
+ pose_cleanup_key,
+ "Ready -> Cleanup");
}
/* Custom shape. */
if (pchan->custom != NULL) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index fdf78cf624e..c8c6cc75418 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -177,7 +177,7 @@ Node *RNANodeQuery::find_node(const PointerRNA *ptr,
RNANodeIdentifier RNANodeQuery::construct_node_identifier(
const PointerRNA *ptr,
const PropertyRNA *prop,
- RNAPointerSource /*source*/)
+ RNAPointerSource source)
{
RNANodeIdentifier node_identifier;
if (ptr->type == NULL) {
@@ -265,7 +265,18 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(
}
}
else if (RNA_struct_is_a(ptr->type, &RNA_Modifier)) {
- node_identifier.type = NodeType::GEOMETRY;
+ /* When modifier is used as FROM operation this is likely referencing to
+ * the property (for example, modifier's influence).
+ * But when it's used as TO operation, this is geometry component. */
+ switch (source) {
+ case RNAPointerSource::ENTRY:
+ node_identifier.type = NodeType::GEOMETRY;
+ break;
+ case RNAPointerSource::EXIT:
+ node_identifier.type = NodeType::PARAMETERS;
+ node_identifier.operation_code = OperationCode::PARAMETERS_EVAL;
+ break;
+ }
return node_identifier;
}
else if (ptr->type == &RNA_Object) {
@@ -333,6 +344,21 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(
node_identifier.type = NodeType::GEOMETRY;
return node_identifier;
}
+ else if (RNA_struct_is_a(ptr->type, &RNA_ImageUser)) {
+ if (GS(node_identifier.id->name) == ID_NT) {
+ node_identifier.type = NodeType::ANIMATION;
+ node_identifier.operation_code = OperationCode::IMAGE_ANIMATION;
+ return node_identifier;
+ }
+ }
+ else if (ELEM(ptr->type, &RNA_MeshVertex,
+ &RNA_MeshEdge,
+ &RNA_MeshLoop,
+ &RNA_MeshPolygon))
+ {
+ node_identifier.type = NodeType::GEOMETRY;
+ return node_identifier;
+ }
if (prop != NULL) {
/* All unknown data effectively falls under "parameter evaluation". */
if (RNA_property_is_idprop(prop)) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.h b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
index a328124d6ec..5e121476087 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
@@ -35,7 +35,7 @@ namespace DEG {
struct Depsgraph;
struct Node;
-struct RNANodeQueryIDData;
+class RNANodeQueryIDData;
/* For queries which gives operation node or key defines whether we are
* interested in a result of the given property or whether we are linking some
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
index 4aaeaf48040..2dfffe92368 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
@@ -148,6 +148,8 @@ bool deg_objects_dupli_iterator_next(BLI_Iterator *iter)
temp_dupli_object->select_id = dupli_parent->select_id;
temp_dupli_object->base_flag = dupli_parent->base_flag | BASE_FROM_DUPLI;
temp_dupli_object->base_local_view_bits = dupli_parent->base_local_view_bits;
+ temp_dupli_object->dt = MIN2(temp_dupli_object->dt, dupli_parent->dt);
+ copy_v4_v4(temp_dupli_object->color, dupli_parent->color);
/* Duplicated elements shouldn't care whether their original collection is visible or not. */
temp_dupli_object->base_flag |= BASE_VISIBLE;
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 493247e252f..f6887af63f2 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -622,8 +622,12 @@ void graph_id_tag_update(Main *bmain,
/* Special case for nested node tree datablocks. */
id_tag_update_ntree_special(bmain, graph, id, flag, update_source);
/* Direct update tags means that something outside of simulated/cached
- * physics did change and that cache is to be invalidated. */
- if (update_source == DEG_UPDATE_SOURCE_USER_EDIT) {
+ * physics did change and that cache is to be invalidated.
+ * This is only needed if data changes. If it's just a drawing, we keep the
+ * point cache. */
+ if (update_source == DEG_UPDATE_SOURCE_USER_EDIT &&
+ flag != ID_RECALC_SHADING)
+ {
graph_id_tag_update_single_flag(
bmain, graph, id, id_node, ID_RECALC_POINT_CACHE, update_source);
}
diff --git a/source/blender/depsgraph/intern/depsgraph_type.h b/source/blender/depsgraph/intern/depsgraph_type.h
index d34b6d724cb..d96c621f4b2 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.h
+++ b/source/blender/depsgraph/intern/depsgraph_type.h
@@ -36,6 +36,8 @@
#include <string>
#include <vector>
#include <algorithm>
+#include <map>
+#include <unordered_map>
struct Depsgraph;
@@ -46,10 +48,14 @@ namespace DEG {
/* Commonly used types. */
using std::string;
using std::vector;
+using std::map;
+using std::pair;
+using std::unordered_map;
/* Commonly used functions. */
using std::max;
using std::to_string;
+using std::make_pair;
/* Function bindings. */
using std::function;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index d3e52ecdf09..eaafcffac97 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -93,9 +93,9 @@ static void deg_task_run_func(TaskPool *pool,
BLI_task_pool_delayed_push_end(pool, thread_id);
}
-typedef struct CalculatePendingData {
+struct CalculatePendingData {
Depsgraph *graph;
-} CalculatePendingData;
+};
static bool check_operation_node_visible(OperationNode *op_node)
{
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 27c5bb89ba9..0d60defa9b6 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
@@ -13,7 +13,7 @@
* 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) 20137Blender Foundation.
+ * The Original Code is Copyright (C) 2017 Blender Foundation.
* All rights reserved.
*/
@@ -26,8 +26,7 @@
* material) to be handled in same way as "real" datablocks, even tho some
* internal BKE routines doesn't treat them like that.
*
- * TODO(sergey): Re-evaluate that after new ID handling is in place.
- */
+ * TODO(sergey): Re-evaluate that after new ID handling is in place. */
#define NESTED_ID_NASTY_WORKAROUND
/* Silence warnings from copying deprecated fields. */
@@ -84,6 +83,7 @@ extern "C" {
#include "BKE_armature.h"
#include "BKE_editmesh.h"
#include "BKE_library_query.h"
+#include "BKE_modifier.h"
#include "BKE_object.h"
}
@@ -162,8 +162,7 @@ void nested_id_hack_discard_pointers(ID *id_cow)
/* Set ID pointer of nested owned IDs (nodetree, key) to NULL.
*
- * Return pointer to a new ID to be used.
- */
+ * Return pointer to a new ID to be used. */
const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage,
const ID *id)
{
@@ -278,8 +277,7 @@ struct ValidateData {
};
/* Similar to generic BKE_id_copy() but does not require main and assumes pointer
- * is already allocated,
- */
+ * is already allocated. */
bool id_copy_inplace_no_main(const ID *id, ID *newid)
{
const ID *id_for_copy = id;
@@ -305,8 +303,7 @@ bool id_copy_inplace_no_main(const ID *id, ID *newid)
}
/* Similar to BKE_scene_copy() but does not require main and assumes pointer
- * is already allocated.
- */
+ * is already allocated. */
bool scene_copy_inplace_no_main(const Scene *scene, Scene *new_scene)
{
const ID *id_for_copy = &scene->id;
@@ -461,8 +458,7 @@ BLI_INLINE bool check_datablock_expanded(const ID *id_cow)
* does not need any remapping or anything.
*
* TODO(sergey): How to make it more robust for the future, so we don't have
- * to maintain exception lists all over the code?
- */
+ * to maintain exception lists all over the code? */
bool check_datablocks_copy_on_writable(const ID *id_orig)
{
const ID_Type id_type = GS(id_orig->name);
@@ -476,8 +472,7 @@ bool check_datablocks_copy_on_writable(const ID *id_orig)
}
/* Callback for BKE_library_foreach_ID_link which remaps original ID pointer
- * with the one created by CoW system.
- */
+ * with the one created by CoW system. */
struct RemapCallbackUserData {
/* Dependency graph for which remapping is happening. */
@@ -592,8 +587,7 @@ void update_mesh_edit_mode_pointers(const Depsgraph *depsgraph,
}
/* Edit data is stored and owned by original datablocks, copied ones
- * are simply referencing to them.
- */
+ * are simply referencing to them. */
void update_edit_mode_pointers(const Depsgraph *depsgraph,
const ID *id_orig, ID *id_cow)
{
@@ -619,18 +613,26 @@ void update_edit_mode_pointers(const Depsgraph *depsgraph,
}
}
+template <typename T>
+void update_list_orig_pointers(const ListBase *listbase_orig,
+ ListBase *listbase,
+ T *T::*orig_field)
+{
+ T *element_orig = reinterpret_cast<T*>(listbase_orig->first);
+ T *element_cow = reinterpret_cast<T*>(listbase->first);
+ while (element_orig != NULL) {
+ element_cow->*orig_field = element_orig;
+ element_cow = element_cow->next;
+ element_orig = element_orig->next;
+ }
+}
+
void update_particle_system_orig_pointers(const Object *object_orig,
Object *object_cow)
{
- ParticleSystem *psys_cow =
- (ParticleSystem *) object_cow->particlesystem.first;
- ParticleSystem *psys_orig =
- (ParticleSystem *) object_orig->particlesystem.first;
- while (psys_orig != NULL) {
- psys_cow->orig_psys = psys_orig;
- psys_cow = psys_cow->next;
- psys_orig = psys_orig->next;
- }
+ update_list_orig_pointers(&object_orig->particlesystem,
+ &object_cow->particlesystem,
+ &ParticleSystem::orig_psys);
}
void set_particle_system_modifiers_loaded(Object *object_cow)
@@ -645,22 +647,31 @@ void set_particle_system_modifiers_loaded(Object *object_cow)
}
}
+void update_particles_after_copy(const Object *object_orig, Object *object_cow)
+{
+ update_particle_system_orig_pointers(object_orig, object_cow);
+ set_particle_system_modifiers_loaded(object_cow);
+}
+
void update_pose_orig_pointers(const bPose *pose_orig, bPose *pose_cow)
{
- bPoseChannel *pchan_cow = (bPoseChannel *) pose_cow->chanbase.first;
- bPoseChannel *pchan_orig = (bPoseChannel *) pose_orig->chanbase.first;
- while (pchan_orig != NULL) {
- pchan_cow->orig_pchan = pchan_orig;
- pchan_cow = pchan_cow->next;
- pchan_orig = pchan_orig->next;
- }
+ update_list_orig_pointers(&pose_orig->chanbase,
+ &pose_cow->chanbase,
+ &bPoseChannel::orig_pchan);
+}
+
+void update_modifiers_orig_pointers(const Object *object_orig,
+ Object *object_cow)
+{
+ update_list_orig_pointers(&object_orig->modifiers,
+ &object_cow->modifiers,
+ &ModifierData::orig_modifier_data);
}
/* Do some special treatment of data transfer from original ID to it's
* CoW complementary part.
*
- * Only use for the newly created CoW datablocks.
- */
+ * Only use for the newly created CoW datablocks. */
void update_id_after_copy(const Depsgraph *depsgraph,
const IDNode *id_node,
const ID *id_orig, ID *id_cow)
@@ -687,8 +698,8 @@ void update_id_after_copy(const Depsgraph *depsgraph,
object_cow->pose);
}
}
- update_particle_system_orig_pointers(object_orig, object_cow);
- set_particle_system_modifiers_loaded(object_cow);
+ update_particles_after_copy(object_orig, object_cow);
+ update_modifiers_orig_pointers(object_orig, object_cow);
break;
}
case ID_SCE:
@@ -709,8 +720,7 @@ void update_id_after_copy(const Depsgraph *depsgraph,
}
/* This callback is used to validate that all nested ID datablocks are
- * properly expanded.
- */
+ * properly expanded. */
int foreach_libblock_validate_callback(void *user_data,
ID * /*id_self*/,
ID **id_p,
@@ -731,8 +741,7 @@ int foreach_libblock_validate_callback(void *user_data,
/* Actual implementation of logic which "expands" all the data which was not
* yet copied-on-write.
*
- * NOTE: Expects that CoW datablock is empty.
- */
+ * NOTE: Expects that CoW datablock is empty. */
ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
const IDNode *id_node,
DepsgraphNodeBuilder *node_builder,
@@ -838,61 +847,119 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
create_placeholders);
}
-static void deg_update_copy_on_write_animation(const Depsgraph *depsgraph,
- const IDNode *id_node)
-{
- DEG_debug_print_eval((::Depsgraph *)depsgraph,
- __func__,
- id_node->id_orig->name,
- id_node->id_cow);
- BKE_animdata_copy_id(NULL, id_node->id_cow, id_node->id_orig, LIB_ID_CREATE_NO_USER_REFCOUNT);
- RemapCallbackUserData user_data = {NULL};
- user_data.depsgraph = depsgraph;
- BKE_library_foreach_ID_link(NULL,
- id_node->id_cow,
- foreach_libblock_remap_callback,
- (void *)&user_data,
- IDWALK_NOP);
-}
+namespace {
+
+/* Identifier used to match modifiers to backup/restore their runtime data.
+ * Identification is happening using original modifier data pointer and the
+ * modifier type.
+ * It is not enough to only pointer, since it's possible to have a situation
+ * when modifier is removed and a new one added, and due to memory allocation
+ * policy they might have same pointer.
+ * By adding type into matching we are at least ensuring that modifier will not
+ * try to interpret runtime data created by another modifier type. */
+class ModifierDataBackupID {
+public:
+ ModifierDataBackupID() : ModifierDataBackupID(NULL, eModifierType_None)
+ {
+ }
+
+ ModifierDataBackupID(ModifierData *modifier_data, ModifierType type)
+ : modifier_data(modifier_data),
+ type(type)
+ {
+ }
+
+ bool operator <(const ModifierDataBackupID& other) const {
+ if (modifier_data < other.modifier_data) {
+ return true;
+ }
+ if (modifier_data == other.modifier_data) {
+ return static_cast<int>(type) < static_cast<int>(other.type);
+ }
+ return false;
+ }
+
+ ModifierData *modifier_data;
+ ModifierType type;
+};
+
+/* Storage for backed up runtime modifier data. */
+typedef map<ModifierDataBackupID, void*> ModifierRuntimeDataBackup;
+
+struct ObjectRuntimeBackup {
+ ObjectRuntimeBackup()
+ : base_flag(0),
+ base_local_view_bits(0)
+ {
+ /* TODO(sergey): Use something like BKE_object_runtime_reset(). */
+ memset(&runtime, 0, sizeof(runtime));
+ }
+
+ /* Make a backup of object's evaluation runtime data, additionally
+ * make object to be safe for free without invalidating backed up
+ * pointers. */
+ void init_from_object(Object *object);
+ void backup_modifier_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);
-typedef struct ObjectRuntimeBackup {
Object_Runtime runtime;
short base_flag;
unsigned short base_local_view_bits;
-} ObjectRuntimeBackup;
+ ModifierRuntimeDataBackup modifier_runtime_data;
+};
-/* Make a backup of object's evaluation runtime data, additionally
- * make object to be safe for free without invalidating backed up
- * pointers.
- */
-static void deg_backup_object_runtime(
- Object *object,
- ObjectRuntimeBackup *object_runtime_backup)
+void ObjectRuntimeBackup::init_from_object(Object *object)
{
/* Store evaluated mesh and curve_cache, and make sure we don't free it. */
Mesh *mesh_eval = object->runtime.mesh_eval;
- object_runtime_backup->runtime = object->runtime;
+ runtime = object->runtime;
BKE_object_runtime_reset(object);
- /* Keep bbox (for now at least...). */
- object->runtime.bb = object_runtime_backup->runtime.bb;
+ /* Keep bbox (for now at least). */
+ object->runtime.bb = runtime.bb;
/* Object update will override actual object->data to an evaluated version.
* Need to make sure we don't have data set to evaluated one before free
* anything. */
if (mesh_eval != NULL && object->data == mesh_eval) {
- object->data = object_runtime_backup->runtime.mesh_orig;
+ object->data = runtime.mesh_orig;
}
/* Make a backup of base flags. */
- object_runtime_backup->base_flag = object->base_flag;
- object_runtime_backup->base_local_view_bits = object->base_local_view_bits;
+ base_flag = object->base_flag;
+ base_local_view_bits = object->base_local_view_bits;
+ /* Backup tuntime data of all modifiers. */
+ backup_modifier_runtime_data(object);
+}
+
+inline ModifierDataBackupID create_modifier_data_id(
+ const ModifierData *modifier_data)
+{
+ return ModifierDataBackupID(modifier_data->orig_modifier_data,
+ static_cast<ModifierType>(modifier_data->type));
+}
+
+void ObjectRuntimeBackup::backup_modifier_runtime_data(Object *object)
+{
+ LISTBASE_FOREACH(ModifierData *, modifier_data, &object->modifiers) {
+ if (modifier_data->runtime == NULL) {
+ continue;
+ }
+ BLI_assert(modifier_data->orig_modifier_data != NULL);
+ ModifierDataBackupID modifier_data_id =
+ create_modifier_data_id(modifier_data);
+ modifier_runtime_data.insert(
+ make_pair(modifier_data_id, modifier_data->runtime));
+ modifier_data->runtime = NULL;
+ }
}
-static void deg_restore_object_runtime(
- Object *object,
- const ObjectRuntimeBackup *object_runtime_backup)
+void ObjectRuntimeBackup::restore_to_object(Object *object)
{
Mesh *mesh_orig = object->runtime.mesh_orig;
BoundBox *bb = object->runtime.bb;
- object->runtime = object_runtime_backup->runtime;
+ object->runtime = runtime;
object->runtime.mesh_orig = mesh_orig;
object->runtime.bb = bb;
if (object->type == OB_MESH && object->runtime.mesh_eval != NULL) {
@@ -919,100 +986,109 @@ static void deg_restore_object_runtime(
mesh_eval->edit_mesh = mesh_orig->edit_mesh;
}
}
- object->base_flag = object_runtime_backup->base_flag;
- object->base_local_view_bits = object_runtime_backup->base_local_view_bits;
+ object->base_flag = base_flag;
+ object->base_local_view_bits = base_local_view_bits;
+ /* Restore modifier's runtime data.
+ * NOTE: Data of unused modifiers will be freed there. */
+ restore_modifier_runtime_data(object);
}
+void ObjectRuntimeBackup::restore_modifier_runtime_data(Object *object)
+{
+ LISTBASE_FOREACH(ModifierData *, modifier_data, &object->modifiers) {
+ BLI_assert(modifier_data->orig_modifier_data != NULL);
+ ModifierDataBackupID modifier_data_id =
+ create_modifier_data_id(modifier_data);
+ ModifierRuntimeDataBackup::iterator runtime_data_iterator =
+ modifier_runtime_data.find(modifier_data_id);
+ if (runtime_data_iterator != modifier_runtime_data.end()) {
+ modifier_data->runtime = runtime_data_iterator->second;
+ runtime_data_iterator->second = NULL;
+ }
+ }
+ for (ModifierRuntimeDataBackup::value_type value : modifier_runtime_data) {
+ const ModifierDataBackupID modifier_data_id = value.first;
+ void *runtime = value.second;
+ if (value.second == NULL) {
+ continue;
+ }
+ const ModifierTypeInfo *modifier_type_info =
+ modifierType_getInfo(modifier_data_id.type);
+ BLI_assert(modifier_type_info != NULL);
+ modifier_type_info->freeRuntimeData(runtime);
+ }
+}
+
+class RuntimeBackup {
+public:
+ RuntimeBackup() : drawdata_ptr(NULL) {
+ drawdata_backup.first = drawdata_backup.last = NULL;
+ }
+
+ /* NOTE: Will reset all runbtime fields which has been backed up to NULL. */
+ void init_from_id(ID *id);
+
+ /* Restore fields to the given ID. */
+ void restore_to_id(ID *id);
+
+ ObjectRuntimeBackup object_backup;
+ DrawDataList drawdata_backup;
+ DrawDataList *drawdata_ptr;
+};
+
+void RuntimeBackup::init_from_id(ID *id)
+{
+ if (!check_datablock_expanded(id)) {
+ return;
+ }
+ const ID_Type id_type = GS(id->name);
+ switch (id_type) {
+ case ID_OB:
+ object_backup.init_from_object(reinterpret_cast<Object*>(id));
+ break;
+ default:
+ break;
+ }
+ /* Note that we never free GPU draw data from here since that's not
+ * safe for threading and draw data is likely to be re-used. */
+ drawdata_ptr = DRW_drawdatalist_from_id(id);
+ if (drawdata_ptr != NULL) {
+ drawdata_backup = *drawdata_ptr;
+ drawdata_ptr->first = drawdata_ptr->last = NULL;
+ }
+}
+
+void RuntimeBackup::restore_to_id(ID *id)
+{
+ const ID_Type id_type = GS(id->name);
+ switch (id_type) {
+ case ID_OB:
+ object_backup.restore_to_object(reinterpret_cast<Object*>(id));
+ break;
+ default:
+ break;
+ }
+ if (drawdata_ptr != NULL) {
+ *drawdata_ptr = drawdata_backup;
+ }
+}
+
+} // namespace
+
ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
const IDNode *id_node)
{
const ID *id_orig = id_node->id_orig;
- const ID_Type id_type = GS(id_orig->name);
ID *id_cow = id_node->id_cow;
/* Similar to expansion, no need to do anything here. */
if (!deg_copy_on_write_is_needed(id_orig)) {
return id_cow;
}
- /* For the rest if datablock types we use simple logic:
- * - Free previously expanded data, if any.
- * - Perform full datablock copy.
- *
- * Note that we never free GPU materials from here since that's not
- * safe for threading and GPU materials are likely to be re-used. */
- /* TODO(sergey): Either move this to an utility function or redesign
- * Copy-on-Write components in a way that only needed parts are being
- * copied over. */
- /* TODO(sergey): Wrap GPU material backup and object runtime backup to a
- * generic backup structure. */
- ListBase gpumaterial_backup;
- ListBase *gpumaterial_ptr = NULL;
- DrawDataList drawdata_backup;
- DrawDataList *drawdata_ptr = NULL;
- ObjectRuntimeBackup object_runtime_backup = {{0}};
- if (check_datablock_expanded(id_cow)) {
- switch (id_type) {
- case ID_MA:
- {
- Material *material = (Material *)id_cow;
- gpumaterial_ptr = &material->gpumaterial;
- break;
- }
- case ID_WO:
- {
- World *world = (World *)id_cow;
- gpumaterial_ptr = &world->gpumaterial;
- break;
- }
- case ID_NT:
- {
- /* Node trees should try to preserve their socket pointers
- * as much as possible. This is due to UBOs code in GPU,
- * which references sockets from trees.
- *
- * These flags CURRENTLY don't need full datablock update,
- * everything is done by node tree update function which
- * only copies socket values. */
- const int ignore_flag = (ID_RECALC_SHADING |
- ID_RECALC_ANIMATION |
- ID_RECALC_COPY_ON_WRITE);
- if ((id_cow->recalc & ~ignore_flag) == 0) {
- deg_update_copy_on_write_animation(depsgraph, id_node);
- return id_cow;
- }
- break;
- }
- case ID_OB:
- {
- Object *ob = (Object *)id_cow;
- deg_backup_object_runtime(ob, &object_runtime_backup);
- break;
- }
- default:
- break;
- }
- if (gpumaterial_ptr != NULL) {
- gpumaterial_backup = *gpumaterial_ptr;
- gpumaterial_ptr->first = gpumaterial_ptr->last = NULL;
- }
- drawdata_ptr = DRW_drawdatalist_from_id(id_cow);
- if (drawdata_ptr != NULL) {
- drawdata_backup = *drawdata_ptr;
- drawdata_ptr->first = drawdata_ptr->last = NULL;
- }
- }
+ RuntimeBackup backup;
+ backup.init_from_id(id_cow);
deg_free_copy_on_write_datablock(id_cow);
deg_expand_copy_on_write_datablock(depsgraph, id_node);
- /* Restore GPU materials. */
- if (gpumaterial_ptr != NULL) {
- *gpumaterial_ptr = gpumaterial_backup;
- }
- /* Restore DrawData. */
- if (drawdata_ptr != NULL) {
- *drawdata_ptr = drawdata_backup;
- }
- if (id_type == ID_OB) {
- deg_restore_object_runtime((Object *)id_cow, &object_runtime_backup);
- }
+ backup.restore_to_id(id_cow);
return id_cow;
}
@@ -1071,8 +1147,7 @@ void discard_scene_pointers(ID *id_cow)
}
/* NULL-ify all edit mode pointers which points to data from
- * original object.
- */
+ * original object. */
void discard_edit_mode_pointers(ID *id_cow)
{
const ID_Type type = GS(id_cow->name);
@@ -1107,8 +1182,7 @@ void discard_edit_mode_pointers(ID *id_cow)
/* Free content of the CoW datablock
* Notes:
* - Does not recurs into nested ID datablocks.
- * - Does not free datablock itself.
- */
+ * - Does not free datablock itself. */
void deg_free_copy_on_write_datablock(ID *id_cow)
{
if (!check_datablock_expanded(id_cow)) {
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
index c6d44382cc7..6f9141a7c19 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
@@ -44,7 +44,7 @@ struct Depsgraph;
namespace DEG {
struct Depsgraph;
-struct DepsgraphNodeBuilder;
+class DepsgraphNodeBuilder;
struct IDNode;
/* Get fully expanded (ready for use) copy-on-write datablock for the given
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 5498e75ade0..08c7b87d5e3 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -390,9 +390,7 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
ComponentNode *comp_node = op_node->owner;
IDNode *id_node = comp_node->owner;
flush_handle_id_node(id_node);
- flush_handle_component_node(id_node,
- comp_node,
- &queue);
+ flush_handle_component_node(id_node, comp_node, &queue);
/* Flush to nodes along links. */
op_node = flush_schedule_children(op_node, &queue);
}
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc
index 893c108dc5a..b0b47f89acf 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc
@@ -61,6 +61,8 @@ const char *operationCodeAsString(OperationCode opcode)
return "TRANSFORM_CONSTRAINTS";
case OperationCode::TRANSFORM_FINAL: return "TRANSFORM_FINAL";
case OperationCode::TRANSFORM_EVAL: return "TRANSFORM_EVAL";
+ case OperationCode::TRANSFORM_SIMULATION_INIT:
+ return "TRANSFORM_SIMULATION_INIT";
/* Rigid body. */
case OperationCode::RIGIDBODY_REBUILD: return "RIGIDBODY_REBUILD";
case OperationCode::RIGIDBODY_SIM: return "RIGIDBODY_SIM";
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h
index c6db7b012d7..56207b08d4a 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.h
@@ -76,6 +76,10 @@ enum class OperationCode {
TRANSFORM_CONSTRAINTS,
/* Handle object-level updates, mainly proxies hacks and recalc flags. */
TRANSFORM_EVAL,
+ /* Initializes transformation for simulation.
+ * For example, ensures point cache is properly reset before doing rigid
+ * body simulation. */
+ TRANSFORM_SIMULATION_INIT,
/* Transform exit point */
TRANSFORM_FINAL,
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index e261de3c900..f5e679a4e73 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -111,6 +111,7 @@ void DRW_draw_render_loop_offscreen(
struct RenderEngineType *engine_type,
struct ARegion *ar, struct View3D *v3d,
const bool draw_background,
+ const bool do_color_management,
struct GPUOffScreen *ofs,
struct GPUViewport *viewport);
void DRW_draw_select_loop(
@@ -121,7 +122,16 @@ void DRW_draw_select_loop(
DRW_ObjectFilterFn object_filter_fn, void *object_filter_user_data);
void DRW_draw_depth_loop(
struct Depsgraph *depsgraph,
- struct ARegion *ar, struct View3D *v3d);
+ struct ARegion *ar, struct View3D *v3d,
+ struct GPUViewport *viewport);
+void DRW_draw_depth_loop_gpencil(
+ struct Depsgraph *depsgraph,
+ struct ARegion *ar, struct View3D *v3d,
+ struct GPUViewport *viewport);
+
+void DRW_framebuffer_select_id_setup(struct ARegion *ar, const bool clear);
+void DRW_framebuffer_select_id_release(struct ARegion *ar);
+void DRW_framebuffer_select_id_read(const struct rcti *rect, uint *r_buf);
/* grease pencil render */
bool DRW_render_check_grease_pencil(struct Depsgraph *depsgraph);
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index 2f1708f56be..91e73e05dbe 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -66,7 +66,7 @@ typedef struct BASIC_Shaders {
static struct {
BASIC_Shaders sh_data[GPU_SHADER_CFG_LEN];
-} e_data = {NULL}; /* Engine data */
+} e_data = {{{NULL}}}; /* Engine data */
typedef struct BASIC_PrivateData {
DRWShadingGroup *depth_shgrp;
@@ -83,7 +83,7 @@ static void basic_engine_init(void *UNUSED(vedata))
/* Depth prepass */
if (!sh_data->depth) {
- sh_data->depth = DRW_shader_create_3D_depth_only(draw_ctx->sh_cfg);
+ sh_data->depth = DRW_shader_create_3d_depth_only(draw_ctx->sh_cfg);
}
}
@@ -139,9 +139,6 @@ static void basic_cache_populate(void *vedata, Object *ob)
psys != NULL;
psys = psys->next)
{
- if (!psys_check_enabled(ob, psys, false)) {
- continue;
- }
if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
continue;
}
diff --git a/source/blender/draw/engines/eevee/eevee_bloom.c b/source/blender/draw/engines/eevee/eevee_bloom.c
index 36ddd68aea9..cd3e1cd6503 100644
--- a/source/blender/draw/engines/eevee/eevee_bloom.c
+++ b/source/blender/draw/engines/eevee/eevee_bloom.c
@@ -105,7 +105,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
effects->blit_texel_size[0] = 1.0f / (float)blitsize[0];
effects->blit_texel_size[1] = 1.0f / (float)blitsize[1];
- effects->bloom_blit = DRW_texture_pool_query_2D(blitsize[0], blitsize[1], GPU_R11F_G11F_B10F,
+ effects->bloom_blit = DRW_texture_pool_query_2d(blitsize[0], blitsize[1], GPU_R11F_G11F_B10F,
&draw_engine_eevee_type);
GPU_framebuffer_ensure_config(&fbl->bloom_blit_fb, {
@@ -147,7 +147,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
effects->downsamp_texel_size[i][0] = 1.0f / (float)texsize[0];
effects->downsamp_texel_size[i][1] = 1.0f / (float)texsize[1];
- effects->bloom_downsample[i] = DRW_texture_pool_query_2D(texsize[0], texsize[1], GPU_R11F_G11F_B10F,
+ effects->bloom_downsample[i] = DRW_texture_pool_query_2d(texsize[0], texsize[1], GPU_R11F_G11F_B10F,
&draw_engine_eevee_type);
GPU_framebuffer_ensure_config(&fbl->bloom_down_fb[i], {
GPU_ATTACHMENT_NONE,
@@ -163,7 +163,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
texsize[0] = MAX2(texsize[0], 2);
texsize[1] = MAX2(texsize[1], 2);
- effects->bloom_upsample[i] = DRW_texture_pool_query_2D(texsize[0], texsize[1], GPU_R11F_G11F_B10F,
+ effects->bloom_upsample[i] = DRW_texture_pool_query_2d(texsize[0], texsize[1], GPU_R11F_G11F_B10F,
&draw_engine_eevee_type);
GPU_framebuffer_ensure_config(&fbl->bloom_accum_fb[i], {
GPU_ATTACHMENT_NONE,
@@ -238,7 +238,7 @@ void EEVEE_bloom_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *ved
* [Downsample] [Upsample]
* v |
* Color Downsampled [1/N] ─────────────────────────┘
- **/
+ */
DRWShadingGroup *grp;
const bool use_highres = true;
const bool use_antiflicker = true;
diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index 597cb830afb..7aa1e48472f 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -97,11 +97,11 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
eGPUTextureFormat down_format = DRW_state_draw_background() ? GPU_R11F_G11F_B10F : GPU_RGBA16F;
- effects->dof_down_near = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], down_format,
+ effects->dof_down_near = DRW_texture_pool_query_2d(buffer_size[0], buffer_size[1], down_format,
&draw_engine_eevee_type);
- effects->dof_down_far = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], down_format,
+ effects->dof_down_far = DRW_texture_pool_query_2d(buffer_size[0], buffer_size[1], down_format,
&draw_engine_eevee_type);
- effects->dof_coc = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], GPU_RG16F,
+ effects->dof_coc = DRW_texture_pool_query_2d(buffer_size[0], buffer_size[1], GPU_RG16F,
&draw_engine_eevee_type);
GPU_framebuffer_ensure_config(&fbl->dof_down_fb, {
@@ -114,7 +114,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
/* Go full 32bits for rendering and reduce the color artifacts. */
eGPUTextureFormat fb_format = DRW_state_is_image_render() ? GPU_RGBA32F : GPU_RGBA16F;
- effects->dof_blur = DRW_texture_pool_query_2D(buffer_size[0] * 2, buffer_size[1], fb_format,
+ effects->dof_blur = DRW_texture_pool_query_2d(buffer_size[0] * 2, buffer_size[1], fb_format,
&draw_engine_eevee_type);
GPU_framebuffer_ensure_config(&fbl->dof_scatter_fb, {
@@ -123,7 +123,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
});
if (!DRW_state_draw_background()) {
- effects->dof_blur_alpha = DRW_texture_pool_query_2D(buffer_size[0] * 2, buffer_size[1], GPU_R32F,
+ effects->dof_blur_alpha = DRW_texture_pool_query_2d(buffer_size[0] * 2, buffer_size[1], GPU_R32F,
&draw_engine_eevee_type);
GPU_framebuffer_texture_attach(fbl->dof_scatter_fb, effects->dof_blur_alpha, 1, 0);
}
@@ -153,9 +153,10 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
sensor_scaled *= rv3d->viewcamtexcofac[0];
}
- effects->dof_params[0] = aperture * fabsf(focal_len_scaled / (focus_dist - focal_len_scaled));
- effects->dof_params[1] = -focus_dist;
- effects->dof_params[2] = viewport_size[0] / sensor_scaled;
+ effects->dof_params[1] = aperture * fabsf(focal_len_scaled / (focus_dist - focal_len_scaled));
+ effects->dof_params[1] *= viewport_size[0] / sensor_scaled;
+ effects->dof_params[0] = -focus_dist * effects->dof_params[1];
+
effects->dof_bokeh[0] = rotation;
effects->dof_bokeh[1] = ratio;
effects->dof_bokeh[2] = scene_eval->eevee.bokeh_max_size;
@@ -193,7 +194,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
* - Shoot quads for every pixel and expand it depending on the CoC.
* Do one pass for near Dof and one pass for far Dof.
* - Finally composite the 2 blurred buffers with the original render.
- **/
+ */
DRWShadingGroup *grp;
struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
const bool use_alpha = !DRW_state_draw_background();
@@ -204,7 +205,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &effects->source_buffer);
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
DRW_shgroup_uniform_vec2(grp, "nearFar", effects->dof_near_far, 1);
- DRW_shgroup_uniform_vec3(grp, "dofParams", effects->dof_params, 1);
+ DRW_shgroup_uniform_vec2(grp, "dofParams", effects->dof_params, 1);
DRW_shgroup_call_add(grp, quad, NULL);
psl->dof_scatter = DRW_pass_create("DoF Scatter", DRW_STATE_WRITE_COLOR | DRW_STATE_ADDITIVE_FULL);
@@ -226,7 +227,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &effects->source_buffer);
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
DRW_shgroup_uniform_vec2(grp, "nearFar", effects->dof_near_far, 1);
- DRW_shgroup_uniform_vec3(grp, "dofParams", effects->dof_params, 1);
+ DRW_shgroup_uniform_vec2(grp, "dofParams", effects->dof_params, 1);
DRW_shgroup_call_add(grp, quad, NULL);
if (use_alpha) {
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index 0090ab338d2..e276fcd63ce 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -110,7 +110,7 @@ static void eevee_create_shader_downsample(void)
#define SETUP_BUFFER(tex, fb, fb_color) { \
eGPUTextureFormat format = (DRW_state_is_scene_render()) ? GPU_RGBA32F : GPU_RGBA16F; \
- DRW_texture_ensure_fullscreen_2D(&tex, format, DRW_TEX_FILTER | DRW_TEX_MIPMAP); \
+ DRW_texture_ensure_fullscreen_2d(&tex, format, DRW_TEX_FILTER | DRW_TEX_MIPMAP); \
GPU_framebuffer_ensure_config(&fb, { \
GPU_ATTACHMENT_TEXTURE(dtxl->depth), \
GPU_ATTACHMENT_TEXTURE(tex), \
@@ -119,14 +119,14 @@ static void eevee_create_shader_downsample(void)
GPU_ATTACHMENT_NONE, \
GPU_ATTACHMENT_TEXTURE(tex), \
}); \
-}
+} ((void)0)
#define CLEANUP_BUFFER(tex, fb, fb_color) { \
/* Cleanup to release memory */ \
DRW_TEXTURE_FREE_SAFE(tex); \
GPU_FRAMEBUFFER_FREE_SAFE(fb); \
GPU_FRAMEBUFFER_FREE_SAFE(fb_color); \
-}
+} ((void)0)
void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object *camera, const bool minimal)
{
@@ -193,10 +193,10 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) {
/* Intel gpu seems to have problem rendering to only depth format */
- DRW_texture_ensure_2D(&txl->maxzbuffer, size[0], size[1], GPU_R32F, DRW_TEX_MIPMAP);
+ DRW_texture_ensure_2d(&txl->maxzbuffer, size[0], size[1], GPU_R32F, DRW_TEX_MIPMAP);
}
else {
- DRW_texture_ensure_2D(&txl->maxzbuffer, size[0], size[1], GPU_DEPTH_COMPONENT24, DRW_TEX_MIPMAP);
+ DRW_texture_ensure_2d(&txl->maxzbuffer, size[0], size[1], GPU_DEPTH_COMPONENT24, DRW_TEX_MIPMAP);
}
if (fbl->downsample_fb == NULL) {
@@ -217,7 +217,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
* Normal buffer for deferred passes.
*/
if ((effects->enabled_effects & EFFECT_NORMAL_BUFFER) != 0) {
- effects->ssr_normal_input = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], GPU_RG16,
+ effects->ssr_normal_input = DRW_texture_pool_query_2d(size_fs[0], size_fs[1], GPU_RG16,
&draw_engine_eevee_type);
GPU_framebuffer_texture_attach(fbl->main_fb, effects->ssr_normal_input, 1, 0);
@@ -230,7 +230,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
* Motion vector buffer for correct TAA / motion blur.
*/
if ((effects->enabled_effects & EFFECT_VELOCITY_BUFFER) != 0) {
- effects->velocity_tx = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], GPU_RG16,
+ effects->velocity_tx = DRW_texture_pool_query_2d(size_fs[0], size_fs[1], GPU_RG16,
&draw_engine_eevee_type);
/* TODO output objects velocity during the mainpass. */
@@ -249,7 +249,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
* Setup depth double buffer.
*/
if ((effects->enabled_effects & EFFECT_DEPTH_DOUBLE_BUFFER) != 0) {
- DRW_texture_ensure_fullscreen_2D(&txl->depth_double_buffer, GPU_DEPTH24_STENCIL8, 0);
+ DRW_texture_ensure_fullscreen_2d(&txl->depth_double_buffer, GPU_DEPTH24_STENCIL8, 0);
GPU_framebuffer_ensure_config(&fbl->double_buffer_depth_fb, {
GPU_ATTACHMENT_TEXTURE(txl->depth_double_buffer)
@@ -465,7 +465,7 @@ void EEVEE_create_minmax_buffer(EEVEE_Data *vedata, GPUTexture *depth_src, int l
/**
* Simple downsampling algorithm. Reconstruct mip chain up to mip level.
- **/
+ */
void EEVEE_downsample_buffer(EEVEE_Data *vedata, GPUTexture *texture_src, int level)
{
EEVEE_FramebufferList *fbl = vedata->fbl;
@@ -481,7 +481,7 @@ void EEVEE_downsample_buffer(EEVEE_Data *vedata, GPUTexture *texture_src, int le
/**
* Simple downsampling algorithm for cubemap. Reconstruct mip chain up to mip level.
- **/
+ */
void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, GPUTexture *texture_src, int level)
{
EEVEE_FramebufferList *fbl = vedata->fbl;
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 54c1415ca49..ad000e0d4c3 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -61,7 +61,7 @@ static void eevee_engine_init(void *ved)
stl->g_data->valid_taa_history = (txl->taa_history != NULL);
/* Main Buffer */
- DRW_texture_ensure_fullscreen_2D(&txl->color, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
+ DRW_texture_ensure_fullscreen_2d(&txl->color, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
GPU_framebuffer_ensure_config(&fbl->main_fb, {
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
@@ -203,7 +203,7 @@ static void eevee_draw_background(void *vedata)
int samp = taa_use_reprojection
? stl->effects->taa_reproject_sample + 1
: stl->effects->taa_current_sample;
- BLI_halton_3D(primes, offset, samp, r);
+ BLI_halton_3d(primes, offset, samp, r);
EEVEE_update_noise(psl, fbl, r);
EEVEE_volumes_set_jitter(sldata, samp - 1);
EEVEE_materials_init(sldata, stl, fbl);
@@ -269,6 +269,7 @@ static void eevee_draw_background(void *vedata)
}
EEVEE_draw_default_passes(psl);
DRW_draw_pass(psl->material_pass);
+ DRW_draw_pass(psl->material_pass_cull);
EEVEE_subsurface_data_render(sldata, vedata);
DRW_stats_group_end();
@@ -318,31 +319,49 @@ static void eevee_draw_background(void *vedata)
/* Debug : Output buffer to view. */
switch (G.debug_value) {
case 1:
- if (txl->maxzbuffer) DRW_transform_to_display(txl->maxzbuffer, false, false);
+ if (txl->maxzbuffer) {
+ DRW_transform_to_display(txl->maxzbuffer, false, false);
+ }
break;
case 2:
- if (effects->ssr_pdf_output) DRW_transform_to_display(effects->ssr_pdf_output, false, false);
+ if (effects->ssr_pdf_output) {
+ DRW_transform_to_display(effects->ssr_pdf_output, false, false);
+ }
break;
case 3:
- if (effects->ssr_normal_input) DRW_transform_to_display(effects->ssr_normal_input, false, false);
+ if (effects->ssr_normal_input) {
+ DRW_transform_to_display(effects->ssr_normal_input, false, false);
+ }
break;
case 4:
- if (effects->ssr_specrough_input) DRW_transform_to_display(effects->ssr_specrough_input, false, false);
+ if (effects->ssr_specrough_input) {
+ DRW_transform_to_display(effects->ssr_specrough_input, false, false);
+ }
break;
case 5:
- if (txl->color_double_buffer) DRW_transform_to_display(txl->color_double_buffer, false, false);
+ if (txl->color_double_buffer) {
+ DRW_transform_to_display(txl->color_double_buffer, false, false);
+ }
break;
case 6:
- if (effects->gtao_horizons_debug) DRW_transform_to_display(effects->gtao_horizons_debug, false, false);
+ if (effects->gtao_horizons_debug) {
+ DRW_transform_to_display(effects->gtao_horizons_debug, false, false);
+ }
break;
case 7:
- if (effects->gtao_horizons) DRW_transform_to_display(effects->gtao_horizons, false, false);
+ if (effects->gtao_horizons) {
+ DRW_transform_to_display(effects->gtao_horizons, false, false);
+ }
break;
case 8:
- if (effects->sss_data) DRW_transform_to_display(effects->sss_data, false, false);
+ if (effects->sss_data) {
+ DRW_transform_to_display(effects->sss_data, false, false);
+ }
break;
case 9:
- if (effects->velocity_tx) DRW_transform_to_display(effects->velocity_tx, false, false);
+ if (effects->velocity_tx) {
+ DRW_transform_to_display(effects->velocity_tx, false, false);
+ }
break;
default:
break;
@@ -388,7 +407,7 @@ static void eevee_id_world_update(void *vedata, World *wo)
EEVEE_WorldEngineData *wedata = EEVEE_world_data_ensure(wo);
if (wedata != NULL && wedata->dd.recalc != 0) {
- if ((lcache->flag & (LIGHTCACHE_BAKED | LIGHTCACHE_BAKING)) == 0) {
+ if ((lcache->flag & LIGHTCACHE_BAKING) == 0) {
lcache->flag |= LIGHTCACHE_UPDATE_WORLD;
}
wedata->dd.recalc = 0;
@@ -420,6 +439,8 @@ static void eevee_render_to_image(void *vedata, RenderEngine *engine, struct Ren
/* Actually do the rendering. */
EEVEE_render_draw(vedata, engine, render_layer, rect);
+
+ EEVEE_volumes_free_smoke_textures();
}
static void eevee_engine_free(void)
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 45ed66859af..812af1c6ac0 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -137,6 +137,7 @@ typedef struct EEVEE_LightBake {
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. */
@@ -249,12 +250,12 @@ LightCache *EEVEE_lightcache_create(
light_cache->cube_data = MEM_callocN(sizeof(EEVEE_LightProbe) * cube_len, "EEVEE_LightProbe");
light_cache->grid_data = MEM_callocN(sizeof(EEVEE_LightGrid) * grid_len, "EEVEE_LightGrid");
- light_cache->grid_tx.tex = DRW_texture_create_2D_array(irr_size[0], irr_size[1], irr_size[2], IRRADIANCE_FORMAT, DRW_TEX_FILTER, NULL);
+ light_cache->grid_tx.tex = DRW_texture_create_2d_array(irr_size[0], irr_size[1], irr_size[2], IRRADIANCE_FORMAT, DRW_TEX_FILTER, NULL);
light_cache->grid_tx.tex_size[0] = irr_size[0];
light_cache->grid_tx.tex_size[1] = irr_size[1];
light_cache->grid_tx.tex_size[2] = irr_size[2];
- light_cache->cube_tx.tex = DRW_texture_create_2D_array(cube_size, cube_size, cube_len, GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+ light_cache->cube_tx.tex = DRW_texture_create_2d_array(cube_size, cube_size, cube_len, GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
light_cache->cube_tx.tex_size[0] = cube_size;
light_cache->cube_tx.tex_size[1] = cube_size;
light_cache->cube_tx.tex_size[2] = cube_len;
@@ -461,7 +462,7 @@ static void eevee_lightbake_create_resources(EEVEE_LightBake *lbake)
lbake->cube_prb = MEM_callocN(sizeof(LightProbe *) * lbake->cube_len, "EEVEE Cube visgroup ptr");
lbake->grid_prb = MEM_callocN(sizeof(LightProbe *) * lbake->grid_len, "EEVEE Grid visgroup ptr");
- lbake->grid_prev = DRW_texture_create_2D_array(
+ lbake->grid_prev = DRW_texture_create_2d_array(
lbake->irr_size[0], lbake->irr_size[1], lbake->irr_size[2],
IRRADIANCE_FORMAT, DRW_TEX_FILTER, NULL);
@@ -499,7 +500,7 @@ static void eevee_lightbake_create_resources(EEVEE_LightBake *lbake)
wmJob *EEVEE_lightbake_job_create(
struct wmWindowManager *wm, struct wmWindow *win, struct Main *bmain,
- struct ViewLayer *view_layer, struct Scene *scene, int delay)
+ struct ViewLayer *view_layer, struct Scene *scene, int delay, int frame)
{
EEVEE_LightBake *lbake = NULL;
@@ -532,6 +533,7 @@ wmJob *EEVEE_lightbake_job_create(
lbake->gl_context = old_lbake->gl_context;
lbake->own_resources = true;
lbake->delay = delay;
+ lbake->frame = frame;
if (lbake->gl_context == NULL) {
lbake->gl_context = WM_opengl_context_create();
@@ -544,7 +546,7 @@ wmJob *EEVEE_lightbake_job_create(
BLI_mutex_unlock(old_lbake->mutex);
}
else {
- lbake = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, true);
+ lbake = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, true, frame);
lbake->delay = delay;
}
@@ -559,7 +561,7 @@ wmJob *EEVEE_lightbake_job_create(
/* MUST run on the main thread. */
void *EEVEE_lightbake_job_data_alloc(
- struct Main *bmain, struct ViewLayer *view_layer, struct Scene *scene, bool run_as_job)
+ struct Main *bmain, struct ViewLayer *view_layer, struct Scene *scene, bool run_as_job, int frame)
{
BLI_assert(BLI_thread_is_main());
@@ -572,6 +574,7 @@ void *EEVEE_lightbake_job_data_alloc(
lbake->own_resources = true;
lbake->own_light_cache = false;
lbake->mutex = BLI_mutex_alloc();
+ lbake->frame = frame;
if (run_as_job) {
lbake->gl_context = WM_opengl_context_create();
@@ -727,7 +730,7 @@ static void eevee_lightbake_copy_irradiance(EEVEE_LightBake *lbake, LightCache *
/* Copy texture by reading back and reuploading it. */
float *tex = GPU_texture_read(lcache->grid_tx.tex, GPU_DATA_FLOAT, 0);
- lbake->grid_prev = DRW_texture_create_2D_array(lbake->irr_size[0], lbake->irr_size[1], lbake->irr_size[2],
+ lbake->grid_prev = DRW_texture_create_2d_array(lbake->irr_size[0], lbake->irr_size[1], lbake->irr_size[2],
IRRADIANCE_FORMAT, DRW_TEX_FILTER, tex);
MEM_freeN(tex);
@@ -981,15 +984,15 @@ static bool eevee_lightbake_cube_comp(EEVEE_LightProbe *prb_a, EEVEE_LightProbe
bool sorted = false; \
while (!sorted) { \
sorted = true; \
- for (int i = 0; i < (elems_len) - 1; ++i) { \
- if ((comp_fn)((elems) + i, (elems) + i+1)) { \
- SWAP(elems_type, (elems)[i], (elems)[i+1]); \
- SWAP(LightProbe *, (prbs)[i], (prbs)[i+1]); \
+ for (int i = 0; i < (elems_len) - 1; i++) { \
+ if ((comp_fn)((elems) + i, (elems) + i + 1)) { \
+ SWAP(elems_type, (elems)[i], (elems)[i + 1]); \
+ SWAP(LightProbe *, (prbs)[i], (prbs)[i + 1]); \
sorted = false; \
} \
} \
} \
-}
+} ((void)0)
static void eevee_lightbake_gather_probes(EEVEE_LightBake *lbake)
{
@@ -1077,10 +1080,9 @@ void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float
{
EEVEE_LightBake *lbake = (EEVEE_LightBake *)custom_data;
Depsgraph *depsgraph = lbake->depsgraph;
- int frame = 0; /* TODO make it user param. */
DEG_graph_relations_update(depsgraph, lbake->bmain, lbake->scene, lbake->view_layer_input);
- DEG_evaluate_on_framechange(lbake->bmain, depsgraph, frame);
+ DEG_evaluate_on_framechange(lbake->bmain, depsgraph, lbake->frame);
lbake->view_layer = DEG_get_evaluated_view_layer(depsgraph);
lbake->stop = stop;
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.h b/source/blender/draw/engines/eevee/eevee_lightcache.h
index 7d2f163055f..03199632031 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.h
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.h
@@ -36,8 +36,9 @@ struct ViewLayer;
/* Light Bake */
struct wmJob *EEVEE_lightbake_job_create(
struct wmWindowManager *wm, struct wmWindow *win, struct Main *bmain,
- struct ViewLayer *view_layer, struct Scene *scene, int delay);
-void *EEVEE_lightbake_job_data_alloc(struct Main *bmain, struct ViewLayer *viewlayer, struct Scene *scene, bool run_as_job);
+ struct ViewLayer *view_layer, struct Scene *scene, int delay, int frame);
+void *EEVEE_lightbake_job_data_alloc(
+ struct Main *bmain, struct ViewLayer *viewlayer, struct Scene *scene, bool run_as_job, int frame);
void EEVEE_lightbake_job_data_free(void *custom_data);
void EEVEE_lightbake_update(void *custom_data);
void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float *progress);
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index dfd8a048276..90a3691f6e5 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -98,13 +98,13 @@ static struct GPUTexture *create_hammersley_sample_texture(int samples)
for (i = 0; i < samples; i++) {
double dphi;
- BLI_hammersley_1D(i, &dphi);
+ BLI_hammersley_1d(i, &dphi);
float phi = (float)dphi * 2.0f * M_PI;
texels[i][0] = cosf(phi);
texels[i][1] = sinf(phi);
}
- tex = DRW_texture_create_1D(samples, GPU_RG16F, DRW_TEX_WRAP, (float *)texels);
+ tex = DRW_texture_create_1d(samples, GPU_RG16F, DRW_TEX_WRAP, (float *)texels);
MEM_freeN(texels);
return tex;
}
@@ -123,21 +123,30 @@ static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref)
// ViewLayer *view_layer = draw_ctx->view_layer;
float screen_percentage = 1.0f;
- int width = (int)(viewport_size[0] * screen_percentage);
- int height = (int)(viewport_size[1] * screen_percentage);
+ int width = max_ii(1, (int)(viewport_size[0] * screen_percentage));
+ int height = max_ii(1, (int)(viewport_size[1] * screen_percentage));
+
+ /* Fix case were the pool was allocated width the dummy size (1,1,1). */
+ if (txl->planar_pool && (num_planar_ref > 0) &&
+ (GPU_texture_width(txl->planar_pool) != width ||
+ GPU_texture_height(txl->planar_pool) != height))
+ {
+ DRW_TEXTURE_FREE_SAFE(txl->planar_pool);
+ DRW_TEXTURE_FREE_SAFE(txl->planar_depth);
+ }
/* We need an Array texture so allocate it ourself */
if (!txl->planar_pool) {
if (num_planar_ref > 0) {
- txl->planar_pool = DRW_texture_create_2D_array(width, height, max_ff(1, num_planar_ref),
+ txl->planar_pool = DRW_texture_create_2d_array(width, height, max_ii(1, num_planar_ref),
GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
- txl->planar_depth = DRW_texture_create_2D_array(width, height, max_ff(1, num_planar_ref),
+ txl->planar_depth = DRW_texture_create_2d_array(width, height, max_ii(1, num_planar_ref),
GPU_DEPTH_COMPONENT24, 0, NULL);
}
else if (num_planar_ref == 0) {
/* Makes Opengl Happy : Create a placeholder texture that will never be sampled but still bound to shader. */
- txl->planar_pool = DRW_texture_create_2D_array(1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
- txl->planar_depth = DRW_texture_create_2D_array(1, 1, 1, GPU_DEPTH_COMPONENT24, 0, NULL);
+ txl->planar_pool = DRW_texture_create_2d_array(1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+ txl->planar_depth = DRW_texture_create_2d_array(1, 1, 1, GPU_DEPTH_COMPONENT24, 0, NULL);
}
}
}
@@ -196,7 +205,7 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
/* Placeholder planar pool: used when rendering planar reflections (avoid dependency loop). */
if (!e_data.planar_pool_placeholder) {
- e_data.planar_pool_placeholder = DRW_texture_create_2D_array(1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER, NULL);
+ e_data.planar_pool_placeholder = DRW_texture_create_2d_array(1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER, NULL);
}
}
@@ -314,7 +323,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
const float *col = G_draw.block.colorBackground;
/* LookDev */
- EEVEE_lookdev_cache_init(vedata, &grp, psl->probe_background, wo, pinfo);
+ EEVEE_lookdev_cache_init(vedata, &grp, psl->probe_background, 1.0f, wo, pinfo);
/* END */
if (!grp && wo) {
col = &wo->horr;
@@ -328,7 +337,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
switch (status) {
case GPU_MAT_SUCCESS:
grp = DRW_shgroup_material_create(gpumat, psl->probe_background);
- DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
+ DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
/* TODO (fclem): remove those (need to clean the GLSL files). */
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
@@ -349,7 +358,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
if (grp == NULL) {
grp = DRW_shgroup_create(EEVEE_shaders_probe_default_sh_get(), psl->probe_background);
DRW_shgroup_uniform_vec3(grp, "color", col, 1);
- DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
+ DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
DRW_shgroup_call_add(grp, geom, NULL);
}
}
@@ -654,23 +663,19 @@ void EEVEE_lightprobes_planar_data_from_object(Object *ob, EEVEE_PlanarReflectio
}
static void lightbake_planar_compute_render_matrices(
- EEVEE_PlanarReflection *eplanar, DRWMatrixState *r_matstate, const float viewmat[4][4])
+ EEVEE_PlanarReflection *eplanar, DRWMatrixState *r_matstate,
+ const float viewmat[4][4], const float winmat[4][4])
{
/* Reflect Camera Matrix. */
mul_m4_m4m4(r_matstate->viewmat, viewmat, eplanar->mtx);
- /* TODO FOV margin */
- /* Temporal sampling jitter should be already applied to the DRW_MAT_WIN. */
- DRW_viewport_matrix_get(r_matstate->winmat, DRW_MAT_WIN);
+ /* Invert X to avoid flipping the triangle facing direction. */
+ r_matstate->viewmat[0][0] = -r_matstate->viewmat[0][0];
+ r_matstate->viewmat[1][0] = -r_matstate->viewmat[1][0];
+ r_matstate->viewmat[2][0] = -r_matstate->viewmat[2][0];
+ r_matstate->viewmat[3][0] = -r_matstate->viewmat[3][0];
/* Apply Projection Matrix. */
- mul_m4_m4m4(r_matstate->persmat, r_matstate->winmat, r_matstate->viewmat);
-
- /* This is the matrix used to reconstruct texture coordinates.
- * We use the original view matrix because it does not create
- * visual artifacts if receiver is not perfectly aligned with
- * the planar reflection probe. */
- mul_m4_m4m4(eplanar->reflectionmat, r_matstate->winmat, viewmat); /* TODO FOV margin */
- /* Convert from [-1, 1] to [0, 1] (NDC to Texture coord). */
- mul_m4_m4m4(eplanar->reflectionmat, texcomat, eplanar->reflectionmat);
+ /* Temporal sampling jitter should be already applied to the DRW_MAT_WIN. */
+ mul_m4_m4m4(r_matstate->persmat, winmat, r_matstate->viewmat);
}
static void eevee_lightprobes_extract_from_cache(EEVEE_LightProbesInfo *pinfo, LightCache *lcache)
@@ -783,12 +788,13 @@ static void render_reflections(
{
DRWMatrixState matstate;
- float original_viewmat[4][4];
+ float original_viewmat[4][4], original_winmat[4][4];
DRW_viewport_matrix_get(original_viewmat, DRW_MAT_VIEW);
+ DRW_viewport_matrix_get(original_winmat, DRW_MAT_WIN);
for (int i = 0; i < ref_count; ++i) {
/* Setup custom matrices */
- lightbake_planar_compute_render_matrices(planar_data + i, &matstate, original_viewmat);
+ lightbake_planar_compute_render_matrices(planar_data + i, &matstate, original_viewmat, original_winmat);
invert_m4_m4(matstate.persinv, matstate.persmat);
invert_m4_m4(matstate.viewinv, matstate.viewmat);
invert_m4_m4(matstate.wininv, matstate.winmat);
@@ -836,7 +842,9 @@ static void lightbake_render_scene_face(int face, EEVEE_BakeRenderData *user_dat
DRW_draw_pass(psl->depth_pass_cull);
DRW_draw_pass(psl->probe_background);
DRW_draw_pass(psl->material_pass);
+ DRW_draw_pass(psl->material_pass_cull);
DRW_draw_pass(psl->sss_pass); /* Only output standard pass */
+ DRW_draw_pass(psl->sss_pass_cull);
EEVEE_draw_default_passes(psl);
}
@@ -884,9 +892,7 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us
/* Be sure that cascaded shadow maps are updated. */
EEVEE_draw_shadows(sldata, vedata);
- /* Since we are rendering with an inverted view matrix, we need
- * to invert the facing for backface culling to be the same. */
- DRW_state_invert_facing();
+
/* Compute offset plane equation (fix missing texels near reflection plane). */
copy_v4_v4(sldata->clip_data.clip_planes[0], eplanar->plane_equation);
sldata->clip_data.clip_planes[0][3] += eplanar->clipsta;
@@ -897,6 +903,9 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us
GPU_framebuffer_bind(fbl->planarref_fb);
GPU_framebuffer_clear_depth(fbl->planarref_fb, 1.0);
+ float prev_background_alpha = vedata->stl->g_data->background_alpha;
+ vedata->stl->g_data->background_alpha = 1.0f;
+
/* Slight modification: we handle refraction as normal
* shading and don't do SSRefraction. */
@@ -914,7 +923,9 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us
/* Shading pass */
EEVEE_draw_default_passes(psl);
DRW_draw_pass(psl->material_pass);
+ DRW_draw_pass(psl->material_pass_cull);
DRW_draw_pass(psl->sss_pass); /* Only output standard pass */
+ DRW_draw_pass(psl->sss_pass_cull);
DRW_draw_pass(psl->refract_pass);
/* Transparent */
@@ -924,7 +935,6 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us
}
DRW_draw_pass(psl->transparent_pass);
- DRW_state_invert_facing();
DRW_state_clip_planes_reset();
DRW_stats_group_end();
@@ -932,6 +942,8 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us
/* Restore */
txl->planar_pool = tmp_planar_pool;
txl->planar_depth = tmp_planar_depth;
+
+ vedata->stl->g_data->background_alpha = prev_background_alpha;
}
static void eevee_lightbake_render_scene_to_planars(
@@ -1213,7 +1225,9 @@ void EEVEE_lightprobes_refresh(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
LightCache *light_cache = vedata->stl->g_data->light_cache;
- if (light_cache->flag & LIGHTCACHE_UPDATE_WORLD) {
+ if ((light_cache->flag & LIGHTCACHE_UPDATE_WORLD) &&
+ (light_cache->flag & LIGHTCACHE_BAKED) == 0)
+ {
DRWMatrixState saved_mats;
DRW_viewport_matrix_get_all(&saved_mats);
EEVEE_lightbake_update_world_quick(sldata, vedata, scene_eval);
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index f4fe088157e..b66563de80a 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -222,8 +222,12 @@ static GPUShader *eevee_lights_get_store_sh(int shadow_method, bool high_blur, b
ds_frag = BLI_dynstr_new();
BLI_dynstr_append(ds_frag, (shadow_method == SHADOW_VSM) ? "#define VSM\n" : "#define ESM\n");
- if (high_blur) BLI_dynstr_append(ds_frag, "#define HIGH_BLUR\n");
- if (cascade) BLI_dynstr_append(ds_frag, "#define CSM\n");
+ if (high_blur) {
+ BLI_dynstr_append(ds_frag, "#define HIGH_BLUR\n");
+ }
+ if (cascade) {
+ BLI_dynstr_append(ds_frag, "#define CSM\n");
+ }
char *define_str = BLI_dynstr_get_cstring(ds_frag);
BLI_dynstr_free(ds_frag);
@@ -336,13 +340,18 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
const float threshold = draw_ctx->scene->eevee.light_threshold;
-
/* Step 1 find all lights in the scene and setup them */
if (linfo->num_light >= MAX_LIGHT) {
printf("Too many lights in the scene !!!\n");
}
else {
Light *la = (Light *)ob->data;
+
+ /* Early out if light has no power. */
+ if (la->energy == 0.0f || is_zero_v3(&la->r)) {
+ return;
+ }
+
EEVEE_Light *evli = linfo->light_data + linfo->num_light;
eevee_light_setup(ob, evli);
@@ -439,7 +448,9 @@ void EEVEE_lights_cache_shcaster_material_add(
/* TODO / PERF : reuse the same shading group for objects with the same material */
DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, psl->shadow_pass);
- if (grp == NULL) return;
+ if (grp == NULL) {
+ return;
+ }
/* Grrr needed for correctness but not 99% of the time not needed.
* TODO detect when needed? */
@@ -555,7 +566,7 @@ void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
linfo->shadow_cube_size, shadow_pool_format, DRW_TEX_FILTER, NULL);
}
if (!sldata->shadow_cube_pool) {
- sldata->shadow_cube_pool = DRW_texture_create_2D_array(
+ sldata->shadow_cube_pool = DRW_texture_create_2d_array(
linfo->shadow_cube_store_size, linfo->shadow_cube_store_size, max_ii(1, linfo->num_cube_layer),
shadow_pool_format, DRW_TEX_FILTER, NULL);
}
@@ -569,13 +580,13 @@ void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
/* CSM */
if (!sldata->shadow_cascade_target) {
- sldata->shadow_cascade_target = DRW_texture_create_2D_array(
+ sldata->shadow_cascade_target = DRW_texture_create_2d_array(
linfo->shadow_cascade_size, linfo->shadow_cascade_size, MAX_CASCADE_NUM, GPU_DEPTH_COMPONENT24, 0, NULL);
- sldata->shadow_cascade_blur = DRW_texture_create_2D_array(
+ sldata->shadow_cascade_blur = DRW_texture_create_2d_array(
linfo->shadow_cascade_size, linfo->shadow_cascade_size, MAX_CASCADE_NUM, shadow_pool_format, DRW_TEX_FILTER, NULL);
}
if (!sldata->shadow_cascade_pool) {
- sldata->shadow_cascade_pool = DRW_texture_create_2D_array(
+ sldata->shadow_cascade_pool = DRW_texture_create_2d_array(
linfo->shadow_cascade_size, linfo->shadow_cascade_size, max_ii(1, linfo->num_cascade_layer),
shadow_pool_format, DRW_TEX_FILTER, NULL);
}
@@ -693,6 +704,14 @@ static void eevee_light_setup(Object *ob, EEVEE_Light *evli)
copy_v3_v3(evli->upvec, mat[1]);
normalize_v3(evli->upvec);
+ /* Make sure we have a consistent Right Hand coord frame.
+ * (in case of negatively scaled Z axis) */
+ float cross[3];
+ cross_v3_v3v3(cross, evli->rightvec, evli->forwardvec);
+ if (dot_v3v3(cross, evli->upvec) < 0.0) {
+ negate_v3(evli->upvec);
+ }
+
light_shape_parameters_set(evli, la, scale);
/* Light Type */
@@ -713,14 +732,14 @@ static void eevee_light_setup(Object *ob, EEVEE_Light *evli)
* Point are distributed in a way that when they are orthogonaly
* projected into any plane, the resulting distribution is (close to)
* a uniform disc distribution.
- **/
+ */
static void sample_ball(int sample_ofs, float radius, float rsample[3])
{
double ht_point[3];
double ht_offset[3] = {0.0, 0.0, 0.0};
uint ht_primes[3] = {2, 3, 7};
- BLI_halton_3D(ht_primes, ht_offset, sample_ofs, ht_point);
+ BLI_halton_3d(ht_primes, ht_offset, sample_ofs, ht_point);
float omega = ht_point[1] * 2.0f * M_PI;
@@ -743,7 +762,7 @@ static void sample_rectangle(
double ht_offset[2] = {0.0, 0.0};
uint ht_primes[2] = {2, 3};
- BLI_halton_2D(ht_primes, ht_offset, sample_ofs, ht_point);
+ BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point);
/* Change ditribution center to be 0,0 */
ht_point[0] = (ht_point[0] > 0.5f) ? ht_point[0] - 1.0f : ht_point[0];
@@ -762,7 +781,7 @@ static void sample_ellipse(
double ht_offset[2] = {0.0, 0.0};
uint ht_primes[2] = {2, 3};
- BLI_halton_2D(ht_primes, ht_offset, sample_ofs, ht_point);
+ BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point);
/* Uniform disc sampling. */
float omega = ht_point[1] * 2.0f * M_PI;
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index d954ff3b0e2..b07b20386a8 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -41,6 +41,7 @@
static void eevee_lookdev_lightcache_delete(EEVEE_Data *vedata)
{
EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_PrivateData *g_data = stl->g_data;
EEVEE_TextureList *txl = vedata->txl;
MEM_SAFE_FREE(stl->lookdev_lightcache);
@@ -48,14 +49,18 @@ static void eevee_lookdev_lightcache_delete(EEVEE_Data *vedata)
MEM_SAFE_FREE(stl->lookdev_cube_data);
DRW_TEXTURE_FREE_SAFE(txl->lookdev_grid_tx);
DRW_TEXTURE_FREE_SAFE(txl->lookdev_cube_tx);
+ g_data->studiolight_index = -1;
+ g_data->studiolight_rot_z = 0.0f;
}
void EEVEE_lookdev_cache_init(
EEVEE_Data *vedata, DRWShadingGroup **grp, DRWPass *pass,
+ float background_alpha,
World *UNUSED(world), EEVEE_LightProbesInfo *pinfo)
{
EEVEE_StorageList *stl = vedata->stl;
EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_PrivateData *g_data = stl->g_data;
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) {
@@ -114,7 +119,7 @@ void EEVEE_lookdev_cache_init(
*grp = DRW_shgroup_create(shader, pass);
axis_angle_to_mat3_single(stl->g_data->studiolight_matrix, 'Z', v3d->shading.studiolight_rot_z);
DRW_shgroup_uniform_mat3(*grp, "StudioLightMatrix", stl->g_data->studiolight_matrix);
- DRW_shgroup_uniform_float(*grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
+ DRW_shgroup_uniform_float_copy(*grp, "backgroundAlpha", background_alpha);
DRW_shgroup_uniform_vec3(*grp, "color", background_color, 1);
DRW_shgroup_call_add(*grp, geom, NULL);
if (!pinfo) {
@@ -131,13 +136,12 @@ void EEVEE_lookdev_cache_init(
DRW_shgroup_uniform_texture(*grp, "image", tex);
/* Do we need to recalc the lightprobes? */
- if (pinfo &&
- ((pinfo->studiolight_index != sl->index) ||
- (pinfo->studiolight_rot_z != v3d->shading.studiolight_rot_z)))
+ if (g_data->studiolight_index != sl->index ||
+ g_data->studiolight_rot_z != v3d->shading.studiolight_rot_z)
{
stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD;
- pinfo->studiolight_index = sl->index;
- pinfo->studiolight_rot_z = v3d->shading.studiolight_rot_z;
+ g_data->studiolight_index = sl->index;
+ g_data->studiolight_rot_z = v3d->shading.studiolight_rot_z;
}
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_lut.h b/source/blender/draw/engines/eevee/eevee_lut.h
index e88ffc6ccb9..d3ba50ba71b 100644
--- a/source/blender/draw/engines/eevee/eevee_lut.h
+++ b/source/blender/draw/engines/eevee/eevee_lut.h
@@ -25,2289 +25,3080 @@
#define __EEVEE_LUT_H__
static float ltc_mat_ggx[64 * 64 * 4] = {
- 0.000200, -0.000000, 1.000000, -0.000000, 0.000504, -0.000000, 1.000000, -0.000000, 0.002016,
- -0.000000, 1.000000, -0.000000, 0.004535, -0.000000, 1.000000, -0.000000, 0.008063, -0.000000,
- 1.000000, -0.000000, 0.012598, -0.000000, 1.000000, -0.000000, 0.018141, -0.000000, 1.000000,
- -0.000000, 0.024692, -0.000000, 1.000000, -0.000000, 0.032252, -0.000000, 1.000000, -0.000000,
- 0.040821, -0.000000, 1.000000, -0.000000, 0.050400, -0.000000, 1.000000, -0.000000, 0.060989,
- -0.000000, 1.000000, -0.000000, 0.072591, -0.000000, 1.000000, -0.000000, 0.085206, -0.000000,
- 1.000000, -0.000000, 0.098836, -0.000000, 1.000000, -0.000000, 0.113483, -0.000000, 1.000000,
- -0.000000, 0.129147, -0.000000, 1.000000, -0.000000, 0.145828, -0.000000, 1.000000, -0.000000,
- 0.163499, -0.000000, 1.000000, -0.000000, 0.181972, -0.000000, 1.000000, -0.000000, 0.199498,
- -0.000000, 1.000000, -0.000000, 0.220031, -0.000000, 1.000000, -0.000000, 0.241588, -0.000000,
- 1.000000, -0.000000, 0.264120, -0.000000, 1.000000, -0.000000, 0.287521, -0.000000, 1.000000,
- -0.000000, 0.311478, -0.000000, 1.000000, -0.000000, 0.335127, -0.000000, 1.000000, -0.000000,
- 0.359811, -0.000000, 1.000000, -0.000000, 0.386446, -0.000000, 1.000000, -0.000000, 0.413161,
- -0.000000, 1.000000, -0.000000, 0.439142, -0.000000, 1.000000, -0.000000, 0.467039, -0.000000,
- 1.000000, -0.000000, 0.495170, -0.000000, 1.000000, -0.000000, 0.522324, -0.000000, 1.000000,
- -0.000000, 0.551482, -0.000000, 1.000000, -0.000000, 0.579621, -0.000000, 1.000000, -0.000000,
- 0.608255, -0.000000, 1.000000, -0.000000, 0.636515, -0.000000, 1.000000, -0.000000, 0.664835,
- -0.000000, 1.000000, -0.000000, 0.692549, -0.000000, 1.000000, -0.000000, 0.720375, -0.000000,
- 1.000000, -0.000000, 0.747238, -0.000000, 1.000000, -0.000000, 0.773956, -0.000000, 1.000000,
- -0.000000, 0.799879, -0.000000, 1.000000, -0.000000, 0.824889, -0.000000, 1.000000, -0.000000,
- 0.849357, -0.000000, 1.000000, -0.000000, 0.873016, -0.000000, 1.000000, -0.000000, 0.895670,
- -0.000000, 1.000000, -0.000000, 0.917194, -0.000000, 1.000000, -0.000000, 0.937978, -0.000000,
- 1.000000, -0.000000, 0.957872, -0.000000, 1.000000, -0.000000, 0.976736, -0.000000, 1.000000,
- -0.000000, 0.994433, -0.000000, 1.000000, -0.000000, 1.011206, -0.000000, 1.000000, -0.000000,
- 1.026820, -0.000000, 1.000000, -0.000000, 1.041720, -0.000000, 1.000000, -0.000000, 1.055657,
- -0.000000, 1.000000, -0.000000, 1.068642, -0.000000, 1.000000, -0.000000, 1.080646, -0.000000,
- 1.000000, -0.000000, 1.091637, -0.000000, 1.000000, -0.000000, 1.101837, -0.000000, 1.000000,
- -0.000000, 1.111292, -0.000000, 1.000000, -0.000000, 1.120025, -0.000000, 1.000000, -0.000000,
- 1.127918, -0.000000, 1.000000, -0.000000, 0.000200, -0.000005, 1.000623, 0.024938, 0.000504,
- -0.000013, 1.000643, 0.024938, 0.002016, -0.000050, 1.000618, 0.024938, 0.004535, -0.000113,
- 1.000621, 0.024938, 0.008063, -0.000201, 1.000746, 0.024938, 0.012596, -0.000314, 1.000463,
- 0.024937, 0.018140, -0.000452, 1.000511, 0.024939, 0.024693, -0.000616, 1.000541, 0.024938,
- 0.032253, -0.000804, 1.000684, 0.024938, 0.040815, -0.001018, 1.000524, 0.024940, 0.050399,
- -0.001257, 1.000582, 0.024937, 0.060989, -0.001521, 1.000655, 0.024937, 0.072591, -0.001810,
- 1.000608, 0.024938, 0.085204, -0.002125, 1.000622, 0.024939, 0.098835, -0.002465, 1.000632,
- 0.024937, 0.113483, -0.002830, 1.000640, 0.024939, 0.129143, -0.003220, 1.000568, 0.024938,
- 0.145830, -0.003633, 1.000635, 0.024938, 0.163497, -0.004062, 1.000626, 0.024938, 0.181956,
- -0.004424, 1.000612, 0.024924, 0.199791, -0.004593, 1.000627, 0.024890, 0.220029, -0.005480,
- 1.000594, 0.024935, 0.241586, -0.006010, 1.000616, 0.024933, 0.264115, -0.006550, 1.000607,
- 0.024927, 0.287514, -0.007072, 1.000595, 0.024909, 0.311455, -0.007472, 1.000616, 0.024872,
- 0.335083, -0.007491, 1.000589, 0.024755, 0.359805, -0.008810, 1.000601, 0.024877, 0.386438,
- -0.009282, 1.000640, 0.024824, 0.413131, -0.009534, 1.000599, 0.024708, 0.439249, -0.009701,
- 1.000497, 0.024573, 0.466997, -0.010878, 1.000467, 0.024652, 0.495138, -0.010959, 1.000539,
- 0.024455, 0.522654, -0.011386, 1.000518, 0.024318, 0.551415, -0.012022, 1.000533, 0.024216,
- 0.579610, -0.011805, 1.000495, 0.023867, 0.608185, -0.012773, 1.000474, 0.023834, 0.636492,
- -0.012377, 1.000488, 0.023327, 0.664826, -0.013172, 1.000576, 0.023205, 0.692674, -0.012847,
- 1.000505, 0.022708, 0.720341, -0.013141, 1.000424, 0.022349, 0.747373, -0.013227, 1.000449,
- 0.021871, 0.773980, -0.012739, 1.000478, 0.021171, 0.799839, -0.012999, 1.000396, 0.020606,
- 0.825113, -0.012727, 1.000425, 0.020006, 0.849579, -0.012170, 1.000469, 0.019089, 0.873046,
- -0.011855, 1.000411, 0.018291, 0.895777, -0.011711, 1.000426, 0.017534, 0.917518, -0.011107,
- 1.000373, 0.016542, 0.938264, -0.010439, 1.000322, 0.015512, 0.958032, -0.009807, 1.000324,
- 0.014491, 0.976838, -0.009268, 1.000341, 0.013468, 0.994631, -0.008662, 1.000318, 0.012376,
- 1.011434, -0.007923, 1.000289, 0.011187, 1.027169, -0.007132, 1.000216, 0.010078, 1.041929,
- -0.006332, 1.000096, 0.008924, 1.055767, -0.005554, 1.000156, 0.007770, 1.068595, -0.004811,
- 1.000084, 0.006611, 1.080612, -0.003950, 1.000047, 0.005485, 1.091785, -0.003174, 1.000109,
- 0.004352, 1.101998, -0.002363, 1.000029, 0.003180, 1.111423, -0.001552, 0.999985, 0.002091,
- 1.120007, -0.000786, 0.999947, 0.000991, 1.127918, 0.000004, 1.000000, -0.000004, 0.000200,
- -0.000010, 1.002495, 0.049907, 0.000504, -0.000025, 1.002476, 0.049908, 0.002016, -0.000101,
- 1.002500, 0.049908, 0.004535, -0.000226, 1.002487, 0.049908, 0.008062, -0.000402, 1.002364,
- 0.049908, 0.012598, -0.000629, 1.002412, 0.049908, 0.018140, -0.000905, 1.002379, 0.049908,
- 0.024691, -0.001232, 1.002490, 0.049907, 0.032251, -0.001610, 1.002398, 0.049908, 0.040821,
- -0.002037, 1.002392, 0.049908, 0.050398, -0.002515, 1.002431, 0.049907, 0.060989, -0.003044,
- 1.002475, 0.049908, 0.072592, -0.003623, 1.002546, 0.049907, 0.085204, -0.004252, 1.002467,
- 0.049907, 0.098832, -0.004932, 1.002450, 0.049908, 0.113481, -0.005663, 1.002482, 0.049907,
- 0.129145, -0.006443, 1.002443, 0.049907, 0.145825, -0.007271, 1.002495, 0.049906, 0.163491,
- -0.008128, 1.002475, 0.049903, 0.181911, -0.008826, 1.002459, 0.049879, 0.200065, -0.009285,
- 1.002443, 0.049824, 0.220025, -0.010966, 1.002450, 0.049897, 0.241581, -0.012025, 1.002463,
- 0.049893, 0.264099, -0.013105, 1.002395, 0.049881, 0.287493, -0.014145, 1.002390, 0.049855,
- 0.311399, -0.014925, 1.002414, 0.049769, 0.335096, -0.015239, 1.002363, 0.049591, 0.359815,
- -0.017559, 1.002415, 0.049777, 0.386365, -0.018554, 1.002354, 0.049675, 0.413017, -0.019043,
- 1.002297, 0.049444, 0.439519, -0.019815, 1.002284, 0.049253, 0.466938, -0.021741, 1.002307,
- 0.049327, 0.494999, -0.021887, 1.002181, 0.048922, 0.522922, -0.022844, 1.002107, 0.048677,
- 0.551270, -0.024014, 1.002101, 0.048478, 0.579771, -0.024156, 1.002060, 0.047904, 0.608156,
- -0.025317, 1.002077, 0.047594, 0.636662, -0.025321, 1.001975, 0.046876, 0.664846, -0.026018,
- 1.001992, 0.046354, 0.692877, -0.026041, 1.001846, 0.045504, 0.720316, -0.026252, 1.001846,
- 0.044655, 0.747658, -0.026159, 1.001931, 0.043670, 0.774252, -0.026086, 1.001845, 0.042515,
- 0.800179, -0.025653, 1.001794, 0.041211, 0.825525, -0.025170, 1.001787, 0.039823, 0.850013,
- -0.024788, 1.001806, 0.038409, 0.873593, -0.023992, 1.001688, 0.036767, 0.896343, -0.022985,
- 1.001666, 0.034900, 0.918062, -0.022005, 1.001548, 0.033010, 0.938928, -0.021110, 1.001503,
- 0.031143, 0.958667, -0.019893, 1.001341, 0.029059, 0.977457, -0.018546, 1.001194, 0.026888,
- 0.995243, -0.017152, 1.001095, 0.024713, 1.012023, -0.015750, 1.001100, 0.022496, 1.027614,
- -0.014289, 1.000851, 0.020153, 1.042389, -0.012688, 1.000724, 0.017839, 1.056161, -0.011118,
- 1.000572, 0.015529, 1.068968, -0.009540, 1.000407, 0.013240, 1.080866, -0.007963, 1.000258,
- 0.010940, 1.091944, -0.006416, 1.000254, 0.008716, 1.102104, -0.004771, 1.000175, 0.006434,
- 1.111571, -0.003056, 1.000148, 0.004169, 1.120084, -0.001458, 1.000050, 0.002033, 1.127981,
- 0.000021, 0.999987, -0.000027, 0.000200, -0.000015, 1.005620, 0.074940, 0.000504, -0.000038,
- 1.005650, 0.074939, 0.002016, -0.000151, 1.005613, 0.074939, 0.004535, -0.000340, 1.005618,
- 0.074939, 0.008062, -0.000604, 1.005614, 0.074939, 0.012597, -0.000944, 1.005616, 0.074940,
- 0.018141, -0.001359, 1.005558, 0.074939, 0.024695, -0.001851, 1.005495, 0.074940, 0.032253,
- -0.002417, 1.005616, 0.074939, 0.040822, -0.003059, 1.005591, 0.074940, 0.050399, -0.003777,
- 1.005596, 0.074940, 0.060989, -0.004570, 1.005599, 0.074939, 0.072591, -0.005440, 1.005616,
- 0.074940, 0.085203, -0.006385, 1.005616, 0.074939, 0.098833, -0.007406, 1.005595, 0.074938,
- 0.113481, -0.008502, 1.005605, 0.074938, 0.129147, -0.009674, 1.005605, 0.074937, 0.145817,
- -0.010916, 1.005513, 0.074937, 0.163485, -0.012199, 1.005579, 0.074928, 0.181824, -0.013172,
- 1.005552, 0.074885, 0.200274, -0.014100, 1.005524, 0.074825, 0.220017, -0.016464, 1.005529,
- 0.074928, 0.241568, -0.018052, 1.005490, 0.074914, 0.264084, -0.019671, 1.005457, 0.074898,
- 0.287450, -0.021217, 1.005431, 0.074860, 0.311281, -0.022341, 1.005395, 0.074717, 0.335228,
- -0.023296, 1.005320, 0.074526, 0.360047, -0.025965, 1.005302, 0.074649, 0.386273, -0.027808,
- 1.005285, 0.074575, 0.412855, -0.028504, 1.005167, 0.074237, 0.439705, -0.030007, 1.005129,
- 0.074013, 0.466975, -0.032263, 1.005082, 0.073967, 0.494874, -0.032931, 1.004960, 0.073475,
- 0.523066, -0.034348, 1.004834, 0.073084, 0.551198, -0.035739, 1.004806, 0.072657, 0.579889,
- -0.036575, 1.004687, 0.072029, 0.608282, -0.037434, 1.004605, 0.071309, 0.636812, -0.038323,
- 1.004589, 0.070507, 0.665010, -0.038676, 1.004403, 0.069424, 0.693063, -0.039237, 1.004340,
- 0.068370, 0.720750, -0.039332, 1.004224, 0.066988, 0.747911, -0.039179, 1.004117, 0.065447,
- 0.774576, -0.039110, 1.004035, 0.063838, 0.800737, -0.038542, 1.004027, 0.061923, 0.825966,
- -0.037966, 1.003825, 0.059859, 0.850534, -0.036943, 1.003786, 0.057529, 0.874289, -0.035853,
- 1.003560, 0.055081, 0.897152, -0.034730, 1.003549, 0.052476, 0.919029, -0.033242, 1.003454,
- 0.049647, 0.939851, -0.031508, 1.003215, 0.046670, 0.959599, -0.029695, 1.002916, 0.043588,
- 0.978293, -0.027845, 1.002720, 0.040401, 0.996085, -0.025775, 1.002445, 0.037060, 1.012768,
- -0.023607, 1.002133, 0.033726, 1.028404, -0.021374, 1.001822, 0.030217, 1.043150, -0.019108,
- 1.001602, 0.026820, 1.056760, -0.016823, 1.001274, 0.023372, 1.069471, -0.014378, 1.000964,
- 0.019891, 1.081283, -0.011884, 1.000684, 0.016405, 1.092238, -0.009398, 1.000514, 0.012950,
- 1.102384, -0.007030, 1.000319, 0.009579, 1.111737, -0.004751, 1.000225, 0.006384, 1.120274,
- -0.002404, 1.000046, 0.003192, 1.128182, 0.000031, 1.000020, 0.000033, 0.000200, -0.000020,
- 1.010006, 0.100065, 0.000504, -0.000050, 1.009927, 0.100065, 0.002016, -0.000202, 1.010026,
- 0.100064, 0.004535, -0.000454, 1.010018, 0.100065, 0.008062, -0.000807, 1.009891, 0.100064,
- 0.012599, -0.001261, 1.010175, 0.100064, 0.018141, -0.001815, 1.010067, 0.100065, 0.024692,
- -0.002471, 1.010014, 0.100066, 0.032251, -0.003227, 1.009950, 0.100065, 0.040818, -0.004084,
- 1.009963, 0.100067, 0.050401, -0.005043, 1.010032, 0.100064, 0.060988, -0.006102, 1.009979,
- 0.100064, 0.072588, -0.007263, 1.009984, 0.100063, 0.085205, -0.008525, 1.010023, 0.100063,
- 0.098832, -0.009888, 1.009960, 0.100062, 0.113479, -0.011352, 1.009974, 0.100063, 0.129142,
- -0.012916, 1.009945, 0.100062, 0.145817, -0.014573, 1.009924, 0.100058, 0.163468, -0.016276,
- 1.009912, 0.100050, 0.181674, -0.017411, 1.009859, 0.099975, 0.200435, -0.019002, 1.009842,
- 0.099932, 0.220005, -0.021978, 1.009820, 0.100043, 0.241550, -0.024096, 1.009778, 0.100031,
- 0.264058, -0.026250, 1.009765, 0.100002, 0.287399, -0.028286, 1.009724, 0.099939, 0.311134,
- -0.029698, 1.009596, 0.099748, 0.335350, -0.031442, 1.009508, 0.099582, 0.360295, -0.034401,
- 1.009475, 0.099613, 0.386112, -0.037030, 1.009329, 0.099558, 0.412733, -0.038163, 1.009250,
- 0.099137, 0.439833, -0.040250, 1.009125, 0.098866, 0.467099, -0.042583, 1.009011, 0.098626,
- 0.494828, -0.044299, 1.008803, 0.098149, 0.523217, -0.045876, 1.008712, 0.097600, 0.551338,
- -0.047440, 1.008509, 0.096929, 0.579917, -0.048995, 1.008371, 0.096178, 0.608454, -0.049901,
- 1.008212, 0.095145, 0.636785, -0.051224, 1.007963, 0.094151, 0.665220, -0.051675, 1.007741,
- 0.092728, 0.693194, -0.052278, 1.007616, 0.091195, 0.721008, -0.052406, 1.007327, 0.089384,
- 0.748196, -0.052529, 1.007219, 0.087461, 0.774975, -0.051950, 1.006851, 0.085133, 0.801129,
- -0.051456, 1.006732, 0.082628, 0.826668, -0.050569, 1.006612, 0.079817, 0.851291, -0.049328,
- 1.006374, 0.076710, 0.875056, -0.047988, 1.006183, 0.073481, 0.897872, -0.046149, 1.005742,
- 0.069943, 0.919803, -0.044144, 1.005514, 0.066151, 0.940701, -0.042095, 1.005153, 0.062247,
- 0.960580, -0.039730, 1.004843, 0.058158, 0.979427, -0.037104, 1.004535, 0.053850, 0.997157,
- -0.034369, 1.004023, 0.049403, 1.013777, -0.031555, 1.003622, 0.044944, 1.029452, -0.028571,
- 1.003212, 0.040414, 1.044029, -0.025416, 1.002698, 0.035723, 1.057586, -0.022217, 1.002202,
- 0.031072, 1.070148, -0.019037, 1.001703, 0.026429, 1.081875, -0.015936, 1.001322, 0.021896,
- 1.092789, -0.012734, 1.001053, 0.017288, 1.102704, -0.009454, 1.000604, 0.012841, 1.112011,
- -0.006199, 1.000387, 0.008446, 1.120590, -0.003010, 1.000166, 0.004122, 1.128283, 0.000027,
- 0.999956, -0.000038, 0.000200, -0.000025, 1.015664, 0.125315, 0.000504, -0.000063, 1.015664,
- 0.125316, 0.002016, -0.000253, 1.015727, 0.125315, 0.004535, -0.000568, 1.015695, 0.125314,
- 0.008063, -0.001010, 1.015823, 0.125316, 0.012599, -0.001579, 1.015867, 0.125315, 0.018141,
- -0.002273, 1.015758, 0.125316, 0.024691, -0.003094, 1.015662, 0.125316, 0.032252, -0.004042,
- 1.015674, 0.125316, 0.040820, -0.005115, 1.015678, 0.125316, 0.050400, -0.006316, 1.015684,
- 0.125315, 0.060989, -0.007642, 1.015685, 0.125315, 0.072590, -0.009096, 1.015703, 0.125314,
- 0.085203, -0.010676, 1.015654, 0.125314, 0.098833, -0.012383, 1.015670, 0.125315, 0.113477,
- -0.014215, 1.015635, 0.125312, 0.129138, -0.016173, 1.015599, 0.125311, 0.145815, -0.018246,
- 1.015610, 0.125306, 0.163450, -0.020360, 1.015564, 0.125294, 0.181595, -0.021807, 1.015460,
- 0.125204, 0.200563, -0.023971, 1.015440, 0.125165, 0.220186, -0.027280, 1.015412, 0.125250,
- 0.241528, -0.030164, 1.015342, 0.125267, 0.264020, -0.032847, 1.015269, 0.125233, 0.287311,
- -0.035345, 1.015232, 0.125138, 0.310993, -0.037108, 1.015063, 0.124903, 0.335467, -0.039653,
- 1.014970, 0.124749, 0.360497, -0.042914, 1.014819, 0.124702, 0.385986, -0.046142, 1.014685,
- 0.124623, 0.412703, -0.048050, 1.014543, 0.124193, 0.439929, -0.050527, 1.014315, 0.123833,
- 0.467163, -0.052880, 1.014087, 0.123375, 0.494824, -0.055672, 1.013898, 0.122982, 0.523222,
- -0.057388, 1.013647, 0.122166, 0.551557, -0.059328, 1.013403, 0.121343, 0.579884, -0.061315,
- 1.013059, 0.120430, 0.608619, -0.062531, 1.012745, 0.119140, 0.637014, -0.063778, 1.012425,
- 0.117721, 0.665425, -0.064734, 1.012067, 0.116069, 0.693580, -0.065315, 1.011712, 0.114146,
- 0.721194, -0.065535, 1.011200, 0.111846, 0.748586, -0.065501, 1.010896, 0.109309, 0.775437,
- -0.065091, 1.010576, 0.106504, 0.801554, -0.064332, 1.010136, 0.103308, 0.827079, -0.063078,
- 1.009629, 0.099695, 0.851693, -0.061728, 1.009233, 0.095946, 0.875586, -0.059853, 1.008726,
- 0.091802, 0.898589, -0.057727, 1.008412, 0.087339, 0.920421, -0.055377, 1.007767, 0.082687,
- 0.941533, -0.052571, 1.007529, 0.077716, 0.961426, -0.049544, 1.006929, 0.072574, 0.980287,
- -0.046400, 1.006393, 0.067217, 0.998080, -0.042966, 1.005872, 0.061757, 1.014940, -0.039321,
- 1.005346, 0.056072, 1.030455, -0.035585, 1.004609, 0.050410, 1.045078, -0.031823, 1.004151,
- 0.044622, 1.058555, -0.027947, 1.003421, 0.038893, 1.071009, -0.023891, 1.002704, 0.032977,
- 1.082594, -0.019822, 1.002023, 0.027290, 1.093265, -0.015765, 1.001403, 0.021543, 1.103132,
- -0.011790, 1.000944, 0.016072, 1.112348, -0.007784, 1.000550, 0.010511, 1.120845, -0.003849,
- 1.000224, 0.005174, 1.128573, 0.000057, 0.999975, -0.000039, 0.000200, -0.000030, 1.022609,
- 0.150725, 0.000504, -0.000076, 1.022728, 0.150725, 0.002016, -0.000304, 1.022728, 0.150725,
- 0.004535, -0.000684, 1.022733, 0.150725, 0.008062, -0.001215, 1.022715, 0.150725, 0.012598,
- -0.001899, 1.022720, 0.150725, 0.018141, -0.002734, 1.022659, 0.150725, 0.024694, -0.003722,
- 1.022801, 0.150724, 0.032254, -0.004861, 1.022779, 0.150726, 0.040815, -0.006152, 1.022693,
- 0.150724, 0.050400, -0.007596, 1.022716, 0.150725, 0.060990, -0.009192, 1.022733, 0.150725,
- 0.072587, -0.010939, 1.022630, 0.150723, 0.085203, -0.012839, 1.022676, 0.150725, 0.098828,
- -0.014891, 1.022659, 0.150725, 0.113473, -0.017095, 1.022589, 0.150720, 0.129137, -0.019449,
- 1.022572, 0.150716, 0.145803, -0.021938, 1.022508, 0.150712, 0.163417, -0.024443, 1.022471,
- 0.150691, 0.181580, -0.026329, 1.022406, 0.150600, 0.200667, -0.028997, 1.022336, 0.150553,
- 0.220429, -0.032584, 1.022296, 0.150610, 0.241497, -0.036260, 1.022202, 0.150658, 0.263975,
- -0.039465, 1.022119, 0.150619, 0.287210, -0.042385, 1.021988, 0.150490, 0.310935, -0.044758,
- 1.021771, 0.150241, 0.335556, -0.047922, 1.021658, 0.150076, 0.360667, -0.051493, 1.021437,
- 0.149931, 0.386028, -0.054931, 1.021228, 0.149754, 0.412665, -0.058007, 1.021023, 0.149400,
- 0.439951, -0.060813, 1.020723, 0.148913, 0.467262, -0.063461, 1.020332, 0.148319, 0.494972,
- -0.066738, 1.020097, 0.147798, 0.523153, -0.068976, 1.019630, 0.146903, 0.551700, -0.071268,
- 1.019245, 0.145863, 0.580046, -0.073439, 1.018797, 0.144695, 0.608649, -0.075193, 1.018201,
- 0.143237, 0.637239, -0.076536, 1.017746, 0.141463, 0.665388, -0.077771, 1.017111, 0.139462,
- 0.693755, -0.078344, 1.016609, 0.137082, 0.721345, -0.078817, 1.015863, 0.134403, 0.748879,
- -0.078512, 1.015390, 0.131252, 0.775560, -0.078128, 1.014652, 0.127866, 0.801897, -0.077094,
- 1.013877, 0.123928, 0.827193, -0.075863, 1.013021, 0.119733, 0.851990, -0.073973, 1.012395,
- 0.115055, 0.875823, -0.071765, 1.011595, 0.110098, 0.898655, -0.069241, 1.010862, 0.104722,
- 0.920915, -0.066232, 1.010185, 0.098991, 0.941969, -0.062980, 1.009588, 0.093044, 0.961882,
- -0.059507, 1.008777, 0.086925, 0.980952, -0.055606, 1.008252, 0.080520, 0.998955, -0.051503,
- 1.007633, 0.073890, 1.015756, -0.047292, 1.006908, 0.067302, 1.031571, -0.042804, 1.006338,
- 0.060412, 1.046095, -0.038132, 1.005512, 0.053497, 1.059542, -0.033380, 1.004592, 0.046569,
- 1.072006, -0.028613, 1.003731, 0.039679, 1.083348, -0.023811, 1.002871, 0.032772, 1.093969,
- -0.018930, 1.002068, 0.025894, 1.103697, -0.014098, 1.001284, 0.019178, 1.112813, -0.009339,
- 1.000820, 0.012652, 1.121193, -0.004661, 1.000324, 0.006226, 1.128930, 0.000052, 0.999988,
- -0.000008, 0.000200, -0.000035, 1.030857, 0.176327, 0.000504, -0.000089, 1.031137, 0.176326,
- 0.002016, -0.000355, 1.031049, 0.176325, 0.004535, -0.000800, 1.031105, 0.176326, 0.008062,
- -0.001422, 1.030973, 0.176326, 0.012598, -0.002221, 1.031168, 0.176326, 0.018141, -0.003199,
- 1.031093, 0.176326, 0.024695, -0.004354, 1.031297, 0.176326, 0.032253, -0.005687, 1.031091,
- 0.176327, 0.040821, -0.007197, 1.031012, 0.176326, 0.050399, -0.008886, 1.031068, 0.176325,
- 0.060987, -0.010752, 1.030967, 0.176323, 0.072588, -0.012797, 1.031028, 0.176324, 0.085200,
- -0.015019, 1.030985, 0.176322, 0.098829, -0.017419, 1.030983, 0.176320, 0.113474, -0.019997,
- 1.030953, 0.176317, 0.129133, -0.022748, 1.030891, 0.176312, 0.145800, -0.025655, 1.030825,
- 0.176306, 0.163372, -0.028510, 1.030781, 0.176279, 0.181578, -0.030914, 1.030683, 0.176187,
- 0.200761, -0.034076, 1.030574, 0.176139, 0.220645, -0.037985, 1.030476, 0.176160, 0.241473,
- -0.042391, 1.030384, 0.176238, 0.263922, -0.046105, 1.030241, 0.176175, 0.287074, -0.049390,
- 1.030049, 0.176013, 0.310915, -0.052511, 1.029839, 0.175776, 0.335604, -0.056236, 1.029608,
- 0.175578, 0.360775, -0.060118, 1.029355, 0.175359, 0.386196, -0.063907, 1.029052, 0.175083,
- 0.412599, -0.067997, 1.028766, 0.174791, 0.439916, -0.071088, 1.028326, 0.174174, 0.467444,
- -0.074247, 1.027890, 0.173487, 0.495132, -0.077728, 1.027374, 0.172774, 0.523117, -0.080822,
- 1.026763, 0.171824, 0.551783, -0.083228, 1.026205, 0.170554, 0.580234, -0.085682, 1.025614,
- 0.169090, 0.608568, -0.087860, 1.024668, 0.167468, 0.637357, -0.089346, 1.023939, 0.165283,
- 0.665507, -0.090704, 1.022946, 0.162966, 0.693704, -0.091388, 1.022010, 0.160131, 0.721396,
- -0.091783, 1.021085, 0.156957, 0.748676, -0.091688, 1.019894, 0.153292, 0.775370, -0.090992,
- 1.018608, 0.149158, 0.801547, -0.089881, 1.017646, 0.144551, 0.827013, -0.088267, 1.016355,
- 0.139614, 0.851708, -0.086132, 1.015446, 0.134026, 0.875652, -0.083707, 1.014321, 0.128101,
- 0.898703, -0.080619, 1.013454, 0.121841, 0.920904, -0.077280, 1.012634, 0.115379, 0.942077,
- -0.073484, 1.011770, 0.108355, 0.962245, -0.069252, 1.010894, 0.101153, 0.981385, -0.064807,
- 1.010114, 0.093666, 0.999379, -0.060080, 1.009294, 0.086007, 1.016494, -0.055007, 1.008591,
- 0.078194, 1.032357, -0.049760, 1.007821, 0.070328, 1.047061, -0.044468, 1.006871, 0.062358,
- 1.060675, -0.038960, 1.006062, 0.054279, 1.073032, -0.033343, 1.004911, 0.046158, 1.084293,
- -0.027699, 1.003791, 0.038111, 1.094724, -0.022130, 1.002744, 0.030239, 1.104302, -0.016508,
- 1.001815, 0.022397, 1.113290, -0.010846, 1.001083, 0.014747, 1.121649, -0.005294, 1.000490,
- 0.007234, 1.129230, 0.000071, 0.999975, -0.000053, 0.000200, -0.000040, 1.040431, 0.202155,
- 0.000504, -0.000102, 1.040912, 0.202154, 0.002016, -0.000407, 1.041328, 0.202152, 0.004535,
- -0.000917, 1.040877, 0.202154, 0.008063, -0.001630, 1.040867, 0.202153, 0.012598, -0.002547,
- 1.040870, 0.202153, 0.018140, -0.003667, 1.040808, 0.202153, 0.024692, -0.004991, 1.040861,
- 0.202153, 0.032252, -0.006519, 1.040861, 0.202153, 0.040822, -0.008252, 1.040864, 0.202153,
- 0.050397, -0.010187, 1.040717, 0.202151, 0.060988, -0.012327, 1.040791, 0.202152, 0.072582,
- -0.014669, 1.040640, 0.202149, 0.085198, -0.017217, 1.040716, 0.202147, 0.098827, -0.019968,
- 1.040748, 0.202141, 0.113467, -0.022921, 1.040632, 0.202142, 0.129129, -0.026074, 1.040606,
- 0.202137, 0.145793, -0.029399, 1.040566, 0.202127, 0.163294, -0.032524, 1.040459, 0.202078,
- 0.181589, -0.035552, 1.040315, 0.201996, 0.200844, -0.039208, 1.040221, 0.201948, 0.220835,
- -0.043489, 1.040047, 0.201945, 0.241471, -0.048523, 1.039921, 0.202031, 0.263854, -0.052764,
- 1.039756, 0.201957, 0.286935, -0.056387, 1.039497, 0.201743, 0.310902, -0.060338, 1.039252,
- 0.201531, 0.335642, -0.064594, 1.038954, 0.201286, 0.360859, -0.068772, 1.038582, 0.200983,
- 0.386419, -0.073086, 1.038160, 0.200651, 0.412588, -0.077887, 1.037724, 0.200343, 0.439836,
- -0.081391, 1.037182, 0.199618, 0.467538, -0.085121, 1.036602, 0.198839, 0.495286, -0.088718,
- 1.035893, 0.197895, 0.523231, -0.092514, 1.035121, 0.196887, 0.551730, -0.095238, 1.034127,
- 0.195390, 0.580302, -0.097949, 1.033131, 0.193668, 0.608559, -0.100418, 1.031962, 0.191773,
- 0.637224, -0.102129, 1.030838, 0.189319, 0.665597, -0.103578, 1.029511, 0.186529, 0.693535,
- -0.104652, 1.028263, 0.183303, 0.721325, -0.104766, 1.026611, 0.179497, 0.748384, -0.104717,
- 1.025128, 0.175283, 0.775058, -0.103846, 1.023385, 0.170493, 0.801387, -0.102728, 1.022236,
- 0.165187, 0.826412, -0.100679, 1.019908, 0.159362, 0.851314, -0.098451, 1.018839, 0.153059,
- 0.875100, -0.095363, 1.017306, 0.146284, 0.898280, -0.092008, 1.016151, 0.138975, 0.920450,
- -0.088095, 1.014880, 0.131361, 0.941727, -0.083690, 1.013556, 0.123417, 0.962308, -0.079077,
- 1.012998, 0.115201, 0.981364, -0.073894, 1.011841, 0.106711, 0.999798, -0.068435, 1.011021,
- 0.098063, 1.016983, -0.062830, 1.010194, 0.089183, 1.033039, -0.056914, 1.009292, 0.080190,
- 1.047994, -0.050721, 1.008474, 0.071010, 1.061580, -0.044454, 1.007386, 0.061867, 1.074023,
- -0.038145, 1.006135, 0.052711, 1.085470, -0.031679, 1.004890, 0.043595, 1.095673, -0.025157,
- 1.003627, 0.034506, 1.105000, -0.018702, 1.002331, 0.025468, 1.113795, -0.012458, 1.001278,
- 0.016834, 1.122012, -0.006169, 1.000548, 0.008265, 1.129683, 0.000078, 0.999988, -0.000072,
- 0.000200, -0.000046, 1.052496, 0.228243, 0.000504, -0.000115, 1.052079, 0.228243, 0.002016,
- -0.000460, 1.052079, 0.228241, 0.004535, -0.001035, 1.052091, 0.228242, 0.008062, -0.001840,
- 1.051962, 0.228242, 0.012598, -0.002875, 1.052087, 0.228242, 0.018141, -0.004140, 1.052088,
- 0.228242, 0.024692, -0.005636, 1.052096, 0.228239, 0.032251, -0.007361, 1.052029, 0.228243,
- 0.040820, -0.009316, 1.052038, 0.228241, 0.050399, -0.011501, 1.052042, 0.228239, 0.060990,
- -0.013917, 1.052046, 0.228238, 0.072586, -0.016562, 1.051990, 0.228236, 0.085198, -0.019437,
- 1.051946, 0.228234, 0.098824, -0.022542, 1.051879, 0.228229, 0.113467, -0.025875, 1.051841,
- 0.228227, 0.129121, -0.029430, 1.051724, 0.228219, 0.145780, -0.033170, 1.051672, 0.228205,
- 0.163222, -0.036567, 1.051556, 0.228143, 0.181604, -0.040245, 1.051382, 0.228069, 0.200913,
- -0.044395, 1.051230, 0.228010, 0.221005, -0.049088, 1.051062, 0.227988, 0.241667, -0.054506,
- 1.050881, 0.228044, 0.263777, -0.059437, 1.050643, 0.227986, 0.286841, -0.063590, 1.050312,
- 0.227755, 0.310879, -0.068224, 1.050009, 0.227525, 0.335650, -0.072986, 1.049597, 0.227253,
- 0.360869, -0.077435, 1.049121, 0.226845, 0.386609, -0.082385, 1.048587, 0.226466, 0.412742,
- -0.087570, 1.047987, 0.226059, 0.439789, -0.091929, 1.047308, 0.225331, 0.467558, -0.096038,
- 1.046423, 0.224409, 0.495406, -0.099938, 1.045481, 0.223288, 0.523417, -0.104050, 1.044512,
- 0.222066, 0.551755, -0.107503, 1.043408, 0.220487, 0.580468, -0.110234, 1.042016, 0.218451,
- 0.608904, -0.112993, 1.040535, 0.216200, 0.637230, -0.115173, 1.038934, 0.213458, 0.665566,
- -0.116433, 1.036961, 0.210158, 0.693413, -0.117589, 1.035130, 0.206457, 0.721025, -0.117885,
- 1.033080, 0.202197, 0.748054, -0.117606, 1.030752, 0.197296, 0.774631, -0.116771, 1.028608,
- 0.191813, 0.800677, -0.115194, 1.026350, 0.185691, 0.826062, -0.113138, 1.024472, 0.179053,
- 0.850590, -0.110359, 1.022174, 0.171839, 0.874550, -0.107072, 1.020381, 0.164067, 0.897567,
- -0.103268, 1.018777, 0.155959, 0.919609, -0.098794, 1.016886, 0.147320, 0.941177, -0.094067,
- 1.015880, 0.138365, 0.961752, -0.088670, 1.014616, 0.129051, 0.981518, -0.082965, 1.013807,
- 0.119515, 0.999880, -0.076971, 1.012793, 0.109897, 1.017370, -0.070518, 1.011894, 0.099872,
- 1.033661, -0.063830, 1.010943, 0.089883, 1.048672, -0.057040, 1.009802, 0.079691, 1.062479,
- -0.049917, 1.008670, 0.069458, 1.075052, -0.042735, 1.007429, 0.059191, 1.086371, -0.035513,
- 1.005991, 0.048894, 1.096623, -0.028359, 1.004468, 0.038770, 1.105871, -0.021111, 1.002927,
- 0.028745, 1.114481, -0.013908, 1.001728, 0.018884, 1.122610, -0.006843, 1.000740, 0.009264,
- 1.130165, 0.000062, 0.999983, -0.000006, 0.000200, -0.000051, 1.064931, 0.254630, 0.000504,
- -0.000128, 1.064668, 0.254630, 0.002016, -0.000513, 1.064794, 0.254630, 0.004535, -0.001155,
- 1.064851, 0.254630, 0.008063, -0.002053, 1.064966, 0.254630, 0.012598, -0.003208, 1.064840,
- 0.254630, 0.018140, -0.004619, 1.064602, 0.254631, 0.024695, -0.006288, 1.064965, 0.254632,
- 0.032251, -0.008211, 1.064795, 0.254630, 0.040821, -0.010393, 1.064802, 0.254628, 0.050398,
- -0.012830, 1.064758, 0.254627, 0.060987, -0.015525, 1.064731, 0.254625, 0.072584, -0.018474,
- 1.064615, 0.254621, 0.085199, -0.021682, 1.064672, 0.254619, 0.098826, -0.025144, 1.064630,
- 0.254613, 0.113465, -0.028860, 1.064515, 0.254606, 0.129119, -0.032823, 1.064416, 0.254598,
- 0.145767, -0.036969, 1.064347, 0.254579, 0.163190, -0.040754, 1.064132, 0.254506, 0.181622,
- -0.044989, 1.063951, 0.254437, 0.200981, -0.049642, 1.063745, 0.254370, 0.221145, -0.054776,
- 1.063547, 0.254324, 0.241896, -0.060538, 1.063289, 0.254346, 0.263684, -0.066113, 1.063013,
- 0.254296, 0.286796, -0.070925, 1.062625, 0.254059, 0.310867, -0.076187, 1.062216, 0.253817,
- 0.335644, -0.081406, 1.061703, 0.253481, 0.360917, -0.086336, 1.061066, 0.253005, 0.386786,
- -0.091790, 1.060454, 0.252558, 0.412921, -0.097230, 1.059568, 0.252008, 0.439722, -0.102574,
- 1.058706, 0.251323, 0.467559, -0.106972, 1.057682, 0.250239, 0.495605, -0.111329, 1.056612,
- 0.248944, 0.523589, -0.115561, 1.055101, 0.247471, 0.551787, -0.119732, 1.053745, 0.245777,
- 0.580426, -0.122711, 1.051829, 0.243448, 0.608778, -0.125436, 1.049642, 0.240769, 0.637069,
- -0.127993, 1.047749, 0.237739, 0.665251, -0.129448, 1.045244, 0.233928, 0.692977, -0.130408,
- 1.042279, 0.229640, 0.720346, -0.130931, 1.039693, 0.224829, 0.747365, -0.130392, 1.036675,
- 0.219144, 0.773734, -0.129540, 1.033719, 0.212965, 0.799578, -0.127689, 1.030774, 0.206047,
- 0.825002, -0.125456, 1.028551, 0.198576, 0.849564, -0.122291, 1.025800, 0.190471, 0.873412,
- -0.118720, 1.023657, 0.181739, 0.896628, -0.114323, 1.021381, 0.172586, 0.918952, -0.109587,
- 1.019674, 0.162914, 0.940602, -0.104093, 1.018126, 0.153039, 0.960917, -0.098187, 1.016339,
- 0.142774, 0.980911, -0.091963, 1.015440, 0.132316, 0.999686, -0.085159, 1.014377, 0.121453,
- 1.017538, -0.078139, 1.013498, 0.110527, 1.033918, -0.070797, 1.012332, 0.099437, 1.049390,
- -0.063129, 1.011368, 0.088157, 1.063402, -0.055354, 1.010111, 0.076951, 1.076096, -0.047522,
- 1.008774, 0.065616, 1.087562, -0.039447, 1.007202, 0.054310, 1.097591, -0.031359, 1.005346,
- 0.042948, 1.106782, -0.023393, 1.003710, 0.031799, 1.115234, -0.015461, 1.002116, 0.020943,
- 1.123166, -0.007589, 1.000858, 0.010288, 1.130796, 0.000104, 1.000032, -0.000024, 0.000200,
- -0.000056, 1.078780, 0.281356, 0.000504, -0.000142, 1.079271, 0.281355, 0.002015, -0.000567,
- 1.078635, 0.281355, 0.004535, -0.001276, 1.079164, 0.281356, 0.008064, -0.002269, 1.079300,
- 0.281355, 0.012598, -0.003544, 1.079149, 0.281355, 0.018143, -0.005104, 1.079329, 0.281355,
- 0.024691, -0.006947, 1.079073, 0.281353, 0.032254, -0.009074, 1.079253, 0.281354, 0.040822,
- -0.011484, 1.079176, 0.281353, 0.050399, -0.014177, 1.079057, 0.281349, 0.060987, -0.017153,
- 1.079007, 0.281347, 0.072586, -0.020412, 1.078998, 0.281343, 0.085203, -0.023956, 1.078962,
- 0.281336, 0.098823, -0.027778, 1.078839, 0.281332, 0.113464, -0.031882, 1.078783, 0.281325,
- 0.129114, -0.036255, 1.078633, 0.281315, 0.145748, -0.040790, 1.078545, 0.281287, 0.163179,
- -0.045024, 1.078311, 0.281208, 0.181649, -0.049791, 1.078135, 0.281137, 0.201042, -0.054953,
- 1.077845, 0.281063, 0.221267, -0.060551, 1.077576, 0.281006, 0.242114, -0.066663, 1.077257,
- 0.280978, 0.263568, -0.072771, 1.076897, 0.280925, 0.286744, -0.078349, 1.076405, 0.280689,
- 0.310840, -0.084201, 1.075898, 0.280418, 0.335612, -0.089846, 1.075287, 0.280020, 0.360975,
- -0.095394, 1.074482, 0.279513, 0.386932, -0.101290, 1.073617, 0.278961, 0.413171, -0.107042,
- 1.072719, 0.278283, 0.439886, -0.113083, 1.071698, 0.277547, 0.467535, -0.118010, 1.070213,
- 0.276311, 0.495701, -0.122793, 1.068857, 0.274867, 0.523772, -0.127278, 1.067037, 0.273153,
- 0.551849, -0.131671, 1.064923, 0.271176, 0.580338, -0.135293, 1.062749, 0.268626, 0.608771,
- -0.138065, 1.059944, 0.265569, 0.636756, -0.140565, 1.056851, 0.262054, 0.664574, -0.142434,
- 1.053461, 0.257807, 0.692151, -0.143237, 1.049910, 0.252930, 0.719376, -0.143717, 1.046426,
- 0.247414, 0.745852, -0.143117, 1.042377, 0.241001, 0.772300, -0.141975, 1.038789, 0.233797,
- 0.798050, -0.140114, 1.035290, 0.226218, 0.823370, -0.137379, 1.032374, 0.217785, 0.847735,
- -0.134119, 1.028853, 0.208748, 0.871897, -0.129985, 1.026395, 0.198877, 0.894950, -0.125324,
- 1.023787, 0.188803, 0.917909, -0.120007, 1.022073, 0.178493, 0.939567, -0.114099, 1.020098,
- 0.167466, 0.960534, -0.107748, 1.018851, 0.156223, 0.980423, -0.100748, 1.017362, 0.144716,
- 0.999334, -0.093494, 1.015961, 0.133028, 1.017561, -0.085728, 1.015059, 0.120953, 1.034225,
- -0.077627, 1.013888, 0.108943, 1.049937, -0.069375, 1.012898, 0.096678, 1.064265, -0.060807,
- 1.011635, 0.084350, 1.077188, -0.052052, 1.010095, 0.071964, 1.088637, -0.043304, 1.008399,
- 0.059531, 1.098766, -0.034458, 1.006397, 0.047134, 1.107697, -0.025637, 1.004354, 0.034887,
- 1.116055, -0.016932, 1.002611, 0.022948, 1.123819, -0.008437, 1.001023, 0.011386, 1.131333,
- 0.000087, 0.999952, -0.000097, 0.000200, -0.000062, 1.095622, 0.308458, 0.000504, -0.000155,
- 1.094863, 0.308458, 0.002016, -0.000622, 1.095169, 0.308458, 0.004535, -0.001399, 1.095156,
- 0.308458, 0.008063, -0.002487, 1.095413, 0.308455, 0.012598, -0.003886, 1.095147, 0.308458,
- 0.018141, -0.005596, 1.095150, 0.308457, 0.024692, -0.007616, 1.095140, 0.308457, 0.032252,
- -0.009947, 1.095098, 0.308456, 0.040822, -0.012589, 1.095096, 0.308453, 0.050399, -0.015541,
- 1.095070, 0.308451, 0.060985, -0.018803, 1.094922, 0.308448, 0.072583, -0.022375, 1.094902,
- 0.308444, 0.085197, -0.026258, 1.094882, 0.308438, 0.098822, -0.030448, 1.094775, 0.308429,
- 0.113460, -0.034944, 1.094641, 0.308419, 0.129112, -0.039731, 1.094530, 0.308403, 0.145711,
- -0.044610, 1.094332, 0.308365, 0.163178, -0.049362, 1.094149, 0.308285, 0.181679, -0.054666,
- 1.093876, 0.308210, 0.201109, -0.060336, 1.093603, 0.308132, 0.221388, -0.066414, 1.093250,
- 0.308047, 0.242315, -0.072881, 1.092835, 0.307985, 0.263651, -0.079453, 1.092391, 0.307902,
- 0.286720, -0.085882, 1.091866, 0.307688, 0.310817, -0.092274, 1.091225, 0.307379, 0.335562,
- -0.098306, 1.090346, 0.306906, 0.361043, -0.104572, 1.089423, 0.306374, 0.387051, -0.110843,
- 1.088437, 0.305710, 0.413405, -0.117062, 1.087228, 0.304906, 0.440122, -0.123501, 1.085879,
- 0.304017, 0.467522, -0.129245, 1.084197, 0.302783, 0.495721, -0.134285, 1.082284, 0.301104,
- 0.523925, -0.139143, 1.080109, 0.299142, 0.551814, -0.143638, 1.077043, 0.296825, 0.579878,
- -0.147774, 1.074071, 0.294071, 0.608316, -0.150724, 1.070621, 0.290519, 0.636059, -0.153168,
- 1.066390, 0.286424, 0.663481, -0.155139, 1.062069, 0.281559, 0.690753, -0.155944, 1.057211,
- 0.276024, 0.717767, -0.156176, 1.052682, 0.269622, 0.743937, -0.155783, 1.047747, 0.262532,
- 0.770214, -0.154245, 1.043510, 0.254609, 0.795542, -0.152192, 1.039121, 0.246007, 0.821099,
- -0.149256, 1.035962, 0.236663, 0.845452, -0.145605, 1.032320, 0.226751, 0.869780, -0.141186,
- 1.029390, 0.216165, 0.893141, -0.136137, 1.026485, 0.204937, 0.916034, -0.130332, 1.024389,
- 0.193624, 0.938089, -0.124040, 1.022270, 0.181756, 0.959488, -0.117011, 1.020457, 0.169339,
- 0.979594, -0.109617, 1.018871, 0.156875, 0.998912, -0.101562, 1.017533, 0.144288, 1.017100,
- -0.093164, 1.016445, 0.131370, 1.034413, -0.084488, 1.015453, 0.118322, 1.050347, -0.075377,
- 1.014259, 0.104963, 1.064958, -0.066108, 1.013057, 0.091722, 1.078045, -0.056702, 1.011491,
- 0.078231, 1.089749, -0.047106, 1.009662, 0.064797, 1.099831, -0.037467, 1.007417, 0.051315,
- 1.108789, -0.027990, 1.005144, 0.038064, 1.116865, -0.018464, 1.002925, 0.025008, 1.124609,
- -0.009068, 1.001221, 0.012250, 1.132040, 0.000093, 0.999984, -0.000071, 0.000200, -0.000067,
- 1.112554, 0.335981, 0.000504, -0.000169, 1.112660, 0.335981, 0.002016, -0.000677, 1.112827,
- 0.335981, 0.004533, -0.001523, 1.112147, 0.335982, 0.008063, -0.002709, 1.112882, 0.335979,
- 0.012598, -0.004233, 1.112891, 0.335980, 0.018141, -0.006095, 1.112882, 0.335980, 0.024693,
- -0.008296, 1.112877, 0.335978, 0.032252, -0.010834, 1.112860, 0.335976, 0.040824, -0.013713,
- 1.112965, 0.335974, 0.050398, -0.016927, 1.112753, 0.335971, 0.060991, -0.020482, 1.112826,
- 0.335970, 0.072587, -0.024371, 1.112676, 0.335962, 0.085199, -0.028597, 1.112593, 0.335955,
- 0.098822, -0.033159, 1.112453, 0.335943, 0.113461, -0.038052, 1.112329, 0.335930, 0.129108,
- -0.043255, 1.112144, 0.335910, 0.145665, -0.048412, 1.111905, 0.335857, 0.163185, -0.053786,
- 1.111668, 0.335781, 0.181710, -0.059608, 1.111345, 0.335696, 0.201166, -0.065794, 1.110979,
- 0.335606, 0.221489, -0.072361, 1.110553, 0.335505, 0.242471, -0.079184, 1.110112, 0.335396,
- 0.263900, -0.086213, 1.109584, 0.335271, 0.286688, -0.093491, 1.108927, 0.335089, 0.310773,
- -0.100406, 1.108091, 0.334737, 0.335573, -0.106987, 1.107169, 0.334208, 0.361117, -0.113844,
- 1.106097, 0.333600, 0.387175, -0.120463, 1.104826, 0.332828, 0.413665, -0.127245, 1.103415,
- 0.331929, 0.440386, -0.133927, 1.101632, 0.330851, 0.467527, -0.140496, 1.099563, 0.329538,
- 0.495630, -0.145874, 1.096956, 0.327618, 0.523864, -0.150997, 1.094201, 0.325390, 0.551705,
- -0.155713, 1.090342, 0.322688, 0.579383, -0.159993, 1.086010, 0.319483, 0.607301, -0.163238,
- 1.081226, 0.315522, 0.634873, -0.165667, 1.076065, 0.310840, 0.662028, -0.167606, 1.070466,
- 0.305377, 0.688755, -0.168626, 1.064601, 0.299056, 0.715612, -0.168578, 1.059269, 0.291963,
- 0.741604, -0.167961, 1.053648, 0.284018, 0.767757, -0.166439, 1.048928, 0.275474, 0.793264,
- -0.164023, 1.044343, 0.266056, 0.818165, -0.160965, 1.039909, 0.255750, 0.843255, -0.156896,
- 1.036180, 0.244843, 0.867249, -0.152262, 1.032303, 0.233464, 0.890994, -0.146655, 1.029365,
- 0.221128, 0.913829, -0.140574, 1.026607, 0.208554, 0.936508, -0.133640, 1.024512, 0.195772,
- 0.957720, -0.126220, 1.022421, 0.182420, 0.978940, -0.118164, 1.021293, 0.168852, 0.998285,
- -0.109558, 1.019444, 0.155261, 1.016764, -0.100562, 1.017825, 0.141395, 1.034387, -0.091064,
- 1.016996, 0.127311, 1.050916, -0.081468, 1.015945, 0.113089, 1.065652, -0.071463, 1.014547,
- 0.098879, 1.079155, -0.061240, 1.013066, 0.084468, 1.090822, -0.050980, 1.010788, 0.069940,
- 1.101100, -0.040549, 1.008563, 0.055475, 1.109824, -0.030101, 1.005950, 0.041033, 1.117828,
- -0.019884, 1.003453, 0.027022, 1.125443, -0.009900, 1.001484, 0.013306, 1.132869, 0.000094,
- 1.000004, -0.000046, 0.000200, -0.000073, 1.132849, 0.363970, 0.000504, -0.000183, 1.132155,
- 0.363969, 0.002016, -0.000734, 1.132516, 0.363969, 0.004535, -0.001651, 1.132256, 0.363969,
- 0.008062, -0.002934, 1.132318, 0.363966, 0.012597, -0.004585, 1.132386, 0.363968, 0.018141,
- -0.006602, 1.132457, 0.363967, 0.024693, -0.008987, 1.132511, 0.363967, 0.032252, -0.011737,
- 1.132488, 0.363965, 0.040819, -0.014853, 1.132241, 0.363959, 0.050398, -0.018336, 1.132372,
- 0.363958, 0.060988, -0.022185, 1.132373, 0.363954, 0.072582, -0.026396, 1.132137, 0.363943,
- 0.085195, -0.030973, 1.132071, 0.363935, 0.098822, -0.035913, 1.131978, 0.363922, 0.113461,
- -0.041209, 1.131801, 0.363905, 0.129116, -0.046833, 1.131535, 0.363867, 0.145640, -0.052346,
- 1.131290, 0.363814, 0.163199, -0.058275, 1.131046, 0.363734, 0.181742, -0.064623, 1.130671,
- 0.363642, 0.201227, -0.071336, 1.130224, 0.363539, 0.221587, -0.078396, 1.129758, 0.363419,
- 0.242625, -0.085545, 1.129213, 0.363256, 0.264183, -0.093110, 1.128549, 0.363097, 0.286668,
- -0.101206, 1.127767, 0.362939, 0.310745, -0.108586, 1.126796, 0.362516, 0.335602, -0.115827,
- 1.125686, 0.361953, 0.361202, -0.123212, 1.124451, 0.361275, 0.387298, -0.130294, 1.122861,
- 0.360376, 0.413918, -0.137553, 1.121154, 0.359362, 0.440680, -0.144577, 1.118825, 0.358069,
- 0.467667, -0.151558, 1.116002, 0.356581, 0.495449, -0.157621, 1.112778, 0.354531, 0.523514,
- -0.162844, 1.108842, 0.351915, 0.551250, -0.167744, 1.104075, 0.348797, 0.578629, -0.172132,
- 1.098733, 0.345222, 0.605757, -0.175733, 1.092224, 0.340665, 0.633392, -0.178109, 1.086201,
- 0.335286, 0.660783, -0.180009, 1.080110, 0.329286, 0.687219, -0.181105, 1.073419, 0.322319,
- 0.713873, -0.181046, 1.067410, 0.314616, 0.740094, -0.180219, 1.061414, 0.306014, 0.765233,
- -0.178559, 1.055287, 0.296704, 0.790885, -0.175806, 1.049727, 0.286394, 0.815464, -0.172354,
- 1.044519, 0.275189, 0.840259, -0.168048, 1.040375, 0.263441, 0.864285, -0.162904, 1.036010,
- 0.250918, 0.888806, -0.157194, 1.033525, 0.237611, 0.911682, -0.150486, 1.029490, 0.223809,
- 0.934481, -0.143212, 1.026778, 0.209705, 0.956337, -0.135233, 1.024632, 0.195281, 0.977380,
- -0.126650, 1.022737, 0.180878, 0.997427, -0.117552, 1.021110, 0.166112, 1.016666, -0.107814,
- 1.019869, 0.151231, 1.034337, -0.097814, 1.018543, 0.136375, 1.051082, -0.087330, 1.017476,
- 0.121187, 1.066326, -0.076614, 1.016083, 0.106043, 1.079897, -0.065793, 1.014227, 0.090566,
- 1.092136, -0.054654, 1.012334, 0.074988, 1.102315, -0.043516, 1.009627, 0.059577, 1.111105,
- -0.032509, 1.006808, 0.044202, 1.118861, -0.021381, 1.003917, 0.028995, 1.126363, -0.010489,
- 1.001670, 0.014269, 1.133598, 0.000083, 0.999989, -0.000035, 0.000200, -0.000079, 1.155026,
- 0.392470, 0.000504, -0.000198, 1.154184, 0.392469, 0.002016, -0.000791, 1.153990, 0.392469,
- 0.004535, -0.001780, 1.154045, 0.392469, 0.008063, -0.003164, 1.154007, 0.392466, 0.012598,
- -0.004944, 1.154022, 0.392469, 0.018141, -0.007119, 1.154015, 0.392468, 0.024692, -0.009690,
- 1.154017, 0.392466, 0.032254, -0.012656, 1.154069, 0.392465, 0.040826, -0.016018, 1.153980,
- 0.392459, 0.050399, -0.019771, 1.153911, 0.392456, 0.060987, -0.023919, 1.153860, 0.392447,
- 0.072588, -0.028461, 1.153777, 0.392442, 0.085197, -0.033393, 1.153582, 0.392428, 0.098822,
- -0.038716, 1.153434, 0.392412, 0.113462, -0.044422, 1.153271, 0.392390, 0.129101, -0.050455,
- 1.153019, 0.392359, 0.145642, -0.056392, 1.152721, 0.392283, 0.163223, -0.062859, 1.152404,
- 0.392201, 0.181779, -0.069721, 1.151941, 0.392099, 0.201289, -0.076968, 1.151422, 0.391978,
- 0.221678, -0.084518, 1.150861, 0.391833, 0.242752, -0.092017, 1.150156, 0.391618, 0.264474,
- -0.100184, 1.149402, 0.391421, 0.286768, -0.108921, 1.148545, 0.391249, 0.310719, -0.116815,
- 1.147388, 0.390773, 0.335638, -0.124785, 1.146042, 0.390168, 0.361240, -0.132630, 1.144529,
- 0.389394, 0.387443, -0.140298, 1.142602, 0.388391, 0.414067, -0.147913, 1.140361, 0.387199,
- 0.440904, -0.155362, 1.137612, 0.385742, 0.467771, -0.162574, 1.133659, 0.383926, 0.494907,
- -0.169312, 1.129246, 0.381715, 0.522801, -0.174778, 1.124228, 0.378678, 0.550751, -0.179824,
- 1.118697, 0.375158, 0.578018, -0.184284, 1.112019, 0.370851, 0.605291, -0.188215, 1.105151,
- 0.365928, 0.632269, -0.190760, 1.097677, 0.360114, 0.659432, -0.192457, 1.090816, 0.353498,
- 0.685839, -0.193458, 1.083286, 0.346094, 0.711876, -0.193502, 1.076245, 0.337754, 0.738184,
- -0.192371, 1.069684, 0.328412, 0.763723, -0.190531, 1.063249, 0.318164, 0.789192, -0.187726,
- 1.057265, 0.306900, 0.813744, -0.183783, 1.051177, 0.295021, 0.838408, -0.179328, 1.045902,
- 0.282144, 0.862116, -0.173573, 1.040853, 0.268438, 0.885636, -0.167350, 1.036515, 0.254108,
- 0.909342, -0.160229, 1.033269, 0.239082, 0.931962, -0.152529, 1.029627, 0.224024, 0.954671,
- -0.144080, 1.027507, 0.208393, 0.975707, -0.135023, 1.024657, 0.192630, 0.996644, -0.125258,
- 1.022998, 0.176741, 1.015817, -0.115089, 1.021234, 0.160926, 1.034301, -0.104317, 1.020025,
- 0.145042, 1.051131, -0.093218, 1.018739, 0.129052, 1.066836, -0.081828, 1.017419, 0.112905,
- 1.081027, -0.070132, 1.015714, 0.096578, 1.093225, -0.058382, 1.013465, 0.080077, 1.103691,
- -0.046527, 1.010853, 0.063580, 1.112431, -0.034624, 1.007702, 0.047118, 1.120035, -0.022913,
- 1.004551, 0.031018, 1.127336, -0.011284, 1.001924, 0.015283, 1.134510, 0.000170, 0.999937,
- -0.000058, 0.000200, -0.000084, 1.177044, 0.421534, 0.000504, -0.000212, 1.177312, 0.421533,
- 0.002016, -0.000850, 1.177730, 0.421533, 0.004535, -0.001912, 1.177722, 0.421533, 0.008063,
- -0.003399, 1.177844, 0.421529, 0.012598, -0.005310, 1.177768, 0.421533, 0.018141, -0.007646,
- 1.177730, 0.421531, 0.024692, -0.010407, 1.177663, 0.421530, 0.032252, -0.013592, 1.177681,
- 0.421527, 0.040821, -0.017201, 1.177562, 0.421524, 0.050401, -0.021234, 1.177445, 0.421516,
- 0.060988, -0.025688, 1.177461, 0.421509, 0.072590, -0.030565, 1.177364, 0.421498, 0.085200,
- -0.035860, 1.177205, 0.421482, 0.098823, -0.041572, 1.177011, 0.421462, 0.113465, -0.047694,
- 1.176794, 0.421436, 0.129094, -0.054122, 1.176504, 0.421396, 0.145652, -0.060530, 1.176203,
- 0.421311, 0.163245, -0.067517, 1.175805, 0.421218, 0.181825, -0.074919, 1.175271, 0.421108,
- 0.201360, -0.082700, 1.174717, 0.420974, 0.221773, -0.090727, 1.174021, 0.420795, 0.242908,
- -0.098719, 1.173173, 0.420536, 0.264742, -0.107417, 1.172285, 0.420296, 0.287091, -0.116601,
- 1.171326, 0.420065, 0.310723, -0.125265, 1.169907, 0.419582, 0.335685, -0.133876, 1.168352,
- 0.418912, 0.361285, -0.142140, 1.166322, 0.418006, 0.387562, -0.150436, 1.164136, 0.416899,
- 0.414175, -0.158388, 1.161162, 0.415513, 0.441021, -0.166258, 1.157608, 0.413836, 0.467698,
- -0.173720, 1.152519, 0.411702, 0.494730, -0.180843, 1.147020, 0.409102, 0.522524, -0.186906,
- 1.141256, 0.405789, 0.550055, -0.192004, 1.134114, 0.401759, 0.577512, -0.196588, 1.127086,
- 0.397153, 0.604348, -0.200420, 1.119029, 0.391767, 0.630970, -0.203320, 1.110308, 0.385573,
- 0.658023, -0.204883, 1.102643, 0.378245, 0.684422, -0.205716, 1.094573, 0.370191, 0.710405,
- -0.205767, 1.086405, 0.361231, 0.736417, -0.204513, 1.078712, 0.351106, 0.761836, -0.202281,
- 1.071619, 0.340096, 0.787140, -0.199395, 1.064873, 0.328139, 0.812197, -0.195185, 1.058313,
- 0.315044, 0.836342, -0.190191, 1.052085, 0.300933, 0.860311, -0.184343, 1.046705, 0.286411,
- 0.883597, -0.177415, 1.041072, 0.270897, 0.906852, -0.170003, 1.036797, 0.254825, 0.929991,
- -0.161592, 1.033264, 0.238176, 0.952478, -0.152792, 1.030250, 0.221581, 0.974216, -0.143032,
- 1.027331, 0.204378, 0.995372, -0.132922, 1.025135, 0.187470, 1.015330, -0.122009, 1.023250,
- 0.170538, 1.034070, -0.110740, 1.022021, 0.153777, 1.051295, -0.099016, 1.020271, 0.136916,
- 1.067460, -0.086920, 1.018948, 0.119880, 1.082022, -0.074729, 1.017336, 0.102565, 1.094378,
- -0.062036, 1.014820, 0.084994, 1.104998, -0.049413, 1.011999, 0.067650, 1.113773, -0.036812,
- 1.008711, 0.050148, 1.121263, -0.024274, 1.005141, 0.032976, 1.128420, -0.012038, 1.002196,
- 0.016239, 1.135496, 0.000106, 1.000042, -0.000062, 0.000200, -0.000090, 1.203048, 0.451217,
- 0.000504, -0.000227, 1.203226, 0.451215, 0.002016, -0.000909, 1.203450, 0.451215, 0.004535,
- -0.002046, 1.203569, 0.451215, 0.008062, -0.003638, 1.203609, 0.451209, 0.012598, -0.005684,
- 1.203580, 0.451214, 0.018141, -0.008185, 1.203515, 0.451212, 0.024694, -0.011141, 1.203618,
- 0.451211, 0.032253, -0.014549, 1.203609, 0.451207, 0.040815, -0.018409, 1.203302, 0.451203,
- 0.050401, -0.022727, 1.203454, 0.451195, 0.060990, -0.027495, 1.203480, 0.451188, 0.072591,
- -0.032713, 1.203220, 0.451172, 0.085203, -0.038378, 1.203058, 0.451154, 0.098829, -0.044489,
- 1.202838, 0.451130, 0.113466, -0.051031, 1.202530, 0.451098, 0.129084, -0.057808, 1.202270,
- 0.451041, 0.145669, -0.064769, 1.201904, 0.450956, 0.163278, -0.072278, 1.201411, 0.450853,
- 0.181880, -0.080224, 1.200825, 0.450721, 0.201436, -0.088537, 1.200164, 0.450566, 0.221865,
- -0.097009, 1.199335, 0.450351, 0.243083, -0.105591, 1.198383, 0.450062, 0.265033, -0.114818,
- 1.197380, 0.449769, 0.287456, -0.124372, 1.196137, 0.449438, 0.310758, -0.133892, 1.194554,
- 0.448974, 0.335721, -0.143052, 1.192649, 0.448216, 0.361348, -0.151868, 1.190233, 0.447202,
- 0.387573, -0.160644, 1.187211, 0.445926, 0.414159, -0.169028, 1.183452, 0.444313, 0.440950,
- -0.177169, 1.178562, 0.442315, 0.467998, -0.185090, 1.173540, 0.439960, 0.494566, -0.192396,
- 1.166344, 0.436989, 0.521730, -0.198915, 1.159283, 0.433439, 0.549405, -0.204240, 1.151503,
- 0.428984, 0.576755, -0.208861, 1.143004, 0.423839, 0.603635, -0.212734, 1.134099, 0.418012,
- 0.629979, -0.215712, 1.124555, 0.411445, 0.656597, -0.217385, 1.115293, 0.403628, 0.683317,
- -0.218093, 1.106460, 0.394639, 0.708990, -0.217835, 1.097389, 0.385012, 0.734898, -0.216774,
- 1.088940, 0.373999, 0.760342, -0.214120, 1.080385, 0.362128, 0.785517, -0.210821, 1.072959,
- 0.349184, 0.809933, -0.206443, 1.065450, 0.335080, 0.834339, -0.200942, 1.058701, 0.320257,
- 0.858793, -0.194938, 1.052711, 0.304133, 0.882300, -0.187615, 1.047044, 0.287771, 0.905560,
- -0.179626, 1.042083, 0.270571, 0.927916, -0.170753, 1.037077, 0.252741, 0.950415, -0.161270,
- 1.033200, 0.234656, 0.972920, -0.151239, 1.030418, 0.216652, 0.993893, -0.140358, 1.027479,
- 0.198252, 1.014204, -0.128963, 1.024897, 0.180113, 1.033878, -0.117128, 1.023648, 0.162282,
- 1.051754, -0.104678, 1.022230, 0.144366, 1.067924, -0.092000, 1.020453, 0.126455, 1.082643,
- -0.078837, 1.018518, 0.108194, 1.095503, -0.065669, 1.016199, 0.089966, 1.106290, -0.052345,
- 1.013113, 0.071530, 1.115219, -0.039024, 1.009636, 0.053158, 1.122587, -0.025789, 1.005801,
- 0.034959, 1.129461, -0.012622, 1.002442, 0.017222, 1.136468, 0.000152, 0.999964, -0.000065,
- 0.000200, -0.000096, 1.231156, 0.481574, 0.000504, -0.000243, 1.232187, 0.481572, 0.002016,
- -0.000971, 1.231948, 0.481572, 0.004535, -0.002184, 1.231919, 0.481572, 0.008061, -0.003882,
- 1.231453, 0.481566, 0.012597, -0.006066, 1.231800, 0.481572, 0.018142, -0.008736, 1.231756,
- 0.481569, 0.024693, -0.011889, 1.232062, 0.481570, 0.032254, -0.015528, 1.231915, 0.481563,
- 0.040822, -0.019650, 1.231863, 0.481559, 0.050402, -0.024255, 1.231737, 0.481550, 0.060992,
- -0.029342, 1.231678, 0.481537, 0.072592, -0.034908, 1.231537, 0.481521, 0.085207, -0.040953,
- 1.231336, 0.481499, 0.098834, -0.047469, 1.231071, 0.481469, 0.113474, -0.054441, 1.230757,
- 0.481431, 0.129077, -0.061556, 1.230424, 0.481359, 0.145691, -0.069091, 1.230022, 0.481269,
- 0.163321, -0.077151, 1.229461, 0.481156, 0.181936, -0.085636, 1.228718, 0.481011, 0.201516,
- -0.094484, 1.228023, 0.480830, 0.221963, -0.103362, 1.227057, 0.480562, 0.243264, -0.112628,
- 1.225997, 0.480247, 0.265291, -0.122366, 1.224744, 0.479891, 0.287824, -0.132256, 1.223255,
- 0.479461, 0.310927, -0.142614, 1.221348, 0.478978, 0.335749, -0.152326, 1.218953, 0.478132,
- 0.361361, -0.161747, 1.215806, 0.476971, 0.387480, -0.170879, 1.211853, 0.475477, 0.414231,
- -0.179865, 1.207783, 0.473686, 0.441065, -0.188331, 1.202051, 0.471415, 0.467923, -0.196454,
- 1.195463, 0.468647, 0.494526, -0.204048, 1.187542, 0.465459, 0.521318, -0.211020, 1.179235,
- 0.461650, 0.548654, -0.216520, 1.170110, 0.456868, 0.575778, -0.221098, 1.160163, 0.451227,
- 0.602610, -0.224923, 1.149751, 0.444866, 0.628891, -0.227895, 1.139169, 0.437577, 0.655635,
- -0.230020, 1.129736, 0.429369, 0.682115, -0.230419, 1.119516, 0.419673, 0.707514, -0.229789,
- 1.108277, 0.409143, 0.733169, -0.228520, 1.099159, 0.397296, 0.758342, -0.225793, 1.089839,
- 0.384578, 0.783477, -0.222049, 1.081428, 0.370323, 0.808497, -0.217562, 1.073742, 0.355253,
- 0.832790, -0.211697, 1.065850, 0.339282, 0.856677, -0.204989, 1.058834, 0.322181, 0.880662,
- -0.197653, 1.053291, 0.304610, 0.903474, -0.188858, 1.046822, 0.286042, 0.926313, -0.179746,
- 1.041663, 0.267224, 0.948458, -0.169542, 1.036532, 0.247978, 0.970873, -0.159005, 1.033008,
- 0.228535, 0.992958, -0.147658, 1.029844, 0.208819, 1.013413, -0.135771, 1.026930, 0.189486,
- 1.033483, -0.123256, 1.025545, 0.170422, 1.051872, -0.110401, 1.023935, 0.152075, 1.068396,
- -0.096860, 1.022092, 0.133169, 1.083731, -0.083259, 1.020221, 0.114022, 1.096849, -0.069266,
- 1.017663, 0.094772, 1.107864, -0.055203, 1.014524, 0.075432, 1.116600, -0.041097, 1.010514,
- 0.055980, 1.123871, -0.027083, 1.006313, 0.036839, 1.130718, -0.013510, 1.002778, 0.018156,
- 1.137649, 0.000154, 1.000033, -0.000028, 0.000200, -0.000103, 1.264025, 0.512670, 0.000504,
- -0.000258, 1.262437, 0.512667, 0.002016, -0.001033, 1.262691, 0.512668, 0.004535, -0.002325,
- 1.262834, 0.512667, 0.008063, -0.004133, 1.262783, 0.512659, 0.012598, -0.006458, 1.262803,
- 0.512666, 0.018141, -0.009299, 1.262720, 0.512665, 0.024683, -0.012652, 1.262061, 0.512655,
- 0.032257, -0.016532, 1.262858, 0.512656, 0.040826, -0.020919, 1.262709, 0.512649, 0.050403,
- -0.025820, 1.262685, 0.512639, 0.060993, -0.031233, 1.262544, 0.512625, 0.072597, -0.037157,
- 1.262435, 0.512607, 0.085211, -0.043587, 1.262209, 0.512581, 0.098842, -0.050520, 1.261907,
- 0.512544, 0.113484, -0.057926, 1.261575, 0.512500, 0.129097, -0.065460, 1.261293, 0.512420,
- 0.145727, -0.073543, 1.260736, 0.512316, 0.163375, -0.082134, 1.260117, 0.512190, 0.182011,
- -0.091173, 1.259299, 0.512024, 0.201598, -0.100540, 1.258381, 0.511810, 0.222084, -0.109931,
- 1.257293, 0.511505, 0.243446, -0.119838, 1.256050, 0.511151, 0.265574, -0.130090, 1.254607,
- 0.510724, 0.288230, -0.140421, 1.252808, 0.510191, 0.311336, -0.151343, 1.250489, 0.509627,
- 0.335719, -0.161689, 1.247279, 0.508688, 0.361314, -0.171748, 1.243467, 0.507393, 0.387541,
- -0.181399, 1.239145, 0.505758, 0.414204, -0.190768, 1.233760, 0.503676, 0.441092, -0.199659,
- 1.227433, 0.501129, 0.467789, -0.207934, 1.219247, 0.498078, 0.494454, -0.215747, 1.210441,
- 0.494630, 0.520950, -0.222869, 1.200559, 0.490467, 0.547802, -0.228881, 1.189872, 0.485444,
- 0.575563, -0.233760, 1.180081, 0.479268, 0.602426, -0.237566, 1.168544, 0.472272, 0.628772,
- -0.240447, 1.156546, 0.464390, 0.654963, -0.242427, 1.145123, 0.455345, 0.681384, -0.242980,
- 1.134322, 0.444885, 0.707173, -0.242150, 1.122665, 0.433338, 0.732477, -0.240435, 1.111733,
- 0.420647, 0.757567, -0.237806, 1.101271, 0.406799, 0.782341, -0.233503, 1.091341, 0.391761,
- 0.806690, -0.228346, 1.082042, 0.375576, 0.830804, -0.222386, 1.073504, 0.358545, 0.854940,
- -0.215141, 1.065880, 0.340431, 0.878709, -0.207207, 1.058850, 0.321690, 0.901928, -0.198273,
- 1.052588, 0.301930, 0.924845, -0.188476, 1.046521, 0.281513, 0.946932, -0.177996, 1.040966,
- 0.261234, 0.969256, -0.166644, 1.036670, 0.240356, 0.991323, -0.154968, 1.032694, 0.219748,
- 1.013013, -0.142425, 1.030061, 0.199103, 1.032845, -0.129456, 1.027254, 0.178936, 1.051887,
- -0.115763, 1.025497, 0.159243, 1.069179, -0.101851, 1.023807, 0.139560, 1.084499, -0.087357,
- 1.021441, 0.119607, 1.097921, -0.072796, 1.018780, 0.099501, 1.109281, -0.058037, 1.015566,
- 0.079211, 1.118194, -0.043226, 1.011494, 0.058873, 1.125351, -0.028633, 1.007089, 0.038736,
- 1.132002, -0.013996, 1.003014, 0.019063, 1.138951, 0.000132, 1.000036, -0.000007, 0.000200,
- -0.000109, 1.296791, 0.544571, 0.000504, -0.000274, 1.296055, 0.544568, 0.002016, -0.001098,
- 1.297239, 0.544568, 0.004535, -0.002470, 1.296600, 0.544568, 0.008062, -0.004390, 1.296368,
- 0.544559, 0.012597, -0.006860, 1.296454, 0.544566, 0.018141, -0.009878, 1.296522, 0.544565,
- 0.024693, -0.013444, 1.296536, 0.544560, 0.032256, -0.017559, 1.296638, 0.544557, 0.040824,
- -0.022218, 1.296491, 0.544547, 0.050408, -0.027426, 1.296552, 0.544532, 0.060997, -0.033173,
- 1.296283, 0.544518, 0.072600, -0.039463, 1.296113, 0.544496, 0.085220, -0.046292, 1.295894,
- 0.544466, 0.098851, -0.053648, 1.295545, 0.544422, 0.113496, -0.061487, 1.295201, 0.544371,
- 0.129112, -0.069467, 1.294754, 0.544273, 0.145765, -0.078092, 1.294209, 0.544160, 0.163431,
- -0.087231, 1.293534, 0.544017, 0.182088, -0.096837, 1.292580, 0.543828, 0.201698, -0.106713,
- 1.291586, 0.543585, 0.222231, -0.116699, 1.290325, 0.543238, 0.243653, -0.127208, 1.288888,
- 0.542836, 0.265855, -0.137949, 1.287131, 0.542329, 0.288623, -0.148847, 1.284936, 0.541700,
- 0.311830, -0.160204, 1.282109, 0.540997, 0.335728, -0.171324, 1.278036, 0.540045, 0.361403,
- -0.181915, 1.273912, 0.538603, 0.387647, -0.192124, 1.268881, 0.536741, 0.414217, -0.201807,
- 1.262363, 0.534432, 0.441090, -0.211093, 1.254755, 0.531623, 0.467823, -0.219678, 1.245456,
- 0.528314, 0.494361, -0.227581, 1.234953, 0.524391, 0.521264, -0.235087, 1.224839, 0.519902,
- 0.547881, -0.241508, 1.213175, 0.514574, 0.574965, -0.246315, 1.200505, 0.507837, 0.601847,
- -0.250061, 1.187901, 0.500286, 0.628207, -0.252822, 1.174601, 0.491502, 0.654445, -0.254691,
- 1.161944, 0.481726, 0.680175, -0.255318, 1.149305, 0.470727, 0.706168, -0.254257, 1.136708,
- 0.458045, 0.731458, -0.252100, 1.124047, 0.444438, 0.756378, -0.249115, 1.112942, 0.429611,
- 0.781311, -0.244899, 1.101800, 0.413501, 0.805755, -0.239225, 1.091662, 0.395889, 0.829867,
- -0.232830, 1.082291, 0.377860, 0.853067, -0.225193, 1.072820, 0.358704, 0.877084, -0.216648,
- 1.065415, 0.338413, 0.900123, -0.207390, 1.058403, 0.317596, 0.923370, -0.197095, 1.051412,
- 0.296301, 0.946021, -0.186084, 1.045877, 0.274498, 0.967669, -0.174262, 1.040316, 0.252565,
- 0.989761, -0.161814, 1.035489, 0.230312, 1.012163, -0.149076, 1.032540, 0.208746, 1.032547,
- -0.135299, 1.029598, 0.187180, 1.052032, -0.121277, 1.027355, 0.166482, 1.069907, -0.106582,
- 1.025622, 0.145939, 1.085563, -0.091589, 1.023244, 0.125362, 1.099447, -0.076263, 1.020661,
- 0.104087, 1.110848, -0.060825, 1.017035, 0.083036, 1.119923, -0.045319, 1.012675, 0.061719,
- 1.126805, -0.029852, 1.007668, 0.040583, 1.133282, -0.014846, 1.003335, 0.019969, 1.140128,
- 0.000149, 1.000024, -0.000037, 0.000200, -0.000116, 1.334863, 0.577350, 0.000504, -0.000291,
- 1.333350, 0.577348, 0.002015, -0.001164, 1.332853, 0.577347, 0.004535, -0.002618, 1.333295,
- 0.577347, 0.008062, -0.004655, 1.333189, 0.577336, 0.012598, -0.007273, 1.333309, 0.577345,
- 0.018141, -0.010472, 1.333274, 0.577342, 0.024694, -0.014253, 1.333231, 0.577339, 0.032254,
- -0.018614, 1.333265, 0.577332, 0.040827, -0.023556, 1.333261, 0.577321, 0.050400, -0.029069,
- 1.332893, 0.577309, 0.061000, -0.035166, 1.332998, 0.577288, 0.072608, -0.041833, 1.332901,
- 0.577263, 0.085227, -0.049067, 1.332603, 0.577226, 0.098864, -0.056860, 1.332264, 0.577177,
- 0.113507, -0.065114, 1.331825, 0.577109, 0.129146, -0.073610, 1.331311, 0.577005, 0.145808,
- -0.082766, 1.330639, 0.576872, 0.163494, -0.092458, 1.329878, 0.576709, 0.182176, -0.102639,
- 1.328889, 0.576501, 0.201804, -0.112983, 1.327710, 0.576207, 0.222394, -0.123650, 1.326256,
- 0.575823, 0.243881, -0.134780, 1.324593, 0.575363, 0.266122, -0.145931, 1.322426, 0.574751,
- 0.289043, -0.157500, 1.319837, 0.574033, 0.312330, -0.169208, 1.316301, 0.573181, 0.336120,
- -0.181125, 1.312251, 0.572188, 0.361506, -0.192232, 1.307003, 0.570631, 0.387757, -0.202981,
- 1.301068, 0.568558, 0.414365, -0.213160, 1.293695, 0.566027, 0.440986, -0.222617, 1.283958,
- 0.562942, 0.467943, -0.231583, 1.274057, 0.559219, 0.494821, -0.239881, 1.262864, 0.554913,
- 0.521486, -0.247336, 1.250633, 0.549953, 0.547884, -0.253921, 1.237448, 0.544251, 0.574582,
- -0.259099, 1.223164, 0.537120, 0.601342, -0.262695, 1.208784, 0.528650, 0.627861, -0.265337,
- 1.194424, 0.518978, 0.653745, -0.266872, 1.179361, 0.508525, 0.679348, -0.267403, 1.165010,
- 0.496705, 0.705068, -0.266429, 1.151693, 0.482926, 0.730312, -0.263829, 1.137584, 0.468519,
- 0.755576, -0.260491, 1.125328, 0.452213, 0.780371, -0.256166, 1.113759, 0.435127, 0.804632,
- -0.250079, 1.101656, 0.416833, 0.828983, -0.243181, 1.091235, 0.397009, 0.852585, -0.235383,
- 1.081475, 0.376647, 0.875237, -0.226031, 1.071806, 0.355506, 0.899152, -0.216343, 1.064453,
- 0.333133, 0.922121, -0.205772, 1.057161, 0.311073, 0.944523, -0.193980, 1.050447, 0.287781,
- 0.967313, -0.181920, 1.044531, 0.264350, 0.989042, -0.168822, 1.039312, 0.241128, 1.010881,
- -0.155350, 1.035298, 0.218138, 1.032368, -0.141231, 1.032073, 0.195579, 1.052254, -0.126521,
- 1.029395, 0.173399, 1.070207, -0.111243, 1.026938, 0.151866, 1.086528, -0.095617, 1.024957,
- 0.130711, 1.100670, -0.079687, 1.021924, 0.108865, 1.112461, -0.063593, 1.018281, 0.086760,
- 1.121588, -0.047313, 1.013747, 0.064575, 1.128522, -0.031385, 1.008433, 0.042499, 1.134759,
- -0.015356, 1.003569, 0.020840, 1.141448, 0.000114, 0.999978, -0.000056, 0.000200, -0.000122,
- 1.372763, 0.611086, 0.000503, -0.000308, 1.371456, 0.611084, 0.002016, -0.001232, 1.373440,
- 0.611084, 0.004535, -0.002771, 1.373387, 0.611083, 0.008061, -0.004926, 1.372916, 0.611083,
- 0.012601, -0.007700, 1.373956, 0.611084, 0.018142, -0.011084, 1.373419, 0.611078, 0.024695,
- -0.015087, 1.373492, 0.611074, 0.032255, -0.019701, 1.373360, 0.611066, 0.040827, -0.024930,
- 1.373327, 0.611055, 0.050408, -0.030769, 1.373222, 0.611037, 0.061004, -0.037217, 1.373079,
- 0.611014, 0.072613, -0.044270, 1.372895, 0.610982, 0.085238, -0.051923, 1.372624, 0.610941,
- 0.098878, -0.060161, 1.372252, 0.610883, 0.113522, -0.068785, 1.371785, 0.610798, 0.129176,
- -0.077863, 1.371103, 0.610683, 0.145876, -0.087593, 1.370541, 0.610537, 0.163570, -0.097847,
- 1.369496, 0.610349, 0.182283, -0.108592, 1.368477, 0.610109, 0.201930, -0.119420, 1.366980,
- 0.609763, 0.222570, -0.130789, 1.365375, 0.609343, 0.244123, -0.142514, 1.363456, 0.608815,
- 0.266437, -0.154232, 1.360916, 0.608114, 0.289467, -0.166370, 1.357909, 0.607291, 0.312861,
- -0.178505, 1.353588, 0.606272, 0.336736, -0.190980, 1.349211, 0.605153, 0.361740, -0.202859,
- 1.343319, 0.603548, 0.387878, -0.213997, 1.335908, 0.601268, 0.414357, -0.224584, 1.326676,
- 0.598499, 0.441442, -0.234664, 1.317331, 0.595066, 0.468409, -0.243875, 1.305818, 0.590996,
- 0.494999, -0.252121, 1.291863, 0.586293, 0.521730, -0.259714, 1.278212, 0.580840, 0.547894,
- -0.266242, 1.262656, 0.574494, 0.573865, -0.271578, 1.246364, 0.567007, 0.601124, -0.275503,
- 1.231274, 0.557771, 0.627606, -0.277954, 1.215252, 0.547255, 0.654004, -0.279404, 1.199977,
- 0.535766, 0.679554, -0.279632, 1.183995, 0.522792, 0.704280, -0.278457, 1.167428, 0.508488,
- 0.729830, -0.275706, 1.152760, 0.492425, 0.754376, -0.271640, 1.137942, 0.475285, 0.779209,
- -0.266911, 1.125222, 0.456679, 0.803562, -0.260838, 1.112179, 0.437267, 0.827985, -0.253353,
- 1.101439, 0.416227, 0.851737, -0.245027, 1.089890, 0.394728, 0.874850, -0.235719, 1.080018,
- 0.372244, 0.897680, -0.225051, 1.070807, 0.348846, 0.921351, -0.214051, 1.063180, 0.324961,
- 0.943818, -0.202039, 1.056148, 0.300836, 0.966368, -0.189134, 1.049277, 0.276333, 0.987426,
- -0.175613, 1.042176, 0.251862, 1.010162, -0.161473, 1.038567, 0.227217, 1.031224, -0.146866,
- 1.034102, 0.203582, 1.052317, -0.131644, 1.031600, 0.180629, 1.070879, -0.115909, 1.028913,
- 0.158165, 1.087407, -0.099638, 1.026193, 0.135905, 1.102159, -0.083091, 1.023567, 0.113394,
- 1.114006, -0.066178, 1.019567, 0.090325, 1.123374, -0.049430, 1.014856, 0.067302, 1.130310,
- -0.032557, 1.009141, 0.044264, 1.136334, -0.016157, 1.003984, 0.021807, 1.142961, 0.000172,
- 0.999951, -0.000077, 0.000200, -0.000129, 1.416584, 0.645866, 0.000504, -0.000326, 1.417762,
- 0.645865, 0.002016, -0.001302, 1.417825, 0.645866, 0.004535, -0.002929, 1.417142, 0.645865,
- 0.008062, -0.005207, 1.416968, 0.645864, 0.012598, -0.008136, 1.417109, 0.645862, 0.018141,
- -0.011715, 1.417001, 0.645859, 0.024690, -0.015941, 1.416878, 0.645853, 0.032257, -0.020823,
- 1.417134, 0.645843, 0.040827, -0.026347, 1.416983, 0.645829, 0.050411, -0.032518, 1.416949,
- 0.645808, 0.061007, -0.039330, 1.416694, 0.645781, 0.072621, -0.046783, 1.416599, 0.645746,
- 0.085249, -0.054865, 1.416241, 0.645695, 0.098897, -0.063563, 1.415832, 0.645630, 0.113546,
- -0.072607, 1.415264, 0.645529, 0.129220, -0.082257, 1.414482, 0.645396, 0.145888, -0.092515,
- 1.413626, 0.645268, 0.163659, -0.103393, 1.412710, 0.645018, 0.182385, -0.114684, 1.411418,
- 0.644739, 0.202078, -0.126098, 1.409822, 0.644348, 0.222772, -0.138145, 1.407948, 0.643872,
- 0.244370, -0.150405, 1.405678, 0.643255, 0.266787, -0.162798, 1.402763, 0.642463, 0.289844,
- -0.175434, 1.398863, 0.641504, 0.313540, -0.188158, 1.394695, 0.640346, 0.337489, -0.201014,
- 1.389376, 0.639042, 0.362008, -0.213719, 1.382439, 0.637412, 0.387990, -0.225248, 1.373281,
- 0.634930, 0.414728, -0.236348, 1.363729, 0.631861, 0.441635, -0.246701, 1.352304, 0.628155,
- 0.468588, -0.256167, 1.339162, 0.623625, 0.495337, -0.264662, 1.323811, 0.618458, 0.521886,
- -0.272207, 1.307630, 0.612373, 0.548355, -0.278890, 1.291265, 0.605263, 0.574535, -0.284442,
- 1.273752, 0.597048, 0.600870, -0.288389, 1.256171, 0.587401, 0.627715, -0.290816, 1.238447,
- 0.576001, 0.653830, -0.291886, 1.221036, 0.563198, 0.679175, -0.291629, 1.202283, 0.549249,
- 0.704539, -0.290489, 1.185866, 0.533881, 0.729126, -0.287529, 1.168822, 0.516966, 0.754297,
- -0.283184, 1.152934, 0.498501, 0.778678, -0.277732, 1.137821, 0.478728, 0.802473, -0.271203,
- 1.123387, 0.457814, 0.826596, -0.263494, 1.110573, 0.435865, 0.850835, -0.254572, 1.099099,
- 0.412597, 0.874203, -0.244815, 1.088403, 0.388995, 0.897271, -0.233993, 1.078085, 0.364487,
- 0.919667, -0.221934, 1.068543, 0.339344, 0.943001, -0.209714, 1.061081, 0.313770, 0.965688,
- -0.196367, 1.054023, 0.287928, 0.987598, -0.182263, 1.047247, 0.262157, 1.009280, -0.167775,
- 1.041376, 0.236855, 1.031762, -0.152530, 1.037647, 0.211847, 1.051965, -0.136809, 1.033396,
- 0.187546, 1.071699, -0.120418, 1.031021, 0.164186, 1.088881, -0.103618, 1.028403, 0.141184,
- 1.103482, -0.086271, 1.024987, 0.117665, 1.115646, -0.068973, 1.020884, 0.093896, 1.125258,
- -0.051285, 1.015966, 0.069978, 1.132045, -0.033998, 1.009990, 0.046126, 1.138004, -0.016696,
- 1.004270, 0.022635, 1.144463, 0.000089, 0.999987, -0.000016, 0.000200, -0.000136, 1.463614,
- 0.681786, 0.000504, -0.000344, 1.465345, 0.681785, 0.002015, -0.001374, 1.464172, 0.681783,
- 0.004535, -0.003092, 1.464846, 0.681784, 0.008062, -0.005496, 1.464783, 0.681784, 0.012598,
- -0.008588, 1.464883, 0.681781, 0.018141, -0.012366, 1.464740, 0.681777, 0.024692, -0.016829,
- 1.464665, 0.681770, 0.032258, -0.021980, 1.464720, 0.681760, 0.040829, -0.027811, 1.464625,
- 0.681742, 0.050415, -0.034324, 1.464571, 0.681720, 0.061013, -0.041513, 1.464346, 0.681688,
- 0.072628, -0.049375, 1.464131, 0.681644, 0.085264, -0.057903, 1.463847, 0.681588, 0.098918,
- -0.067067, 1.463369, 0.681509, 0.113568, -0.076570, 1.462549, 0.681389, 0.129265, -0.086782,
- 1.461703, 0.681239, 0.145997, -0.097637, 1.460840, 0.681047, 0.163751, -0.109101, 1.459737,
- 0.680806, 0.182505, -0.120922, 1.458231, 0.680480, 0.202241, -0.133007, 1.456393, 0.680042,
- 0.222987, -0.145693, 1.454258, 0.679503, 0.244638, -0.158488, 1.451543, 0.678792, 0.267132,
- -0.171585, 1.448115, 0.677907, 0.290365, -0.184746, 1.443992, 0.676796, 0.314178, -0.198101,
- 1.439271, 0.675498, 0.338289, -0.211370, 1.432830, 0.673922, 0.362543, -0.224489, 1.424163,
- 0.672151, 0.388470, -0.236914, 1.415160, 0.669601, 0.415105, -0.248342, 1.403811, 0.666255,
- 0.441925, -0.258957, 1.390149, 0.662166, 0.468668, -0.268556, 1.374104, 0.657229, 0.495720,
- -0.277359, 1.358102, 0.651347, 0.522574, -0.285078, 1.340754, 0.644598, 0.548981, -0.291718,
- 1.322033, 0.636820, 0.574946, -0.297087, 1.302148, 0.627812, 0.600744, -0.301079, 1.282130,
- 0.617485, 0.627565, -0.303566, 1.263339, 0.605047, 0.653598, -0.304330, 1.242712, 0.591167,
- 0.679239, -0.303820, 1.223212, 0.576025, 0.704043, -0.302064, 1.203763, 0.559649, 0.728796,
- -0.299095, 1.185434, 0.541271, 0.753581, -0.294392, 1.167630, 0.521800, 0.778577, -0.288603,
- 1.151930, 0.500628, 0.802550, -0.281604, 1.136072, 0.478434, 0.825803, -0.273472, 1.121673,
- 0.455384, 0.849768, -0.264011, 1.108491, 0.430811, 0.873250, -0.253653, 1.096550, 0.405524,
- 0.896725, -0.242642, 1.085905, 0.380038, 0.919158, -0.230191, 1.075091, 0.353482, 0.942236,
- -0.217145, 1.066848, 0.326605, 0.965031, -0.203555, 1.059310, 0.299842, 0.987048, -0.188777,
- 1.051749, 0.272859, 1.008718, -0.173613, 1.044999, 0.246040, 1.031097, -0.157972, 1.040066,
- 0.219826, 1.052493, -0.141589, 1.035951, 0.194278, 1.071773, -0.124814, 1.032520, 0.169830,
- 1.089646, -0.107321, 1.029803, 0.146135, 1.104932, -0.089726, 1.026612, 0.122127, 1.117687,
- -0.071433, 1.022391, 0.097461, 1.127188, -0.053395, 1.017113, 0.072556, 1.134010, -0.035151,
- 1.010934, 0.047749, 1.139746, -0.017427, 1.004633, 0.023530, 1.146205, 0.000151, 1.000020,
- -0.000106, 0.000200, -0.000144, 1.517643, 0.718949, 0.000504, -0.000362, 1.516387, 0.718947,
- 0.002016, -0.001449, 1.516742, 0.718946, 0.004536, -0.003261, 1.517196, 0.718946, 0.008063,
- -0.005796, 1.516806, 0.718945, 0.012598, -0.009057, 1.516986, 0.718943, 0.018140, -0.013039,
- 1.516603, 0.718937, 0.024694, -0.017747, 1.516739, 0.718929, 0.032260, -0.023178, 1.516994,
- 0.718917, 0.040831, -0.029325, 1.516649, 0.718896, 0.050419, -0.036192, 1.516594, 0.718870,
- 0.061019, -0.043770, 1.516327, 0.718833, 0.072638, -0.052056, 1.516054, 0.718782, 0.085274,
- -0.061039, 1.515628, 0.718714, 0.098938, -0.070676, 1.515199, 0.718623, 0.113607, -0.080679,
- 1.514222, 0.718483, 0.129329, -0.091485, 1.513354, 0.718316, 0.146077, -0.102931, 1.512301,
- 0.718096, 0.163856, -0.114986, 1.510977, 0.717818, 0.182640, -0.127305, 1.509225, 0.717432,
- 0.202432, -0.140147, 1.507152, 0.716939, 0.223229, -0.153468, 1.504780, 0.716331, 0.244943,
- -0.166875, 1.501612, 0.715527, 0.267559, -0.180658, 1.497898, 0.714523, 0.290926, -0.194405,
- 1.493208, 0.713266, 0.314863, -0.208302, 1.487388, 0.711758, 0.339053, -0.222020, 1.479677,
- 0.709982, 0.363627, -0.235683, 1.470950, 0.707958, 0.388887, -0.248723, 1.459907, 0.705346,
- 0.415474, -0.260563, 1.446579, 0.701644, 0.442065, -0.271352, 1.429962, 0.697134, 0.469418,
- -0.281541, 1.414343, 0.691665, 0.496419, -0.290429, 1.395681, 0.685227, 0.523071, -0.298032,
- 1.375347, 0.677815, 0.549641, -0.304679, 1.354816, 0.669063, 0.575489, -0.309902, 1.332505,
- 0.659071, 0.601108, -0.313771, 1.309752, 0.647799, 0.627199, -0.316225, 1.288381, 0.634856,
- 0.653243, -0.316679, 1.265785, 0.619627, 0.678960, -0.315816, 1.244333, 0.603244, 0.704055,
- -0.313776, 1.223315, 0.585191, 0.728713, -0.310417, 1.203142, 0.565969, 0.753301, -0.305786,
- 1.184323, 0.545347, 0.777890, -0.299262, 1.166070, 0.522753, 0.802354, -0.291830, 1.149599,
- 0.499017, 0.826005, -0.283281, 1.133655, 0.474335, 0.848920, -0.273512, 1.118132, 0.449019,
- 0.872765, -0.262525, 1.105606, 0.422329, 0.895950, -0.250769, 1.093539, 0.395057, 0.918816,
- -0.238257, 1.082388, 0.367709, 0.941089, -0.224381, 1.072484, 0.339350, 0.964514, -0.210289,
- 1.064054, 0.311239, 0.987128, -0.195488, 1.056645, 0.283272, 1.009064, -0.179491, 1.049549,
- 0.255163, 1.030163, -0.163172, 1.042741, 0.227757, 1.052502, -0.146457, 1.038270, 0.200970,
- 1.072971, -0.129054, 1.035014, 0.175767, 1.091223, -0.111285, 1.032231, 0.151118, 1.106518,
- -0.092617, 1.028211, 0.126196, 1.119235, -0.074168, 1.023686, 0.100828, 1.129311, -0.055212,
- 1.018311, 0.075240, 1.135983, -0.036571, 1.011485, 0.049558, 1.141648, -0.017954, 1.004952,
- 0.024273, 1.147938, 0.000125, 1.000009, -0.000048, 0.000199, -0.000151, 1.566887, 0.757466,
- 0.000504, -0.000382, 1.574111, 0.757466, 0.002016, -0.001527, 1.573735, 0.757466, 0.004535,
- -0.003435, 1.573737, 0.757466, 0.008062, -0.006107, 1.573782, 0.757464, 0.012599, -0.009542,
- 1.573796, 0.757460, 0.018142, -0.013739, 1.573710, 0.757455, 0.024694, -0.018697, 1.573562,
- 0.757446, 0.032259, -0.024418, 1.573667, 0.757429, 0.040834, -0.030895, 1.573555, 0.757407,
- 0.050422, -0.038127, 1.573383, 0.757376, 0.061025, -0.046108, 1.573086, 0.757332, 0.072650,
- -0.054835, 1.572833, 0.757274, 0.085296, -0.064294, 1.572395, 0.757195, 0.098962, -0.074376,
- 1.571729, 0.757087, 0.113649, -0.084955, 1.570571, 0.756925, 0.129389, -0.096334, 1.569582,
- 0.756729, 0.146167, -0.108406, 1.568444, 0.756481, 0.163973, -0.121056, 1.566905, 0.756158,
- 0.182798, -0.133970, 1.564939, 0.755715, 0.202650, -0.147522, 1.562666, 0.755167, 0.223502,
- -0.161466, 1.559877, 0.754465, 0.245269, -0.175539, 1.556008, 0.753552, 0.268010, -0.189957,
- 1.552013, 0.752420, 0.291474, -0.204361, 1.546509, 0.751008, 0.315527, -0.218714, 1.539575,
- 0.749266, 0.339954, -0.233029, 1.530968, 0.747232, 0.364649, -0.247149, 1.520994, 0.744906,
- 0.389520, -0.260672, 1.507748, 0.742123, 0.415717, -0.272873, 1.491777, 0.738187, 0.442862,
- -0.284317, 1.475658, 0.733189, 0.469939, -0.294552, 1.456572, 0.727165, 0.496916, -0.303517,
- 1.435237, 0.720043, 0.523480, -0.311061, 1.412192, 0.711640, 0.550092, -0.317596, 1.389033,
- 0.702174, 0.576384, -0.322921, 1.365086, 0.691225, 0.602280, -0.326806, 1.341317, 0.678841,
- 0.627676, -0.329057, 1.316518, 0.664815, 0.653458, -0.329372, 1.291877, 0.648548, 0.679227,
- -0.328067, 1.268126, 0.630676, 0.704476, -0.325585, 1.244424, 0.611585, 0.729232, -0.321775,
- 1.223010, 0.590803, 0.753405, -0.316713, 1.201297, 0.568653, 0.777274, -0.309858, 1.181071,
- 0.544763, 0.801882, -0.301866, 1.162826, 0.519747, 0.826030, -0.292861, 1.145704, 0.493531,
- 0.849359, -0.282794, 1.129629, 0.466900, 0.871837, -0.271197, 1.114155, 0.439230, 0.895896,
- -0.258954, 1.102334, 0.410570, 0.918951, -0.245878, 1.090163, 0.381314, 0.941148, -0.231897,
- 1.078738, 0.352268, 0.963464, -0.216743, 1.068862, 0.322688, 0.986628, -0.201486, 1.061077,
- 0.293523, 1.009289, -0.185521, 1.053561, 0.264125, 1.030659, -0.168429, 1.046627, 0.235706,
- 1.052382, -0.151210, 1.040953, 0.208022, 1.073476, -0.133289, 1.036534, 0.181245, 1.092237,
- -0.114768, 1.033580, 0.155661, 1.108200, -0.095917, 1.029997, 0.130223, 1.121435, -0.076492,
- 1.025374, 0.104098, 1.131382, -0.057204, 1.019485, 0.077776, 1.137994, -0.037747, 1.012188,
- 0.051250, 1.143441, -0.018673, 1.005309, 0.025245, 1.149714, 0.000216, 1.000004, -0.000120,
- 0.000200, -0.000159, 1.633988, 0.797469, 0.000504, -0.000402, 1.636076, 0.797469, 0.002016,
- -0.001607, 1.635679, 0.797467, 0.004535, -0.003617, 1.636040, 0.797468, 0.008063, -0.006430,
- 1.636159, 0.797467, 0.012599, -0.010046, 1.636128, 0.797462, 0.018141, -0.014464, 1.635730,
- 0.797457, 0.024696, -0.019685, 1.635836, 0.797445, 0.032259, -0.025705, 1.635719, 0.797426,
- 0.040835, -0.032523, 1.635610, 0.797401, 0.050425, -0.040135, 1.635460, 0.797363, 0.061033,
- -0.048536, 1.635182, 0.797313, 0.072661, -0.057718, 1.634817, 0.797243, 0.085315, -0.067666,
- 1.634314, 0.797150, 0.098985, -0.078179, 1.633350, 0.797016, 0.113699, -0.089383, 1.632253,
- 0.796839, 0.129456, -0.101364, 1.631025, 0.796623, 0.146275, -0.114081, 1.629867, 0.796331,
- 0.164108, -0.127318, 1.628043, 0.795956, 0.182983, -0.140901, 1.625813, 0.795458, 0.202891,
- -0.155174, 1.623149, 0.794834, 0.223787, -0.169654, 1.619686, 0.794015, 0.245678, -0.184540,
- 1.615694, 0.793013, 0.268495, -0.199543, 1.610812, 0.791727, 0.292093, -0.214639, 1.604629,
- 0.790107, 0.316184, -0.229499, 1.596061, 0.788154, 0.340986, -0.244407, 1.587195, 0.785797,
- 0.365808, -0.258907, 1.575031, 0.783093, 0.390528, -0.272746, 1.559448, 0.779970, 0.416510,
- -0.285845, 1.543294, 0.775852, 0.443443, -0.297404, 1.523476, 0.770323, 0.470442, -0.307757,
- 1.501515, 0.763721, 0.497499, -0.316846, 1.477841, 0.755889, 0.524316, -0.324561, 1.452427,
- 0.746662, 0.551212, -0.331060, 1.427421, 0.736004, 0.577323, -0.335956, 1.400369, 0.723810,
- 0.602976, -0.339501, 1.373093, 0.710184, 0.628357, -0.341577, 1.345853, 0.695017, 0.653642,
- -0.342031, 1.319040, 0.677972, 0.679440, -0.340342, 1.292490, 0.658877, 0.704744, -0.337356,
- 1.267182, 0.638085, 0.729692, -0.333042, 1.243280, 0.615615, 0.753920, -0.327504, 1.219751,
- 0.592054, 0.777695, -0.320537, 1.197796, 0.566967, 0.801426, -0.311880, 1.176872, 0.540643,
- 0.825649, -0.302211, 1.158160, 0.512906, 0.849282, -0.291665, 1.141257, 0.484587, 0.872341,
- -0.280050, 1.125469, 0.455556, 0.895110, -0.266978, 1.110222, 0.425652, 0.918841, -0.253326,
- 1.097419, 0.395015, 0.941209, -0.238899, 1.086101, 0.364948, 0.963142, -0.223523, 1.075023,
- 0.334151, 0.985996, -0.207346, 1.065628, 0.303708, 1.008718, -0.190889, 1.057256, 0.273008,
- 1.030554, -0.173517, 1.049720, 0.243221, 1.053085, -0.155645, 1.043837, 0.214426, 1.074267,
- -0.137472, 1.039312, 0.187036, 1.093591, -0.118385, 1.035457, 0.160512, 1.109850, -0.098883,
- 1.031630, 0.134384, 1.123516, -0.079050, 1.026762, 0.107424, 1.133578, -0.058977, 1.020640,
- 0.080317, 1.140289, -0.039013, 1.013096, 0.052944, 1.145610, -0.019228, 1.005694, 0.025989,
- 1.151704, 0.000105, 0.999981, -0.000019, 0.000200, -0.000168, 1.704841, 0.839096, 0.000504,
- -0.000423, 1.704242, 0.839097, 0.002016, -0.001691, 1.703821, 0.839091, 0.004534, -0.003805,
- 1.703804, 0.839094, 0.008063, -0.006765, 1.704224, 0.839092, 0.012598, -0.010570, 1.704013,
- 0.839087, 0.018142, -0.015219, 1.703889, 0.839079, 0.024697, -0.020712, 1.704023, 0.839066,
- 0.032261, -0.027046, 1.703836, 0.839045, 0.040837, -0.034218, 1.703608, 0.839014, 0.050429,
- -0.042224, 1.703414, 0.838972, 0.061041, -0.051061, 1.703148, 0.838912, 0.072676, -0.060717,
- 1.702744, 0.838831, 0.085340, -0.071175, 1.702223, 0.838724, 0.099023, -0.082182, 1.700984,
- 0.838567, 0.113759, -0.094007, 1.699764, 0.838367, 0.129546, -0.106621, 1.698462, 0.838112,
- 0.146382, -0.119956, 1.696938, 0.837782, 0.164260, -0.133760, 1.694868, 0.837346, 0.183188,
- -0.148108, 1.692262, 0.836780, 0.203158, -0.163075, 1.689251, 0.836073, 0.224147, -0.178255,
- 1.685408, 0.835148, 0.246147, -0.193900, 1.680946, 0.833992, 0.269072, -0.209553, 1.675277,
- 0.832546, 0.292718, -0.225226, 1.667626, 0.830727, 0.317159, -0.240836, 1.658952, 0.828510,
- 0.341979, -0.256103, 1.647624, 0.825843, 0.366844, -0.270887, 1.633014, 0.822760, 0.392043,
- -0.285324, 1.617191, 0.819159, 0.417356, -0.298817, 1.597501, 0.814788, 0.444093, -0.310711,
- 1.575184, 0.808751, 0.471379, -0.321410, 1.551590, 0.801294, 0.498267, -0.330421, 1.524134,
- 0.792711, 0.525401, -0.338331, 1.496672, 0.782480, 0.551846, -0.344430, 1.467062, 0.770659,
- 0.578009, -0.349047, 1.436943, 0.757348, 0.604054, -0.352490, 1.407611, 0.742541, 0.629387,
- -0.354158, 1.377441, 0.726071, 0.654435, -0.354422, 1.347651, 0.707524, 0.679845, -0.352663,
- 1.318769, 0.687067, 0.704892, -0.348994, 1.290600, 0.664637, 0.729763, -0.344105, 1.263997,
- 0.640663, 0.754345, -0.338129, 1.239273, 0.615484, 0.778629, -0.330905, 1.215858, 0.589210,
- 0.801939, -0.322113, 1.192318, 0.561550, 0.825723, -0.311673, 1.171380, 0.532175, 0.849387,
- -0.300410, 1.152991, 0.502055, 0.872792, -0.288328, 1.136139, 0.471308, 0.895083, -0.275087,
- 1.119534, 0.440427, 0.918335, -0.260700, 1.105542, 0.409260, 0.941577, -0.245717, 1.093070,
- 0.377142, 0.963992, -0.230079, 1.081207, 0.345289, 0.986510, -0.213523, 1.071488, 0.313508,
- 1.008806, -0.196157, 1.062011, 0.281962, 1.030724, -0.178467, 1.053240, 0.251177, 1.053782,
- -0.160291, 1.047057, 0.220986, 1.075451, -0.141308, 1.041842, 0.192256, 1.094947, -0.121975,
- 1.037704, 0.165023, 1.111783, -0.101744, 1.033300, 0.138228, 1.125525, -0.081476, 1.028234,
- 0.110679, 1.135873, -0.060770, 1.021695, 0.082672, 1.142478, -0.040207, 1.013838, 0.054506,
- 1.147889, -0.019908, 1.006166, 0.026938, 1.153852, 0.000204, 0.999983, -0.000123, 0.000199,
- -0.000176, 1.771601, 0.882501, 0.000504, -0.000445, 1.779195, 0.882504, 0.002016, -0.001779,
- 1.779635, 0.882498, 0.004536, -0.004003, 1.779586, 0.882499, 0.008062, -0.007115, 1.778613,
- 0.882496, 0.012598, -0.011116, 1.778678, 0.882492, 0.018142, -0.016005, 1.778531, 0.882481,
- 0.024696, -0.021782, 1.778556, 0.882466, 0.032262, -0.028444, 1.778507, 0.882442, 0.040842,
- -0.035987, 1.778385, 0.882408, 0.050436, -0.044404, 1.778034, 0.882364, 0.061053, -0.053695,
- 1.777761, 0.882287, 0.072692, -0.063842, 1.777256, 0.882190, 0.085364, -0.074821, 1.776518,
- 0.882067, 0.099064, -0.086368, 1.775080, 0.881884, 0.113828, -0.098805, 1.773836, 0.881657,
- 0.129649, -0.112090, 1.772370, 0.881361, 0.146518, -0.126067, 1.770594, 0.880982, 0.164440,
- -0.140493, 1.768089, 0.880484, 0.183437, -0.155646, 1.765301, 0.879843, 0.203468, -0.171266,
- 1.761698, 0.879035, 0.224562, -0.187231, 1.757518, 0.877982, 0.246665, -0.203540, 1.752318,
- 0.876667, 0.269652, -0.219916, 1.745356, 0.875028, 0.293531, -0.236255, 1.737186, 0.872977,
- 0.318048, -0.252410, 1.726709, 0.870448, 0.342963, -0.268192, 1.713109, 0.867400, 0.368336,
- -0.283587, 1.698087, 0.863882, 0.393512, -0.298186, 1.678638, 0.859724, 0.418602, -0.311882,
- 1.655604, 0.854835, 0.445080, -0.324500, 1.632250, 0.848353, 0.472289, -0.335295, 1.605069,
- 0.840218, 0.499128, -0.344256, 1.573846, 0.830556, 0.525834, -0.351716, 1.541120, 0.819269,
- 0.553177, -0.358241, 1.511385, 0.806222, 0.579480, -0.362640, 1.477866, 0.791647, 0.605205,
- -0.365513, 1.444218, 0.775398, 0.630617, -0.366822, 1.410954, 0.757144, 0.655730, -0.366785,
- 1.379010, 0.737323, 0.680529, -0.364904, 1.347280, 0.715601, 0.705800, -0.360990, 1.316416,
- 0.691547, 0.730550, -0.355397, 1.286344, 0.666141, 0.754970, -0.348664, 1.258954, 0.638929,
- 0.779042, -0.340774, 1.232965, 0.611015, 0.802839, -0.331767, 1.209775, 0.581877, 0.825793,
- -0.321054, 1.185813, 0.551509, 0.849512, -0.309016, 1.165080, 0.519698, 0.873120, -0.296369,
- 1.147091, 0.487506, 0.895942, -0.282704, 1.129658, 0.455320, 0.917996, -0.268007, 1.113463,
- 0.422605, 0.941281, -0.252329, 1.100040, 0.389347, 0.964584, -0.236203, 1.087973, 0.356430,
- 0.986371, -0.219209, 1.075983, 0.323089, 1.009522, -0.201588, 1.066940, 0.290806, 1.031976,
- -0.183296, 1.057999, 0.258682, 1.053461, -0.164509, 1.049542, 0.227722, 1.076121, -0.145165,
- 1.043718, 0.197439, 1.096597, -0.125199, 1.039607, 0.169578, 1.113908, -0.104921, 1.035528,
- 0.142222, 1.127939, -0.083623, 1.029807, 0.113802, 1.138391, -0.062589, 1.023312, 0.085164,
- 1.145110, -0.041376, 1.014806, 0.056186, 1.150141, -0.020433, 1.006501, 0.027654, 1.156069,
- 0.000097, 0.999949, -0.000046, 0.000200, -0.000185, 1.858268, 0.927857, 0.000504, -0.000468,
- 1.861583, 0.927859, 0.002016, -0.001870, 1.860659, 0.927855, 0.004535, -0.004208, 1.860963,
- 0.927867, 0.008063, -0.007480, 1.860766, 0.927855, 0.012594, -0.011683, 1.859996, 0.927851,
- 0.018142, -0.016828, 1.860739, 0.927839, 0.024698, -0.022901, 1.860763, 0.927818, 0.032263,
- -0.029903, 1.860501, 0.927791, 0.040846, -0.037834, 1.860431, 0.927751, 0.050440, -0.046680,
- 1.859827, 0.927690, 0.061066, -0.056446, 1.859624, 0.927610, 0.072713, -0.067109, 1.859039,
- 0.927505, 0.085393, -0.078613, 1.858144, 0.927357, 0.099120, -0.090747, 1.856618, 0.927145,
- 0.113910, -0.103850, 1.855221, 0.926884, 0.129755, -0.117777, 1.853470, 0.926546, 0.146669,
- -0.132441, 1.851413, 0.926104, 0.164648, -0.147565, 1.848498, 0.925530, 0.183708, -0.163470,
- 1.845281, 0.924802, 0.203832, -0.179763, 1.841273, 0.923871, 0.225029, -0.196564, 1.836481,
- 0.922691, 0.247221, -0.213537, 1.830273, 0.921198, 0.270343, -0.230662, 1.822374, 0.919320,
- 0.294399, -0.247740, 1.812975, 0.917008, 0.319040, -0.264448, 1.800693, 0.914141, 0.344269,
- -0.280831, 1.785923, 0.910707, 0.369625, -0.296478, 1.767203, 0.906585, 0.394925, -0.311287,
- 1.744434, 0.901918, 0.420583, -0.325578, 1.720938, 0.896240, 0.446200, -0.338384, 1.693005,
- 0.889335, 0.472969, -0.349187, 1.660901, 0.880394, 0.500490, -0.358687, 1.628806, 0.869705,
- 0.527312, -0.366042, 1.593001, 0.857145, 0.554207, -0.372045, 1.557046, 0.842943, 0.580620,
- -0.376134, 1.520192, 0.826837, 0.606480, -0.378636, 1.482947, 0.808891, 0.631815, -0.379414,
- 1.445954, 0.789119, 0.657021, -0.378972, 1.410833, 0.767564, 0.681686, -0.376728, 1.376575,
- 0.744338, 0.706498, -0.372844, 1.342935, 0.718799, 0.731258, -0.366649, 1.311052, 0.691756,
- 0.755937, -0.359354, 1.280478, 0.662683, 0.779259, -0.350487, 1.250585, 0.632892, 0.803295,
- -0.340941, 1.225722, 0.602160, 0.826570, -0.330174, 1.201003, 0.570520, 0.849954, -0.317854,
- 1.178488, 0.537651, 0.873696, -0.304426, 1.158302, 0.503799, 0.896695, -0.290120, 1.139886,
- 0.469645, 0.919149, -0.275106, 1.122884, 0.435625, 0.942121, -0.259282, 1.107691, 0.401228,
- 0.964627, -0.242123, 1.093661, 0.367086, 0.986614, -0.224575, 1.081580, 0.332885, 1.009623,
- -0.206837, 1.071375, 0.299209, 1.033126, -0.188092, 1.062241, 0.266187, 1.054954, -0.168637,
- 1.052912, 0.233733, 1.077660, -0.149166, 1.047047, 0.203192, 1.097983, -0.128587, 1.041607,
- 0.173918, 1.115586, -0.107339, 1.036850, 0.145531, 1.130170, -0.086203, 1.031427, 0.116890,
- 1.141018, -0.064171, 1.024395, 0.087388, 1.147681, -0.042530, 1.015719, 0.057733, 1.152560,
- -0.021011, 1.006883, 0.028413, 1.158406, 0.000158, 0.999897, -0.000106, 0.000200, -0.000195,
- 1.950982, 0.975366, 0.000504, -0.000491, 1.950207, 0.975365, 0.002015, -0.001966, 1.950675,
- 0.975362, 0.004535, -0.004423, 1.951281, 0.975370, 0.008062, -0.007863, 1.951045, 0.975362,
- 0.012597, -0.012285, 1.951199, 0.975356, 0.018145, -0.017692, 1.951528, 0.975340, 0.024699,
- -0.024074, 1.951194, 0.975321, 0.032266, -0.031434, 1.950865, 0.975288, 0.040853, -0.039771,
- 1.951038, 0.975244, 0.050452, -0.049067, 1.950336, 0.975173, 0.061077, -0.059324, 1.949805,
- 0.975078, 0.072736, -0.070526, 1.949133, 0.974951, 0.085431, -0.082528, 1.947947, 0.974777,
- 0.099182, -0.095345, 1.946337, 0.974540, 0.113999, -0.109118, 1.944725, 0.974241, 0.129888,
- -0.123741, 1.942857, 0.973852, 0.146842, -0.139071, 1.940251, 0.973342, 0.164890, -0.154986,
- 1.937086, 0.972684, 0.184025, -0.171661, 1.933404, 0.971856, 0.204245, -0.188672, 1.928770,
- 0.970785, 0.225528, -0.206252, 1.923041, 0.969448, 0.247841, -0.223972, 1.915788, 0.967742,
- 0.271157, -0.241827, 1.907008, 0.965607, 0.295297, -0.259562, 1.895854, 0.963007, 0.320121,
- -0.276909, 1.881289, 0.959722, 0.345566, -0.293883, 1.864528, 0.955831, 0.371012, -0.309816,
- 1.842062, 0.951127, 0.396834, -0.325157, 1.818068, 0.945725, 0.422277, -0.339357, 1.788874,
- 0.939318, 0.447928, -0.352387, 1.758283, 0.931470, 0.474315, -0.363680, 1.723668, 0.921900,
- 0.501560, -0.372963, 1.686081, 0.909996, 0.528391, -0.380159, 1.645816, 0.896244, 0.554754,
- -0.385545, 1.603709, 0.880326, 0.581888, -0.389778, 1.565475, 0.862716, 0.607791, -0.391839,
- 1.524196, 0.843146, 0.633511, -0.392331, 1.483921, 0.821554, 0.658621, -0.391193, 1.445013,
- 0.798336, 0.683160, -0.388424, 1.406963, 0.773299, 0.707429, -0.384104, 1.370996, 0.746668,
- 0.732212, -0.377945, 1.335879, 0.717502, 0.756871, -0.369856, 1.302489, 0.686954, 0.781065,
- -0.360707, 1.271815, 0.655372, 0.804167, -0.350091, 1.242416, 0.622683, 0.827948, -0.338941,
- 1.217208, 0.589185, 0.850901, -0.326427, 1.192354, 0.555005, 0.873589, -0.312199, 1.169639,
- 0.519594, 0.897085, -0.297374, 1.150181, 0.484105, 0.920459, -0.281932, 1.132858, 0.448661,
- 0.942637, -0.265625, 1.115401, 0.413051, 0.965341, -0.248332, 1.101078, 0.377329, 0.987530,
- -0.229983, 1.087377, 0.342349, 1.010739, -0.211647, 1.076582, 0.307824, 1.033449, -0.192725,
- 1.065900, 0.273368, 1.055618, -0.172726, 1.056958, 0.240238, 1.079345, -0.152640, 1.049620,
- 0.208322, 1.100058, -0.131931, 1.044084, 0.178242, 1.118547, -0.110351, 1.039387, 0.149493,
- 1.132748, -0.088128, 1.033049, 0.119673, 1.143419, -0.066069, 1.025521, 0.089728, 1.150316,
- -0.043513, 1.016378, 0.059253, 1.155208, -0.021593, 1.007506, 0.029140, 1.160871, 0.000111,
- 0.999916, -0.000035, 0.000201, -0.000206, 2.061000, 1.025243, 0.000504, -0.000516, 2.049647,
- 1.025237, 0.002015, -0.002066, 2.050169, 1.025237, 0.004535, -0.004650, 2.051254, 1.025255,
- 0.008063, -0.008266, 2.051302, 1.025236, 0.012600, -0.012915, 2.051508, 1.025226, 0.018144,
- -0.018594, 2.050981, 1.025215, 0.024700, -0.025304, 2.050841, 1.025190, 0.032267, -0.033038,
- 2.050537, 1.025152, 0.040852, -0.041795, 2.050660, 1.025090, 0.050460, -0.051570, 2.049921,
- 1.025017, 0.061094, -0.062347, 2.049350, 1.024908, 0.072762, -0.074111, 2.048517, 1.024760,
- 0.085475, -0.086661, 2.047009, 1.024555, 0.099249, -0.100160, 2.045261, 1.024278, 0.114106,
- -0.114628, 2.043508, 1.023941, 0.130032, -0.130002, 2.041321, 1.023488, 0.147050, -0.145985,
- 2.038299, 1.022905, 0.165164, -0.162762, 2.034658, 1.022151, 0.184380, -0.180172, 2.030312,
- 1.021200, 0.204704, -0.198022, 2.024944, 1.019966, 0.226129, -0.216359, 2.018546, 1.018424,
- 0.248582, -0.234923, 2.010153, 1.016519, 0.272011, -0.253474, 1.999659, 1.014072, 0.296259,
- -0.271820, 1.986076, 1.011071, 0.321423, -0.289959, 1.970618, 1.007389, 0.346897, -0.307283,
- 1.949667, 1.002955, 0.372750, -0.323817, 1.925287, 0.997633, 0.398603, -0.339241, 1.896006,
- 0.991354, 0.424351, -0.353633, 1.863658, 0.983937, 0.449887, -0.366660, 1.827430, 0.975254,
- 0.475715, -0.378213, 1.789521, 0.964753, 0.502204, -0.387133, 1.745632, 0.951594, 0.530179,
- -0.394976, 1.705347, 0.936344, 0.556732, -0.400134, 1.658928, 0.918907, 0.583123, -0.403439,
- 1.613077, 0.899504, 0.609477, -0.405285, 1.567884, 0.878172, 0.634927, -0.405055, 1.523507,
- 0.854396, 0.660357, -0.403494, 1.481712, 0.829259, 0.684851, -0.400104, 1.439000, 0.802359,
- 0.709654, -0.395536, 1.400956, 0.773534, 0.733472, -0.388996, 1.362156, 0.743230, 0.757502,
- -0.380263, 1.325113, 0.711090, 0.782249, -0.370594, 1.292913, 0.677166, 0.806017, -0.359509,
- 1.262088, 0.642527, 0.828687, -0.347126, 1.232059, 0.607589, 0.852372, -0.334474, 1.207160,
- 0.571938, 0.874266, -0.320074, 1.181978, 0.535518, 0.898168, -0.304719, 1.161156, 0.498375,
- 0.920456, -0.288246, 1.140667, 0.461179, 0.942832, -0.271311, 1.122780, 0.424533, 0.966458,
- -0.254154, 1.108743, 0.387784, 0.988907, -0.235659, 1.093872, 0.351689, 1.011557, -0.216322,
- 1.081959, 0.315743, 1.035099, -0.197007, 1.070885, 0.280402, 1.056354, -0.176878, 1.059968,
- 0.246472, 1.079854, -0.156058, 1.051815, 0.212818, 1.101494, -0.134772, 1.045757, 0.182143,
- 1.120587, -0.113071, 1.041169, 0.152867, 1.135399, -0.090411, 1.034844, 0.122796, 1.146612,
- -0.067477, 1.026974, 0.091888, 1.153168, -0.044849, 1.017303, 0.060779, 1.157912, -0.021998,
- 1.007735, 0.029919, 1.163607, 0.000121, 0.999959, 0.000003, 0.000200, -0.000216, 2.163956,
- 1.077737, 0.000504, -0.000543, 2.161128, 1.077732, 0.002016, -0.002173, 2.162732, 1.077729,
- 0.004535, -0.004887, 2.161402, 1.077749, 0.008066, -0.008692, 2.163252, 1.077732, 0.012599,
- -0.013576, 2.161300, 1.077727, 0.018145, -0.019546, 2.161151, 1.077702, 0.024702, -0.026599,
- 2.161223, 1.077675, 0.032272, -0.034729, 2.160949, 1.077632, 0.040862, -0.043936, 2.160967,
- 1.077575, 0.050470, -0.054203, 2.160035, 1.077473, 0.061113, -0.065528, 2.159490, 1.077348,
- 0.072794, -0.077882, 2.158517, 1.077178, 0.085528, -0.091030, 2.156605, 1.076937, 0.099337,
- -0.105251, 2.154828, 1.076631, 0.114228, -0.120456, 2.152812, 1.076229, 0.130202, -0.136573,
- 2.150298, 1.075713, 0.147284, -0.153306, 2.146752, 1.075031, 0.165480, -0.170931, 2.142744,
- 1.074173, 0.184793, -0.189083, 2.137475, 1.073063, 0.205224, -0.207840, 2.131320, 1.071683,
- 0.226743, -0.226939, 2.123154, 1.069914, 0.249401, -0.246344, 2.114086, 1.067718, 0.272955,
- -0.265640, 2.101599, 1.064924, 0.297494, -0.284846, 2.086612, 1.061512, 0.322731, -0.303452,
- 2.067356, 1.057359, 0.348451, -0.321330, 2.043711, 1.052294, 0.374451, -0.338201, 2.015033,
- 1.046153, 0.400454, -0.353816, 1.981139, 1.039003, 0.426434, -0.368216, 1.944128, 1.030498,
- 0.452088, -0.381251, 1.903094, 1.020454, 0.477901, -0.392833, 1.860402, 1.008793, 0.504173,
- -0.402408, 1.814402, 0.994791, 0.531520, -0.409545, 1.766273, 0.977733, 0.558049, -0.414351,
- 1.714119, 0.958625, 0.584778, -0.417437, 1.664612, 0.937189, 0.610808, -0.418519, 1.613793,
- 0.913543, 0.636915, -0.418094, 1.565942, 0.888137, 0.662204, -0.415742, 1.518783, 0.860728,
- 0.686848, -0.411746, 1.473306, 0.831793, 0.710992, -0.406153, 1.430153, 0.800862, 0.735382,
- -0.399519, 1.389824, 0.768768, 0.759079, -0.390927, 1.350744, 0.734825, 0.782912, -0.380111,
- 1.313559, 0.699450, 0.806746, -0.368383, 1.280028, 0.663191, 0.830269, -0.355606, 1.249814,
- 0.625927, 0.853305, -0.341988, 1.221138, 0.588644, 0.876326, -0.327545, 1.195837, 0.550849,
- 0.898322, -0.311779, 1.171844, 0.512694, 0.921811, -0.294944, 1.150671, 0.474225, 0.944563,
- -0.277333, 1.132224, 0.435772, 0.967089, -0.259340, 1.115422, 0.398001, 0.989754, -0.240836,
- 1.100405, 0.360802, 1.012470, -0.221293, 1.086533, 0.323566, 1.036426, -0.201191, 1.075496,
- 0.287387, 1.058709, -0.180590, 1.064233, 0.252184, 1.081593, -0.159810, 1.055296, 0.218441,
- 1.103146, -0.137772, 1.047978, 0.186223, 1.122814, -0.115347, 1.042693, 0.156019, 1.137790,
- -0.092582, 1.036049, 0.125579, 1.149184, -0.069152, 1.027944, 0.093986, 1.156062, -0.045661,
- 1.018039, 0.062122, 1.160733, -0.022719, 1.008072, 0.030650, 1.166487, 0.000231, 1.000063,
- -0.000120, 0.000201, -0.000228, 2.308308, 1.133128, 0.000504, -0.000571, 2.283756, 1.133123,
- 0.002016, -0.002284, 2.283756, 1.133123, 0.004535, -0.005138, 2.283310, 1.133144, 0.008048,
- -0.009119, 2.266192, 1.133138, 0.012600, -0.014274, 2.284377, 1.133110, 0.018147, -0.020553,
- 2.284204, 1.133093, 0.024702, -0.027964, 2.283517, 1.133060, 0.032272, -0.036510, 2.282997,
- 1.133007, 0.040866, -0.046188, 2.282986, 1.132930, 0.050481, -0.056979, 2.282260, 1.132824,
- 0.061133, -0.068881, 2.281533, 1.132678, 0.072830, -0.081850, 2.280504, 1.132481, 0.085592,
- -0.095657, 2.278304, 1.132202, 0.099431, -0.110594, 2.276269, 1.131845, 0.114360, -0.126590,
- 2.273890, 1.131383, 0.130388, -0.143454, 2.270761, 1.130784, 0.147547, -0.161029, 2.266794,
- 1.130003, 0.165836, -0.179523, 2.262332, 1.129016, 0.185269, -0.198527, 2.256326, 1.127738,
- 0.205822, -0.218138, 2.249031, 1.126156, 0.227527, -0.238141, 2.239993, 1.124132, 0.250325,
- -0.258302, 2.228878, 1.121594, 0.274070, -0.278329, 2.214204, 1.118449, 0.298793, -0.298310,
- 2.196654, 1.114528, 0.324131, -0.317462, 2.173394, 1.109783, 0.350101, -0.335853, 2.146395,
- 1.103901, 0.376293, -0.353064, 2.112341, 1.096954, 0.402547, -0.368950, 2.073700, 1.088642,
- 0.428791, -0.383462, 2.031152, 1.078946, 0.454976, -0.396635, 1.986661, 1.067536, 0.480566,
- -0.407873, 1.937038, 1.054403, 0.506154, -0.417303, 1.885155, 1.038894, 0.532862, -0.424194,
- 1.830369, 1.020535, 0.560354, -0.429344, 1.776976, 0.999295, 0.587114, -0.431949, 1.721214,
- 0.975990, 0.613345, -0.432547, 1.665739, 0.950239, 0.639335, -0.431338, 1.612200, 0.922467,
- 0.664996, -0.428473, 1.561035, 0.892593, 0.688947, -0.423355, 1.508240, 0.861325, 0.713403,
- -0.417235, 1.461776, 0.828289, 0.737649, -0.409848, 1.418888, 0.793863, 0.761275, -0.400901,
- 1.376807, 0.758074, 0.784778, -0.390174, 1.337204, 0.721974, 0.808762, -0.377683, 1.301527,
- 0.682718, 0.831993, -0.364037, 1.267144, 0.644001, 0.854696, -0.349494, 1.236023, 0.605478,
- 0.877933, -0.334499, 1.209284, 0.565588, 0.900180, -0.318435, 1.183967, 0.526138, 0.923039,
- -0.301669, 1.161513, 0.486524, 0.945895, -0.283298, 1.140838, 0.446747, 0.968069, -0.264438,
- 1.122475, 0.408041, 0.991179, -0.245463, 1.106968, 0.369477, 1.012926, -0.225680, 1.091435,
- 0.331626, 1.036995, -0.205401, 1.079561, 0.294288, 1.060909, -0.184310, 1.068215, 0.257696,
- 1.083531, -0.162846, 1.058133, 0.223343, 1.105644, -0.141040, 1.050851, 0.190541, 1.125691,
- -0.117965, 1.045001, 0.159310, 1.141297, -0.094377, 1.038028, 0.128238, 1.152672, -0.070831,
- 1.029694, 0.096282, 1.159333, -0.046853, 1.019136, 0.063720, 1.163819, -0.022991, 1.008518,
- 0.031234, 1.169564, 0.000125, 1.000069, -0.000024, 0.000202, -0.000241, 2.458341, 1.191742,
- 0.000504, -0.000600, 2.418738, 1.191740, 0.002015, -0.002401, 2.418821, 1.191730, 0.004535,
- -0.005405, 2.421986, 1.191756, 0.008071, -0.009618, 2.424988, 1.191753, 0.012600, -0.015012,
- 2.420242, 1.191727, 0.018145, -0.021612, 2.419937, 1.191703, 0.024704, -0.029410, 2.419746,
- 1.191662, 0.032278, -0.038398, 2.419409, 1.191604, 0.040874, -0.048574, 2.418995, 1.191515,
- 0.050496, -0.059920, 2.418190, 1.191389, 0.061160, -0.072432, 2.417487, 1.191221, 0.072871,
- -0.086009, 2.415853, 1.190984, 0.085664, -0.100559, 2.413669, 1.190664, 0.099543, -0.116283,
- 2.411423, 1.190256, 0.114520, -0.133071, 2.408711, 1.189719, 0.130616, -0.150670, 2.404900,
- 1.189019, 0.147856, -0.169197, 2.400512, 1.188125, 0.166235, -0.188545, 2.394939, 1.186972,
- 0.185804, -0.208480, 2.388232, 1.185515, 0.206488, -0.228883, 2.379190, 1.183673, 0.228383,
- -0.249897, 2.369208, 1.181382, 0.251305, -0.270851, 2.355459, 1.178478, 0.275349, -0.291780,
- 2.339142, 1.174857, 0.300106, -0.312257, 2.316655, 1.170411, 0.325849, -0.332225, 2.291540,
- 1.164883, 0.351782, -0.350862, 2.257242, 1.158196, 0.378248, -0.368431, 2.218671, 1.150173,
- 0.404674, -0.384428, 2.173680, 1.140703, 0.431385, -0.399230, 2.127083, 1.129555, 0.457407,
- -0.411875, 2.073236, 1.116436, 0.483275, -0.423013, 2.018223, 1.101373, 0.509278, -0.432624,
- 1.962674, 1.084257, 0.534751, -0.439261, 1.900814, 1.064592, 0.561895, -0.443801, 1.839558,
- 1.040881, 0.588677, -0.445872, 1.777763, 1.015208, 0.614900, -0.445896, 1.716550, 0.987252,
- 0.641051, -0.444148, 1.657984, 0.957271, 0.666409, -0.440299, 1.600832, 0.924841, 0.691872,
- -0.435318, 1.548237, 0.891185, 0.716638, -0.428631, 1.497572, 0.855929, 0.739864, -0.419872,
- 1.447043, 0.819676, 0.763707, -0.410456, 1.403648, 0.781455, 0.786744, -0.399390, 1.360844,
- 0.742965, 0.809585, -0.386381, 1.320529, 0.703260, 0.834164, -0.372622, 1.286467, 0.662385,
- 0.856713, -0.357177, 1.252306, 0.621379, 0.879820, -0.341458, 1.223070, 0.580238, 0.902721,
- -0.325024, 1.197115, 0.539028, 0.924650, -0.307543, 1.172314, 0.498592, 0.947613, -0.289557,
- 1.151171, 0.457980, 0.969590, -0.269799, 1.129986, 0.417696, 0.992961, -0.250111, 1.113321,
- 0.377529, 1.014582, -0.229761, 1.097149, 0.339096, 1.038069, -0.209375, 1.083913, 0.301119,
- 1.061661, -0.188038, 1.071241, 0.263506, 1.085069, -0.165874, 1.060508, 0.227921, 1.107744,
- -0.143437, 1.052930, 0.194062, 1.127982, -0.120574, 1.046396, 0.162506, 1.144541, -0.096569,
- 1.039880, 0.130788, 1.155876, -0.072039, 1.030946, 0.098057, 1.162719, -0.047888, 1.020124,
- 0.064956, 1.167089, -0.023740, 1.008953, 0.031966, 1.172775, 0.000277, 1.000067, -0.000111,
- 0.000200, -0.000251, 2.573709, 1.253951, 0.000504, -0.000632, 2.572401, 1.253940, 0.002015,
- -0.002527, 2.571267, 1.253927, 0.004535, -0.005687, 2.572481, 1.253948, 0.008062, -0.010108,
- 2.571851, 1.253941, 0.012588, -0.015780, 2.568431, 1.253934, 0.018139, -0.022731, 2.569765,
- 1.253893, 0.024709, -0.030948, 2.572115, 1.253853, 0.032283, -0.040401, 2.571456, 1.253785,
- 0.040883, -0.051105, 2.571041, 1.253683, 0.050514, -0.063041, 2.570153, 1.253538, 0.061188,
- -0.076195, 2.569085, 1.253336, 0.072926, -0.090402, 2.567184, 1.253065, 0.085746, -0.105745,
- 2.564731, 1.252697, 0.099661, -0.122296, 2.561995, 1.252218, 0.114699, -0.139912, 2.559019,
- 1.251590, 0.130882, -0.158362, 2.555017, 1.250766, 0.148202, -0.177856, 2.549419, 1.249744,
- 0.166706, -0.198049, 2.542908, 1.248423, 0.186404, -0.219014, 2.535205, 1.246741, 0.207272,
- -0.240376, 2.524893, 1.244596, 0.229345, -0.262230, 2.512804, 1.241917, 0.252494, -0.284134,
- 2.496923, 1.238610, 0.276690, -0.305828, 2.476583, 1.234474, 0.301798, -0.327107, 2.451548,
- 1.229292, 0.327423, -0.347300, 2.418630, 1.222997, 0.353848, -0.366699, 2.381002, 1.215366,
- 0.380342, -0.384421, 2.334413, 1.206199, 0.407390, -0.400855, 2.285660, 1.195374, 0.433913,
- -0.415241, 2.228604, 1.182290, 0.460837, -0.428275, 2.171532, 1.167385, 0.486381, -0.438573,
- 2.105639, 1.150401, 0.511959, -0.447348, 2.040835, 1.130990, 0.537586, -0.454152, 1.974797,
- 1.109302, 0.564035, -0.458684, 1.907895, 1.084131, 0.590690, -0.460058, 1.839482, 1.055803,
- 0.617250, -0.459662, 1.772332, 1.025103, 0.643406, -0.457260, 1.707313, 0.992502, 0.668794,
- -0.452666, 1.644722, 0.957657, 0.693930, -0.446641, 1.586832, 0.921340, 0.718708, -0.439121,
- 1.531197, 0.883841, 0.743469, -0.430429, 1.480765, 0.844931, 0.766080, -0.419622, 1.430338,
- 0.804786, 0.789801, -0.408368, 1.386295, 0.764206, 0.812718, -0.395392, 1.343758, 0.722565,
- 0.835453, -0.380699, 1.304655, 0.680585, 0.858801, -0.364834, 1.269287, 0.637235, 0.881537,
- -0.348092, 1.237493, 0.594579, 0.904656, -0.331087, 1.208862, 0.552313, 0.926357, -0.312966,
- 1.182365, 0.510080, 0.949001, -0.294684, 1.159452, 0.468677, 0.971598, -0.275361, 1.138706,
- 0.426723, 0.994905, -0.254947, 1.120552, 0.385875, 1.017981, -0.234109, 1.104215, 0.345751,
- 1.040840, -0.213040, 1.089276, 0.306762, 1.063893, -0.191616, 1.075845, 0.269066, 1.086907,
- -0.169272, 1.063788, 0.232171, 1.109937, -0.146076, 1.054977, 0.197826, 1.130808, -0.122544,
- 1.048572, 0.165272, 1.146831, -0.098492, 1.040742, 0.133280, 1.158955, -0.073710, 1.031818,
- 0.100262, 1.166161, -0.048610, 1.020747, 0.066165, 1.170491, -0.024209, 1.009380, 0.032741,
- 1.176111, 0.000010, 1.000042, 0.000056, 0.000202, -0.000267, 2.786357, 1.320169, 0.000504,
- -0.000665, 2.741889, 1.320168, 0.002015, -0.002660, 2.740000, 1.320143, 0.004536, -0.005987,
- 2.744276, 1.320161, 0.008063, -0.010644, 2.743432, 1.320162, 0.012600, -0.016628, 2.741741,
- 1.320148, 0.018144, -0.023937, 2.741314, 1.320127, 0.024708, -0.032577, 2.741916, 1.320061,
- 0.032290, -0.042536, 2.742132, 1.319976, 0.040894, -0.053799, 2.741199, 1.319861, 0.050533,
- -0.066361, 2.740258, 1.319691, 0.061223, -0.080202, 2.739045, 1.319458, 0.072985, -0.095109,
- 2.736519, 1.319138, 0.085841, -0.111296, 2.733903, 1.318715, 0.099808, -0.128685, 2.730944,
- 1.318156, 0.114903, -0.147202, 2.727293, 1.317424, 0.131164, -0.166575, 2.722169, 1.316485,
- 0.148599, -0.187019, 2.716148, 1.315274, 0.167245, -0.208240, 2.708701, 1.313733, 0.187078,
- -0.230151, 2.698998, 1.311792, 0.208153, -0.252538, 2.687341, 1.309343, 0.230418, -0.275295,
- 2.672621, 1.306247, 0.253802, -0.298066, 2.653619, 1.302374, 0.278261, -0.320673, 2.629943,
- 1.297573, 0.303527, -0.342528, 2.599228, 1.291625, 0.329571, -0.363531, 2.562226, 1.284374,
- 0.355939, -0.382963, 2.515491, 1.275478, 0.382987, -0.401306, 2.464858, 1.264866, 0.409917,
- -0.417455, 2.404877, 1.252184, 0.437015, -0.432067, 2.341408, 1.237415, 0.463474, -0.444204,
- 2.271837, 1.220687, 0.489835, -0.454631, 2.200593, 1.200973, 0.516054, -0.463338, 2.129733,
- 1.179346, 0.541397, -0.469425, 2.055635, 1.155039, 0.566798, -0.473526, 1.980812, 1.127866,
- 0.593114, -0.474632, 1.904723, 1.097304, 0.619945, -0.473597, 1.832456, 1.063603, 0.646325,
- -0.470656, 1.761501, 1.027971, 0.672320, -0.465675, 1.694248, 0.990692, 0.697163, -0.458527,
- 1.629227, 0.951582, 0.721472, -0.449904, 1.568132, 0.911197, 0.745855, -0.440140, 1.512084,
- 0.869745, 0.770089, -0.429338, 1.460694, 0.827648, 0.792546, -0.416701, 1.410739, 0.784728,
- 0.815161, -0.403151, 1.365438, 0.741884, 0.837994, -0.388714, 1.324811, 0.697800, 0.861220,
- -0.372573, 1.287723, 0.653341, 0.883737, -0.355024, 1.252491, 0.609455, 0.906784, -0.337092,
- 1.221844, 0.565275, 0.928493, -0.318370, 1.192881, 0.521558, 0.951495, -0.299605, 1.169131,
- 0.478149, 0.973586, -0.280067, 1.146316, 0.436325, 0.996400, -0.259823, 1.127860, 0.394409,
- 1.019780, -0.238313, 1.110521, 0.353045, 1.042775, -0.216506, 1.093915, 0.312803, 1.066822,
- -0.194695, 1.080326, 0.274100, 1.089869, -0.172290, 1.067722, 0.236657, 1.113606, -0.149264,
- 1.058471, 0.201603, 1.134229, -0.124814, 1.050701, 0.168398, 1.150922, -0.100070, 1.043051,
- 0.135616, 1.163224, -0.075155, 1.033742, 0.102144, 1.169965, -0.049933, 1.021818, 0.067532,
- 1.174200, -0.024461, 1.009916, 0.033215, 1.179766, 0.000188, 1.000045, -0.000014, 0.000202,
- -0.000281, 2.964186, 1.390880, 0.000505, -0.000702, 2.945157, 1.390903, 0.002015, -0.002802,
- 2.931184, 1.390863, 0.004535, -0.006307, 2.935673, 1.390900, 0.008063, -0.011213, 2.934274,
- 1.390890, 0.012598, -0.017516, 2.932216, 1.390876, 0.018147, -0.025221, 2.933324, 1.390832,
- 0.024711, -0.034322, 2.933945, 1.390769, 0.032295, -0.044810, 2.933496, 1.390674, 0.040904,
- -0.056673, 2.932487, 1.390538, 0.050555, -0.069906, 2.931571, 1.390342, 0.061259, -0.084468,
- 2.929914, 1.390064, 0.073053, -0.100152, 2.927039, 1.389695, 0.085948, -0.117202, 2.924241,
- 1.389201, 0.099968, -0.135531, 2.920760, 1.388548, 0.115135, -0.154906, 2.915998, 1.387692,
- 0.131496, -0.175352, 2.910285, 1.386611, 0.149049, -0.196783, 2.903174, 1.385190, 0.167848,
- -0.219066, 2.894584, 1.383407, 0.187879, -0.241983, 2.883171, 1.381148, 0.209143, -0.265398,
- 2.869102, 1.378261, 0.231689, -0.289254, 2.852238, 1.374690, 0.255223, -0.312776, 2.828264,
- 1.370166, 0.279952, -0.336260, 2.800175, 1.364591, 0.305572, -0.358865, 2.764282, 1.357758,
- 0.331650, -0.380223, 2.717845, 1.349413, 0.358491, -0.400252, 2.665326, 1.339084, 0.385445,
- -0.418422, 2.602293, 1.326773, 0.412947, -0.434993, 2.536973, 1.312141, 0.439681, -0.448757,
- 2.459463, 1.295205, 0.467272, -0.461427, 2.386250, 1.275573, 0.493568, -0.471102, 2.303225,
- 1.253400, 0.519743, -0.478930, 2.221945, 1.228890, 0.544882, -0.484098, 2.136425, 1.201730,
- 0.570690, -0.488125, 2.057093, 1.172022, 0.595905, -0.489185, 1.975334, 1.139312, 0.622747,
- -0.487535, 1.895055, 1.103038, 0.648695, -0.483482, 1.815995, 1.064364, 0.675159, -0.478096,
- 1.744272, 1.024098, 0.700714, -0.470492, 1.675257, 0.982186, 0.725641, -0.461398, 1.609135,
- 0.939137, 0.748552, -0.449825, 1.545091, 0.894791, 0.772808, -0.438185, 1.489394, 0.850373,
- 0.795928, -0.425073, 1.437026, 0.805287, 0.818900, -0.411028, 1.389654, 0.760003, 0.841633,
- -0.396047, 1.345873, 0.714914, 0.863213, -0.379637, 1.305185, 0.669271, 0.886662, -0.362227,
- 1.269147, 0.622935, 0.908504, -0.343068, 1.234714, 0.577757, 0.931425, -0.323982, 1.204997,
- 0.532922, 0.953835, -0.304347, 1.178871, 0.488154, 0.975813, -0.284219, 1.155019, 0.444885,
- 0.997662, -0.263544, 1.133941, 0.402224, 1.021167, -0.242611, 1.116100, 0.360530, 1.044038,
- -0.220065, 1.098348, 0.318968, 1.068837, -0.197580, 1.084605, 0.279107, 1.092548, -0.174779,
- 1.071217, 0.241111, 1.116157, -0.151596, 1.060486, 0.204913, 1.137486, -0.127478, 1.052751,
- 0.171410, 1.154694, -0.101915, 1.044807, 0.137999, 1.166867, -0.076246, 1.034824, 0.103807,
- 1.173715, -0.050661, 1.022501, 0.068802, 1.178236, -0.025355, 1.010324, 0.034155, 1.183545,
- 0.000205, 1.000059, -0.000110, 0.000201, -0.000294, 3.161080, 1.466721, 0.000505, -0.000740,
- 3.155526, 1.466737, 0.002016, -0.002957, 3.152852, 1.466688, 0.004537, -0.006655, 3.150654,
- 1.466667, 0.008066, -0.011828, 3.153109, 1.466694, 0.012604, -0.018479, 3.152143, 1.466721,
- 0.018150, -0.026598, 3.151025, 1.466636, 0.024714, -0.036191, 3.150300, 1.466562, 0.032301,
- -0.047249, 3.149861, 1.466450, 0.040924, -0.059766, 3.149548, 1.466289, 0.050579, -0.073703,
- 3.147516, 1.466055, 0.061306, -0.089022, 3.145680, 1.465738, 0.073135, -0.105563, 3.142428,
- 1.465301, 0.086075, -0.123544, 3.139113, 1.464715, 0.100153, -0.142853, 3.135064, 1.463956,
- 0.115411, -0.163183, 3.129509, 1.462962, 0.131876, -0.184760, 3.122959, 1.461670, 0.149570,
- -0.207172, 3.114153, 1.460045, 0.168523, -0.230578, 3.103626, 1.457945, 0.188784, -0.254658,
- 3.090818, 1.455279, 0.210264, -0.279114, 3.073352, 1.451998, 0.233030, -0.303930, 3.052592,
- 1.447780, 0.256959, -0.328517, 3.025187, 1.442568, 0.281901, -0.352755, 2.990341, 1.436026,
- 0.307728, -0.375894, 2.946820, 1.427979, 0.334197, -0.397924, 2.892845, 1.418249, 0.360966,
- -0.417914, 2.827937, 1.406370, 0.388478, -0.436526, 2.758006, 1.392134, 0.415567, -0.452366,
- 2.674696, 1.375244, 0.443518, -0.466917, 2.595136, 1.355660, 0.470631, -0.478417, 2.504173,
- 1.333123, 0.497419, -0.487825, 2.413227, 1.308181, 0.523961, -0.495064, 2.321239, 1.280227,
- 0.549708, -0.499844, 2.228911, 1.249894, 0.575296, -0.502844, 2.138834, 1.217130, 0.600168,
- -0.503368, 2.049030, 1.181412, 0.625874, -0.501622, 1.962267, 1.142648, 0.652164, -0.496936,
- 1.876900, 1.101268, 0.678029, -0.490319, 1.796344, 1.057782, 0.703248, -0.481575, 1.718925,
- 1.012884, 0.728520, -0.471822, 1.648358, 0.966487, 0.752577, -0.460134, 1.581989, 0.919880,
- 0.776163, -0.447164, 1.520109, 0.873087, 0.800016, -0.433601, 1.465081, 0.825803, 0.822176,
- -0.418388, 1.412564, 0.778249, 0.844873, -0.402704, 1.366184, 0.730849, 0.865955, -0.385633,
- 1.321865, 0.684037, 0.888173, -0.368255, 1.283464, 0.637192, 0.910994, -0.349332, 1.249215,
- 0.590131, 0.934270, -0.329612, 1.218366, 0.543213, 0.956653, -0.309228, 1.189808, 0.497752,
- 0.978476, -0.288310, 1.163674, 0.452837, 1.000755, -0.267243, 1.141389, 0.409481, 1.023827,
- -0.246015, 1.122012, 0.367354, 1.045572, -0.223777, 1.103303, 0.325171, 1.070445, -0.200837,
- 1.088010, 0.284442, 1.094268, -0.177211, 1.073650, 0.245138, 1.118639, -0.153531, 1.063051,
- 0.208289, 1.139786, -0.129074, 1.053921, 0.173607, 1.157848, -0.104051, 1.045968, 0.140467,
- 1.170697, -0.077694, 1.035782, 0.105594, 1.177874, -0.051393, 1.023483, 0.069898, 1.182242,
- -0.025392, 1.010620, 0.034532, 1.187612, -0.000032, 1.000062, -0.000035, 0.000202, -0.000313,
- 3.450327, 1.548291, 0.000504, -0.000780, 3.396162, 1.548289, 0.002015, -0.003120, 3.395621,
- 1.548260, 0.004533, -0.007019, 3.394299, 1.548217, 0.008066, -0.012486, 3.398803, 1.548274,
- 0.012600, -0.019500, 3.396363, 1.548245, 0.018151, -0.028076, 3.396805, 1.548192, 0.024722,
- -0.038209, 3.396384, 1.548109, 0.032306, -0.049868, 3.395158, 1.547979, 0.040936, -0.063077,
- 3.394303, 1.547785, 0.050610, -0.077791, 3.392979, 1.547513, 0.061360, -0.093869, 3.389910,
- 1.547134, 0.073227, -0.111380, 3.386669, 1.546619, 0.086217, -0.130371, 3.382974, 1.545938,
- 0.100364, -0.150684, 3.378046, 1.545039, 0.115733, -0.172116, 3.371719, 1.543880, 0.132309,
- -0.194809, 3.363764, 1.542380, 0.150174, -0.218431, 3.353699, 1.540462, 0.169340, -0.242954,
- 3.341397, 1.538002, 0.189788, -0.268175, 3.324957, 1.534894, 0.211581, -0.293776, 3.304776,
- 1.530954, 0.234561, -0.319619, 3.278192, 1.526033, 0.258776, -0.345089, 3.244910, 1.519926,
- 0.284059, -0.370176, 3.203338, 1.512296, 0.310312, -0.394171, 3.152477, 1.502956, 0.336748,
- -0.416137, 3.083616, 1.491463, 0.364029, -0.436752, 3.010481, 1.477493, 0.391575, -0.455102,
- 2.925454, 1.460933, 0.419409, -0.471378, 2.834380, 1.441554, 0.446811, -0.484714, 2.733329,
- 1.418861, 0.474489, -0.496021, 2.633630, 1.393405, 0.501751, -0.504991, 2.530935, 1.364633,
- 0.528488, -0.511392, 2.426653, 1.333234, 0.554428, -0.515395, 2.323633, 1.299138, 0.580434,
- -0.517761, 2.224964, 1.262462, 0.605474, -0.517598, 2.127228, 1.223784, 0.629888, -0.514946,
- 2.030545, 1.182321, 0.655579, -0.510177, 1.939070, 1.138515, 0.681940, -0.503097, 1.852355,
- 1.091502, 0.707228, -0.493537, 1.768084, 1.043464, 0.731894, -0.482372, 1.690840, 0.994242,
- 0.756741, -0.470312, 1.619277, 0.944749, 0.780160, -0.456412, 1.553430, 0.894816, 0.803384,
- -0.441492, 1.493357, 0.845202, 0.826347, -0.425944, 1.437830, 0.795954, 0.849145, -0.409532,
- 1.388578, 0.746915, 0.870617, -0.391988, 1.341527, 0.698025, 0.892943, -0.374229, 1.302188,
- 0.649579, 0.913828, -0.355148, 1.262877, 0.601833, 0.936830, -0.335238, 1.230136, 0.554521,
- 0.958687, -0.313939, 1.199596, 0.507208, 0.982008, -0.292741, 1.173619, 0.461357, 1.003691,
- -0.270940, 1.149015, 0.416031, 1.027223, -0.249102, 1.128689, 0.372457, 1.050048, -0.226899,
- 1.109444, 0.330281, 1.074105, -0.204329, 1.092943, 0.288987, 1.098971, -0.180560, 1.078591,
- 0.249075, 1.123324, -0.155987, 1.066885, 0.211519, 1.145445, -0.130929, 1.057617, 0.176506,
- 1.162856, -0.105269, 1.048453, 0.142345, 1.175360, -0.079267, 1.037439, 0.107452, 1.182514,
- -0.052547, 1.024393, 0.071252, 1.186575, -0.025744, 1.011093, 0.035019, 1.192050, 0.000318,
- 1.000013, -0.000152, 0.000204, -0.000334, 3.909175, 1.636412, 0.000504, -0.000825, 3.678647,
- 1.636410, 0.002015, -0.003298, 3.678315, 1.636387, 0.004533, -0.007417, 3.674126, 1.636310,
- 0.008062, -0.013190, 3.676771, 1.636376, 0.012603, -0.020613, 3.678135, 1.636369, 0.018153,
- -0.029675, 3.677315, 1.636299, 0.024723, -0.040378, 3.676872, 1.636196, 0.032318, -0.052708,
- 3.675750, 1.636038, 0.040955, -0.066660, 3.674803, 1.635810, 0.050645, -0.082203, 3.672735,
- 1.635494, 0.061429, -0.099150, 3.669047, 1.635048, 0.073333, -0.117679, 3.665401, 1.634437,
- 0.086388, -0.137725, 3.661315, 1.633634, 0.100620, -0.159081, 3.654992, 1.632571, 0.116087,
- -0.181721, 3.647341, 1.631202, 0.132820, -0.205611, 3.637877, 1.629432, 0.150867, -0.230542,
- 3.626333, 1.627161, 0.170234, -0.256239, 3.610671, 1.624266, 0.190981, -0.282751, 3.591685,
- 1.620589, 0.213013, -0.309430, 3.565864, 1.615999, 0.236387, -0.336427, 3.534826, 1.610216,
- 0.260943, -0.362931, 3.493984, 1.603047, 0.286497, -0.388644, 3.442075, 1.593920, 0.312769,
- -0.412912, 3.375973, 1.582961, 0.339832, -0.435635, 3.299355, 1.569343, 0.367214, -0.456181,
- 3.208994, 1.553137, 0.394935, -0.474325, 3.108910, 1.533791, 0.422935, -0.490318, 3.001767,
- 1.511093, 0.451166, -0.503827, 2.891735, 1.485145, 0.478695, -0.514185, 2.773430, 1.455617,
- 0.506313, -0.522502, 2.657639, 1.422946, 0.533427, -0.528119, 2.541132, 1.387843, 0.559942,
- -0.531430, 2.426950, 1.349542, 0.585150, -0.531978, 2.312437, 1.309303, 0.610500, -0.531054,
- 2.205966, 1.266280, 0.635380, -0.528058, 2.101993, 1.221709, 0.659852, -0.522751, 2.002950,
- 1.175062, 0.685151, -0.515026, 1.908647, 1.125078, 0.710920, -0.505020, 1.819389, 1.074296,
- 0.736066, -0.493268, 1.735806, 1.022420, 0.760503, -0.480032, 1.658607, 0.970230, 0.785091,
- -0.465986, 1.589424, 0.917077, 0.807523, -0.449721, 1.522533, 0.864888, 0.830974, -0.433461,
- 1.465416, 0.813006, 0.852659, -0.415808, 1.409076, 0.761689, 0.874841, -0.397855, 1.360758,
- 0.711258, 0.896322, -0.379041, 1.316829, 0.661721, 0.918134, -0.360048, 1.278574, 0.612263,
- 0.939356, -0.340108, 1.242200, 0.564369, 0.961025, -0.318877, 1.210305, 0.516506, 0.984371,
- -0.297130, 1.183689, 0.469342, 1.006905, -0.274661, 1.157466, 0.423080, 1.029941, -0.252234,
- 1.135066, 0.378315, 1.052751, -0.229268, 1.114518, 0.335169, 1.077981, -0.206662, 1.097760,
- 0.293336, 1.102542, -0.183331, 1.082051, 0.252984, 1.126539, -0.158797, 1.068935, 0.214990,
- 1.149023, -0.133014, 1.058996, 0.178903, 1.167550, -0.106641, 1.050245, 0.144559, 1.179994,
- -0.079952, 1.038648, 0.108667, 1.187104, -0.053316, 1.025284, 0.072209, 1.191406, -0.026826,
- 1.011453, 0.035833, 1.196748, 0.000226, 1.000034, -0.000061, 0.000200, -0.000346, 3.996419,
- 1.732034, 0.000504, -0.000873, 4.000138, 1.732038, 0.002016, -0.003492, 4.002078, 1.732012,
- 0.004538, -0.007859, 4.005626, 1.731962, 0.008064, -0.013963, 3.998500, 1.731999, 0.012590,
- -0.021794, 3.995024, 1.732004, 0.018154, -0.031406, 3.999233, 1.731901, 0.024727, -0.042733,
- 3.998497, 1.731774, 0.032327, -0.055781, 3.997064, 1.731599, 0.040974, -0.070543, 3.995856,
- 1.731325, 0.050685, -0.086984, 3.993839, 1.730945, 0.061506, -0.104897, 3.989519, 1.730417,
- 0.073458, -0.124506, 3.985313, 1.729697, 0.086573, -0.145706, 3.979984, 1.728747, 0.100909,
- -0.168211, 3.972562, 1.727491, 0.116509, -0.192198, 3.963836, 1.725854, 0.133404, -0.217280,
- 3.951919, 1.723749, 0.151659, -0.243556, 3.937734, 1.721093, 0.171288, -0.270611, 3.919021,
- 1.717640, 0.192301, -0.298389, 3.895171, 1.713272, 0.214683, -0.326338, 3.864171, 1.707825,
- 0.238392, -0.354394, 3.824682, 1.700956, 0.263151, -0.381636, 3.771168, 1.692392, 0.289155,
- -0.408266, 3.709961, 1.681769, 0.315832, -0.433070, 3.630302, 1.668539, 0.342942, -0.455741,
- 3.534719, 1.652513, 0.370892, -0.476655, 3.431531, 1.633428, 0.398985, -0.494692, 3.314933,
- 1.610694, 0.427206, -0.510313, 3.189741, 1.584240, 0.455266, -0.522760, 3.058325, 1.554195,
- 0.483472, -0.532872, 2.927213, 1.520805, 0.511192, -0.540229, 2.794112, 1.484026, 0.538706,
- -0.545105, 2.663786, 1.443796, 0.565422, -0.547251, 2.534841, 1.401429, 0.591270, -0.547115,
- 2.408437, 1.356231, 0.616787, -0.545113, 2.291284, 1.308887, 0.641380, -0.540853, 2.177478,
- 1.260447, 0.665344, -0.534561, 2.069265, 1.210634, 0.690147, -0.527115, 1.969776, 1.158569,
- 0.714578, -0.516171, 1.870847, 1.104593, 0.740349, -0.504048, 1.782674, 1.049578, 0.764563,
- -0.489683, 1.698614, 0.994458, 0.788710, -0.474541, 1.624447, 0.938612, 0.812154, -0.458099,
- 1.554453, 0.883694, 0.834566, -0.440345, 1.490045, 0.830220, 0.857486, -0.422491, 1.432889,
- 0.776499, 0.879224, -0.403588, 1.380669, 0.724257, 0.899971, -0.383819, 1.333124, 0.673311,
- 0.922111, -0.364250, 1.292648, 0.622999, 0.942842, -0.343873, 1.253933, 0.573304, 0.964398,
- -0.323206, 1.221027, 0.525090, 0.986860, -0.301711, 1.191806, 0.477580, 1.009760, -0.278695,
- 1.165162, 0.430624, 1.033347, -0.255591, 1.141715, 0.384482, 1.055937, -0.232039, 1.119739,
- 0.340532, 1.081178, -0.208664, 1.102117, 0.297311, 1.105696, -0.184935, 1.085062, 0.256227,
- 1.129575, -0.160673, 1.070918, 0.217709, 1.152135, -0.135414, 1.060642, 0.181471, 1.171221,
- -0.108462, 1.051041, 0.146380, 1.184412, -0.081008, 1.039694, 0.110120, 1.191820, -0.053710,
- 1.025903, 0.073052, 1.196195, -0.026625, 1.011816, 0.036129, 1.201677, -0.000175, 0.999945,
- 0.000098, 0.000196, -0.000360, 4.100786, 1.836290, 0.000504, -0.000925, 4.370184, 1.836295,
- 0.002018, -0.003706, 4.385247, 1.836243, 0.004534, -0.008324, 4.370146, 1.836210, 0.008064,
- -0.014805, 4.372335, 1.836256, 0.012597, -0.023116, 4.359918, 1.836259, 0.018158, -0.033299,
- 4.371503, 1.836123, 0.024732, -0.045301, 4.370533, 1.835988, 0.032344, -0.059143, 4.369649,
- 1.835768, 0.040999, -0.074779, 4.367861, 1.835454, 0.050739, -0.092178, 4.364322, 1.834974,
- 0.061594, -0.111161, 4.359221, 1.834355, 0.073604, -0.131958, 4.354620, 1.833499, 0.086796,
- -0.154393, 4.347915, 1.832355, 0.101246, -0.178201, 4.339152, 1.830880, 0.116990, -0.203531,
- 4.328327, 1.828936, 0.134086, -0.230043, 4.314240, 1.826442, 0.152589, -0.257718, 4.296795,
- 1.823230, 0.172514, -0.286176, 4.273985, 1.819124, 0.193853, -0.315295, 4.244136, 1.813909,
- 0.216582, -0.344507, 4.205152, 1.807410, 0.240668, -0.373646, 4.154781, 1.799084, 0.265904,
- -0.401897, 4.091563, 1.788905, 0.292226, -0.429136, 4.013199, 1.776206, 0.319045, -0.454057,
- 3.912886, 1.760500, 0.346721, -0.477219, 3.800927, 1.741586, 0.374849, -0.497883, 3.675652,
- 1.718818, 0.403078, -0.515504, 3.536892, 1.692138, 0.431597, -0.530621, 3.391351, 1.661434,
- 0.460246, -0.542852, 3.242817, 1.626989, 0.488899, -0.552238, 3.093685, 1.588582, 0.517215,
- -0.559045, 2.944163, 1.546300, 0.544480, -0.562351, 2.794189, 1.501299, 0.571542, -0.563394,
- 2.650239, 1.453758, 0.598167, -0.562590, 2.513757, 1.403321, 0.624104, -0.559636, 2.384203,
- 1.352431, 0.648789, -0.554148, 2.259149, 1.298758, 0.672715, -0.546779, 2.140250, 1.244943,
- 0.696258, -0.537896, 2.030401, 1.189971, 0.720048, -0.527401, 1.928311, 1.134526, 0.744078,
- -0.514142, 1.830175, 1.076504, 0.768895, -0.499352, 1.740731, 1.018032, 0.792551, -0.482982,
- 1.658911, 0.960250, 0.817007, -0.466406, 1.586579, 0.903029, 0.839035, -0.447616, 1.516969,
- 0.846484, 0.862742, -0.429261, 1.458675, 0.791420, 0.884307, -0.409479, 1.402989, 0.737125,
- 0.905641, -0.389303, 1.352817, 0.683912, 0.926185, -0.368344, 1.306684, 0.632690, 0.947229,
- -0.347366, 1.267395, 0.581739, 0.969502, -0.326720, 1.233192, 0.532305, 0.990758, -0.304973,
- 1.201017, 0.484166, 1.012749, -0.282816, 1.173018, 0.437385, 1.035533, -0.259084, 1.147184,
- 0.390755, 1.059915, -0.235239, 1.125388, 0.345399, 1.084348, -0.211044, 1.105859, 0.301356,
- 1.109544, -0.186698, 1.088888, 0.259708, 1.133770, -0.161900, 1.073848, 0.220324, 1.157553,
- -0.136604, 1.063190, 0.183857, 1.176461, -0.110428, 1.053110, 0.148521, 1.190137, -0.082898,
- 1.041484, 0.112124, 1.197215, -0.054554, 1.026844, 0.074160, 1.201654, -0.026744, 1.012264,
- 0.036527, 1.207085, 0.000399, 1.000034, -0.000201, 0.000191, -0.000373, 4.194318, 1.950551,
- 0.000504, -0.000983, 4.804350, 1.950552, 0.002015, -0.003931, 4.802820, 1.950518, 0.004536,
- -0.008847, 4.805254, 1.950472, 0.008064, -0.015725, 4.804152, 1.950517, 0.012693, -0.024740,
- 4.826828, 1.949914, 0.018159, -0.035365, 4.803103, 1.950349, 0.024740, -0.048122, 4.803220,
- 1.950183, 0.032361, -0.062822, 4.801522, 1.949917, 0.041034, -0.079430, 4.799593, 1.949538,
- 0.050815, -0.097841, 4.797179, 1.948972, 0.061702, -0.118026, 4.789557, 1.948246, 0.073766,
- -0.140112, 4.783293, 1.947204, 0.087066, -0.163819, 4.775698, 1.945855, 0.101637, -0.189122,
- 4.764612, 1.944052, 0.117558, -0.215884, 4.751486, 1.941710, 0.134884, -0.243968, 4.734791,
- 1.938727, 0.153637, -0.273170, 4.712078, 1.934891, 0.173890, -0.303146, 4.683575, 1.929976,
- 0.195643, -0.333704, 4.646766, 1.923740, 0.218767, -0.364170, 4.596814, 1.915888, 0.243337,
- -0.394530, 4.535509, 1.905970, 0.268860, -0.423512, 4.452006, 1.893623, 0.295173, -0.450609,
- 4.345682, 1.878286, 0.322784, -0.476488, 4.231632, 1.859391, 0.350616, -0.499420, 4.093553,
- 1.836912, 0.379127, -0.519862, 3.944127, 1.809625, 0.407860, -0.537373, 3.782223, 1.778529,
- 0.436717, -0.551802, 3.615563, 1.742684, 0.465345, -0.562951, 3.440672, 1.702289, 0.494158,
- -0.571334, 3.268070, 1.658666, 0.522896, -0.577227, 3.100668, 1.611027, 0.551379, -0.580514,
- 2.937615, 1.559742, 0.578992, -0.580610, 2.778703, 1.507257, 0.605095, -0.577729, 2.621626,
- 1.451941, 0.630653, -0.573000, 2.476506, 1.395218, 0.656175, -0.566944, 2.341592, 1.337862,
- 0.681036, -0.558988, 2.216478, 1.279275, 0.704713, -0.549211, 2.096972, 1.220526, 0.726894,
- -0.537190, 1.983311, 1.161709, 0.749865, -0.524167, 1.881100, 1.102095, 0.773553, -0.508991,
- 1.785637, 1.042039, 0.797102, -0.491658, 1.697234, 0.981588, 0.821187, -0.474093, 1.620250,
- 0.921265, 0.843848, -0.454980, 1.547071, 0.862757, 0.866662, -0.435421, 1.482008, 0.804700,
- 0.888696, -0.414990, 1.424116, 0.749432, 0.910945, -0.394472, 1.372658, 0.694767, 0.932300,
- -0.373239, 1.325157, 0.641106, 0.952850, -0.351347, 1.282217, 0.589689, 0.974718, -0.329809,
- 1.244897, 0.539322, 0.996445, -0.307902, 1.212306, 0.490083, 1.017580, -0.285392, 1.181402,
- 0.442702, 1.040342, -0.262782, 1.155996, 0.395911, 1.064399, -0.238995, 1.131708, 0.350206,
- 1.089464, -0.214297, 1.111215, 0.305175, 1.115565, -0.189293, 1.093094, 0.262686, 1.140640,
- -0.163843, 1.077994, 0.223078, 1.163824, -0.137789, 1.066014, 0.185651, 1.182577, -0.111087,
- 1.055615, 0.150045, 1.195775, -0.083945, 1.042940, 0.113457, 1.203175, -0.056145, 1.028015,
- 0.075453, 1.207282, -0.027685, 1.012552, 0.037217, 1.213019, 0.000362, 0.999938, -0.000293,
- 0.000187, -0.000388, 4.316009, 2.076500, 0.000504, -0.001048, 5.317799, 2.076499, 0.002014,
- -0.004182, 5.306557, 2.076523, 0.004539, -0.009425, 5.317505, 2.076453, 0.008063, -0.016737,
- 5.312143, 2.076410, 0.012614, -0.026171, 5.316434, 2.076389, 0.018158, -0.037641, 5.307836,
- 2.076265, 0.024767, -0.051266, 5.315297, 2.076044, 0.032372, -0.066859, 5.307433, 2.075743,
- 0.041066, -0.084538, 5.304809, 2.075270, 0.050871, -0.104062, 5.299277, 2.074622, 0.061821,
- -0.125613, 5.293419, 2.073708, 0.073970, -0.149085, 5.286629, 2.072457, 0.087375, -0.174214,
- 5.275937, 2.070804, 0.102105, -0.201136, 5.263267, 2.068647, 0.118223, -0.229505, 5.246309,
- 2.065846, 0.135814, -0.259217, 5.225496, 2.062189, 0.154887, -0.289990, 5.196580, 2.057566,
- 0.175510, -0.321618, 5.160716, 2.051593, 0.197636, -0.353632, 5.112202, 2.043949, 0.221168,
- -0.385303, 5.046981, 2.034445, 0.246099, -0.416511, 4.965386, 2.022368, 0.272070, -0.446377,
- 4.860735, 2.007160, 0.299090, -0.474279, 4.735140, 1.988598, 0.326702, -0.499809, 4.584962,
- 1.965865, 0.355017, -0.522790, 4.420447, 1.938705, 0.383856, -0.542755, 4.241942, 1.906370,
- 0.413059, -0.559903, 4.053302, 1.869455, 0.441882, -0.573174, 3.852753, 1.827946, 0.471516,
- -0.584151, 3.660377, 1.781652, 0.500872, -0.591843, 3.466027, 1.730885, 0.529677, -0.596253,
- 3.272812, 1.676821, 0.557683, -0.597604, 3.084286, 1.620064, 0.585652, -0.596591, 2.906111,
- 1.560909, 0.612819, -0.593138, 2.738258, 1.500318, 0.639848, -0.588245, 2.584172, 1.438127,
- 0.664758, -0.580140, 2.430697, 1.375746, 0.688754, -0.570189, 2.290701, 1.312727, 0.712848,
- -0.559420, 2.162679, 1.250063, 0.735111, -0.546570, 2.042186, 1.187840, 0.757521, -0.532944,
- 1.933435, 1.125513, 0.780056, -0.517981, 1.833524, 1.063827, 0.802513, -0.500724, 1.739053,
- 1.002154, 0.825462, -0.481625, 1.652381, 0.939811, 0.848973, -0.462327, 1.577560, 0.878279,
- 0.871521, -0.441928, 1.509291, 0.819200, 0.892325, -0.420297, 1.443799, 0.761607, 0.914935,
- -0.399072, 1.389647, 0.705351, 0.936429, -0.377232, 1.339903, 0.650213, 0.957614, -0.355091,
- 1.295467, 0.597773, 0.979578, -0.332767, 1.256692, 0.545914, 1.000860, -0.310147, 1.221666,
- 0.495661, 1.022550, -0.287395, 1.190775, 0.448026, 1.045005, -0.264582, 1.162641, 0.400490,
- 1.068703, -0.241464, 1.138358, 0.354088, 1.093098, -0.217504, 1.115973, 0.309812, 1.119230,
- -0.192140, 1.096284, 0.266297, 1.144608, -0.165975, 1.080042, 0.225831, 1.168599, -0.139174,
- 1.067749, 0.187761, 1.187970, -0.111910, 1.056635, 0.151322, 1.201240, -0.083978, 1.043566,
- 0.114337, 1.208895, -0.056089, 1.028366, 0.076083, 1.213344, -0.028369, 1.013074, 0.037735,
- 1.219220, -0.000534, 0.999968, 0.000076, 0.000182, -0.000404, 4.433519, 2.216201, 0.000504,
- -0.001117, 5.911693, 2.216198, 0.002017, -0.004469, 5.919142, 2.216190, 0.004536, -0.010051,
- 5.913172, 2.216130, 0.008065, -0.017867, 5.911791, 2.216145, 0.012467, -0.027603, 5.785357,
- 2.216447, 0.018156, -0.040159, 5.901121, 2.215958, 0.024758, -0.054670, 5.908781, 2.215654,
- 0.032395, -0.071352, 5.906098, 2.215283, 0.041108, -0.090201, 5.902558, 2.214715, 0.050955,
- -0.111004, 5.895707, 2.213905, 0.061968, -0.134002, 5.888736, 2.212807, 0.074206, -0.159038,
- 5.880633, 2.211303, 0.087742, -0.185801, 5.867001, 2.209297, 0.102652, -0.214368, 5.851446,
- 2.206657, 0.119006, -0.244573, 5.830722, 2.203232, 0.136883, -0.276067, 5.802688, 2.198778,
- 0.156335, -0.308660, 5.767185, 2.193091, 0.177396, -0.341940, 5.719726, 2.185858, 0.200070,
- -0.375591, 5.658792, 2.176584, 0.224067, -0.408564, 5.573508, 2.164759, 0.249420, -0.440668,
- 5.465696, 2.149777, 0.275879, -0.471138, 5.332207, 2.131225, 0.303307, -0.499204, 5.173339,
- 2.108794, 0.331189, -0.524547, 4.985102, 2.080585, 0.359932, -0.547256, 4.785788, 2.047792,
- 0.389063, -0.566479, 4.569344, 2.009518, 0.418725, -0.583031, 4.349557, 1.965601, 0.448181,
- -0.595809, 4.121278, 1.916911, 0.477703, -0.605102, 3.892291, 1.863530, 0.507999, -0.612462,
- 3.676557, 1.806286, 0.536889, -0.615451, 3.456241, 1.745841, 0.565778, -0.616029, 3.249464,
- 1.681137, 0.593863, -0.613644, 3.050273, 1.615238, 0.620770, -0.608268, 2.859599, 1.548003,
- 0.647171, -0.601116, 2.683287, 1.480447, 0.673458, -0.592840, 2.524036, 1.412084, 0.698064,
- -0.581973, 2.371046, 1.345130, 0.721011, -0.568963, 2.229104, 1.278440, 0.744293, -0.555642,
- 2.103213, 1.212448, 0.766314, -0.540934, 1.985370, 1.146287, 0.788164, -0.525271, 1.878842,
- 1.082600, 0.809019, -0.507986, 1.779821, 1.019978, 0.830947, -0.489717, 1.691630, 0.956931,
- 0.853732, -0.469345, 1.607513, 0.894207, 0.874904, -0.447618, 1.531176, 0.833436, 0.897289,
- -0.426124, 1.467302, 0.773611, 0.919226, -0.404025, 1.408321, 0.716016, 0.940860, -0.381454,
- 1.356209, 0.659515, 0.962764, -0.358901, 1.310082, 0.604629, 0.984322, -0.335983, 1.268485,
- 0.552335, 1.005343, -0.312533, 1.230662, 0.501591, 1.028153, -0.289452, 1.199168, 0.452032,
- 1.049283, -0.265754, 1.168575, 0.404347, 1.073687, -0.242571, 1.143533, 0.357445, 1.097546,
- -0.218681, 1.119859, 0.312534, 1.123340, -0.194465, 1.099634, 0.269437, 1.148166, -0.168797,
- 1.081968, 0.228586, 1.172518, -0.141552, 1.068789, 0.189866, 1.192930, -0.113325, 1.057548,
- 0.152772, 1.206816, -0.084800, 1.044145, 0.115390, 1.215045, -0.056019, 1.028938, 0.076493,
- 1.220048, -0.027733, 1.013338, 0.037767, 1.225852, 0.000050, 0.999927, -0.000160, 0.000178,
- -0.000422, 4.587902, 2.372253, 0.000504, -0.001195, 6.624675, 2.372248, 0.002016, -0.004782,
- 6.626884, 2.372187, 0.004531, -0.010746, 6.607379, 2.372318, 0.008081, -0.019161, 6.640102,
- 2.372084, 0.012637, -0.029945, 6.653708, 2.372128, 0.018167, -0.042999, 6.623837, 2.371902,
- 0.024769, -0.058516, 6.624484, 2.371595, 0.032421, -0.076370, 6.620877, 2.371120, 0.041164,
- -0.096474, 6.615235, 2.370428, 0.051057, -0.118786, 6.607844, 2.369440, 0.062136, -0.143390,
- 6.599216, 2.368075, 0.074490, -0.170034, 6.588018, 2.366218, 0.088179, -0.198717, 6.572526,
- 2.363747, 0.103307, -0.229147, 6.551868, 2.360517, 0.119964, -0.261253, 6.526089, 2.356304,
- 0.138173, -0.294703, 6.489593, 2.350797, 0.158072, -0.329261, 6.443573, 2.343783, 0.179592,
- -0.364298, 6.379764, 2.334673, 0.202709, -0.399375, 6.295845, 2.323125, 0.227335, -0.433616,
- 6.184929, 2.308547, 0.253230, -0.466794, 6.045905, 2.289980, 0.280100, -0.497509, 5.871803,
- 2.266964, 0.308146, -0.525956, 5.672422, 2.239074, 0.336544, -0.551101, 5.443256, 2.204809,
- 0.365223, -0.572471, 5.188034, 2.164827, 0.395484, -0.592088, 4.943783, 2.119489, 0.424416,
- -0.606026, 4.666400, 2.067262, 0.455641, -0.619671, 4.418961, 2.009937, 0.485298, -0.627583,
- 4.152737, 1.948900, 0.514774, -0.632072, 3.893344, 1.882692, 0.544172, -0.634033, 3.645332,
- 1.814073, 0.573283, -0.633239, 3.414651, 1.742717, 0.602155, -0.630008, 3.195712, 1.669703,
- 0.630520, -0.624550, 2.994536, 1.596021, 0.657121, -0.615749, 2.799373, 1.522572, 0.682071,
- -0.604738, 2.616102, 1.448978, 0.707605, -0.593301, 2.456112, 1.376250, 0.731492, -0.579628,
- 2.303517, 1.305297, 0.754139, -0.564473, 2.165340, 1.235548, 0.776505, -0.548787, 2.041646,
- 1.167051, 0.796833, -0.531415, 1.923334, 1.100534, 0.817565, -0.513778, 1.818176, 1.035144,
- 0.837981, -0.495167, 1.723830, 0.971583, 0.858513, -0.475690, 1.638448, 0.908841, 0.879892,
- -0.454099, 1.559420, 0.846701, 0.902258, -0.432038, 1.491471, 0.785332, 0.924114, -0.409316,
- 1.428878, 0.726409, 0.944230, -0.385618, 1.370785, 0.668588, 0.967001, -0.362604, 1.323529,
- 0.612943, 0.988579, -0.339117, 1.279679, 0.559038, 1.010210, -0.315355, 1.240104, 0.506867,
- 1.032084, -0.291408, 1.205261, 0.456934, 1.054671, -0.267387, 1.175197, 0.407792, 1.078314,
- -0.243346, 1.148153, 0.360992, 1.102443, -0.219205, 1.123799, 0.315577, 1.128524, -0.194996,
- 1.102624, 0.271742, 1.153989, -0.169897, 1.085134, 0.230702, 1.179420, -0.143960, 1.071699,
- 0.192146, 1.200098, -0.116173, 1.060179, 0.155164, 1.214837, -0.086655, 1.046290, 0.117071,
- 1.222749, -0.056956, 1.030040, 0.077450, 1.227273, -0.027883, 1.013650, 0.038092, 1.233293,
- 0.000831, 1.000043, -0.000462, 0.000173, -0.000442, 4.741539, 2.547922, 0.000504, -0.001284,
- 7.491127, 2.547919, 0.002014, -0.005132, 7.484889, 2.547844, 0.004523, -0.011521, 7.439875,
- 2.547587, 0.008059, -0.020524, 7.483694, 2.547725, 0.012586, -0.032029, 7.470912, 2.547685,
- 0.018081, -0.045948, 7.422534, 2.547686, 0.024783, -0.062844, 7.487581, 2.547107, 0.032451,
- -0.082011, 7.483603, 2.546522, 0.041233, -0.103540, 7.475124, 2.545684, 0.051181, -0.127537,
- 7.467521, 2.544438, 0.062347, -0.153921, 7.456266, 2.542744, 0.074829, -0.182427, 7.440422,
- 2.540459, 0.088703, -0.213134, 7.420694, 2.537380, 0.104080, -0.245750, 7.394875, 2.533347,
- 0.121050, -0.279941, 7.358515, 2.528069, 0.139697, -0.315591, 7.313001, 2.521237, 0.160036,
- -0.351980, 7.246342, 2.512378, 0.182147, -0.388993, 7.163688, 2.500993, 0.205799, -0.425570,
- 7.048339, 2.486450, 0.231091, -0.461093, 6.902586, 2.468174, 0.257405, -0.494668, 6.712721,
- 2.444774, 0.284956, -0.525889, 6.491261, 2.415538, 0.313180, -0.553693, 6.232833, 2.380610,
- 0.342327, -0.578724, 5.953834, 2.338525, 0.371689, -0.599706, 5.649698, 2.290256, 0.401919,
- -0.617615, 5.347900, 2.235157, 0.432204, -0.631632, 5.036417, 2.173932, 0.463151, -0.643082,
- 4.735976, 2.107298, 0.493388, -0.649970, 4.432044, 2.036121, 0.524128, -0.654188, 4.145472,
- 1.961595, 0.553930, -0.654671, 3.866877, 1.883602, 0.583856, -0.653051, 3.607848, 1.804521,
- 0.611762, -0.646994, 3.356237, 1.724047, 0.639117, -0.638860, 3.122531, 1.643016, 0.666279,
- -0.629093, 2.913178, 1.563932, 0.692936, -0.617862, 2.722675, 1.484614, 0.716498, -0.603279,
- 2.536926, 1.406734, 0.742273, -0.589878, 2.381054, 1.331469, 0.764031, -0.572744, 2.228312,
- 1.256796, 0.786601, -0.555933, 2.095451, 1.185290, 0.807776, -0.537992, 1.972866, 1.115940,
- 0.828400, -0.519596, 1.863394, 1.048371, 0.847412, -0.499847, 1.760630, 0.982934, 0.866850,
- -0.479920, 1.670998, 0.919972, 0.886340, -0.459434, 1.587962, 0.858100, 0.906933, -0.437767,
- 1.515505, 0.796714, 0.927490, -0.414068, 1.448243, 0.736162, 0.950217, -0.390910, 1.390505,
- 0.677613, 0.971545, -0.366964, 1.337865, 0.620477, 0.992901, -0.342603, 1.291104, 0.565807,
- 1.015460, -0.318596, 1.251138, 0.513086, 1.037859, -0.294242, 1.214291, 0.461573, 1.060535,
- -0.269601, 1.182517, 0.411838, 1.086885, -0.245608, 1.155300, 0.363221, 1.111237, -0.220589,
- 1.129715, 0.317174, 1.138718, -0.196008, 1.108103, 0.273213, 1.164223, -0.170408, 1.089640,
- 0.231968, 1.187256, -0.144205, 1.074145, 0.192987, 1.207851, -0.116945, 1.061615, 0.156118,
- 1.222217, -0.088852, 1.047599, 0.118674, 1.230315, -0.059381, 1.030869, 0.078993, 1.235052,
- -0.029145, 1.014126, 0.038924, 1.241359, 0.000479, 1.000114, -0.000211, 0.000169, -0.000465,
- 4.953966, 2.747437, 0.000504, -0.001384, 8.544530, 2.747430, 0.002015, -0.005537, 8.545147,
- 2.747339, 0.004542, -0.012477, 8.557734, 2.747125, 0.008064, -0.022143, 8.530193, 2.747341,
- 0.012543, -0.034411, 8.465151, 2.747411, 0.018178, -0.049792, 8.543328, 2.746874, 0.024810,
- -0.067784, 8.547247, 2.746396, 0.032489, -0.088416, 8.537436, 2.745730, 0.041313, -0.111580,
- 8.526655, 2.744596, 0.051332, -0.137462, 8.517438, 2.743082, 0.062603, -0.165860, 8.502803,
- 2.740950, 0.075240, -0.196548, 8.481507, 2.738057, 0.089341, -0.229440, 8.454287, 2.734174,
- 0.105021, -0.264395, 8.420289, 2.729086, 0.122399, -0.301020, 8.373503, 2.722420, 0.141526,
- -0.338997, 8.309059, 2.713686, 0.162451, -0.377589, 8.221539, 2.702492, 0.185098, -0.416349,
- 8.100116, 2.687893, 0.209406, -0.454284, 7.941704, 2.669386, 0.235098, -0.490450, 7.733318,
- 2.645590, 0.262100, -0.524592, 7.486120, 2.615709, 0.290103, -0.555558, 7.193498, 2.579231,
- 0.319135, -0.583516, 6.874796, 2.534957, 0.348286, -0.606714, 6.516118, 2.483017, 0.378840,
- -0.627850, 6.163912, 2.424214, 0.409608, -0.644715, 5.801404, 2.357563, 0.440553, -0.657657,
- 5.435955, 2.285835, 0.470599, -0.665621, 5.063481, 2.207940, 0.503172, -0.673767, 4.743532,
- 2.126440, 0.533884, -0.676009, 4.413409, 2.040694, 0.563808, -0.674536, 4.092169, 1.953979,
- 0.591849, -0.668913, 3.787057, 1.865897, 0.621474, -0.663159, 3.520578, 1.777762, 0.650500,
- -0.655018, 3.275065, 1.689902, 0.678011, -0.643949, 3.043141, 1.603528, 0.703490, -0.630030,
- 2.827104, 1.519484, 0.728250, -0.614910, 2.632620, 1.436677, 0.752165, -0.598649, 2.455570,
- 1.355753, 0.775894, -0.581771, 2.295932, 1.278884, 0.797650, -0.563193, 2.152291, 1.202767,
- 0.818505, -0.543750, 2.022099, 1.130338, 0.838596, -0.524017, 1.903562, 1.060263, 0.858396,
- -0.504064, 1.797204, 0.993077, 0.877088, -0.483418, 1.701208, 0.928606, 0.896606, -0.462786,
- 1.617736, 0.866039, 0.914342, -0.440943, 1.539227, 0.804293, 0.933550, -0.419129, 1.470383,
- 0.745206, 0.955237, -0.396100, 1.409100, 0.685832, 0.976700, -0.371743, 1.354930, 0.627953,
- 0.997681, -0.346882, 1.305249, 0.572127, 1.020784, -0.322391, 1.262603, 0.517941, 1.043840,
- -0.297564, 1.225115, 0.466188, 1.067224, -0.272639, 1.190817, 0.415499, 1.092358, -0.247664,
- 1.161265, 0.366782, 1.117573, -0.222260, 1.133935, 0.319377, 1.145730, -0.196933, 1.111750,
- 0.275293, 1.170822, -0.170577, 1.091981, 0.233306, 1.194559, -0.143878, 1.075810, 0.193950,
- 1.214819, -0.116347, 1.062438, 0.156724, 1.229830, -0.088233, 1.048092, 0.118984, 1.238185,
- -0.059408, 1.031325, 0.079385, 1.243527, -0.030703, 1.014698, 0.039893, 1.249724, -0.001520,
- 0.999819, 0.000760, 0.000164, -0.000489, 5.157359, 2.976300, 0.000505, -0.001502, 9.891415,
- 2.976286, 0.002016, -0.006000, 9.857730, 2.976197, 0.004543, -0.013519, 9.870651, 2.975832,
- 0.008064, -0.023985, 9.855780, 2.976170, 0.012611, -0.037471, 9.850209, 2.975941, 0.018162,
- -0.053866, 9.827134, 2.974968, 0.024820, -0.073390, 9.849955, 2.975010, 0.032545, -0.095758,
- 9.842021, 2.974073, 0.041418, -0.120834, 9.829989, 2.972700, 0.051511, -0.148861, 9.817421,
- 2.970736, 0.062920, -0.179456, 9.797347, 2.968033, 0.075744, -0.212674, 9.771533, 2.964371,
- 0.090131, -0.248193, 9.735924, 2.959437, 0.106187, -0.285748, 9.687707, 2.952881, 0.124035,
- -0.325017, 9.622684, 2.944273, 0.143733, -0.365463, 9.531452, 2.933093, 0.165262, -0.406157,
- 9.401732, 2.918484, 0.188622, -0.446833, 9.232451, 2.899529, 0.213693, -0.486209, 9.013432,
- 2.875137, 0.239987, -0.522925, 8.725671, 2.844166, 0.267796, -0.557452, 8.400028, 2.805649,
- 0.296547, -0.588266, 8.023041, 2.758720, 0.325838, -0.614837, 7.606773, 2.702676, 0.355479,
- -0.636760, 7.160680, 2.638483, 0.386984, -0.657230, 6.736765, 2.566849, 0.418853, -0.673592,
- 6.313742, 2.488091, 0.450302, -0.684966, 5.884479, 2.402458, 0.481149, -0.691591, 5.455771,
- 2.311816, 0.512177, -0.695337, 5.055698, 2.217330, 0.543437, -0.696370, 4.681506, 2.121285,
- 0.574309, -0.694186, 4.334716, 2.024160, 0.604787, -0.689158, 4.008524, 1.927738, 0.633483,
- -0.680580, 3.703505, 1.830456, 0.660766, -0.669088, 3.418386, 1.734934, 0.688471, -0.656673,
- 3.168101, 1.642316, 0.715729, -0.642820, 2.941735, 1.550744, 0.740435, -0.626155, 2.730570,
- 1.463345, 0.764114, -0.608299, 2.537561, 1.378151, 0.787028, -0.589519, 2.364323, 1.297630,
- 0.807985, -0.569257, 2.207970, 1.217830, 0.830663, -0.550055, 2.076646, 1.142746, 0.850416,
- -0.528812, 1.948085, 1.070757, 0.869609, -0.507478, 1.834684, 1.001282, 0.888324, -0.486131,
- 1.734879, 0.934987, 0.907482, -0.464910, 1.645974, 0.871203, 0.924829, -0.442742, 1.563550,
- 0.809260, 0.942958, -0.420777, 1.491264, 0.750037, 0.961999, -0.398842, 1.428069, 0.691715,
- 0.981043, -0.375967, 1.369668, 0.635669, 1.002371, -0.351469, 1.318588, 0.578689, 1.025343,
- -0.326601, 1.273628, 0.524424, 1.048511, -0.301395, 1.234572, 0.471403, 1.072242, -0.275835,
- 1.198354, 0.419950, 1.096758, -0.250200, 1.166392, 0.370733, 1.122781, -0.224474, 1.138991,
- 0.322864, 1.150871, -0.198592, 1.114313, 0.277723, 1.177319, -0.171805, 1.093534, 0.234950,
- 1.201765, -0.144291, 1.077462, 0.195376, 1.222629, -0.115949, 1.063288, 0.157315, 1.237334,
- -0.087140, 1.048366, 0.118843, 1.246153, -0.058094, 1.031224, 0.079207, 1.252570, -0.029194,
- 1.014695, 0.039376, 1.259060, -0.000418, 0.999881, 0.000307, 0.000159, -0.000515, 5.393984,
- 3.241865, 0.000505, -0.001636, 11.548038, 3.241848, 0.002016, -0.006534, 11.506640, 3.241718,
- 0.004537, -0.014706, 11.513460, 3.241196, 0.008068, -0.026134, 11.510533, 3.241693, 0.012573,
- -0.040676, 11.428978, 3.241030, 0.018212, -0.058794, 11.510745, 3.240924, 0.024847, -0.079926,
- 11.497339, 3.240201, 0.032603, -0.104160, 11.484607, 3.238994, 0.041543, -0.131552, 11.470801,
- 3.237182, 0.051738, -0.162012, 11.453219, 3.234635, 0.063313, -0.195260, 11.427244, 3.231153,
- 0.076381, -0.231205, 11.388534, 3.226361, 0.091096, -0.269678, 11.340406, 3.219943, 0.107600,
- -0.310170, 11.270127, 3.211448, 0.126017, -0.352435, 11.178583, 3.200168, 0.146411, -0.395551,
- 11.046559, 3.185328, 0.168663, -0.438627, 10.858624, 3.165972, 0.192730, -0.480660, 10.606379,
- 3.140735, 0.218497, -0.520987, 10.288093, 3.108388, 0.245752, -0.558483, 9.907480, 3.067586,
- 0.273993, -0.592090, 9.453246, 3.016931, 0.303495, -0.622416, 8.966138, 2.956444, 0.333717,
- -0.648303, 8.443776, 2.885116, 0.363928, -0.668640, 7.894122, 2.805963, 0.396240, -0.687748,
- 7.385728, 2.718338, 0.427161, -0.699903, 6.838511, 2.622346, 0.460175, -0.711210, 6.356371,
- 2.522476, 0.492593, -0.717734, 5.878312, 2.417984, 0.524449, -0.719956, 5.423285, 2.310941,
- 0.556010, -0.719127, 4.997909, 2.201885, 0.587032, -0.715077, 4.600426, 2.093330, 0.617030,
- -0.707574, 4.235885, 1.986585, 0.644684, -0.695781, 3.881712, 1.881279, 0.674483, -0.685313,
- 3.590960, 1.777918, 0.700290, -0.669619, 3.303138, 1.678004, 0.727892, -0.654728, 3.057771,
- 1.581162, 0.751694, -0.635727, 2.826642, 1.487769, 0.776271, -0.617343, 2.622178, 1.399628,
- 0.799502, -0.597683, 2.441265, 1.313195, 0.821768, -0.577090, 2.276954, 1.232316, 0.841960,
- -0.555165, 2.125744, 1.153914, 0.861582, -0.532983, 1.991236, 1.079598, 0.881460, -0.510933,
- 1.874027, 1.008883, 0.899952, -0.488321, 1.766812, 0.940802, 0.918954, -0.466405, 1.673436,
- 0.875653, 0.936130, -0.443623, 1.586986, 0.813130, 0.954799, -0.421532, 1.513558, 0.752241,
- 0.972435, -0.398897, 1.445787, 0.694711, 0.990147, -0.376302, 1.384382, 0.638770, 1.009189,
- -0.353623, 1.331934, 0.583826, 1.029687, -0.330635, 1.284478, 0.530476, 1.052604, -0.305698,
- 1.243632, 0.477187, 1.076524, -0.279917, 1.204997, 0.425349, 1.101701, -0.253951, 1.171750,
- 0.375165, 1.127264, -0.227541, 1.142519, 0.326869, 1.156397, -0.201265, 1.116817, 0.280912,
- 1.183020, -0.173943, 1.095289, 0.237447, 1.208448, -0.145860, 1.078296, 0.196694, 1.230417,
- -0.116901, 1.064416, 0.158409, 1.248617, -0.087507, 1.050504, 0.119483, 1.257310, -0.057353,
- 1.032796, 0.079092, 1.263076, -0.027785, 1.015128, 0.038883, 1.269870, 0.001331, 0.999935,
- -0.000557, 0.000154, -0.000549, 5.705205, 3.554136, 0.000506, -0.001797, 13.703335, 3.554133,
- 0.002014, -0.007156, 13.614074, 3.553937, 0.004544, -0.016145, 13.657344, 3.553096, 0.008070,
- -0.028652, 13.627997, 3.553894, 0.012584, -0.044617, 13.606235, 3.554000, 0.018180, -0.064288,
- 13.581339, 3.549637, 0.024887, -0.087627, 13.608851, 3.552006, 0.032690, -0.114134, 13.599099,
- 3.550341, 0.041705, -0.144154, 13.579829, 3.547982, 0.052035, -0.177400, 13.552845, 3.544641,
- 0.063810, -0.213813, 13.515619, 3.539941, 0.077171, -0.252978, 13.460460, 3.533696, 0.092329,
- -0.294852, 13.393559, 3.524977, 0.109390, -0.338688, 13.292376, 3.513655, 0.128455, -0.384018,
- 13.147332, 3.498484, 0.149661, -0.429960, 12.945774, 3.478323, 0.172694, -0.475024, 12.658979,
- 3.451862, 0.197650, -0.518614, 12.289564, 3.417602, 0.224156, -0.559298, 11.828307, 3.372913,
- 0.252008, -0.596110, 11.285162, 3.317454, 0.281165, -0.629292, 10.684922, 3.251171, 0.311434,
- -0.658379, 10.052939, 3.172222, 0.342741, -0.683455, 9.405296, 3.082825, 0.373543, -0.701674,
- 8.716078, 2.983976, 0.407008, -0.719664, 8.108425, 2.876244, 0.438623, -0.729882, 7.461252,
- 2.763279, 0.471872, -0.738696, 6.880182, 2.645590, 0.504700, -0.743136, 6.324308, 2.524680,
- 0.537118, -0.743676, 5.808302, 2.402723, 0.569412, -0.741181, 5.332306, 2.281437, 0.598202,
- -0.732348, 4.857402, 2.161401, 0.629640, -0.724832, 4.465554, 2.043872, 0.659239, -0.713435,
- 4.093661, 1.930129, 0.686547, -0.698539, 3.752593, 1.817654, 0.715529, -0.684471, 3.457593,
- 1.712567, 0.739456, -0.664983, 3.171220, 1.610687, 0.764892, -0.646322, 2.929674, 1.512031,
- 0.789301, -0.626393, 2.710719, 1.419033, 0.809881, -0.603498, 2.506139, 1.330115, 0.833385,
- -0.582934, 2.336089, 1.245859, 0.854254, -0.560419, 2.178470, 1.165042, 0.873964, -0.537294,
- 2.040087, 1.086633, 0.893433, -0.514264, 1.911969, 1.015028, 0.911756, -0.490657, 1.799840,
- 0.944938, 0.930894, -0.467601, 1.703188, 0.878743, 0.948078, -0.444043, 1.612092, 0.815356,
- 0.966162, -0.421155, 1.534444, 0.753883, 0.984166, -0.398238, 1.462397, 0.695534, 1.002184,
- -0.375278, 1.400793, 0.638806, 1.019669, -0.352159, 1.344172, 0.584549, 1.039571, -0.329651,
- 1.295227, 0.531660, 1.059989, -0.306804, 1.251281, 0.480529, 1.081116, -0.283345, 1.211504,
- 0.430071, 1.105742, -0.258568, 1.176400, 0.380277, 1.133080, -0.232146, 1.144519, 0.331076,
- 1.161888, -0.205244, 1.118059, 0.284040, 1.192408, -0.177932, 1.097561, 0.239958, 1.221043,
- -0.149532, 1.082021, 0.198751, 1.244141, -0.120046, 1.067634, 0.160114, 1.259465, -0.089542,
- 1.051626, 0.121101, 1.268124, -0.058593, 1.033296, 0.079898, 1.274330, -0.028011, 1.015382,
- 0.039038, 1.281590, 0.002330, 1.000087, -0.001259, 0.000149, -0.000587, 6.059834, 3.927143,
- 0.000507, -0.001992, 16.560400, 3.927149, 0.002014, -0.007910, 16.406326, 3.926821, 0.004549,
- -0.017856, 16.545532, 3.927027, 0.008064, -0.031632, 16.375853, 3.925487, 0.012450, -0.048749,
- 15.928564, 3.928272, 0.018030, -0.070371, 16.072989, 3.917862, 0.024964, -0.096897, 16.458925,
- 3.924489, 0.032807, -0.126073, 16.377851, 3.921896, 0.041917, -0.159205, 16.351561, 3.918860,
- 0.052416, -0.195762, 16.307037, 3.914339, 0.064464, -0.235784, 16.255514, 3.907954, 0.078225,
- -0.278812, 16.176226, 3.899254, 0.093900, -0.324457, 16.066530, 3.887455, 0.111657, -0.372174,
- 15.913818, 3.871777, 0.131478, -0.420530, 15.669197, 3.850776, 0.153574, -0.469330, 15.355453,
- 3.822348, 0.177505, -0.516029, 14.908978, 3.785168, 0.203383, -0.560585, 14.352687, 3.736602,
- 0.230569, -0.600607, 13.666022, 3.675046, 0.259188, -0.636296, 12.900244, 3.599811, 0.289272,
- -0.668312, 12.111226, 3.510550, 0.320490, -0.695986, 11.292102, 3.408535, 0.353031, -0.719848,
- 10.493485, 3.295667, 0.385228, -0.737073, 9.661955, 3.171998, 0.419219, -0.752419, 8.909942,
- 3.042428, 0.452096, -0.761179, 8.155107, 2.907108, 0.484909, -0.766166, 7.450609, 2.769858,
- 0.518306, -0.768596, 6.811866, 2.631935, 0.550067, -0.765683, 6.205275, 2.492870, 0.582562,
- -0.761197, 5.663215, 2.358645, 0.614450, -0.753834, 5.165358, 2.227377, 0.644563, -0.742860,
- 4.712554, 2.097547, 0.673658, -0.729294, 4.306101, 1.974920, 0.702857, -0.714839, 3.943352,
- 1.857613, 0.729350, -0.696774, 3.609432, 1.743601, 0.754958, -0.677394, 3.308389, 1.636607,
- 0.779575, -0.657018, 3.043803, 1.533841, 0.800491, -0.633342, 2.793592, 1.437092, 0.825030,
- -0.612471, 2.590307, 1.344272, 0.847535, -0.589882, 2.406477, 1.256436, 0.865979, -0.564850,
- 2.231999, 1.173938, 0.886254, -0.541357, 2.083556, 1.094722, 0.905566, -0.517353, 1.950928,
- 1.021107, 0.924607, -0.493320, 1.835979, 0.948941, 0.943365, -0.469366, 1.731417, 0.881060,
- 0.960405, -0.444745, 1.635838, 0.816479, 0.977893, -0.420493, 1.552981, 0.754604, 0.996573,
- -0.397150, 1.481595, 0.694917, 1.014000, -0.373483, 1.414070, 0.638445, 1.031807, -0.349985,
- 1.356031, 0.584035, 1.051877, -0.327062, 1.305041, 0.530010, 1.071701, -0.304134, 1.258836,
- 0.479439, 1.093109, -0.280962, 1.217297, 0.429763, 1.116681, -0.258121, 1.182063, 0.381050,
- 1.143886, -0.235365, 1.150039, 0.333395, 1.175163, -0.211621, 1.125074, 0.287477, 1.203675,
- -0.184061, 1.102339, 0.243301, 1.230477, -0.154815, 1.083927, 0.201826, 1.253134, -0.124513,
- 1.067989, 0.162271, 1.270092, -0.093383, 1.052032, 0.122855, 1.279576, -0.061770, 1.033685,
- 0.081639, 1.286472, -0.030317, 1.015583, 0.040411, 1.294476, 0.000964, 1.000206, -0.000454,
- 0.000144, -0.000630, 6.467978, 4.381146, 0.000504, -0.002208, 20.193617, 4.381151, 0.002017,
- -0.008834, 20.206446, 4.380687, 0.004536, -0.019864, 20.183254, 4.380550, 0.008174, -0.035759,
- 20.564249, 4.381247, 0.012608, -0.055034, 20.111612, 4.382390, 0.018198, -0.079119, 20.106096,
- 4.379815, 0.025057, -0.108067, 20.215635, 4.376874, 0.032962, -0.140630, 20.153549, 4.374143,
- 0.042199, -0.177350, 20.084061, 4.369558, 0.052928, -0.218094, 20.026609, 4.363287, 0.065327,
- -0.262407, 19.940054, 4.354386, 0.079568, -0.309833, 19.806814, 4.342127, 0.095961, -0.360074,
- 19.641878, 4.325533, 0.114516, -0.411747, 19.370914, 4.302950, 0.135349, -0.463726, 18.983900,
- 4.271991, 0.158293, -0.514211, 18.433926, 4.230856, 0.183348, -0.562511, 17.733471, 4.176250,
- 0.209959, -0.606310, 16.864214, 4.105895, 0.238736, -0.646958, 15.935207, 4.020104, 0.268543,
- -0.681574, 14.890014, 3.916094, 0.299996, -0.712458, 13.846786, 3.798239, 0.331930, -0.737130,
- 12.758296, 3.664191, 0.365222, -0.758156, 11.732940, 3.521867, 0.399061, -0.774364, 10.741743,
- 3.369831, 0.433480, -0.786412, 9.812527, 3.212079, 0.467002, -0.792373, 8.915130, 3.053715,
- 0.500754, -0.795410, 8.094276, 2.894526, 0.534023, -0.794617, 7.342067, 2.735959, 0.566988,
- -0.790689, 6.664186, 2.581160, 0.599960, -0.784433, 6.052983, 2.432318, 0.630599, -0.773378,
- 5.486277, 2.287630, 0.660807, -0.760334, 4.982516, 2.150183, 0.690103, -0.745430, 4.531104,
- 2.017266, 0.717315, -0.727511, 4.120734, 1.891699, 0.743819, -0.708376, 3.759599, 1.772680,
- 0.770147, -0.688632, 3.441912, 1.660620, 0.793510, -0.665931, 3.152600, 1.553166, 0.816535,
- -0.643045, 2.898883, 1.452080, 0.839163, -0.619917, 2.674488, 1.355544, 0.859066, -0.594923,
- 2.469262, 1.267232, 0.879489, -0.570343, 2.292209, 1.181702, 0.898525, -0.544975, 2.131086,
- 1.102089, 0.918359, -0.520585, 1.994526, 1.024744, 0.937502, -0.496044, 1.873079, 0.951712,
- 0.955573, -0.471010, 1.761232, 0.883374, 0.972957, -0.445712, 1.661604, 0.818008, 0.991248,
- -0.421201, 1.577169, 0.754446, 1.008997, -0.396444, 1.499653, 0.694518, 1.028127, -0.372362,
- 1.432030, 0.637259, 1.045710, -0.347895, 1.369870, 0.581515, 1.065977, -0.324409, 1.317341,
- 0.527713, 1.087469, -0.301181, 1.270447, 0.476281, 1.109943, -0.277866, 1.228398, 0.426403,
- 1.134440, -0.254849, 1.190986, 0.377822, 1.160986, -0.231754, 1.157681, 0.330740, 1.188458,
- -0.207973, 1.128665, 0.286014, 1.214405, -0.183424, 1.103711, 0.243600, 1.239504, -0.157972,
- 1.084253, 0.203686, 1.262961, -0.130607, 1.068258, 0.165214, 1.280340, -0.099652, 1.051919,
- 0.126067, 1.292129, -0.067363, 1.034016, 0.084791, 1.299876, -0.035026, 1.015775, 0.042786,
- 1.308328, -0.002944, 0.999963, 0.001385, 0.000138, -0.000681, 6.943771, 4.946556, 0.000503,
- -0.002486, 25.346689, 4.946532, 0.002016, -0.009973, 25.494320, 4.946311, 0.004539, -0.022440,
- 25.484949, 4.945823, 0.008069, -0.039836, 25.420902, 4.945311, 0.012628, -0.062172, 25.394403,
- 4.945041, 0.018294, -0.089609, 25.440279, 4.943295, 0.025079, -0.121584, 25.399988, 4.939368,
- 0.033142, -0.158595, 25.356537, 4.936200, 0.042596, -0.199971, 25.295067, 4.929842, 0.053628,
- -0.245624, 25.196465, 4.920586, 0.066496, -0.295240, 25.055311, 4.907700, 0.081434, -0.348006,
- 24.846170, 4.889647, 0.098640, -0.403167, 24.527803, 4.864680, 0.118231, -0.459106, 24.051735,
- 4.830574, 0.140139, -0.513907, 23.352467, 4.783530, 0.164198, -0.565953, 22.418245, 4.720530,
- 0.190502, -0.614858, 21.324049, 4.638075, 0.218530, -0.658304, 20.038671, 4.535464, 0.248094,
- -0.696133, 18.639786, 4.411646, 0.279435, -0.729388, 17.234526, 4.268872, 0.312002, -0.757534,
- 15.830426, 4.109603, 0.346173, -0.781866, 14.495901, 3.938782, 0.379435, -0.797579, 13.136444,
- 3.756138, 0.414945, -0.812334, 11.946491, 3.571258, 0.449991, -0.821119, 10.811908, 3.384217,
- 0.484636, -0.825066, 9.763482, 3.198076, 0.518675, -0.824728, 8.796811, 3.015808, 0.552559,
- -0.821710, 7.932528, 2.836886, 0.587272, -0.817478, 7.185156, 2.664995, 0.616960, -0.804441,
- 6.445302, 2.502223, 0.648054, -0.792063, 5.818812, 2.345851, 0.678575, -0.777793, 5.264731,
- 2.197150, 0.707287, -0.760476, 4.766033, 2.056042, 0.735851, -0.742541, 4.335871, 1.922805,
- 0.760594, -0.720503, 3.928021, 1.798585, 0.784534, -0.697719, 3.579153, 1.680605, 0.811029,
- -0.677036, 3.285307, 1.568942, 0.831809, -0.651479, 3.001423, 1.465496, 0.854364, -0.627376,
- 2.760672, 1.367849, 0.872639, -0.600496, 2.540697, 1.275644, 0.894296, -0.576297, 2.355273,
- 1.188638, 0.913123, -0.550377, 2.188563, 1.105652, 0.932025, -0.524640, 2.040739, 1.028614,
- 0.949876, -0.498402, 1.910315, 0.954421, 0.968933, -0.473220, 1.795750, 0.884061, 0.985366,
- -0.447086, 1.690336, 0.817765, 1.004940, -0.422394, 1.599626, 0.753295, 1.022217, -0.396726,
- 1.519055, 0.693380, 1.041490, -0.371854, 1.448745, 0.635747, 1.059920, -0.346769, 1.384292,
- 0.579508, 1.080408, -0.322343, 1.328798, 0.525045, 1.101632, -0.297979, 1.279898, 0.473773,
- 1.124812, -0.274059, 1.234005, 0.422949, 1.148503, -0.249954, 1.195373, 0.374609, 1.174554,
- -0.225988, 1.160362, 0.327350, 1.202931, -0.201932, 1.131307, 0.283494, 1.229335, -0.176886,
- 1.105885, 0.241092, 1.254254, -0.151225, 1.085802, 0.201514, 1.275743, -0.124282, 1.068524,
- 0.162866, 1.292929, -0.097122, 1.051493, 0.124991, 1.305805, -0.068939, 1.033890, 0.085521,
- 1.314991, -0.040082, 1.015927, 0.045247, 1.324033, -0.009923, 0.999893, 0.004738, 0.000131,
- -0.000745, 7.562414, 5.671075, 0.000473, -0.002681, 27.216688, 5.670949, 0.002021, -0.011462,
- 32.962402, 5.670177, 0.004540, -0.025728, 33.183949, 5.670197, 0.008087, -0.045746, 33.185688,
- 5.667313, 0.012673, -0.071427, 33.170441, 5.668396, 0.018358, -0.102673, 33.145138, 5.665252,
- 0.025299, -0.139780, 33.303326, 5.653404, 0.033469, -0.181718, 33.107243, 5.652829, 0.043139,
- -0.228698, 32.859524, 5.645676, 0.054622, -0.280648, 32.694893, 5.631547, 0.068115, -0.336524,
- 32.422569, 5.611561, 0.083957, -0.395671, 32.035511, 5.583449, 0.102259, -0.456164, 31.415047,
- 5.543651, 0.123021, -0.515765, 30.470440, 5.488278, 0.146127, -0.572309, 29.186451, 5.413118,
- 0.171749, -0.625710, 27.653852, 5.312369, 0.199549, -0.673853, 25.902435, 5.185774, 0.229188,
- -0.715905, 23.978609, 5.030582, 0.260421, -0.751533, 21.999035, 4.853484, 0.293421, -0.782309,
- 20.087366, 4.656137, 0.327077, -0.806332, 18.186535, 4.443975, 0.361892, -0.825818, 16.418409,
- 4.223844, 0.397146, -0.840019, 14.774344, 3.998959, 0.434169, -0.852434, 13.321097, 3.775443,
- 0.469288, -0.856632, 11.929448, 3.552818, 0.504319, -0.857130, 10.675201, 3.338825, 0.540067,
- -0.855903, 9.591900, 3.130547, 0.575404, -0.851565, 8.607655, 2.932930, 0.606782, -0.839818,
- 7.690560, 2.743876, 0.638660, -0.827508, 6.900781, 2.565115, 0.670577, -0.814154, 6.216821,
- 2.395215, 0.696718, -0.793162, 5.551886, 2.238233, 0.725990, -0.775291, 5.015406, 2.090264,
- 0.754140, -0.755758, 4.546843, 1.950834, 0.775992, -0.729824, 4.094254, 1.820582, 0.802990,
- -0.708909, 3.732984, 1.699191, 0.828291, -0.686483, 3.413194, 1.583805, 0.847406, -0.659162,
- 3.103861, 1.478093, 0.864951, -0.631051, 2.832976, 1.378496, 0.887154, -0.606590, 2.616645,
- 1.282127, 0.906337, -0.580124, 2.413988, 1.194643, 0.927184, -0.554835, 2.244380, 1.110354,
- 0.943810, -0.527583, 2.081964, 1.031996, 0.963630, -0.502243, 1.948979, 0.956718, 0.979691,
- -0.475006, 1.822701, 0.886957, 0.997690, -0.448815, 1.715714, 0.819006, 1.016460, -0.423044,
- 1.621868, 0.754892, 1.035485, -0.397637, 1.539537, 0.693707, 1.053165, -0.371775, 1.462285,
- 0.634867, 1.072394, -0.346372, 1.396193, 0.578574, 1.093397, -0.321291, 1.338344, 0.524341,
- 1.115194, -0.296102, 1.287594, 0.472059, 1.137943, -0.271023, 1.240495, 0.421674, 1.164163,
- -0.246367, 1.201224, 0.371963, 1.191457, -0.221414, 1.164472, 0.325040, 1.220253, -0.196228,
- 1.134325, 0.280343, 1.245456, -0.169991, 1.108214, 0.238098, 1.270647, -0.143314, 1.087277,
- 0.197886, 1.292124, -0.115881, 1.069397, 0.159560, 1.309091, -0.087816, 1.051426, 0.120547,
- 1.321130, -0.059301, 1.032904, 0.080834, 1.332484, -0.030912, 1.015767, 0.040933, 1.342834,
- -0.002172, 0.999591, 0.001185, 0.000125, -0.000830, 8.392562, 6.634228, 0.000443, -0.002936,
- 29.687805, 6.634032, 0.002016, -0.013374, 45.025234, 6.633008, 0.004540, -0.030089, 45.020294,
- 6.633056, 0.008092, -0.053499, 45.066029, 6.626466, 0.012710, -0.083610, 44.810101, 6.630330,
- 0.018485, -0.120260, 45.216747, 6.614516, 0.025134, -0.161031, 44.674168, 6.600349, 0.033897,
- -0.212161, 44.819195, 6.610186, 0.043978, -0.266661, 44.450245, 6.593605, 0.056094, -0.326582,
- 44.134544, 6.570142, 0.070528, -0.390342, 43.591648, 6.536712, 0.087498, -0.456162, 42.708160,
- 6.488329, 0.107138, -0.521609, 41.365093, 6.420198, 0.129461, -0.584225, 39.525822, 6.323702,
- 0.154245, -0.641931, 37.186111, 6.193606, 0.181228, -0.692829, 34.478470, 6.026897, 0.210711,
- -0.738440, 31.680904, 5.825769, 0.242181, -0.777397, 28.828054, 5.595428, 0.275337, -0.809980,
- 26.042755, 5.342321, 0.309698, -0.835990, 23.376804, 5.073076, 0.345702, -0.858077, 20.965754,
- 4.794572, 0.382135, -0.874122, 18.710079, 4.516676, 0.419871, -0.887133, 16.713011, 4.241767,
- 0.455609, -0.891199, 14.819674, 3.972124, 0.492617, -0.894082, 13.187921, 3.717271, 0.528186,
- -0.891270, 11.708584, 3.471719, 0.563462, -0.885719, 10.422834, 3.237760, 0.596013, -0.874241,
- 9.237741, 3.019060, 0.629455, -0.862814, 8.248549, 2.813572, 0.661110, -0.848126, 7.358398,
- 2.621046, 0.690314, -0.829798, 6.569392, 2.441627, 0.720589, -0.812314, 5.905934, 2.274629,
- 0.745631, -0.788704, 5.276800, 2.119423, 0.771488, -0.766133, 4.752773, 1.974380, 0.798704,
- -0.744726, 4.306095, 1.839482, 0.820172, -0.718062, 3.889792, 1.713244, 0.844368, -0.693972,
- 3.545456, 1.594809, 0.863128, -0.665748, 3.212762, 1.487512, 0.880094, -0.637003, 2.926572,
- 1.386724, 0.904252, -0.613728, 2.704260, 1.288131, 0.920506, -0.585217, 2.483164, 1.199845,
- 0.940919, -0.559603, 2.300348, 1.114958, 0.957044, -0.531597, 2.130516, 1.034754, 0.972648,
- -0.503583, 1.979313, 0.960912, 0.994318, -0.478813, 1.859664, 0.889786, 1.008754, -0.450943,
- 1.742705, 0.820833, 1.028667, -0.425516, 1.645220, 0.756332, 1.046145, -0.398977, 1.557184,
- 0.693921, 1.067212, -0.373657, 1.480814, 0.635955, 1.084111, -0.346657, 1.408762, 0.578832,
- 1.106749, -0.321392, 1.350468, 0.523561, 1.128440, -0.295773, 1.294865, 0.471146, 1.151073,
- -0.270028, 1.246118, 0.420298, 1.178601, -0.244816, 1.204226, 0.370575, 1.206845, -0.219027,
- 1.166896, 0.323716, 1.235963, -0.192622, 1.135756, 0.278058, 1.263030, -0.165331, 1.109240,
- 0.235743, 1.288937, -0.137489, 1.088379, 0.195390, 1.310681, -0.108685, 1.068987, 0.156439,
- 1.334352, -0.079710, 1.054273, 0.117096, 1.344847, -0.049947, 1.034598, 0.076554, 1.354943,
- -0.020272, 1.016079, 0.035585, 1.365515, 0.009170, 0.999969, -0.004771, 0.000117, -0.000935,
- 9.424866, 7.979243, 0.000410, -0.003275, 33.013195, 7.979422, 0.002009, -0.016024, 64.370331,
- 7.977156, 0.004541, -0.036176, 64.655952, 7.976128, 0.008109, -0.064384, 64.864494, 7.964988,
- 0.012694, -0.099984, 64.487198, 7.971348, 0.018554, -0.143991, 64.637970, 7.923116, 0.025303,
- -0.192040, 61.930538, 7.953975, 0.035297, -0.259442, 66.274422, 7.921861, 0.045226, -0.318370,
- 63.334690, 7.909609, 0.058370, -0.388821, 62.686401, 7.864696, 0.074083, -0.461667, 61.332054,
- 7.801843, 0.092537, -0.533744, 59.125607, 7.708949, 0.113781, -0.601905, 55.997845, 7.575799,
- 0.137786, -0.664409, 52.177567, 7.393524, 0.164770, -0.721193, 48.019485, 7.161756, 0.193894,
- -0.768842, 43.460278, 6.882018, 0.225586, -0.810332, 39.086590, 6.564607, 0.259311, -0.845096,
- 34.896049, 6.221983, 0.294517, -0.872849, 30.952213, 5.865831, 0.331163, -0.895159, 27.375792,
- 5.507064, 0.368964, -0.912860, 24.213310, 5.149763, 0.407255, -0.925338, 21.364958, 4.806172,
- 0.444704, -0.930956, 18.791691, 4.472272, 0.482041, -0.932576, 16.521160, 4.160864, 0.519572,
- -0.931547, 14.589918, 3.865206, 0.556236, -0.926554, 12.887797, 3.590445, 0.590431, -0.915839,
- 11.352402, 3.332747, 0.622723, -0.901266, 10.002660, 3.093264, 0.657029, -0.888747, 8.905210,
- 2.873842, 0.686164, -0.868666, 7.876704, 2.666740, 0.719168, -0.853152, 7.051816, 2.479017,
- 0.742294, -0.826169, 6.226034, 2.306498, 0.770320, -0.804936, 5.590831, 2.141328, 0.792337,
- -0.777772, 4.984083, 1.994663, 0.819050, -0.755478, 4.507655, 1.853950, 0.837684, -0.726072,
- 4.049884, 1.725590, 0.861324, -0.701424, 3.678201, 1.606303, 0.880741, -0.673615, 3.337163,
- 1.495452, 0.903335, -0.648506, 3.055720, 1.391162, 0.920311, -0.619640, 2.792068, 1.294734,
- 0.935769, -0.590245, 2.554566, 1.204518, 0.956592, -0.564944, 2.366468, 1.118630, 0.972424,
- -0.536842, 2.187863, 1.038323, 0.986269, -0.508020, 2.023480, 0.963803, 1.006122, -0.482411,
- 1.895137, 0.890986, 1.022504, -0.455110, 1.775886, 0.820936, 1.037905, -0.427450, 1.665951,
- 0.758556, 1.059281, -0.402198, 1.577363, 0.696126, 1.076613, -0.375156, 1.493391, 0.636676,
- 1.097828, -0.349577, 1.421129, 0.579947, 1.116671, -0.322955, 1.355205, 0.525140, 1.140514,
- -0.297406, 1.299979, 0.471460, 1.166473, -0.271786, 1.249847, 0.420473, 1.192591, -0.245461,
- 1.204625, 0.371118, 1.223349, -0.219412, 1.166686, 0.322600, 1.254833, -0.192660, 1.134121,
- 0.277572, 1.285808, -0.165167, 1.108617, 0.234417, 1.322015, -0.137236, 1.093841, 0.194640,
- 1.342172, -0.106871, 1.074616, 0.155001, 1.357238, -0.075759, 1.053550, 0.114648, 1.367725,
- -0.044279, 1.033851, 0.073254, 1.379461, -0.013001, 1.015713, 0.031895, 1.391625, 0.018075,
- 1.000203, -0.009397, 0.000109, -0.001093, 10.986820, 9.992467, 0.000378, -0.003779, 37.989063,
- 9.992861, 0.002028, -0.020252, 101.850441, 9.988345, 0.004557, -0.045429, 101.106750, 9.983879,
- 0.008115, -0.080453, 100.646606, 9.953411, 0.012864, -0.125836, 101.366592, 9.943727, 0.018734,
- -0.179350, 100.786118, 9.908408, 0.026314, -0.243680, 99.779343, 9.821631, 0.035500, -0.313552,
- 98.608231, 9.782450, 0.047562, -0.394644, 97.689568, 9.845875, 0.062065, -0.476697, 95.177795,
- 9.755218, 0.079552, -0.557933, 91.095581, 9.615121, 0.099905, -0.632818, 85.110382, 9.408299,
- 0.123231, -0.699926, 77.948921, 9.120996, 0.149980, -0.760671, 70.491119, 8.764173, 0.179550,
- -0.812251, 62.821407, 8.341752, 0.211839, -0.855909, 55.512890, 7.876337, 0.246434, -0.892023,
- 48.744549, 7.386268, 0.282317, -0.919200, 42.462059, 6.886009, 0.319580, -0.940333, 36.901031,
- 6.400318, 0.360135, -0.962176, 32.353752, 5.937503, 0.397805, -0.969755, 27.996445, 5.489783,
- 0.437077, -0.976494, 24.359192, 5.072855, 0.474388, -0.975265, 21.124300, 4.684682, 0.513695,
- -0.975335, 18.476677, 4.326597, 0.551542, -0.970264, 16.167391, 3.999049, 0.587525, -0.960365,
- 14.143442, 3.696317, 0.621251, -0.945944, 12.374341, 3.414176, 0.654738, -0.930709, 10.877112,
- 3.160455, 0.685794, -0.911702, 9.580887, 2.921461, 0.717135, -0.892948, 8.481939, 2.707478,
- 0.740798, -0.865086, 7.435941, 2.510382, 0.770920, -0.845137, 6.650625, 2.329648, 0.792303,
- -0.815956, 5.879976, 2.163206, 0.818363, -0.792225, 5.274404, 2.008042, 0.837362, -0.762396,
- 4.700960, 1.867576, 0.862266, -0.738465, 4.254798, 1.735819, 0.880069, -0.708890, 3.828697,
- 1.614690, 0.896021, -0.678588, 3.451655, 1.503477, 0.920156, -0.654832, 3.168722, 1.395800,
- 0.934948, -0.624740, 2.879533, 1.299955, 0.949686, -0.595203, 2.628258, 1.208597, 0.970989,
- -0.570041, 2.433689, 1.122310, 0.985606, -0.541116, 2.241461, 1.042168, 1.000819, -0.512835,
- 2.075567, 0.966543, 1.012209, -0.483024, 1.919932, 0.895758, 1.035320, -0.459125, 1.807884,
- 0.825668, 1.052077, -0.432333, 1.695689, 0.760812, 1.070459, -0.406131, 1.595491, 0.699897,
- 1.088704, -0.379721, 1.508512, 0.640575, 1.103817, -0.352104, 1.428159, 0.583765, 1.131711,
- -0.328122, 1.366565, 0.528240, 1.156448, -0.302568, 1.306843, 0.473988, 1.181821, -0.276487,
- 1.252861, 0.422189, 1.211347, -0.250540, 1.205265, 0.372005, 1.243636, -0.224264, 1.165943,
- 0.324184, 1.283038, -0.198289, 1.137772, 0.278419, 1.316722, -0.170179, 1.115057, 0.235425,
- 1.342715, -0.140095, 1.092994, 0.195084, 1.363288, -0.108794, 1.071875, 0.155439, 1.380656,
- -0.076774, 1.052475, 0.114636, 1.394826, -0.044509, 1.032525, 0.072890, 1.408830, -0.011968,
- 1.015459, 0.031101, 1.422370, 0.020555, 0.999808, -0.011002, 0.000100, -0.001334, 13.377127,
- 13.342275, 0.000342, -0.004563, 45.758434, 13.342710, 0.002026, -0.027004, 179.672058,
- 13.331846, 0.004559, -0.060563, 179.294235, 13.314877, 0.008232, -0.108154, 181.242035,
- 13.222856, 0.013031, -0.167590, 179.684509, 13.153860, 0.019526, -0.242041, 181.004608,
- 12.986094, 0.026364, -0.309289, 159.606293, 13.247752, 0.037670, -0.409755, 179.468521,
- 12.368877, 0.051804, -0.512051, 167.955582, 12.981333, 0.068214, -0.601994, 156.278793,
- 12.704532, 0.088295, -0.686849, 143.096878, 12.316531, 0.111478, -0.758670, 127.423111,
- 11.793048, 0.138336, -0.821348, 111.763031, 11.157992, 0.168447, -0.873616, 96.887924,
- 10.447472, 0.201411, -0.916322, 83.225327, 9.696606, 0.237443, -0.953090, 71.403137, 8.949244,
- 0.274234, -0.977751, 60.739277, 8.225874, 0.314566, -1.003135, 52.115578, 7.547433, 0.353932,
- -1.016312, 44.341869, 6.910326, 0.393858, -1.024848, 37.827263, 6.324401, 0.433805, -1.028950,
- 32.380932, 5.790555, 0.475812, -1.034084, 27.955982, 5.312826, 0.513254, -1.026743, 23.977417,
- 4.866118, 0.549965, -1.016740, 20.628025, 4.468437, 0.590300, -1.012030, 18.036856, 4.105483,
- 0.626420, -0.998919, 15.669224, 3.780593, 0.658897, -0.979874, 13.603898, 3.482054, 0.687252,
- -0.955238, 11.788331, 3.211213, 0.718941, -0.935663, 10.355552, 2.962083, 0.749877, -0.915206,
- 9.131123, 2.741382, 0.772094, -0.884837, 7.973935, 2.536501, 0.799495, -0.861214, 7.086230,
- 2.347282, 0.820136, -0.830976, 6.240769, 2.179332, 0.846715, -0.807408, 5.604792, 2.018005,
- 0.865176, -0.776657, 4.975034, 1.877021, 0.881100, -0.744657, 4.442767, 1.743528, 0.907637,
- -0.722088, 4.035177, 1.621563, 0.922239, -0.690432, 3.633160, 1.506158, 0.936558, -0.659650,
- 3.281798, 1.403606, 0.950047, -0.629105, 2.974179, 1.304276, 0.961959, -0.598277, 2.704483,
- 1.213888, 0.987410, -0.576085, 2.510453, 1.125569, 0.999996, -0.546494, 2.304016, 1.045567,
- 1.014127, -0.518186, 2.127867, 0.970718, 1.036275, -0.494009, 1.985804, 0.897557, 1.049695,
- -0.465659, 1.845074, 0.830584, 1.064617, -0.438159, 1.725130, 0.766083, 1.077131, -0.409813,
- 1.613818, 0.705101, 1.101054, -0.385632, 1.528694, 0.644828, 1.122361, -0.360045, 1.447086,
- 0.587878, 1.147359, -0.335186, 1.377588, 0.532130, 1.169881, -0.309040, 1.313673, 0.478843,
- 1.200554, -0.284590, 1.257256, 0.426855, 1.232047, -0.259332, 1.208431, 0.376125, 1.275402,
- -0.235215, 1.174692, 0.326614, 1.306595, -0.207508, 1.141042, 0.281524, 1.334304, -0.178290,
- 1.111778, 0.238694, 1.364678, -0.148530, 1.090976, 0.198549, 1.387168, -0.117114, 1.069308,
- 0.158529, 1.408657, -0.084977, 1.050625, 0.118042, 1.426214, -0.052052, 1.031444, 0.076541,
- 1.444257, -0.018653, 1.014298, 0.034061, 1.460618, 0.015206, 0.999413, -0.008132, 0.000100,
- -0.002003, 20.052612, 20.032721, 0.000297, -0.005947, 59.540512, 20.033842, 0.002022,
- -0.040439, 404.848511, 20.032743, 0.004588, -0.090999, 403.741241, 19.910591, 0.008769,
- -0.169802, 441.471558, 19.572552, 0.013708, -0.253629, 411.667816, 19.145721, 0.020331,
- -0.349396, 371.322571, 18.591049, 0.030259, -0.468121, 385.816498, 18.331083, 0.045190,
- -0.611444, 391.924133, 15.807686, 0.058476, -0.676875, 319.638641, 16.947781, 0.079894,
- -0.781421, 278.804260, 17.512903, 0.103871, -0.855116, 235.999786, 16.290295, 0.131756,
- -0.915747, 197.168076, 14.956566, 0.163487, -0.966333, 163.452347, 13.608010, 0.198693,
- -1.008386, 135.632706, 12.299661, 0.236157, -1.039862, 111.919281, 11.088790, 0.274579,
- -1.059988, 92.136581, 9.983883, 0.317164, -1.084069, 77.063034, 9.008505, 0.357624, -1.092124,
- 63.963051, 8.127298, 0.399009, -1.097560, 53.483341, 7.347628, 0.441182, -1.100981, 45.052429,
- 6.658191, 0.481606, -1.097318, 37.932640, 6.047333, 0.524253, -1.096570, 32.395638, 5.505878,
- 0.564351, -1.088739, 27.679380, 5.018494, 0.600843, -1.073396, 23.611519, 4.580770, 0.635527,
- -1.055024, 20.207081, 4.194785, 0.672045, -1.039775, 17.469036, 3.847436, 0.698372, -1.009545,
- 14.928226, 3.532546, 0.729336, -0.987168, 12.953170, 3.248834, 0.761147, -0.966299, 11.346271,
- 2.994166, 0.782270, -0.932841, 9.813129, 2.762244, 0.811832, -0.910431, 8.672224, 2.549933,
- 0.832053, -0.878369, 7.578633, 2.363132, 0.849383, -0.844673, 6.648379, 2.189266, 0.866020,
- -0.811703, 5.850784, 2.031716, 0.893083, -0.789181, 5.273372, 1.884480, 0.909212, -0.757541,
- 4.700618, 1.750298, 0.923169, -0.725157, 4.196640, 1.627590, 0.937112, -0.693769, 3.764841,
- 1.514906, 0.961901, -0.670828, 3.444598, 1.406839, 0.975245, -0.640240, 3.120745, 1.307873,
- 0.989696, -0.611032, 2.840732, 1.216417, 1.002057, -0.581144, 2.591596, 1.132553, 1.014022,
- -0.551620, 2.373820, 1.051695, 1.025307, -0.522268, 2.177992, 0.977500, 1.052190, -0.500826,
- 2.042511, 0.904301, 1.064408, -0.472355, 1.891934, 0.837557, 1.077876, -0.444815, 1.761054,
- 0.773004, 1.088939, -0.416531, 1.638939, 0.713958, 1.118551, -0.395057, 1.555724, 0.652485,
- 1.134469, -0.368289, 1.465490, 0.596330, 1.162778, -0.345095, 1.390977, 0.539703, 1.185298,
- -0.319527, 1.321225, 0.486250, 1.208419, -0.293590, 1.259318, 0.434178, 1.261013, -0.273471,
- 1.219767, 0.382032, 1.297811, -0.248226, 1.176422, 0.334190, 1.326591, -0.220354, 1.139881,
- 0.289075, 1.357918, -0.191937, 1.111418, 0.246259, 1.387590, -0.162282, 1.086511, 0.205129,
- 1.415797, -0.131515, 1.067072, 0.165601, 1.440194, -0.099555, 1.047799, 0.125462, 1.465600,
- -0.066957, 1.030406, 0.084082, 1.487714, -0.033496, 1.013889, 0.041981, 1.509947, 0.000663,
- 0.998773, -0.000485, 0.000100, -0.004009, 40.102047, 40.087105, 0.000228, -0.009141, 91.431366,
- 40.074432, 0.001522, -0.060544, 605.651733, 39.918827, 0.004919, -0.188871, 1712.982300,
- 38.873421, 0.009053, -0.320325, 1583.453125, 39.715633, 0.015375, -0.471415, 1486.033691,
- 39.162876, 0.029306, -0.735111, 1751.701050, 28.083200, 0.043450, -0.859759, 1392.475220,
- 24.599945, 0.079075, -1.220033, 1629.972656, 18.507019, 0.090130, -1.091255, 940.347351,
- 17.961655, 0.098008, -0.945965, 425.901093, 24.478010, 0.138246, -1.084105, 416.823944,
- 20.003433, 0.174489, -1.133148, 302.730042, 18.550846, 0.207969, -1.138483, 242.853577,
- 15.923334, 0.249132, -1.168197, 191.649445, 13.940813, 0.291391, -1.187038, 152.910309,
- 12.263267, 0.332856, -1.192793, 121.905075, 10.822873, 0.377473, -1.202846, 99.145561,
- 9.618412, 0.422601, -1.208871, 81.343315, 8.591735, 0.465276, -1.204545, 66.742569, 7.692911,
- 0.504710, -1.190839, 54.787876, 6.915612, 0.544909, -1.178827, 45.507313, 6.242786, 0.582125,
- -1.160590, 37.819912, 5.651690, 0.620694, -1.145481, 31.926588, 5.123660, 0.659127, -1.130178,
- 27.147310, 4.669475, 0.684358, -1.093728, 22.650702, 4.258717, 0.719453, -1.074591, 19.454103,
- 3.901225, 0.751695, -1.051678, 16.735672, 3.576870, 0.775082, -1.017716, 14.281039, 3.287471,
- 0.796233, -0.982759, 12.261332, 3.023708, 0.827404, -0.961227, 10.767912, 2.787740, 0.848149,
- -0.928433, 9.371350, 2.570737, 0.864891, -0.892838, 8.142364, 2.379204, 0.880979, -0.858193,
- 7.118954, 2.204470, 0.910434, -0.837281, 6.389041, 2.041554, 0.925396, -0.803638, 5.643217,
- 1.893353, 0.942463, -0.772925, 5.031223, 1.757331, 0.955217, -0.739720, 4.486978, 1.633572,
- 0.968570, -0.708048, 4.014621, 1.520414, 0.981672, -0.677109, 3.617768, 1.412506, 0.992829,
- -0.645712, 3.258773, 1.317079, 1.021270, -0.625746, 3.006640, 1.222611, 1.031247, -0.594628,
- 2.733073, 1.137911, 1.043581, -0.565540, 2.498495, 1.058439, 1.055930, -0.536962, 2.289843,
- 0.984428, 1.066727, -0.508076, 2.108603, 0.912794, 1.081225, -0.481297, 1.951454, 0.845536,
- 1.088198, -0.451563, 1.801891, 0.782718, 1.123316, -0.433247, 1.704316, 0.721664, 1.133206,
- -0.404812, 1.586153, 0.662761, 1.152889, -0.379901, 1.490958, 0.606866, 1.188158, -0.359421,
- 1.415730, 0.550666, 1.217064, -0.336049, 1.344172, 0.496748, 1.257727, -0.314816, 1.283196,
- 0.443538, 1.286647, -0.289530, 1.225903, 0.394018, 1.308729, -0.262053, 1.173928, 0.346255,
- 1.351453, -0.237704, 1.139992, 0.300393, 1.380284, -0.209733, 1.105997, 0.256661, 1.414621,
- -0.181613, 1.082109, 0.215429, 1.453045, -0.152797, 1.063853, 0.177098, 1.481066, -0.121803,
- 1.043185, 0.137203, 1.514113, -0.090250, 1.027072, 0.096998, 1.547317, -0.057603, 1.012551,
- 0.055328, 1.577983, -0.023799, 0.999267, 0.013094, 0.000108, -0.124970, 1249.704346,
- 1249.703491, 0.000140, -0.119585, 1195.855469, 1195.854370, 0.003995, -0.927433, 9274.246094,
- 232.443573, 0.012013, -1.131580, 11315.999023, 98.211105, 0.023892, -1.216018, 12162.739258,
- 67.214500, 0.047506, -1.517865, 15186.294922, 42.410069, 0.082523, -1.812564, 18145.718750,
- 24.421545, 0.112452, -1.805072, 11112.966797, 18.450365, 0.164460, -2.016784, 8086.032715,
- 14.043465, 0.195870, -1.898199, 4245.658203, 13.178202, 0.197797, -1.556158, 1315.561768,
- 30.760096, 0.219540, -1.433455, 802.380371, 25.037956, 0.268696, -1.483235, 579.715515,
- 20.975695, 0.265968, -1.261051, 386.583649, 12.017023, 0.325369, -1.343349, 316.795959,
- 12.612406, 0.387968, -1.411606, 232.491623, 13.296940, 0.435543, -1.411236, 181.515228,
- 11.646996, 0.482729, -1.405722, 143.425354, 10.265131, 0.531742, -1.402782, 114.920082,
- 9.114828, 0.559383, -1.346165, 88.589005, 8.089214, 0.607851, -1.342407, 73.056610, 7.249064,
- 0.656928, -1.338238, 60.826897, 6.531094, 0.681212, -1.285692, 48.727219, 5.868711, 0.729238,
- -1.279951, 41.256016, 5.324553, 0.751172, -1.230045, 33.728260, 4.816513, 0.773107, -1.184288,
- 27.913816, 4.377203, 0.815726, -1.171653, 24.065962, 3.999965, 0.837886, -1.130636, 20.254860,
- 3.658493, 0.857674, -1.089071, 17.138168, 3.347930, 0.876120, -1.048303, 14.572968, 3.072666,
- 0.893935, -1.009040, 12.496377, 2.825165, 0.927998, -0.989064, 11.040731, 2.605520, 0.928445,
- -0.935017, 9.365102, 2.401481, 0.945279, -0.899993, 8.177711, 2.222282, 0.959378, -0.863854,
- 7.155303, 2.059342, 0.971761, -0.827684, 6.284632, 1.909314, 0.987812, -0.795878, 5.583837,
- 1.771094, 1.001958, -0.763540, 4.962345, 1.645968, 1.014357, -0.730897, 4.435898, 1.527438,
- 1.025946, -0.698675, 3.973241, 1.421337, 1.036435, -0.666662, 3.568025, 1.323677, 1.046807,
- -0.635466, 3.218647, 1.232678, 1.052974, -0.602660, 2.902273, 1.147675, 1.086089, -0.585364,
- 2.694939, 1.068352, 1.094660, -0.554784, 2.454491, 0.993445, 1.117131, -0.531500, 2.270746,
- 0.923758, 1.114009, -0.496581, 2.063934, 0.858381, 1.137328, -0.473914, 1.917990, 0.794980,
- 1.158671, -0.450127, 1.786523, 0.735697, 1.177878, -0.425306, 1.662454, 0.677498, 1.207510,
- -0.403797, 1.559058, 0.621762, 1.244496, -0.383812, 1.466801, 0.566190, 1.240412, -0.351080,
- 1.366853, 0.514288, 1.321257, -0.341200, 1.309808, 0.464621, 1.336512, -0.312710, 1.241822,
- 0.413228, 1.365047, -0.286935, 1.186612, 0.366092, 1.418984, -0.265184, 1.152120, 0.321528,
- 1.388864, -0.227750, 1.089937, 0.271827, 1.464383, -0.207168, 1.077271, 0.232838, 1.473125,
- -0.175770, 1.041835, 0.193289, 1.542908, -0.150424, 1.036794, 0.156153, 1.563005, -0.118748,
- 1.013029, 0.114866, 1.637048, -0.089604, 1.013493, 0.076804, 1.670777, -0.056398, 0.999208,
- 0.032691,
+ 1.000000, 0.000000, 0.000000, 0.000020, 1.000000, 0.000000, 0.000000, 0.000504,
+ 1.000000, 0.000000, 0.000000, 0.002016, 1.000000, 0.000000, 0.000000, 0.004535,
+ 1.000000, 0.000000, 0.000000, 0.008063, 1.000000, 0.000000, 0.000000, 0.012598,
+ 1.000000, 0.000000, 0.000000, 0.018141, 1.000000, 0.000000, 0.000000, 0.024692,
+ 1.000000, 0.000000, 0.000000, 0.032253, 1.000000, 0.000000, 0.000000, 0.040821,
+ 1.000000, 0.000000, 0.000000, 0.050400, 1.000000, 0.000000, 0.000000, 0.060989,
+ 1.000000, 0.000000, 0.000000, 0.072591, 1.000000, 0.000000, 0.000000, 0.085206,
+ 1.000000, 0.000000, 0.000000, 0.098836, 1.000000, 0.000000, 0.000000, 0.113484,
+ 1.000000, 0.000000, 0.000000, 0.129153, 1.000000, 0.000000, 0.000000, 0.145839,
+ 1.000000, 0.000000, 0.000000, 0.163548, 1.000000, 0.000000, 0.000000, 0.182266,
+ 1.000000, 0.000000, 0.000000, 0.201942, 1.000000, 0.000000, 0.000000, 0.222314,
+ 1.000000, 0.000000, 0.000000, 0.241906, 1.000000, 0.000000, 0.000000, 0.262314,
+ 1.000000, 0.000000, 0.000000, 0.285754, 1.000000, 0.000000, 0.000000, 0.310159,
+ 1.000000, 0.000000, 0.000000, 0.335426, 1.000000, 0.000000, 0.000000, 0.361341,
+ 1.000000, 0.000000, 0.000000, 0.387445, 1.000000, 0.000000, 0.000000, 0.412784,
+ 1.000000, 0.000000, 0.000000, 0.438197, 1.000000, 0.000000, 0.000000, 0.466966,
+ 1.000000, 0.000000, 0.000000, 0.495590, 1.000000, 0.000000, 0.000000, 0.523448,
+ 1.000000, 0.000000, 0.000000, 0.549938, 1.000000, 0.000000, 0.000000, 0.579790,
+ 1.000000, 0.000000, 0.000000, 0.608746, 1.000000, 0.000000, 0.000000, 0.636185,
+ 1.000000, 0.000000, 0.000000, 0.664748, 1.000000, 0.000000, 0.000000, 0.693130,
+ 1.000000, 0.000000, 0.000000, 0.719660, 1.000000, 0.000000, 0.000000, 0.747662,
+ 1.000000, 0.000000, 0.000000, 0.774023, 1.000000, 0.000000, 0.000000, 0.799775,
+ 1.000000, 0.000000, 0.000000, 0.825274, 1.000000, 0.000000, 0.000000, 0.849156,
+ 1.000000, 0.000000, 0.000000, 0.873248, 1.000000, 0.000000, 0.000000, 0.895320,
+ 1.000000, 0.000000, 0.000000, 0.917565, 1.000000, 0.000000, 0.000000, 0.937863,
+ 1.000000, 0.000000, 0.000000, 0.958139, 1.000000, 0.000000, 0.000000, 0.976563,
+ 1.000000, 0.000000, 0.000000, 0.994658, 1.000000, 0.000000, 0.000000, 1.011200,
+ 1.000000, 0.000000, 0.000000, 1.027120, 1.000000, 0.000000, 0.000000, 1.041890,
+ 1.000000, 0.000000, 0.000000, 1.055680, 1.000000, 0.000000, 0.000000, 1.068770,
+ 1.000000, 0.000000, 0.000000, 1.080580, 1.000000, 0.000000, 0.000000, 1.091940,
+ 1.000000, 0.000000, 0.000000, 1.101910, 1.000000, 0.000000, 0.000000, 1.111610,
+ 1.000000, 0.000000, 0.000000, 1.119900, 1.000000, 0.000000, 0.000000, 1.128130,
+ 0.999547, -0.000000, 0.022442, 0.000020, 0.999495, -0.000011, 0.022441, 0.000504,
+ 0.999496, -0.000045, 0.022441, 0.002015, 0.999496, -0.000102, 0.022441, 0.004533,
+ 0.999495, -0.000181, 0.022441, 0.008058, 0.999497, -0.000283, 0.022441, 0.012591,
+ 0.999496, -0.000407, 0.022441, 0.018132, 0.999498, -0.000554, 0.022441, 0.024680,
+ 0.999499, -0.000724, 0.022441, 0.032236, 0.999495, -0.000916, 0.022440, 0.040801,
+ 0.999499, -0.001131, 0.022441, 0.050375, 0.999494, -0.001369, 0.022440, 0.060959,
+ 0.999489, -0.001629, 0.022440, 0.072554, 0.999489, -0.001912, 0.022441, 0.085162,
+ 0.999498, -0.002218, 0.022441, 0.098787, 0.999492, -0.002546, 0.022441, 0.113426,
+ 0.999507, -0.002898, 0.022442, 0.129088, 0.999494, -0.003272, 0.022439, 0.145767,
+ 0.999546, -0.003667, 0.022442, 0.163472, 0.999543, -0.004082, 0.022439, 0.182182,
+ 0.999499, -0.004501, 0.022434, 0.201843, 0.999503, -0.004837, 0.022420, 0.222198,
+ 0.999546, -0.004529, 0.022315, 0.241714, 0.999508, -0.005874, 0.022433, 0.262184,
+ 0.999509, -0.006388, 0.022427, 0.285609, 0.999501, -0.006910, 0.022417, 0.309998,
+ 0.999539, -0.007420, 0.022399, 0.335262, 0.999454, -0.007863, 0.022367, 0.361154,
+ 0.999529, -0.008119, 0.022283, 0.387224, 0.999503, -0.007999, 0.022106, 0.412520,
+ 0.999561, -0.009528, 0.022306, 0.438006, 0.999557, -0.009913, 0.022207, 0.466735,
+ 0.999541, -0.010094, 0.022040, 0.495332, 0.999562, -0.009968, 0.021807, 0.523197,
+ 0.999556, -0.010503, 0.021710, 0.550223, 0.999561, -0.011419, 0.021722, 0.579498,
+ 0.999588, -0.011182, 0.021336, 0.608416, 0.999633, -0.010773, 0.020869, 0.635965,
+ 0.999527, -0.012167, 0.021015, 0.664476, 0.999508, -0.011600, 0.020431, 0.692786,
+ 0.999568, -0.011560, 0.019979, 0.719709, 0.999671, -0.012112, 0.019741, 0.747370,
+ 0.999688, -0.011077, 0.018885, 0.773692, 0.999620, -0.012237, 0.018845, 0.799534,
+ 0.999823, -0.011033, 0.017800, 0.825046, 0.999599, -0.011492, 0.017422, 0.849075,
+ 0.999619, -0.010592, 0.016435, 0.872999, 0.999613, -0.010599, 0.015823, 0.895371,
+ 0.999640, -0.009799, 0.014813, 0.917364, 0.999770, -0.009672, 0.014072, 0.938002,
+ 0.999726, -0.008692, 0.012954, 0.957917, 0.999730, -0.008669, 0.012233, 0.976557,
+ 0.999773, -0.007320, 0.010896, 0.994459, 0.999811, -0.007560, 0.010271, 1.011180,
+ 0.999862, -0.005837, 0.008788, 1.027010, 0.999835, -0.006314, 0.008275, 1.041860,
+ 0.999871, -0.004508, 0.006746, 1.055690, 0.999867, -0.004861, 0.006210, 1.068610,
+ 0.999939, -0.003221, 0.004783, 1.080640, 0.999918, -0.003182, 0.004064, 1.091810,
+ 1.000030, -0.001933, 0.002807, 1.102070, 0.999928, -0.001537, 0.001987, 1.111520,
+ 0.999933, -0.000624, 0.000918, 1.120090, 1.000000, -0.000001, 0.000001, 1.128130,
+ 0.997866, -0.000001, 0.044833, 0.000020, 0.997987, -0.000023, 0.044839, 0.000503,
+ 0.997987, -0.000090, 0.044839, 0.002012, 0.997985, -0.000203, 0.044839, 0.004526,
+ 0.997986, -0.000362, 0.044839, 0.008046, 0.997987, -0.000565, 0.044839, 0.012572,
+ 0.997988, -0.000813, 0.044839, 0.018104, 0.997984, -0.001107, 0.044839, 0.024643,
+ 0.997985, -0.001446, 0.044839, 0.032188, 0.997987, -0.001830, 0.044839, 0.040739,
+ 0.997983, -0.002260, 0.044839, 0.050299, 0.997991, -0.002735, 0.044839, 0.060867,
+ 0.997984, -0.003255, 0.044838, 0.072444, 0.998002, -0.003820, 0.044839, 0.085035,
+ 0.997997, -0.004431, 0.044840, 0.098637, 0.998007, -0.005088, 0.044840, 0.113255,
+ 0.998008, -0.005790, 0.044840, 0.128891, 0.998003, -0.006537, 0.044838, 0.145548,
+ 0.997983, -0.007327, 0.044836, 0.163221, 0.997985, -0.008155, 0.044836, 0.181899,
+ 0.998005, -0.008990, 0.044829, 0.201533, 0.998026, -0.009644, 0.044793, 0.221821,
+ 0.998055, -0.009227, 0.044611, 0.241282, 0.998040, -0.011736, 0.044825, 0.261791,
+ 0.998048, -0.012763, 0.044816, 0.285181, 0.998088, -0.013806, 0.044800, 0.309540,
+ 0.998058, -0.014821, 0.044767, 0.334751, 0.998099, -0.015700, 0.044697, 0.360610,
+ 0.998116, -0.016198, 0.044512, 0.386603, 0.998195, -0.015945, 0.044171, 0.411844,
+ 0.998168, -0.018395, 0.044425, 0.437730, 0.998184, -0.019791, 0.044381, 0.466009,
+ 0.998251, -0.020143, 0.044069, 0.494574, 0.998305, -0.019885, 0.043563, 0.522405,
+ 0.998273, -0.021058, 0.043414, 0.549967, 0.998254, -0.022790, 0.043394, 0.578655,
+ 0.998349, -0.022311, 0.042653, 0.607580, 0.998430, -0.022309, 0.042000, 0.635524,
+ 0.998373, -0.024114, 0.041899, 0.663621, 0.998425, -0.023145, 0.040812, 0.691906,
+ 0.998504, -0.023368, 0.040057, 0.719339, 0.998443, -0.024165, 0.039463, 0.746430,
+ 0.998480, -0.022871, 0.038000, 0.773086, 0.998569, -0.023519, 0.037232, 0.798988,
+ 0.998619, -0.022311, 0.035647, 0.824249, 0.998594, -0.022311, 0.034523, 0.848808,
+ 0.998622, -0.021343, 0.032889, 0.872270, 0.998669, -0.020791, 0.031437, 0.895157,
+ 0.998705, -0.019842, 0.029693, 0.916769, 0.998786, -0.018917, 0.027963, 0.937773,
+ 0.998888, -0.017881, 0.026160, 0.957431, 0.999060, -0.016685, 0.024216, 0.976495,
+ 0.999038, -0.015546, 0.022264, 0.994169, 0.999237, -0.014135, 0.020197, 1.011120,
+ 0.999378, -0.012932, 0.018174, 1.026920, 0.999433, -0.011319, 0.015990, 1.041740,
+ 0.999439, -0.010124, 0.014039, 1.055590, 0.999614, -0.008375, 0.011783, 1.068520,
+ 0.999722, -0.007218, 0.009837, 1.080690, 0.999817, -0.005541, 0.007690, 1.091760,
+ 0.999830, -0.004270, 0.005782, 1.102110, 0.999964, -0.002739, 0.003745, 1.111520,
+ 1.000010, -0.001367, 0.001872, 1.120310, 0.999946, 0.000039, -0.000029, 1.128040,
+ 0.995847, -0.000001, 0.067179, 0.000020, 0.995464, -0.000034, 0.067153, 0.000502,
+ 0.995470, -0.000135, 0.067153, 0.002006, 0.995471, -0.000305, 0.067153, 0.004515,
+ 0.995470, -0.000541, 0.067153, 0.008026, 0.995471, -0.000846, 0.067153, 0.012541,
+ 0.995470, -0.001218, 0.067153, 0.018059, 0.995470, -0.001658, 0.067153, 0.024581,
+ 0.995463, -0.002166, 0.067153, 0.032106, 0.995468, -0.002741, 0.067153, 0.040637,
+ 0.995474, -0.003384, 0.067153, 0.050172, 0.995473, -0.004096, 0.067153, 0.060713,
+ 0.995478, -0.004875, 0.067153, 0.072262, 0.995476, -0.005721, 0.067153, 0.084819,
+ 0.995477, -0.006637, 0.067154, 0.098388, 0.995498, -0.007620, 0.067154, 0.112972,
+ 0.995509, -0.008671, 0.067154, 0.128568, 0.995509, -0.009790, 0.067153, 0.145183,
+ 0.995503, -0.010972, 0.067149, 0.162808, 0.995501, -0.012211, 0.067146, 0.181441,
+ 0.995530, -0.013456, 0.067137, 0.201015, 0.995550, -0.014391, 0.067083, 0.221206,
+ 0.995580, -0.014351, 0.066888, 0.240813, 0.995577, -0.017400, 0.067105, 0.261257,
+ 0.995602, -0.019111, 0.067118, 0.284467, 0.995623, -0.020671, 0.067095, 0.308765,
+ 0.995658, -0.022184, 0.067047, 0.333905, 0.995705, -0.023483, 0.066942, 0.359677,
+ 0.995719, -0.024193, 0.066671, 0.385554, 0.995786, -0.024354, 0.066266, 0.410951,
+ 0.995887, -0.027187, 0.066437, 0.437163, 0.995944, -0.029601, 0.066493, 0.464842,
+ 0.996004, -0.030104, 0.066010, 0.493320, 0.996128, -0.029831, 0.065269, 0.521131,
+ 0.996253, -0.031643, 0.065074, 0.549167, 0.996244, -0.033904, 0.064943, 0.577370,
+ 0.996309, -0.033329, 0.063893, 0.606073, 0.996417, -0.033894, 0.063085, 0.634527,
+ 0.996372, -0.035310, 0.062508, 0.662560, 0.996542, -0.034894, 0.061199, 0.690516,
+ 0.996568, -0.035161, 0.060069, 0.718317, 0.996711, -0.035432, 0.058852, 0.745280,
+ 0.996671, -0.034951, 0.057190, 0.772061, 0.996865, -0.034562, 0.055532, 0.798089,
+ 0.996802, -0.034257, 0.053782, 0.823178, 0.996992, -0.033086, 0.051610, 0.847949,
+ 0.996944, -0.032467, 0.049554, 0.871431, 0.997146, -0.030954, 0.047030, 0.894357,
+ 0.997189, -0.029937, 0.044604, 0.916142, 0.997471, -0.028139, 0.041881, 0.937193,
+ 0.997515, -0.026870, 0.039182, 0.957000, 0.997812, -0.024717, 0.036134, 0.975936,
+ 0.998027, -0.023353, 0.033395, 0.993910, 0.998233, -0.020984, 0.030192, 1.010750,
+ 0.998481, -0.019431, 0.027271, 1.026690, 0.998859, -0.016973, 0.024016, 1.041730,
+ 0.998940, -0.015232, 0.021052, 1.055510, 0.999132, -0.012750, 0.017863, 1.068560,
+ 0.999369, -0.010828, 0.014787, 1.080540, 0.999549, -0.008459, 0.011619, 1.091850,
+ 0.999805, -0.006394, 0.008672, 1.102070, 0.999850, -0.004146, 0.005668, 1.111700,
+ 0.999912, -0.002074, 0.002776, 1.120220, 1.000010, 0.000087, -0.000054, 1.128320,
+ 0.991943, -0.000002, 0.089338, 0.000020, 0.991952, -0.000045, 0.089339, 0.000500,
+ 0.991956, -0.000180, 0.089339, 0.001999, 0.991955, -0.000405, 0.089339, 0.004499,
+ 0.991953, -0.000720, 0.089339, 0.007998, 0.991955, -0.001125, 0.089339, 0.012496,
+ 0.991957, -0.001621, 0.089340, 0.017995, 0.991958, -0.002206, 0.089340, 0.024494,
+ 0.991947, -0.002881, 0.089339, 0.031993, 0.991962, -0.003647, 0.089340, 0.040493,
+ 0.991965, -0.004503, 0.089340, 0.049995, 0.991980, -0.005449, 0.089341, 0.060499,
+ 0.991970, -0.006485, 0.089340, 0.072007, 0.991976, -0.007612, 0.089341, 0.084521,
+ 0.991980, -0.008829, 0.089341, 0.098041, 0.991982, -0.010137, 0.089340, 0.112571,
+ 0.992008, -0.011535, 0.089342, 0.128115, 0.992026, -0.013023, 0.089341, 0.144672,
+ 0.992064, -0.014597, 0.089342, 0.162241, 0.992041, -0.016242, 0.089336, 0.180801,
+ 0.992086, -0.017889, 0.089321, 0.200302, 0.992157, -0.019037, 0.089240, 0.220332,
+ 0.992181, -0.019558, 0.089053, 0.240144, 0.992175, -0.022726, 0.089215, 0.260728,
+ 0.992210, -0.025420, 0.089304, 0.283473, 0.992220, -0.027488, 0.089270, 0.307673,
+ 0.992317, -0.029490, 0.089203, 0.332729, 0.992374, -0.031186, 0.089058, 0.358387,
+ 0.992505, -0.032066, 0.088699, 0.384102, 0.992568, -0.032972, 0.088320, 0.409767,
+ 0.992675, -0.036006, 0.088360, 0.436145, 0.992746, -0.039290, 0.088459, 0.463217,
+ 0.992873, -0.039934, 0.087829, 0.491557, 0.992934, -0.040231, 0.087011, 0.519516,
+ 0.993091, -0.042201, 0.086586, 0.547741, 0.993259, -0.044350, 0.086194, 0.575792,
+ 0.993455, -0.044637, 0.085119, 0.604233, 0.993497, -0.045430, 0.084058, 0.632925,
+ 0.993694, -0.046330, 0.082967, 0.660985, 0.993718, -0.047062, 0.081718, 0.688714,
+ 0.993973, -0.046884, 0.080029, 0.716743, 0.994207, -0.046705, 0.078129, 0.743770,
+ 0.994168, -0.046970, 0.076334, 0.770420, 0.994500, -0.045682, 0.073818, 0.796659,
+ 0.994356, -0.045552, 0.071554, 0.821868, 0.994747, -0.043949, 0.068609, 0.846572,
+ 0.994937, -0.043006, 0.065869, 0.870435, 0.995142, -0.041341, 0.062645, 0.893272,
+ 0.995451, -0.039652, 0.059290, 0.915376, 0.995445, -0.037845, 0.055850, 0.936196,
+ 0.995967, -0.035522, 0.052095, 0.956376, 0.996094, -0.033515, 0.048377, 0.975327,
+ 0.996622, -0.030682, 0.044257, 0.993471, 0.996938, -0.028550, 0.040469, 1.010520,
+ 0.997383, -0.025340, 0.036090, 1.026370, 0.997714, -0.023165, 0.032218, 1.041390,
+ 0.998249, -0.019814, 0.027843, 1.055420, 0.998596, -0.017434, 0.023876, 1.068460,
+ 0.998946, -0.014135, 0.019594, 1.080560, 0.999280, -0.011560, 0.015628, 1.091810,
+ 0.999507, -0.008391, 0.011461, 1.102130, 0.999697, -0.005666, 0.007633, 1.111690,
+ 0.999869, -0.002699, 0.003649, 1.120420, 1.000010, 0.000062, -0.000032, 1.128320,
+ 0.987221, -0.000002, 0.111332, 0.000020, 0.987390, -0.000056, 0.111351, 0.000498,
+ 0.987448, -0.000224, 0.111357, 0.001990, 0.987441, -0.000505, 0.111357, 0.004478,
+ 0.987442, -0.000898, 0.111357, 0.007961, 0.987442, -0.001403, 0.111357, 0.012440,
+ 0.987444, -0.002020, 0.111357, 0.017913, 0.987442, -0.002750, 0.111357, 0.024382,
+ 0.987446, -0.003591, 0.111357, 0.031847, 0.987435, -0.004546, 0.111356, 0.040309,
+ 0.987461, -0.005612, 0.111358, 0.049768, 0.987458, -0.006791, 0.111358, 0.060224,
+ 0.987443, -0.008083, 0.111356, 0.071679, 0.987476, -0.009487, 0.111358, 0.084136,
+ 0.987490, -0.011004, 0.111361, 0.097597, 0.987508, -0.012634, 0.111362, 0.112062,
+ 0.987494, -0.014377, 0.111357, 0.127533, 0.987526, -0.016231, 0.111359, 0.144015,
+ 0.987558, -0.018191, 0.111361, 0.161502, 0.987602, -0.020239, 0.111355, 0.179979,
+ 0.987692, -0.022273, 0.111346, 0.199386, 0.987702, -0.023531, 0.111215, 0.219183,
+ 0.987789, -0.024763, 0.111061, 0.239202, 0.987776, -0.028067, 0.111171, 0.259957,
+ 0.987856, -0.031675, 0.111327, 0.282198, 0.987912, -0.034247, 0.111282, 0.306294,
+ 0.988000, -0.036721, 0.111198, 0.331219, 0.988055, -0.038777, 0.110994, 0.356708,
+ 0.988241, -0.039772, 0.110547, 0.382234, 0.988399, -0.041608, 0.110198, 0.408227,
+ 0.988539, -0.044819, 0.110137, 0.434662, 0.988661, -0.048379, 0.110143, 0.461442,
+ 0.988967, -0.049590, 0.109453, 0.489318, 0.989073, -0.050680, 0.108628, 0.517516,
+ 0.989274, -0.052695, 0.108003, 0.545844, 0.989528, -0.054578, 0.107255, 0.573823,
+ 0.989709, -0.056150, 0.106294, 0.601944, 0.989991, -0.056866, 0.104896, 0.630855,
+ 0.990392, -0.057291, 0.103336, 0.658925, 0.990374, -0.058622, 0.101890, 0.686661,
+ 0.990747, -0.058476, 0.099783, 0.714548, 0.991041, -0.058266, 0.097431, 0.741860,
+ 0.991236, -0.058412, 0.095168, 0.768422, 0.991585, -0.057306, 0.092158, 0.794817,
+ 0.991984, -0.056424, 0.089117, 0.820336, 0.992100, -0.055361, 0.085805, 0.844930,
+ 0.992749, -0.053382, 0.082035, 0.868961, 0.992880, -0.051866, 0.078218, 0.891931,
+ 0.993511, -0.049249, 0.073894, 0.914186, 0.993617, -0.047196, 0.069640, 0.935320,
+ 0.994110, -0.044216, 0.064966, 0.955430, 0.994595, -0.041665, 0.060318, 0.974685,
+ 0.994976, -0.038431, 0.055349, 0.992807, 0.995579, -0.035349, 0.050394, 1.009960,
+ 0.996069, -0.031979, 0.045212, 1.026060, 0.996718, -0.028472, 0.040011, 1.041140,
+ 0.997173, -0.025079, 0.034946, 1.055170, 0.997818, -0.021333, 0.029653, 1.068300,
+ 0.998318, -0.017851, 0.024549, 1.080500, 0.998853, -0.014112, 0.019420, 1.091770,
+ 0.999218, -0.010591, 0.014387, 1.102200, 0.999594, -0.006935, 0.009435, 1.111750,
+ 0.999750, -0.003405, 0.004641, 1.120560, 1.000010, 0.000109, -0.000113, 1.128530,
+ 0.983383, -0.000003, 0.133358, 0.000020, 0.981942, -0.000067, 0.133162, 0.000495,
+ 0.981946, -0.000268, 0.133163, 0.001979, 0.981944, -0.000604, 0.133163, 0.004453,
+ 0.981941, -0.001074, 0.133162, 0.007917, 0.981946, -0.001678, 0.133163, 0.012370,
+ 0.981944, -0.002416, 0.133162, 0.017813, 0.981945, -0.003288, 0.133163, 0.024247,
+ 0.981945, -0.004295, 0.133162, 0.031670, 0.981955, -0.005436, 0.133164, 0.040085,
+ 0.981951, -0.006711, 0.133163, 0.049490, 0.981968, -0.008121, 0.133165, 0.059889,
+ 0.981979, -0.009665, 0.133166, 0.071281, 0.981996, -0.011345, 0.133168, 0.083669,
+ 0.982014, -0.013159, 0.133169, 0.097053, 0.982011, -0.015107, 0.133167, 0.111438,
+ 0.982062, -0.017191, 0.133172, 0.126826, 0.982100, -0.019407, 0.133175, 0.143215,
+ 0.982149, -0.021750, 0.133176, 0.160609, 0.982163, -0.024195, 0.133173, 0.178981,
+ 0.982247, -0.026591, 0.133148, 0.198249, 0.982291, -0.027916, 0.132974, 0.217795,
+ 0.982396, -0.029966, 0.132868, 0.238042, 0.982456, -0.033454, 0.132934, 0.258901,
+ 0.982499, -0.037864, 0.133137, 0.280639, 0.982617, -0.040927, 0.133085, 0.304604,
+ 0.982740, -0.043852, 0.132985, 0.329376, 0.982944, -0.046229, 0.132728, 0.354697,
+ 0.983080, -0.047600, 0.132228, 0.380102, 0.983391, -0.050190, 0.131924, 0.406256,
+ 0.983514, -0.053590, 0.131737, 0.432735, 0.983730, -0.057186, 0.131567, 0.459359,
+ 0.984056, -0.059235, 0.130932, 0.486637, 0.984234, -0.061049, 0.130092, 0.515090,
+ 0.984748, -0.063076, 0.129230, 0.543461, 0.985073, -0.064740, 0.128174, 0.571376,
+ 0.985195, -0.067194, 0.127133, 0.599414, 0.985734, -0.068135, 0.125576, 0.628134,
+ 0.986241, -0.068609, 0.123639, 0.656399, 0.986356, -0.069851, 0.121834, 0.684258,
+ 0.986894, -0.070093, 0.119454, 0.711818, 0.987382, -0.069832, 0.116718, 0.739511,
+ 0.988109, -0.069398, 0.113699, 0.766267, 0.988363, -0.068958, 0.110454, 0.792456,
+ 0.989112, -0.067235, 0.106602, 0.818130, 0.989241, -0.066203, 0.102670, 0.842889,
+ 0.990333, -0.063894, 0.098138, 0.867204, 0.990591, -0.061853, 0.093539, 0.890380,
+ 0.991106, -0.059312, 0.088553, 0.912576, 0.991919, -0.056268, 0.083219, 0.934118,
+ 0.992111, -0.053408, 0.077830, 0.954254, 0.992997, -0.049546, 0.072045, 0.973722,
+ 0.993317, -0.046371, 0.066346, 0.991949, 0.994133, -0.042125, 0.060188, 1.009360,
+ 0.994705, -0.038498, 0.054250, 1.025590, 0.995495, -0.034096, 0.047986, 1.040830,
+ 0.996206, -0.030105, 0.041887, 1.054970, 0.996971, -0.025610, 0.035535, 1.068240,
+ 0.997796, -0.021393, 0.029365, 1.080560, 0.998272, -0.016961, 0.023293, 1.091820,
+ 0.998857, -0.012676, 0.017279, 1.102190, 0.999390, -0.008325, 0.011316, 1.111920,
+ 0.999752, -0.004108, 0.005579, 1.120750, 1.000000, 0.000151, -0.000119, 1.128850,
+ 0.975169, -0.000003, 0.154669, 0.000020, 0.975439, -0.000078, 0.154712, 0.000492,
+ 0.975464, -0.000312, 0.154716, 0.001966, 0.975464, -0.000702, 0.154716, 0.004424,
+ 0.975462, -0.001247, 0.154715, 0.007865, 0.975461, -0.001949, 0.154715, 0.012289,
+ 0.975464, -0.002807, 0.154715, 0.017696, 0.975468, -0.003820, 0.154716, 0.024087,
+ 0.975471, -0.004990, 0.154716, 0.031461, 0.975472, -0.006315, 0.154717, 0.039820,
+ 0.975486, -0.007797, 0.154718, 0.049164, 0.975489, -0.009435, 0.154718, 0.059493,
+ 0.975509, -0.011229, 0.154721, 0.070811, 0.975540, -0.013180, 0.154724, 0.083118,
+ 0.975557, -0.015288, 0.154726, 0.096415, 0.975585, -0.017551, 0.154728, 0.110705,
+ 0.975605, -0.019971, 0.154729, 0.125992, 0.975645, -0.022545, 0.154729, 0.142272,
+ 0.975711, -0.025265, 0.154735, 0.159549, 0.975788, -0.028099, 0.154736, 0.177805,
+ 0.975872, -0.030823, 0.154704, 0.196911, 0.975968, -0.032484, 0.154525, 0.216324,
+ 0.976063, -0.035128, 0.154432, 0.236628, 0.976157, -0.038862, 0.154460, 0.257539,
+ 0.976204, -0.043770, 0.154665, 0.278975, 0.976358, -0.047514, 0.154652, 0.302606,
+ 0.976571, -0.050864, 0.154535, 0.327204, 0.976725, -0.053499, 0.154221, 0.352276,
+ 0.977013, -0.055555, 0.153737, 0.377696, 0.977294, -0.058673, 0.153403, 0.403855,
+ 0.977602, -0.062272, 0.153120, 0.430333, 0.977932, -0.065817, 0.152755, 0.456855,
+ 0.978241, -0.068988, 0.152233, 0.483668, 0.978602, -0.071280, 0.151320, 0.512097,
+ 0.979234, -0.073277, 0.150235, 0.540455, 0.979770, -0.075163, 0.148978, 0.568486,
+ 0.979995, -0.077803, 0.147755, 0.596524, 0.980780, -0.079185, 0.146019, 0.624825,
+ 0.981628, -0.079967, 0.143906, 0.653403, 0.982067, -0.080853, 0.141561, 0.681445,
+ 0.982710, -0.081602, 0.139025, 0.708918, 0.983734, -0.081251, 0.135764, 0.736594,
+ 0.984310, -0.080620, 0.132152, 0.763576, 0.985071, -0.080160, 0.128460, 0.789797,
+ 0.986180, -0.078421, 0.124084, 0.815804, 0.986886, -0.076664, 0.119300, 0.840869,
+ 0.987485, -0.074774, 0.114236, 0.864952, 0.988431, -0.071670, 0.108654, 0.888431,
+ 0.988886, -0.069161, 0.102994, 0.910963, 0.990024, -0.065405, 0.096728, 0.932629,
+ 0.990401, -0.061976, 0.090384, 0.953130, 0.991093, -0.057930, 0.083789, 0.972587,
+ 0.992018, -0.053658, 0.077017, 0.991184, 0.992536, -0.049372, 0.070149, 1.008630,
+ 0.993421, -0.044481, 0.062953, 1.024940, 0.993928, -0.040008, 0.056045, 1.040170,
+ 0.994994, -0.034798, 0.048560, 1.054630, 0.995866, -0.030102, 0.041615, 1.068070,
+ 0.996916, -0.024823, 0.034260, 1.080390, 0.997766, -0.019923, 0.027167, 1.091770,
+ 0.998479, -0.014742, 0.020139, 1.102350, 0.999210, -0.009802, 0.013194, 1.112060,
+ 0.999652, -0.004743, 0.006407, 1.121040, 0.999998, 0.000089, -0.000104, 1.129060,
+ 0.967868, -0.000004, 0.175947, 0.000019, 0.968001, -0.000089, 0.175972, 0.000488,
+ 0.968010, -0.000355, 0.175973, 0.001951, 0.968012, -0.000798, 0.175974, 0.004390,
+ 0.968011, -0.001419, 0.175973, 0.007805, 0.968011, -0.002217, 0.175973, 0.012195,
+ 0.968016, -0.003192, 0.175974, 0.017561, 0.968019, -0.004345, 0.175974, 0.023903,
+ 0.968018, -0.005675, 0.175974, 0.031221, 0.968033, -0.007183, 0.175977, 0.039516,
+ 0.968049, -0.008868, 0.175979, 0.048788, 0.968047, -0.010731, 0.175978, 0.059039,
+ 0.968072, -0.012772, 0.175981, 0.070270, 0.968108, -0.014991, 0.175986, 0.082484,
+ 0.968112, -0.017387, 0.175985, 0.095678, 0.968173, -0.019961, 0.175993, 0.109862,
+ 0.968270, -0.022713, 0.176008, 0.125033, 0.968292, -0.025639, 0.176010, 0.141193,
+ 0.968339, -0.028730, 0.176007, 0.158336, 0.968389, -0.031940, 0.176001, 0.176441,
+ 0.968501, -0.034941, 0.175962, 0.195359, 0.968646, -0.037081, 0.175793, 0.214686,
+ 0.968789, -0.040233, 0.175708, 0.234973, 0.968860, -0.044260, 0.175700, 0.255871,
+ 0.969013, -0.049398, 0.175876, 0.277238, 0.969242, -0.053993, 0.175940, 0.300326,
+ 0.969419, -0.057730, 0.175781, 0.324702, 0.969763, -0.060564, 0.175432, 0.349527,
+ 0.970093, -0.063449, 0.174992, 0.374976, 0.970361, -0.067059, 0.174611, 0.401097,
+ 0.970825, -0.070825, 0.174226, 0.427496, 0.971214, -0.074287, 0.173684, 0.453858,
+ 0.971622, -0.078261, 0.173186, 0.480637, 0.972175, -0.081315, 0.172288, 0.508655,
+ 0.972944, -0.083268, 0.170979, 0.536973, 0.973595, -0.085596, 0.169573, 0.565138,
+ 0.974345, -0.088216, 0.168152, 0.593222, 0.975233, -0.090167, 0.166314, 0.621201,
+ 0.976239, -0.091211, 0.163931, 0.649919, 0.977289, -0.091696, 0.161106, 0.678011,
+ 0.978076, -0.092706, 0.158272, 0.705717, 0.979533, -0.092556, 0.154750, 0.733228,
+ 0.980335, -0.091816, 0.150638, 0.760454, 0.981808, -0.090851, 0.146201, 0.786918,
+ 0.983061, -0.089617, 0.141386, 0.812953, 0.984148, -0.087159, 0.135837, 0.838281,
+ 0.985047, -0.085062, 0.130135, 0.862594, 0.986219, -0.081854, 0.123882, 0.886330,
+ 0.987043, -0.078452, 0.117126, 0.908952, 0.988107, -0.074960, 0.110341, 0.930744,
+ 0.988955, -0.070355, 0.102885, 0.951728, 0.989426, -0.066280, 0.095417, 0.971166,
+ 0.990421, -0.061083, 0.087633, 0.989984, 0.991032, -0.056294, 0.079779, 1.007650,
+ 0.992041, -0.050815, 0.071817, 1.024340, 0.992794, -0.045405, 0.063713, 1.039760,
+ 0.993691, -0.039819, 0.055534, 1.054180, 0.994778, -0.034148, 0.047339, 1.067720,
+ 0.995915, -0.028428, 0.039102, 1.080280, 0.997109, -0.022642, 0.030995, 1.091850,
+ 0.998095, -0.016874, 0.023029, 1.102470, 0.998985, -0.011127, 0.015072, 1.112290,
+ 0.999581, -0.005439, 0.007406, 1.121310, 1.000030, 0.000162, -0.000106, 1.129460,
+ 0.959505, -0.000004, 0.196876, 0.000019, 0.959599, -0.000099, 0.196895, 0.000484,
+ 0.959641, -0.000397, 0.196903, 0.001934, 0.959599, -0.000893, 0.196895, 0.004352,
+ 0.959603, -0.001587, 0.196896, 0.007737, 0.959604, -0.002480, 0.196896, 0.012089,
+ 0.959605, -0.003572, 0.196896, 0.017408, 0.959605, -0.004862, 0.196896, 0.023695,
+ 0.959613, -0.006350, 0.196897, 0.030950, 0.959619, -0.008037, 0.196898, 0.039172,
+ 0.959636, -0.009923, 0.196901, 0.048365, 0.959634, -0.012007, 0.196900, 0.058527,
+ 0.959675, -0.014290, 0.196906, 0.069661, 0.959712, -0.016772, 0.196911, 0.081768,
+ 0.959752, -0.019452, 0.196918, 0.094849, 0.959807, -0.022332, 0.196925, 0.108910,
+ 0.959828, -0.025409, 0.196924, 0.123947, 0.959906, -0.028681, 0.196934, 0.139968,
+ 0.960005, -0.032137, 0.196944, 0.156968, 0.960071, -0.035711, 0.196936, 0.174910,
+ 0.960237, -0.038906, 0.196882, 0.193597, 0.960367, -0.041623, 0.196731, 0.212850,
+ 0.960562, -0.045266, 0.196654, 0.233075, 0.960735, -0.049621, 0.196643, 0.253941,
+ 0.960913, -0.054938, 0.196774, 0.275278, 0.961121, -0.060341, 0.196893, 0.297733,
+ 0.961390, -0.064424, 0.196717, 0.321877, 0.961818, -0.067556, 0.196314, 0.346476,
+ 0.962175, -0.071271, 0.195917, 0.371907, 0.962550, -0.075285, 0.195500, 0.397916,
+ 0.963164, -0.079207, 0.195026, 0.424229, 0.963782, -0.082822, 0.194424, 0.450637,
+ 0.964306, -0.087312, 0.193831, 0.477288, 0.964923, -0.091105, 0.192973, 0.504716,
+ 0.966048, -0.093251, 0.191510, 0.533053, 0.967024, -0.095898, 0.190013, 0.561366,
+ 0.968038, -0.098350, 0.188253, 0.589464, 0.969152, -0.100754, 0.186257, 0.617433,
+ 0.970557, -0.102239, 0.183775, 0.645801, 0.972104, -0.102767, 0.180645, 0.674278,
+ 0.973203, -0.103492, 0.177242, 0.702004, 0.975123, -0.103793, 0.173450, 0.729529,
+ 0.976410, -0.102839, 0.168886, 0.756712, 0.978313, -0.101687, 0.163892, 0.783801,
+ 0.980036, -0.100314, 0.158439, 0.809671, 0.981339, -0.097836, 0.152211, 0.835402,
+ 0.982794, -0.095001, 0.145679, 0.860081, 0.984123, -0.092099, 0.138949, 0.883757,
+ 0.984918, -0.087864, 0.131283, 0.906850, 0.985999, -0.083939, 0.123464, 0.928786,
+ 0.987151, -0.079123, 0.115324, 0.949830, 0.987827, -0.073933, 0.106854, 0.969620,
+ 0.988806, -0.068809, 0.098269, 0.988610, 0.989588, -0.062896, 0.089346, 1.006670,
+ 0.990438, -0.057315, 0.080539, 1.023440, 0.991506, -0.050943, 0.071373, 1.039330,
+ 0.992492, -0.044872, 0.062373, 1.053780, 0.993663, -0.038350, 0.053084, 1.067470,
+ 0.994956, -0.031959, 0.043951, 1.080070, 0.996340, -0.025401, 0.034780, 1.091820,
+ 0.997610, -0.018969, 0.025795, 1.102500, 0.998630, -0.012444, 0.016989, 1.112470,
+ 0.999470, -0.006140, 0.008295, 1.121510, 1.000080, 0.000217, -0.000146, 1.129930,
+ 0.950129, -0.000004, 0.217413, 0.000019, 0.950264, -0.000110, 0.217444, 0.000479,
+ 0.950300, -0.000438, 0.217451, 0.001915, 0.950246, -0.000986, 0.217440, 0.004310,
+ 0.950246, -0.001753, 0.217440, 0.007661, 0.950245, -0.002739, 0.217440, 0.011971,
+ 0.950253, -0.003945, 0.217441, 0.017239, 0.950258, -0.005369, 0.217442, 0.023464,
+ 0.950267, -0.007013, 0.217444, 0.030648, 0.950277, -0.008876, 0.217446, 0.038791,
+ 0.950284, -0.010958, 0.217446, 0.047893, 0.950312, -0.013259, 0.217451, 0.057957,
+ 0.950334, -0.015780, 0.217454, 0.068982, 0.950378, -0.018520, 0.217462, 0.080971,
+ 0.950417, -0.021480, 0.217467, 0.093926, 0.950488, -0.024659, 0.217479, 0.107850,
+ 0.950534, -0.028057, 0.217483, 0.122743, 0.950633, -0.031669, 0.217498, 0.138611,
+ 0.950698, -0.035479, 0.217499, 0.155442, 0.950844, -0.039400, 0.217507, 0.173208,
+ 0.950999, -0.042681, 0.217419, 0.191605, 0.951221, -0.046130, 0.217317, 0.210840,
+ 0.951412, -0.050213, 0.217238, 0.230945, 0.951623, -0.054918, 0.217220, 0.251745,
+ 0.951867, -0.060449, 0.217306, 0.273001, 0.952069, -0.066519, 0.217466, 0.294874,
+ 0.952459, -0.070918, 0.217266, 0.318732, 0.952996, -0.074611, 0.216891, 0.343180,
+ 0.953425, -0.078925, 0.216503, 0.368490, 0.953885, -0.083329, 0.216042, 0.394373,
+ 0.954617, -0.087371, 0.215469, 0.420505, 0.955429, -0.091405, 0.214802, 0.446907,
+ 0.956068, -0.096167, 0.214146, 0.473522, 0.957094, -0.100480, 0.213286, 0.500520,
+ 0.958372, -0.103248, 0.211796, 0.528715, 0.959654, -0.106033, 0.210160, 0.557065,
+ 0.961305, -0.108384, 0.208149, 0.585286, 0.962785, -0.111122, 0.206024, 0.613334,
+ 0.964848, -0.112981, 0.203442, 0.641334, 0.966498, -0.113717, 0.199960, 0.669955,
+ 0.968678, -0.114121, 0.196105, 0.698094, 0.970489, -0.114524, 0.191906, 0.725643,
+ 0.972903, -0.113792, 0.186963, 0.752856, 0.974701, -0.112406, 0.181343, 0.780013,
+ 0.976718, -0.110685, 0.175185, 0.806268, 0.978905, -0.108468, 0.168535, 0.832073,
+ 0.980267, -0.105061, 0.161106, 0.857149, 0.981967, -0.101675, 0.153387, 0.881145,
+ 0.983063, -0.097449, 0.145199, 0.904255, 0.984432, -0.092581, 0.136527, 0.926686,
+ 0.985734, -0.087798, 0.127584, 0.947901, 0.986228, -0.081884, 0.118125, 0.968111,
+ 0.987190, -0.076121, 0.108594, 0.987190, 0.988228, -0.069820, 0.099000, 1.005590,
+ 0.989046, -0.063274, 0.089007, 1.022460, 0.990242, -0.056522, 0.079083, 1.038410,
+ 0.991252, -0.049527, 0.068918, 1.053470, 0.992542, -0.042537, 0.058859, 1.067240,
+ 0.994096, -0.035320, 0.048683, 1.080090, 0.995593, -0.028235, 0.038598, 1.091770,
+ 0.997110, -0.020951, 0.028646, 1.102740, 0.998263, -0.013929, 0.018850, 1.112620,
+ 0.999254, -0.006736, 0.009208, 1.121910, 0.999967, 0.000142, -0.000066, 1.130240,
+ 0.935608, -0.000005, 0.236466, 0.000019, 0.939960, -0.000120, 0.237568, 0.000474,
+ 0.939959, -0.000479, 0.237567, 0.001895, 0.939954, -0.001077, 0.237566, 0.004263,
+ 0.939956, -0.001915, 0.237566, 0.007578, 0.939954, -0.002993, 0.237566, 0.011841,
+ 0.939960, -0.004310, 0.237567, 0.017052, 0.939969, -0.005866, 0.237569, 0.023210,
+ 0.939982, -0.007662, 0.237572, 0.030316, 0.939987, -0.009697, 0.237572, 0.038371,
+ 0.939997, -0.011971, 0.237574, 0.047375, 0.940031, -0.014486, 0.237581, 0.057330,
+ 0.940073, -0.017240, 0.237589, 0.068237, 0.940120, -0.020234, 0.237598, 0.080097,
+ 0.940162, -0.023466, 0.237604, 0.092912, 0.940237, -0.026939, 0.237615, 0.106686,
+ 0.940328, -0.030649, 0.237632, 0.121421, 0.940419, -0.034592, 0.237645, 0.137115,
+ 0.940522, -0.038748, 0.237654, 0.153766, 0.940702, -0.042991, 0.237661, 0.171330,
+ 0.940871, -0.046509, 0.237561, 0.189502, 0.941103, -0.050531, 0.237480, 0.208616,
+ 0.941369, -0.055066, 0.237423, 0.228595, 0.941641, -0.060134, 0.237399, 0.249287,
+ 0.941903, -0.065880, 0.237443, 0.270467, 0.942224, -0.072267, 0.237597, 0.292024,
+ 0.942633, -0.077179, 0.237419, 0.315272, 0.943172, -0.081562, 0.237068, 0.339579,
+ 0.943691, -0.086397, 0.236682, 0.364717, 0.944382, -0.091154, 0.236213, 0.390435,
+ 0.945392, -0.095297, 0.235562, 0.416425, 0.946185, -0.099895, 0.234832, 0.442772,
+ 0.947212, -0.104796, 0.234114, 0.469347, 0.948778, -0.109280, 0.233222, 0.496162,
+ 0.950149, -0.113081, 0.231845, 0.523978, 0.951989, -0.115893, 0.230005, 0.552295,
+ 0.953921, -0.118460, 0.227862, 0.580569, 0.955624, -0.121150, 0.225439, 0.608698,
+ 0.958234, -0.123373, 0.222635, 0.636696, 0.960593, -0.124519, 0.219093, 0.665208,
+ 0.963201, -0.124736, 0.214749, 0.693557, 0.965642, -0.125012, 0.210059, 0.721334,
+ 0.968765, -0.124661, 0.204935, 0.748613, 0.971753, -0.122996, 0.198661, 0.776224,
+ 0.973751, -0.120998, 0.191823, 0.802461, 0.976709, -0.118583, 0.184359, 0.828399,
+ 0.977956, -0.115102, 0.176437, 0.853693, 0.979672, -0.111077, 0.167681, 0.877962,
+ 0.981816, -0.106880, 0.158872, 0.901564, 0.982380, -0.101469, 0.149398, 0.924057,
+ 0.983964, -0.096001, 0.139436, 0.945751, 0.984933, -0.089963, 0.129430, 0.966272,
+ 0.985694, -0.083297, 0.118940, 0.985741, 0.986822, -0.076708, 0.108349, 1.004070,
+ 0.987725, -0.069361, 0.097603, 1.021540, 0.988770, -0.062110, 0.086652, 1.037570,
+ 0.990129, -0.054414, 0.075618, 1.052960, 0.991337, -0.046744, 0.064575, 1.066830,
+ 0.992978, -0.038793, 0.053468, 1.079800, 0.994676, -0.030973, 0.042414, 1.091810,
+ 0.996450, -0.023031, 0.031404, 1.102860, 0.997967, -0.015206, 0.020687, 1.112910,
+ 0.999220, -0.007448, 0.010155, 1.122370, 1.000020, 0.000240, -0.000075, 1.130890,
+ 0.922948, -0.000005, 0.255626, 0.000019, 0.928785, -0.000130, 0.257244, 0.000468,
+ 0.928761, -0.000518, 0.257237, 0.001872, 0.928751, -0.001167, 0.257235, 0.004212,
+ 0.928751, -0.002074, 0.257234, 0.007488, 0.928754, -0.003241, 0.257235, 0.011700,
+ 0.928760, -0.004666, 0.257236, 0.016849, 0.928763, -0.006351, 0.257237, 0.022933,
+ 0.928774, -0.008296, 0.257239, 0.029955, 0.928791, -0.010500, 0.257243, 0.037914,
+ 0.928804, -0.012962, 0.257245, 0.046811, 0.928847, -0.015685, 0.257255, 0.056647,
+ 0.928890, -0.018666, 0.257263, 0.067425, 0.928924, -0.021907, 0.257268, 0.079143,
+ 0.928989, -0.025407, 0.257282, 0.091808, 0.929090, -0.029165, 0.257301, 0.105419,
+ 0.929180, -0.033180, 0.257316, 0.119978, 0.929290, -0.037447, 0.257332, 0.135491,
+ 0.929453, -0.041939, 0.257357, 0.151948, 0.929586, -0.046461, 0.257347, 0.169275,
+ 0.929858, -0.050343, 0.257269, 0.187257, 0.930125, -0.054841, 0.257199, 0.206204,
+ 0.930403, -0.059806, 0.257149, 0.226010, 0.930726, -0.065244, 0.257122, 0.246561,
+ 0.931098, -0.071238, 0.257153, 0.267618, 0.931396, -0.077751, 0.257237, 0.288993,
+ 0.931947, -0.083237, 0.257124, 0.311527, 0.932579, -0.088396, 0.256830, 0.335697,
+ 0.933194, -0.093704, 0.256444, 0.360634, 0.934013, -0.098729, 0.255939, 0.386126,
+ 0.935307, -0.103215, 0.255282, 0.412018, 0.936374, -0.108234, 0.254538, 0.438292,
+ 0.937760, -0.113234, 0.253728, 0.464805, 0.939599, -0.118013, 0.252750, 0.491464,
+ 0.941036, -0.122661, 0.251404, 0.518751, 0.943370, -0.125477, 0.249435, 0.547133,
+ 0.945318, -0.128374, 0.247113, 0.575456, 0.947995, -0.130996, 0.244441, 0.603720,
+ 0.950818, -0.133438, 0.241352, 0.631740, 0.954378, -0.135004, 0.237849, 0.659971,
+ 0.957151, -0.135313, 0.233188, 0.688478, 0.960743, -0.135210, 0.228001, 0.716767,
+ 0.964352, -0.135007, 0.222249, 0.744349, 0.967273, -0.133523, 0.215420, 0.771786,
+ 0.969767, -0.131155, 0.208039, 0.798639, 0.973195, -0.128492, 0.200076, 0.824774,
+ 0.975557, -0.125094, 0.191451, 0.850222, 0.977692, -0.120578, 0.181840, 0.874761,
+ 0.980260, -0.115882, 0.172102, 0.898497, 0.981394, -0.110372, 0.161859, 0.921636,
+ 0.982386, -0.104150, 0.151080, 0.943467, 0.983783, -0.097813, 0.140407, 0.964045,
+ 0.984220, -0.090617, 0.129058, 0.983980, 0.985447, -0.083292, 0.117614, 1.002760,
+ 0.986682, -0.075441, 0.105850, 1.020470, 0.987326, -0.067389, 0.094094, 1.036780,
+ 0.988707, -0.059256, 0.082209, 1.052180, 0.990185, -0.050717, 0.070192, 1.066520,
+ 0.991866, -0.042349, 0.058208, 1.079650, 0.993897, -0.033612, 0.046099, 1.091880,
+ 0.995841, -0.025218, 0.034274, 1.103070, 0.997605, -0.016489, 0.022483, 1.113240,
+ 0.999037, -0.008171, 0.011065, 1.122620, 1.000030, 0.000292, -0.000169, 1.131390,
+ 0.915304, -0.000006, 0.275999, 0.000018, 0.916680, -0.000139, 0.276414, 0.000462,
+ 0.916664, -0.000557, 0.276409, 0.001848, 0.916653, -0.001254, 0.276406, 0.004157,
+ 0.916651, -0.002229, 0.276405, 0.007391, 0.916655, -0.003482, 0.276406, 0.011548,
+ 0.916653, -0.005014, 0.276405, 0.016629, 0.916667, -0.006825, 0.276409, 0.022635,
+ 0.916680, -0.008914, 0.276412, 0.029565, 0.916690, -0.011282, 0.276413, 0.037420,
+ 0.916727, -0.013928, 0.276422, 0.046202, 0.916759, -0.016853, 0.276429, 0.055910,
+ 0.916793, -0.020056, 0.276436, 0.066547, 0.916849, -0.023537, 0.276448, 0.078114,
+ 0.916964, -0.027297, 0.276474, 0.090616, 0.917047, -0.031334, 0.276491, 0.104051,
+ 0.917152, -0.035646, 0.276511, 0.118424, 0.917286, -0.040227, 0.276533, 0.133736,
+ 0.917469, -0.045041, 0.276564, 0.149978, 0.917686, -0.049787, 0.276563, 0.167057,
+ 0.917953, -0.054094, 0.276493, 0.184846, 0.918228, -0.059071, 0.276437, 0.203614,
+ 0.918572, -0.064428, 0.276398, 0.223212, 0.918918, -0.070233, 0.276362, 0.243584,
+ 0.919356, -0.076484, 0.276383, 0.264465, 0.919842, -0.083081, 0.276434, 0.285701,
+ 0.920451, -0.089297, 0.276407, 0.307559, 0.921113, -0.095016, 0.276128, 0.331501,
+ 0.921881, -0.100771, 0.275754, 0.356207, 0.923027, -0.106029, 0.275254, 0.381477,
+ 0.924364, -0.111029, 0.274595, 0.407220, 0.925818, -0.116345, 0.273841, 0.433385,
+ 0.927460, -0.121424, 0.272913, 0.459848, 0.929167, -0.126570, 0.271837, 0.486493,
+ 0.931426, -0.131581, 0.270575, 0.513432, 0.934001, -0.135038, 0.268512, 0.541502,
+ 0.936296, -0.138039, 0.266135, 0.569658, 0.939985, -0.140687, 0.263271, 0.598375,
+ 0.943516, -0.143247, 0.260058, 0.626563, 0.947820, -0.145135, 0.256138, 0.654711,
+ 0.951023, -0.145733, 0.251154, 0.683285, 0.955338, -0.145554, 0.245562, 0.711831,
+ 0.959629, -0.145008, 0.239265, 0.739573, 0.963123, -0.144003, 0.232064, 0.767027,
+ 0.966742, -0.141289, 0.224036, 0.794359, 0.969991, -0.138247, 0.215305, 0.820361,
+ 0.973403, -0.134786, 0.206051, 0.846548, 0.975317, -0.129966, 0.195914, 0.871541,
+ 0.977647, -0.124710, 0.185184, 0.895313, 0.980137, -0.119086, 0.174161, 0.918398,
+ 0.981031, -0.112297, 0.162792, 0.940679, 0.982037, -0.105372, 0.150952, 0.961991,
+ 0.983164, -0.097821, 0.138921, 0.981913, 0.983757, -0.089724, 0.126611, 1.001090,
+ 0.985036, -0.081597, 0.114228, 1.019020, 0.986289, -0.072773, 0.101389, 1.036040,
+ 0.987329, -0.063932, 0.088648, 1.051490, 0.989193, -0.054811, 0.075684, 1.066190,
+ 0.990716, -0.045687, 0.062758, 1.079480, 0.992769, -0.036431, 0.049834, 1.091720,
+ 0.995240, -0.027176, 0.037031, 1.103300, 0.997154, -0.017961, 0.024396, 1.113530,
+ 0.998845, -0.008781, 0.011957, 1.123190, 1.000020, 0.000259, -0.000108, 1.131770,
+ 0.903945, -0.000006, 0.295126, 0.000018, 0.903668, -0.000149, 0.295037, 0.000455,
+ 0.903677, -0.000595, 0.295040, 0.001821, 0.903673, -0.001338, 0.295039, 0.004098,
+ 0.903666, -0.002379, 0.295036, 0.007286, 0.903668, -0.003717, 0.295037, 0.011384,
+ 0.903679, -0.005352, 0.295040, 0.016394, 0.903684, -0.007285, 0.295041, 0.022314,
+ 0.903698, -0.009515, 0.295044, 0.029146, 0.903718, -0.012042, 0.295049, 0.036890,
+ 0.903754, -0.014866, 0.295058, 0.045548, 0.903801, -0.017988, 0.295070, 0.055119,
+ 0.903851, -0.021406, 0.295082, 0.065606, 0.903921, -0.025122, 0.295097, 0.077011,
+ 0.904002, -0.029134, 0.295116, 0.089335, 0.904111, -0.033441, 0.295140, 0.102583,
+ 0.904246, -0.038041, 0.295169, 0.116755, 0.904408, -0.042926, 0.295202, 0.131853,
+ 0.904637, -0.048047, 0.295245, 0.147869, 0.904821, -0.052921, 0.295214, 0.164658,
+ 0.905163, -0.057775, 0.295185, 0.182274, 0.905469, -0.063176, 0.295143, 0.200828,
+ 0.905851, -0.068917, 0.295112, 0.220200, 0.906322, -0.075086, 0.295104, 0.240372,
+ 0.906761, -0.081586, 0.295086, 0.261082, 0.907350, -0.088214, 0.295095, 0.282123,
+ 0.908087, -0.095082, 0.295139, 0.303563, 0.908826, -0.101488, 0.294920, 0.327028,
+ 0.909832, -0.107577, 0.294577, 0.351464, 0.911393, -0.113033, 0.294115, 0.376497,
+ 0.912804, -0.118629, 0.293446, 0.402115, 0.914081, -0.124232, 0.292581, 0.428111,
+ 0.916370, -0.129399, 0.291660, 0.454442, 0.918140, -0.134892, 0.290422, 0.481024,
+ 0.921179, -0.140069, 0.289194, 0.507924, 0.924544, -0.144431, 0.287421, 0.535557,
+ 0.927995, -0.147498, 0.284867, 0.563984, 0.931556, -0.150197, 0.281722, 0.592300,
+ 0.935777, -0.152711, 0.278207, 0.620832, 0.940869, -0.154836, 0.274148, 0.649069,
+ 0.945994, -0.155912, 0.269057, 0.677746, 0.949634, -0.155641, 0.262799, 0.706293,
+ 0.955032, -0.154809, 0.256097, 0.734278, 0.959170, -0.153678, 0.248618, 0.761751,
+ 0.962931, -0.151253, 0.239794, 0.789032, 0.966045, -0.147625, 0.230281, 0.815422,
+ 0.969710, -0.143964, 0.220382, 0.841787, 0.972747, -0.139464, 0.209846, 0.867446,
+ 0.975545, -0.133459, 0.198189, 0.892004, 0.978381, -0.127424, 0.186362, 0.915458,
+ 0.979935, -0.120506, 0.173964, 0.937948, 0.980948, -0.112820, 0.161429, 0.959732,
+ 0.982234, -0.104941, 0.148557, 0.980118, 0.982767, -0.096291, 0.135508, 0.999463,
+ 0.983544, -0.087362, 0.122338, 1.017560, 0.984965, -0.078345, 0.108669, 1.034920,
+ 0.986233, -0.068480, 0.094991, 1.050870, 0.987796, -0.059087, 0.081139, 1.065600,
+ 0.989885, -0.048914, 0.067310, 1.079400, 0.991821, -0.039100, 0.053567, 1.091740,
+ 0.994480, -0.029087, 0.039753, 1.103410, 0.996769, -0.019114, 0.026146, 1.113830,
+ 0.998641, -0.009470, 0.012873, 1.123700, 0.999978, 0.000446, -0.000169, 1.132530,
+ 0.888362, -0.000006, 0.312578, 0.000018, 0.889988, -0.000158, 0.313148, 0.000448,
+ 0.889825, -0.000631, 0.313092, 0.001794, 0.889840, -0.001420, 0.313097, 0.004036,
+ 0.889828, -0.002524, 0.313092, 0.007174, 0.889831, -0.003944, 0.313093, 0.011210,
+ 0.889831, -0.005680, 0.313093, 0.016143, 0.889844, -0.007731, 0.313096, 0.021972,
+ 0.889858, -0.010097, 0.313100, 0.028700, 0.889882, -0.012779, 0.313106, 0.036326,
+ 0.889918, -0.015776, 0.313116, 0.044851, 0.889967, -0.019088, 0.313129, 0.054276,
+ 0.890030, -0.022715, 0.313145, 0.064603, 0.890108, -0.026657, 0.313165, 0.075834,
+ 0.890218, -0.030913, 0.313193, 0.087973, 0.890351, -0.035482, 0.313226, 0.101019,
+ 0.890510, -0.040361, 0.313263, 0.114979, 0.890672, -0.045539, 0.313294, 0.129848,
+ 0.890882, -0.050944, 0.313333, 0.145616, 0.891189, -0.055966, 0.313324, 0.162122,
+ 0.891457, -0.061312, 0.313281, 0.179524, 0.891856, -0.067149, 0.313281, 0.197855,
+ 0.892312, -0.073273, 0.313268, 0.216991, 0.892819, -0.079786, 0.313263, 0.236924,
+ 0.893369, -0.086527, 0.313247, 0.257433, 0.894045, -0.093159, 0.313205, 0.278215,
+ 0.894884, -0.100532, 0.313276, 0.299467, 0.895832, -0.107716, 0.313205, 0.322276,
+ 0.897043, -0.114099, 0.312873, 0.346420, 0.898515, -0.119941, 0.312331, 0.371187,
+ 0.900191, -0.126044, 0.311731, 0.396656, 0.901880, -0.131808, 0.310859, 0.422488,
+ 0.904359, -0.137289, 0.309857, 0.448744, 0.906923, -0.142991, 0.308714, 0.475239,
+ 0.910634, -0.148253, 0.307465, 0.501983, 0.914502, -0.153332, 0.305774, 0.529254,
+ 0.919046, -0.156646, 0.303156, 0.557709, 0.923194, -0.159612, 0.299928, 0.586267,
+ 0.928858, -0.162027, 0.296245, 0.614925, 0.934464, -0.164203, 0.291832, 0.643187,
+ 0.939824, -0.165602, 0.286565, 0.671601, 0.944582, -0.165383, 0.280073, 0.700213,
+ 0.949257, -0.164439, 0.272891, 0.728432, 0.954389, -0.162953, 0.264771, 0.756082,
+ 0.958595, -0.161007, 0.255927, 0.783690, 0.962138, -0.157243, 0.245769, 0.810769,
+ 0.966979, -0.152872, 0.235127, 0.836999, 0.969566, -0.148209, 0.223470, 0.862684,
+ 0.972372, -0.142211, 0.211147, 0.887847, 0.975916, -0.135458, 0.198606, 0.911843,
+ 0.978026, -0.128398, 0.185498, 0.934795, 0.979686, -0.120313, 0.171710, 0.956787,
+ 0.980748, -0.111660, 0.158159, 0.978046, 0.981622, -0.103035, 0.144399, 0.997693,
+ 0.982356, -0.093033, 0.130010, 1.016420, 0.983308, -0.083463, 0.115778, 1.033660,
+ 0.985037, -0.073225, 0.101327, 1.050140, 0.986493, -0.062814, 0.086554, 1.065070,
+ 0.988484, -0.052656, 0.072041, 1.079070, 0.991051, -0.041574, 0.057115, 1.091890,
+ 0.993523, -0.031427, 0.042664, 1.103690, 0.996280, -0.020360, 0.027932, 1.114230,
+ 0.998344, -0.010245, 0.013818, 1.124210, 0.999997, 0.000426, -0.000194, 1.133300,
+ 0.871555, -0.000007, 0.329176, 0.000017, 0.875255, -0.000167, 0.330571, 0.000441,
+ 0.875644, -0.000666, 0.330718, 0.001764, 0.875159, -0.001499, 0.330536, 0.003969,
+ 0.875160, -0.002665, 0.330536, 0.007056, 0.875158, -0.004164, 0.330535, 0.011025,
+ 0.875160, -0.005996, 0.330535, 0.015876, 0.875163, -0.008161, 0.330536, 0.021610,
+ 0.875174, -0.010659, 0.330538, 0.028227, 0.875199, -0.013490, 0.330545, 0.035727,
+ 0.875257, -0.016654, 0.330563, 0.044112, 0.875304, -0.020150, 0.330575, 0.053382,
+ 0.875373, -0.023978, 0.330595, 0.063539, 0.875464, -0.028139, 0.330619, 0.074587,
+ 0.875565, -0.032630, 0.330645, 0.086526, 0.875691, -0.037452, 0.330676, 0.099360,
+ 0.875897, -0.042599, 0.330733, 0.113093, 0.876091, -0.048058, 0.330776, 0.127722,
+ 0.876353, -0.053722, 0.330826, 0.143227, 0.876649, -0.058981, 0.330809, 0.159462,
+ 0.877034, -0.064786, 0.330819, 0.176642, 0.877443, -0.070979, 0.330817, 0.194702,
+ 0.877956, -0.077478, 0.330832, 0.213577, 0.878499, -0.084318, 0.330822, 0.233246,
+ 0.879144, -0.091271, 0.330804, 0.253512, 0.879982, -0.098082, 0.330766, 0.274137,
+ 0.880970, -0.105823, 0.330864, 0.295209, 0.882051, -0.113671, 0.330896, 0.317226,
+ 0.883397, -0.120303, 0.330545, 0.341068, 0.884987, -0.126670, 0.330068, 0.365613,
+ 0.886789, -0.133118, 0.329418, 0.390807, 0.889311, -0.139024, 0.328683, 0.416494,
+ 0.891995, -0.144971, 0.327729, 0.442618, 0.895106, -0.150747, 0.326521, 0.469131,
+ 0.899527, -0.156283, 0.325229, 0.495921, 0.905040, -0.161707, 0.323780, 0.523162,
+ 0.909875, -0.165661, 0.321220, 0.550920, 0.915610, -0.168755, 0.317942, 0.579928,
+ 0.921225, -0.171193, 0.313983, 0.608539, 0.927308, -0.173190, 0.309636, 0.636854,
+ 0.933077, -0.174819, 0.304262, 0.665230, 0.938766, -0.175002, 0.297563, 0.693609,
+ 0.943667, -0.173946, 0.289613, 0.722157, 0.949033, -0.172221, 0.281227, 0.750021,
+ 0.953765, -0.169869, 0.271545, 0.777466, 0.958040, -0.166578, 0.261034, 0.804853,
+ 0.962302, -0.161761, 0.249434, 0.831569, 0.966544, -0.156636, 0.237484, 0.857779,
+ 0.969372, -0.150784, 0.224395, 0.883051, 0.972486, -0.143672, 0.210786, 0.907864,
+ 0.975853, -0.135772, 0.196556, 0.931223, 0.977975, -0.127942, 0.182307, 0.954061,
+ 0.979122, -0.118347, 0.167607, 0.975310, 0.980719, -0.109112, 0.152739, 0.995666,
+ 0.981223, -0.099179, 0.137932, 1.014750, 0.982160, -0.088355, 0.122692, 1.032530,
+ 0.983379, -0.078082, 0.107493, 1.049170, 0.985434, -0.066565, 0.091779, 1.064640,
+ 0.987332, -0.055771, 0.076495, 1.078960, 0.990004, -0.044281, 0.060721, 1.091990,
+ 0.992975, -0.033168, 0.045228, 1.103930, 0.995811, -0.021955, 0.029793, 1.114760,
+ 0.998200, -0.010761, 0.014642, 1.124840, 1.000020, 0.000249, -0.000146, 1.134130,
+ 0.859519, -0.000007, 0.347264, 0.000017, 0.859843, -0.000175, 0.347394, 0.000433,
+ 0.859656, -0.000700, 0.347319, 0.001733, 0.859671, -0.001575, 0.347325, 0.003899,
+ 0.859669, -0.002800, 0.347324, 0.006931, 0.859670, -0.004375, 0.347324, 0.010830,
+ 0.859665, -0.006300, 0.347321, 0.015595, 0.859685, -0.008575, 0.347328, 0.021228,
+ 0.859694, -0.011200, 0.347329, 0.027727, 0.859718, -0.014175, 0.347336, 0.035095,
+ 0.859760, -0.017499, 0.347348, 0.043331, 0.859820, -0.021172, 0.347366, 0.052438,
+ 0.859892, -0.025194, 0.347387, 0.062417, 0.860006, -0.029565, 0.347422, 0.073271,
+ 0.860122, -0.034283, 0.347453, 0.085000, 0.860282, -0.039346, 0.347499, 0.097610,
+ 0.860482, -0.044751, 0.347554, 0.111104, 0.860719, -0.050478, 0.347614, 0.125479,
+ 0.860998, -0.056358, 0.347666, 0.140703, 0.861322, -0.061947, 0.347662, 0.156681,
+ 0.861724, -0.068128, 0.347684, 0.173597, 0.862198, -0.074657, 0.347709, 0.191371,
+ 0.862733, -0.081523, 0.347727, 0.209976, 0.863371, -0.088664, 0.347744, 0.229351,
+ 0.864140, -0.095791, 0.347734, 0.249340, 0.865138, -0.102912, 0.347720, 0.269797,
+ 0.866182, -0.110924, 0.347800, 0.290654, 0.867436, -0.119223, 0.347911, 0.312074,
+ 0.869087, -0.126197, 0.347649, 0.335438, 0.870859, -0.133145, 0.347222, 0.359732,
+ 0.872997, -0.139869, 0.346645, 0.384670, 0.875939, -0.146089, 0.345935, 0.410190,
+ 0.879012, -0.152334, 0.345012, 0.436218, 0.883353, -0.158210, 0.343924, 0.462641,
+ 0.888362, -0.164097, 0.342636, 0.489449, 0.895026, -0.169528, 0.341351, 0.516629,
+ 0.900753, -0.174408, 0.339115, 0.544109, 0.906814, -0.177510, 0.335809, 0.572857,
+ 0.912855, -0.180101, 0.331597, 0.601554, 0.919438, -0.182116, 0.326980, 0.630198,
+ 0.925962, -0.183494, 0.321449, 0.658404, 0.931734, -0.184159, 0.314595, 0.686625,
+ 0.937620, -0.183040, 0.306462, 0.715310, 0.943858, -0.181323, 0.297514, 0.744272,
+ 0.948662, -0.178683, 0.287447, 0.771462, 0.953299, -0.175379, 0.276166, 0.798593,
+ 0.957346, -0.170395, 0.263758, 0.825600, 0.962565, -0.165042, 0.251019, 0.852575,
+ 0.966075, -0.158655, 0.237011, 0.878316, 0.969048, -0.151707, 0.222518, 0.903290,
+ 0.972423, -0.143271, 0.207848, 0.927745, 0.975833, -0.134824, 0.192463, 0.950859,
+ 0.977629, -0.125444, 0.176800, 0.972947, 0.978995, -0.114949, 0.161033, 0.993263,
+ 0.980533, -0.104936, 0.145523, 1.013370, 0.980745, -0.093558, 0.129799, 1.031280,
+ 0.981814, -0.082296, 0.113486, 1.048250, 0.983943, -0.071008, 0.097293, 1.064050,
+ 0.986141, -0.058793, 0.080814, 1.078500, 0.988878, -0.047275, 0.064491, 1.092040,
+ 0.992132, -0.034913, 0.047813, 1.104130, 0.995300, -0.023241, 0.031621, 1.115270,
+ 0.998117, -0.011271, 0.015494, 1.125510, 1.000030, 0.000340, -0.000196, 1.135040,
+ 0.845441, -0.000007, 0.364305, 0.000017, 0.843588, -0.000183, 0.363506, 0.000425,
+ 0.843412, -0.000733, 0.363430, 0.001700, 0.843401, -0.001648, 0.363426, 0.003825,
+ 0.843399, -0.002930, 0.363425, 0.006800, 0.843401, -0.004578, 0.363425, 0.010625,
+ 0.843394, -0.006592, 0.363421, 0.015300, 0.843398, -0.008973, 0.363421, 0.020826,
+ 0.843415, -0.011719, 0.363426, 0.027202, 0.843438, -0.014831, 0.363432, 0.034431,
+ 0.843483, -0.018309, 0.363447, 0.042512, 0.843560, -0.022152, 0.363472, 0.051447,
+ 0.843646, -0.026360, 0.363499, 0.061238, 0.843743, -0.030932, 0.363527, 0.071887,
+ 0.843880, -0.035866, 0.363569, 0.083397, 0.844079, -0.041162, 0.363631, 0.095774,
+ 0.844279, -0.046813, 0.363688, 0.109015, 0.844549, -0.052792, 0.363761, 0.123124,
+ 0.844858, -0.058820, 0.363817, 0.138044, 0.845220, -0.064757, 0.363830, 0.153755,
+ 0.845669, -0.071318, 0.363879, 0.170394, 0.846155, -0.078170, 0.363908, 0.187861,
+ 0.846789, -0.085391, 0.363969, 0.206176, 0.847502, -0.092809, 0.363999, 0.225244,
+ 0.848400, -0.100050, 0.363997, 0.244926, 0.849461, -0.107615, 0.364008, 0.265188,
+ 0.850562, -0.115814, 0.364055, 0.285870, 0.851962, -0.124334, 0.364179, 0.306926,
+ 0.854326, -0.131995, 0.364233, 0.329605, 0.856295, -0.139338, 0.363856, 0.353590,
+ 0.858857, -0.146346, 0.363347, 0.378310, 0.862428, -0.152994, 0.362807, 0.403722,
+ 0.866203, -0.159463, 0.361963, 0.429537, 0.871629, -0.165623, 0.361120, 0.456000,
+ 0.877365, -0.171649, 0.359917, 0.482773, 0.883744, -0.177151, 0.358480, 0.509705,
+ 0.890693, -0.182381, 0.356523, 0.537215, 0.897278, -0.186076, 0.353300, 0.565493,
+ 0.903958, -0.188602, 0.349095, 0.594293, 0.910908, -0.190755, 0.344215, 0.623165,
+ 0.918117, -0.192063, 0.338606, 0.651573, 0.924644, -0.192758, 0.331544, 0.679869,
+ 0.931054, -0.192238, 0.323163, 0.708668, 0.937303, -0.190035, 0.313529, 0.737201,
+ 0.943387, -0.187162, 0.303152, 0.764977, 0.948494, -0.183876, 0.291460, 0.792683,
+ 0.952546, -0.178901, 0.277917, 0.819228, 0.958077, -0.173173, 0.264753, 0.846559,
+ 0.962462, -0.166450, 0.250020, 0.872962, 0.966569, -0.159452, 0.234873, 0.898729,
+ 0.969108, -0.150740, 0.218752, 0.923126, 0.973072, -0.141523, 0.202673, 0.947278,
+ 0.975452, -0.132075, 0.186326, 0.969938, 0.977784, -0.121257, 0.169396, 0.991325,
+ 0.978990, -0.110182, 0.153044, 1.011230, 0.979777, -0.098963, 0.136485, 1.029900,
+ 0.980865, -0.086589, 0.119343, 1.047270, 0.982432, -0.074611, 0.102452, 1.063410,
+ 0.984935, -0.062182, 0.085242, 1.078340, 0.987776, -0.049569, 0.067855, 1.092000,
+ 0.991030, -0.037239, 0.050692, 1.104300, 0.994740, -0.024435, 0.033332, 1.115760,
+ 0.997768, -0.012145, 0.016435, 1.126170, 1.000030, 0.000318, -0.000170, 1.135980,
+ 0.825551, -0.000008, 0.378425, 0.000017, 0.826640, -0.000191, 0.378923, 0.000417,
+ 0.826323, -0.000763, 0.378779, 0.001666, 0.826359, -0.001718, 0.378795, 0.003748,
+ 0.826360, -0.003054, 0.378795, 0.006663, 0.826368, -0.004772, 0.378798, 0.010410,
+ 0.826364, -0.006871, 0.378795, 0.014991, 0.826368, -0.009352, 0.378795, 0.020405,
+ 0.826376, -0.012215, 0.378797, 0.026653, 0.826399, -0.015458, 0.378803, 0.033736,
+ 0.826460, -0.019082, 0.378824, 0.041654, 0.826525, -0.023087, 0.378846, 0.050409,
+ 0.826614, -0.027472, 0.378876, 0.060003, 0.826740, -0.032236, 0.378917, 0.070439,
+ 0.826888, -0.037377, 0.378964, 0.081720, 0.827078, -0.042894, 0.379024, 0.093849,
+ 0.827318, -0.048778, 0.379099, 0.106828, 0.827640, -0.054994, 0.379199, 0.120659,
+ 0.827926, -0.061106, 0.379227, 0.135260, 0.828325, -0.067505, 0.379275, 0.150713,
+ 0.828801, -0.074345, 0.379332, 0.167034, 0.829400, -0.081552, 0.379415, 0.184209,
+ 0.830094, -0.089078, 0.379495, 0.202203, 0.830900, -0.096736, 0.379555, 0.220945,
+ 0.831943, -0.104135, 0.379577, 0.240306, 0.833037, -0.112106, 0.379604, 0.260317,
+ 0.834278, -0.120554, 0.379668, 0.280800, 0.836192, -0.129128, 0.379900, 0.301654,
+ 0.838671, -0.137541, 0.380109, 0.323502, 0.840939, -0.145230, 0.379809, 0.347176,
+ 0.844575, -0.152480, 0.379593, 0.371706, 0.848379, -0.159607, 0.379090, 0.396880,
+ 0.853616, -0.166267, 0.378617, 0.422702, 0.858921, -0.172698, 0.377746, 0.448919,
+ 0.865324, -0.178823, 0.376749, 0.475661, 0.872207, -0.184542, 0.375363, 0.502599,
+ 0.880018, -0.189836, 0.373657, 0.529914, 0.886940, -0.194294, 0.370673, 0.557683,
+ 0.894779, -0.197022, 0.366620, 0.586848, 0.902242, -0.199108, 0.361380, 0.615831,
+ 0.909914, -0.200398, 0.355434, 0.644478, 0.917088, -0.200940, 0.348173, 0.672905,
+ 0.923888, -0.200671, 0.339482, 0.701327, 0.930495, -0.198773, 0.329560, 0.730101,
+ 0.937247, -0.195394, 0.318363, 0.758383, 0.943108, -0.191956, 0.306323, 0.786539,
+ 0.948296, -0.187227, 0.292576, 0.813637, 0.953472, -0.181165, 0.278234, 0.840793,
+ 0.958485, -0.174119, 0.263054, 0.867712, 0.962714, -0.166564, 0.246756, 0.893635,
+ 0.966185, -0.158181, 0.229945, 0.919028, 0.970146, -0.148275, 0.212633, 0.943413,
+ 0.973491, -0.138157, 0.195229, 0.966627, 0.975741, -0.127574, 0.178048, 0.988817,
+ 0.977238, -0.115540, 0.160312, 1.009240, 0.978411, -0.103640, 0.142857, 1.028450,
+ 0.979811, -0.091312, 0.125317, 1.046480, 0.981160, -0.078256, 0.107627, 1.062840,
+ 0.983543, -0.065596, 0.089586, 1.077980, 0.986789, -0.052041, 0.071376, 1.092000,
+ 0.990292, -0.038973, 0.053228, 1.104840, 0.994187, -0.025808, 0.035194, 1.116420,
+ 0.997499, -0.012607, 0.017320, 1.127030, 0.999999, 0.000276, -0.000149, 1.136740,
+ 0.810750, -0.000008, 0.394456, 0.000016, 0.808692, -0.000198, 0.393453, 0.000408,
+ 0.808460, -0.000793, 0.393340, 0.001630, 0.808595, -0.001784, 0.393407, 0.003667,
+ 0.808597, -0.003172, 0.393408, 0.006519, 0.808598, -0.004956, 0.393408, 0.010187,
+ 0.808591, -0.007136, 0.393403, 0.014669, 0.808592, -0.009713, 0.393402, 0.019967,
+ 0.808610, -0.012686, 0.393407, 0.026080, 0.808633, -0.016054, 0.393413, 0.033011,
+ 0.808680, -0.019817, 0.393429, 0.040759, 0.808748, -0.023976, 0.393453, 0.049326,
+ 0.808854, -0.028529, 0.393490, 0.058716, 0.808992, -0.033475, 0.393540, 0.068930,
+ 0.809141, -0.038812, 0.393588, 0.079971, 0.809352, -0.044538, 0.393660, 0.091843,
+ 0.809608, -0.050643, 0.393742, 0.104549, 0.809915, -0.057071, 0.393834, 0.118085,
+ 0.810253, -0.063353, 0.393885, 0.132377, 0.810687, -0.070097, 0.393953, 0.147537,
+ 0.811233, -0.077227, 0.394047, 0.163543, 0.811865, -0.084763, 0.394148, 0.180394,
+ 0.812648, -0.092566, 0.394265, 0.198051, 0.813583, -0.100416, 0.394363, 0.216443,
+ 0.814683, -0.108119, 0.394402, 0.235502, 0.815948, -0.116440, 0.394489, 0.255242,
+ 0.817278, -0.125036, 0.394542, 0.275441, 0.819605, -0.133655, 0.394860, 0.296094,
+ 0.822256, -0.142682, 0.395248, 0.317309, 0.825349, -0.150756, 0.395241, 0.340516,
+ 0.829605, -0.158392, 0.395285, 0.364819, 0.833910, -0.165801, 0.394922, 0.389736,
+ 0.839808, -0.172677, 0.394691, 0.415409, 0.845708, -0.179448, 0.394006, 0.441546,
+ 0.853025, -0.185746, 0.393279, 0.468320, 0.859666, -0.191684, 0.391655, 0.495302,
+ 0.867890, -0.197146, 0.390068, 0.522620, 0.875845, -0.201904, 0.387270, 0.550336,
+ 0.882634, -0.205023, 0.382688, 0.578825, 0.891076, -0.207098, 0.377543, 0.608103,
+ 0.900589, -0.208474, 0.371752, 0.637230, 0.907910, -0.209068, 0.364016, 0.665769,
+ 0.915971, -0.208655, 0.355593, 0.694428, 0.923455, -0.207290, 0.345439, 0.723224,
+ 0.931514, -0.203821, 0.334099, 0.751925, 0.937885, -0.199860, 0.321069, 0.780249,
+ 0.943136, -0.194993, 0.306571, 0.807700, 0.948818, -0.189132, 0.291556, 0.834970,
+ 0.954433, -0.181617, 0.275745, 0.861880, 0.959078, -0.173595, 0.258695, 0.888562,
+ 0.962705, -0.164855, 0.240825, 0.914008, 0.966753, -0.155129, 0.222680, 0.939145,
+ 0.970704, -0.144241, 0.204542, 0.963393, 0.973367, -0.133188, 0.185927, 0.985983,
+ 0.975984, -0.121146, 0.167743, 1.007040, 0.976994, -0.108366, 0.149218, 1.027150,
+ 0.978485, -0.095675, 0.131310, 1.045500, 0.980074, -0.082073, 0.112513, 1.062210,
+ 0.982250, -0.068406, 0.093832, 1.077820, 0.985530, -0.054950, 0.074951, 1.091990,
+ 0.989529, -0.040786, 0.055848, 1.105080, 0.993536, -0.027198, 0.036858, 1.116840,
+ 0.997247, -0.013272, 0.018184, 1.127890, 1.000000, 0.000432, -0.000199, 1.137920,
+ 0.785886, -0.000008, 0.405036, 0.000016, 0.790388, -0.000205, 0.407355, 0.000398,
+ 0.790145, -0.000821, 0.407231, 0.001593, 0.790135, -0.001847, 0.407226, 0.003583,
+ 0.790119, -0.003283, 0.407218, 0.006370, 0.790126, -0.005130, 0.407220, 0.009954,
+ 0.790130, -0.007387, 0.407221, 0.014334, 0.790135, -0.010054, 0.407221, 0.019511,
+ 0.790134, -0.013131, 0.407217, 0.025485, 0.790160, -0.016617, 0.407224, 0.032257,
+ 0.790197, -0.020512, 0.407236, 0.039828, 0.790273, -0.024816, 0.407263, 0.048201,
+ 0.790381, -0.029527, 0.407304, 0.057378, 0.790521, -0.034645, 0.407355, 0.067360,
+ 0.790704, -0.040167, 0.407420, 0.078152, 0.790925, -0.046090, 0.407499, 0.089758,
+ 0.791195, -0.052402, 0.407589, 0.102180, 0.791522, -0.059012, 0.407691, 0.115410,
+ 0.791878, -0.065488, 0.407748, 0.129390, 0.792361, -0.072521, 0.407849, 0.144237,
+ 0.792942, -0.079984, 0.407963, 0.159924, 0.793620, -0.087790, 0.408087, 0.176425,
+ 0.794529, -0.095845, 0.408259, 0.193733, 0.795521, -0.103827, 0.408362, 0.211756,
+ 0.796778, -0.111937, 0.408482, 0.230524, 0.798027, -0.120521, 0.408547, 0.249967,
+ 0.799813, -0.129242, 0.408721, 0.269926, 0.802387, -0.138048, 0.409148, 0.290338,
+ 0.805279, -0.147301, 0.409641, 0.311193, 0.809251, -0.155895, 0.410154, 0.333611,
+ 0.813733, -0.163942, 0.410297, 0.357615, 0.819081, -0.171666, 0.410373, 0.382339,
+ 0.825427, -0.178905, 0.410348, 0.407828, 0.831720, -0.185812, 0.409486, 0.434034,
+ 0.838770, -0.192318, 0.408776, 0.460493, 0.845817, -0.198249, 0.407176, 0.487346,
+ 0.854664, -0.204034, 0.405719, 0.514832, 0.863495, -0.208908, 0.403282, 0.542401,
+ 0.871883, -0.212765, 0.399293, 0.570683, 0.880650, -0.214911, 0.393803, 0.599947,
+ 0.890040, -0.216214, 0.387536, 0.629320, 0.898476, -0.216745, 0.379846, 0.658319,
+ 0.906738, -0.216387, 0.370625, 0.687138, 0.914844, -0.215053, 0.360139, 0.716010,
+ 0.923877, -0.212007, 0.348849, 0.745124, 0.931925, -0.207481, 0.335639, 0.773366,
+ 0.938054, -0.202418, 0.320798, 0.801636, 0.943895, -0.196507, 0.304772, 0.829055,
+ 0.949468, -0.189009, 0.288033, 0.856097, 0.955152, -0.180539, 0.270532, 0.883010,
+ 0.959403, -0.171437, 0.251639, 0.909296, 0.963309, -0.161661, 0.232563, 0.934868,
+ 0.967399, -0.150425, 0.213231, 0.959662, 0.972009, -0.138659, 0.194247, 0.983020,
+ 0.974330, -0.126595, 0.174718, 1.005170, 0.975823, -0.113205, 0.155518, 1.025660,
+ 0.976371, -0.099610, 0.136709, 1.044180, 0.978705, -0.086075, 0.117571, 1.061460,
+ 0.981477, -0.071444, 0.098005, 1.077770, 0.984263, -0.057230, 0.078218, 1.092140,
+ 0.988423, -0.042888, 0.058405, 1.105530, 0.993000, -0.028244, 0.038522, 1.117580,
+ 0.997040, -0.014018, 0.019015, 1.128640, 0.999913, 0.000369, -0.000145, 1.139010,
+ 0.777662, -0.000008, 0.423844, 0.000015, 0.770458, -0.000212, 0.419915, 0.000388,
+ 0.770716, -0.000847, 0.420055, 0.001554, 0.770982, -0.001906, 0.420202, 0.003497,
+ 0.770981, -0.003388, 0.420201, 0.006216, 0.770980, -0.005293, 0.420200, 0.009713,
+ 0.770983, -0.007622, 0.420200, 0.013987, 0.770985, -0.010374, 0.420198, 0.019038,
+ 0.770996, -0.013549, 0.420200, 0.024868, 0.771029, -0.017146, 0.420212, 0.031476,
+ 0.771052, -0.021165, 0.420215, 0.038865, 0.771131, -0.025605, 0.420245, 0.047036,
+ 0.771235, -0.030465, 0.420284, 0.055991, 0.771383, -0.035744, 0.420341, 0.065735,
+ 0.771591, -0.041439, 0.420423, 0.076269, 0.771819, -0.047546, 0.420506, 0.087598,
+ 0.772123, -0.054051, 0.420617, 0.099727, 0.772464, -0.060797, 0.420720, 0.112637,
+ 0.772855, -0.067539, 0.420799, 0.126313, 0.773317, -0.074832, 0.420893, 0.140824,
+ 0.773981, -0.082568, 0.421058, 0.156170, 0.774746, -0.090631, 0.421226, 0.172322,
+ 0.775660, -0.098898, 0.421397, 0.189253, 0.776837, -0.106994, 0.421569, 0.206912,
+ 0.778097, -0.115528, 0.421704, 0.225359, 0.779588, -0.124317, 0.421849, 0.244470,
+ 0.781574, -0.133139, 0.422097, 0.264156, 0.784451, -0.142179, 0.422615, 0.284318,
+ 0.787682, -0.151650, 0.423269, 0.304902, 0.792433, -0.160771, 0.424396, 0.326500,
+ 0.797359, -0.169166, 0.424772, 0.350140, 0.803986, -0.177149, 0.425475, 0.374768,
+ 0.809504, -0.184745, 0.424996, 0.399928, 0.815885, -0.191730, 0.424247, 0.425796,
+ 0.823513, -0.198525, 0.423515, 0.452287, 0.832549, -0.204709, 0.422787, 0.479321,
+ 0.841653, -0.210447, 0.421187, 0.506718, 0.850401, -0.215501, 0.418519, 0.534320,
+ 0.859854, -0.219752, 0.414715, 0.562420, 0.869364, -0.222305, 0.409462, 0.591558,
+ 0.878837, -0.223744, 0.402926, 0.621074, 0.888636, -0.224065, 0.395043, 0.650538,
+ 0.898132, -0.223742, 0.385640, 0.679538, 0.907181, -0.222308, 0.375378, 0.708674,
+ 0.915621, -0.219837, 0.363212, 0.737714, 0.923900, -0.215233, 0.349313, 0.767014,
+ 0.931644, -0.209592, 0.334162, 0.795133, 0.938887, -0.203644, 0.317943, 0.823228,
+ 0.945282, -0.196349, 0.300581, 0.850822, 0.950758, -0.187420, 0.282195, 0.877594,
+ 0.956146, -0.177879, 0.262481, 0.904564, 0.960355, -0.167643, 0.242487, 0.930741,
+ 0.965256, -0.156671, 0.222668, 0.955868, 0.968029, -0.144123, 0.201907, 0.979869,
+ 0.972510, -0.131305, 0.182020, 1.002910, 0.974925, -0.118335, 0.161909, 1.023920,
+ 0.975402, -0.103714, 0.142129, 1.043300, 0.976987, -0.089415, 0.122447, 1.060890,
+ 0.979677, -0.074886, 0.102248, 1.077130, 0.983184, -0.059609, 0.081485, 1.092180,
+ 0.987466, -0.044767, 0.060948, 1.105850, 0.992348, -0.029522, 0.040183, 1.118290,
+ 0.996674, -0.014392, 0.019816, 1.129660, 1.000030, 0.000321, -0.000150, 1.140200,
+ 0.757901, -0.000009, 0.436176, 0.000015, 0.751195, -0.000218, 0.432317, 0.000379,
+ 0.751178, -0.000871, 0.432307, 0.001514, 0.751195, -0.001961, 0.432317, 0.003407,
+ 0.751198, -0.003486, 0.432318, 0.006057, 0.751195, -0.005446, 0.432315, 0.009464,
+ 0.751207, -0.007842, 0.432320, 0.013628, 0.751213, -0.010673, 0.432320, 0.018550,
+ 0.751221, -0.013939, 0.432319, 0.024230, 0.751244, -0.017640, 0.432325, 0.030669,
+ 0.751300, -0.021774, 0.432348, 0.037870, 0.751358, -0.026341, 0.432367, 0.045832,
+ 0.751458, -0.031340, 0.432404, 0.054559, 0.751608, -0.036768, 0.432464, 0.064054,
+ 0.751800, -0.042625, 0.432540, 0.074322, 0.752065, -0.048903, 0.432645, 0.085367,
+ 0.752376, -0.055583, 0.432762, 0.097191, 0.752715, -0.062386, 0.432859, 0.109768,
+ 0.753137, -0.069415, 0.432958, 0.123126, 0.753676, -0.077004, 0.433099, 0.137308,
+ 0.754345, -0.084971, 0.433272, 0.152290, 0.755235, -0.093268, 0.433504, 0.168075,
+ 0.756186, -0.101710, 0.433693, 0.184625, 0.757363, -0.110019, 0.433857, 0.201897,
+ 0.758840, -0.118870, 0.434102, 0.220014, 0.760467, -0.127881, 0.434306, 0.238778,
+ 0.762969, -0.136766, 0.434751, 0.258172, 0.765823, -0.146120, 0.435290, 0.278062,
+ 0.769676, -0.155660, 0.436236, 0.298437, 0.774909, -0.165177, 0.437754, 0.319532,
+ 0.779940, -0.174020, 0.438343, 0.342505, 0.785757, -0.182201, 0.438609, 0.366693,
+ 0.792487, -0.190104, 0.438762, 0.391668, 0.800380, -0.197438, 0.438795, 0.417494,
+ 0.808494, -0.204365, 0.438226, 0.443933, 0.817695, -0.210714, 0.437283, 0.470929,
+ 0.828111, -0.216651, 0.436087, 0.498569, 0.837901, -0.221804, 0.433717, 0.526165,
+ 0.847813, -0.226318, 0.430133, 0.554155, 0.858314, -0.229297, 0.425213, 0.582822,
+ 0.868891, -0.230999, 0.418576, 0.612847, 0.878941, -0.231155, 0.410405, 0.642445,
+ 0.888809, -0.230935, 0.400544, 0.672024, 0.898089, -0.229343, 0.389613, 0.701366,
+ 0.908081, -0.226886, 0.377197, 0.730763, 0.916819, -0.222676, 0.363397, 0.759642,
+ 0.924968, -0.216835, 0.347437, 0.788775, 0.932906, -0.210245, 0.329950, 0.817135,
+ 0.940025, -0.202992, 0.312262, 0.844912, 0.946101, -0.194360, 0.293313, 0.872164,
+ 0.952835, -0.184125, 0.273638, 0.899443, 0.957347, -0.173657, 0.252385, 0.926389,
+ 0.961434, -0.162204, 0.231038, 0.951947, 0.965522, -0.149790, 0.209834, 0.976751,
+ 0.969412, -0.136307, 0.188821, 1.000220, 0.973902, -0.122527, 0.168013, 1.022290,
+ 0.974045, -0.108213, 0.147634, 1.041990, 0.975775, -0.092740, 0.127050, 1.060190,
+ 0.978383, -0.077821, 0.106309, 1.077110, 0.982110, -0.062122, 0.084928, 1.092450,
+ 0.986517, -0.046385, 0.063352, 1.106510, 0.991696, -0.030935, 0.041970, 1.119030,
+ 0.996349, -0.015091, 0.020627, 1.130730, 1.000030, 0.000442, -0.000231, 1.141460,
+ 0.727498, -0.000009, 0.441528, 0.000015, 0.730897, -0.000224, 0.443589, 0.000368,
+ 0.730796, -0.000894, 0.443528, 0.001473, 0.730805, -0.002011, 0.443533, 0.003314,
+ 0.730814, -0.003576, 0.443538, 0.005892, 0.730815, -0.005587, 0.443538, 0.009207,
+ 0.730822, -0.008045, 0.443540, 0.013258, 0.730836, -0.010950, 0.443545, 0.018047,
+ 0.730848, -0.014301, 0.443546, 0.023573, 0.730871, -0.018097, 0.443552, 0.029838,
+ 0.730915, -0.022338, 0.443567, 0.036844, 0.730982, -0.027023, 0.443591, 0.044591,
+ 0.731076, -0.032149, 0.443627, 0.053083, 0.731245, -0.037717, 0.443699, 0.062324,
+ 0.731440, -0.043722, 0.443777, 0.072318, 0.731700, -0.050158, 0.443881, 0.083069,
+ 0.732034, -0.056994, 0.444014, 0.094581, 0.732388, -0.063876, 0.444113, 0.106825,
+ 0.732853, -0.071203, 0.444247, 0.119859, 0.733473, -0.079008, 0.444442, 0.133690,
+ 0.734195, -0.087194, 0.444645, 0.148304, 0.735069, -0.095696, 0.444877, 0.163702,
+ 0.736169, -0.104260, 0.445133, 0.179861, 0.737470, -0.112853, 0.445370, 0.196778,
+ 0.738991, -0.121990, 0.445651, 0.214496, 0.740865, -0.131153, 0.445958, 0.232913,
+ 0.743637, -0.140245, 0.446548, 0.251977, 0.746797, -0.149722, 0.447246, 0.271551,
+ 0.751517, -0.159341, 0.448656, 0.291774, 0.756156, -0.169106, 0.449866, 0.312455,
+ 0.761519, -0.178436, 0.450919, 0.334552, 0.768295, -0.186904, 0.451776, 0.358491,
+ 0.776613, -0.195117, 0.452832, 0.383446, 0.783966, -0.202695, 0.452490, 0.408945,
+ 0.793542, -0.209850, 0.452587, 0.435364, 0.803192, -0.216403, 0.451852, 0.462336,
+ 0.813892, -0.222510, 0.450708, 0.489870, 0.824968, -0.227676, 0.448600, 0.517697,
+ 0.835859, -0.232443, 0.445156, 0.545975, 0.846825, -0.235775, 0.440351, 0.574483,
+ 0.858085, -0.237897, 0.433641, 0.604246, 0.868825, -0.238074, 0.425354, 0.634101,
+ 0.879638, -0.237661, 0.415383, 0.664201, 0.889966, -0.236186, 0.404136, 0.693918,
+ 0.899479, -0.233599, 0.390917, 0.723481, 0.908769, -0.229737, 0.376352, 0.752580,
+ 0.917966, -0.223836, 0.360372, 0.781764, 0.926304, -0.217067, 0.342551, 0.811139,
+ 0.934626, -0.209309, 0.324238, 0.839585, 0.941841, -0.200710, 0.304484, 0.867044,
+ 0.947890, -0.190602, 0.283607, 0.894579, 0.954196, -0.179253, 0.262205, 0.921743,
+ 0.958383, -0.167646, 0.239847, 0.948026, 0.963119, -0.155073, 0.218078, 0.973296,
+ 0.966941, -0.141426, 0.195899, 0.998135, 0.970836, -0.126849, 0.174121, 1.020210,
+ 0.973301, -0.112296, 0.153052, 1.040850, 0.974480, -0.096496, 0.131733, 1.059460,
+ 0.977045, -0.080489, 0.109970, 1.076930, 0.980751, -0.064844, 0.088166, 1.092540,
+ 0.985475, -0.048194, 0.065799, 1.106970, 0.991089, -0.031919, 0.043521, 1.120040,
+ 0.996122, -0.015809, 0.021478, 1.131730, 1.000010, 0.000372, -0.000200, 1.142910,
+ 0.708622, -0.000009, 0.453040, 0.000014, 0.711162, -0.000229, 0.454662, 0.000358,
+ 0.709812, -0.000914, 0.453797, 0.001430, 0.709865, -0.002058, 0.453834, 0.003219,
+ 0.709864, -0.003659, 0.453833, 0.005723, 0.709855, -0.005717, 0.453826, 0.008943,
+ 0.709862, -0.008232, 0.453828, 0.012878, 0.709875, -0.011204, 0.453832, 0.017529,
+ 0.709896, -0.014632, 0.453839, 0.022898, 0.709925, -0.018516, 0.453847, 0.028984,
+ 0.709974, -0.022855, 0.453866, 0.035789, 0.710045, -0.027647, 0.453892, 0.043316,
+ 0.710133, -0.032891, 0.453924, 0.051567, 0.710292, -0.038585, 0.453992, 0.060546,
+ 0.710485, -0.044725, 0.454070, 0.070257, 0.710769, -0.051305, 0.454192, 0.080708,
+ 0.711106, -0.058273, 0.454329, 0.091896, 0.711516, -0.065287, 0.454460, 0.103814,
+ 0.712071, -0.072843, 0.454653, 0.116508, 0.712676, -0.080831, 0.454840, 0.129968,
+ 0.713476, -0.089222, 0.455096, 0.144206, 0.714377, -0.097905, 0.455346, 0.159212,
+ 0.715579, -0.106531, 0.455647, 0.174973, 0.716977, -0.115492, 0.455961, 0.191504,
+ 0.718620, -0.124821, 0.456315, 0.208835, 0.720840, -0.134079, 0.456800, 0.226869,
+ 0.723786, -0.143427, 0.457521, 0.245582, 0.727464, -0.153061, 0.458475, 0.264957,
+ 0.732771, -0.162768, 0.460239, 0.284948, 0.736515, -0.172627, 0.460899, 0.305220,
+ 0.743519, -0.182487, 0.463225, 0.326717, 0.750041, -0.191295, 0.464027, 0.350113,
+ 0.758589, -0.199746, 0.465227, 0.374782, 0.767703, -0.207584, 0.465877, 0.400226,
+ 0.777484, -0.214973, 0.465996, 0.426442, 0.788792, -0.221796, 0.466019, 0.453688,
+ 0.800194, -0.228038, 0.465083, 0.481246, 0.811234, -0.233346, 0.462506, 0.509086,
+ 0.822859, -0.238073, 0.459257, 0.537338, 0.835082, -0.241764, 0.454863, 0.566108,
+ 0.846332, -0.244241, 0.448163, 0.595126, 0.858355, -0.244736, 0.439709, 0.625574,
+ 0.870340, -0.244278, 0.429837, 0.656170, 0.881027, -0.242550, 0.418002, 0.686029,
+ 0.891007, -0.239912, 0.404325, 0.716039, 0.900874, -0.236133, 0.389222, 0.745518,
+ 0.911072, -0.230672, 0.373269, 0.775026, 0.920359, -0.223560, 0.355083, 0.804521,
+ 0.928604, -0.215591, 0.335533, 0.834045, 0.937175, -0.206503, 0.315278, 0.861612,
+ 0.942825, -0.196684, 0.293653, 0.889131, 0.949805, -0.185116, 0.271503, 0.916853,
+ 0.955535, -0.172703, 0.248821, 0.943541, 0.959843, -0.159978, 0.225591, 0.970132,
+ 0.964393, -0.146375, 0.202719, 0.994709, 0.968008, -0.131269, 0.179928, 1.018600,
+ 0.971013, -0.115690, 0.158007, 1.039280, 0.973334, -0.100300, 0.136240, 1.058870,
+ 0.975775, -0.083335, 0.113800, 1.076520, 0.979579, -0.066898, 0.091314, 1.092970,
+ 0.984323, -0.050090, 0.068305, 1.107340, 0.990351, -0.033238, 0.045177, 1.120840,
+ 0.995823, -0.016149, 0.022170, 1.132960, 1.000100, 0.000234, -0.000109, 1.144410,
+ 0.683895, -0.000009, 0.460150, 0.000014, 0.688330, -0.000233, 0.463134, 0.000347,
+ 0.688368, -0.000934, 0.463159, 0.001387, 0.688367, -0.002100, 0.463159, 0.003122,
+ 0.688369, -0.003734, 0.463159, 0.005550, 0.688377, -0.005834, 0.463163, 0.008672,
+ 0.688386, -0.008401, 0.463166, 0.012488, 0.688398, -0.011434, 0.463169, 0.016999,
+ 0.688418, -0.014933, 0.463175, 0.022205, 0.688453, -0.018896, 0.463188, 0.028108,
+ 0.688515, -0.023324, 0.463214, 0.034709, 0.688570, -0.028214, 0.463231, 0.042009,
+ 0.688679, -0.033564, 0.463276, 0.050013, 0.688854, -0.039373, 0.463356, 0.058725,
+ 0.689038, -0.045635, 0.463430, 0.068148, 0.689321, -0.052343, 0.463553, 0.078290,
+ 0.689662, -0.059412, 0.463693, 0.089150, 0.690188, -0.066574, 0.463900, 0.100735,
+ 0.690755, -0.074311, 0.464107, 0.113074, 0.691405, -0.082472, 0.464329, 0.126161,
+ 0.692198, -0.091048, 0.464585, 0.140007, 0.693196, -0.099878, 0.464893, 0.154612,
+ 0.694540, -0.108651, 0.465285, 0.169984, 0.695921, -0.117855, 0.465596, 0.186106,
+ 0.697749, -0.127340, 0.466056, 0.203034, 0.700375, -0.136714, 0.466771, 0.220703,
+ 0.703395, -0.146386, 0.467579, 0.239062, 0.707904, -0.156096, 0.469067, 0.258188,
+ 0.711673, -0.165904, 0.469851, 0.277759, 0.717489, -0.175812, 0.471815, 0.297935,
+ 0.724051, -0.185931, 0.473890, 0.318916, 0.731965, -0.195238, 0.475870, 0.341591,
+ 0.741151, -0.204021, 0.477523, 0.366062, 0.751416, -0.212113, 0.478881, 0.391396,
+ 0.761848, -0.219790, 0.479226, 0.417599, 0.771886, -0.226700, 0.478495, 0.444401,
+ 0.783998, -0.232991, 0.477622, 0.472084, 0.796523, -0.238645, 0.475833, 0.500193,
+ 0.808851, -0.243396, 0.472568, 0.528650, 0.821191, -0.247226, 0.467857, 0.557362,
+ 0.834261, -0.250102, 0.461871, 0.586768, 0.846762, -0.251056, 0.453543, 0.617085,
+ 0.859867, -0.250604, 0.443494, 0.647659, 0.871948, -0.248783, 0.431711, 0.678119,
+ 0.882967, -0.245855, 0.417911, 0.708399, 0.892826, -0.242168, 0.401993, 0.738256,
+ 0.903320, -0.237062, 0.385371, 0.767999, 0.913633, -0.229970, 0.366837, 0.798191,
+ 0.922774, -0.221687, 0.346372, 0.827756, 0.931371, -0.212345, 0.325682, 0.856425,
+ 0.938929, -0.202060, 0.303665, 0.884299, 0.944821, -0.190981, 0.280786, 0.912023,
+ 0.951792, -0.178065, 0.257300, 0.939669, 0.957712, -0.164634, 0.233448, 0.966550,
+ 0.961912, -0.150863, 0.209504, 0.992366, 0.966382, -0.135770, 0.185970, 1.016330,
+ 0.969588, -0.119593, 0.162905, 1.038430, 0.971777, -0.103203, 0.140530, 1.058410,
+ 0.974330, -0.086589, 0.117909, 1.076320, 0.978686, -0.069083, 0.094410, 1.093260,
+ 0.983281, -0.051657, 0.070567, 1.107960, 0.989562, -0.034558, 0.046859, 1.121820,
+ 0.995465, -0.016781, 0.022985, 1.134200, 0.999991, 0.000373, -0.000236, 1.145900,
+ 0.662251, -0.000009, 0.468575, 0.000013, 0.666634, -0.000238, 0.471675, 0.000336,
+ 0.666411, -0.000950, 0.471516, 0.001343, 0.666399, -0.002138, 0.471509, 0.003022,
+ 0.666386, -0.003801, 0.471499, 0.005373, 0.666405, -0.005940, 0.471511, 0.008395,
+ 0.666406, -0.008553, 0.471508, 0.012090, 0.666428, -0.011640, 0.471519, 0.016457,
+ 0.666444, -0.015201, 0.471522, 0.021497, 0.666490, -0.019236, 0.471543, 0.027212,
+ 0.666537, -0.023743, 0.471558, 0.033603, 0.666617, -0.028720, 0.471591, 0.040673,
+ 0.666718, -0.034165, 0.471631, 0.048424, 0.666889, -0.040076, 0.471710, 0.056862,
+ 0.667104, -0.046448, 0.471805, 0.065991, 0.667374, -0.053268, 0.471923, 0.075818,
+ 0.667772, -0.060380, 0.472098, 0.086343, 0.668371, -0.067739, 0.472363, 0.097592,
+ 0.668971, -0.075603, 0.472596, 0.109567, 0.669696, -0.083929, 0.472869, 0.122272,
+ 0.670481, -0.092668, 0.473126, 0.135718, 0.671500, -0.101600, 0.473442, 0.149914,
+ 0.672911, -0.110566, 0.473890, 0.164882, 0.674512, -0.119984, 0.474354, 0.180602,
+ 0.676510, -0.129574, 0.474922, 0.197110, 0.679292, -0.139106, 0.475764, 0.214371,
+ 0.682798, -0.148993, 0.476886, 0.232405, 0.686955, -0.158737, 0.478179, 0.251153,
+ 0.691406, -0.168754, 0.479432, 0.270436, 0.697438, -0.178703, 0.481481, 0.290374,
+ 0.704761, -0.188955, 0.484143, 0.311044, 0.713599, -0.198814, 0.487007, 0.333003,
+ 0.723194, -0.207869, 0.488962, 0.357144, 0.732601, -0.216189, 0.489815, 0.382169,
+ 0.744193, -0.223980, 0.490888, 0.408227, 0.754907, -0.231156, 0.490355, 0.434928,
+ 0.767403, -0.237470, 0.489548, 0.462599, 0.781070, -0.243503, 0.488274, 0.490908,
+ 0.793893, -0.248114, 0.484843, 0.519421, 0.807296, -0.252220, 0.480300, 0.548561,
+ 0.820529, -0.255265, 0.474097, 0.577772, 0.833716, -0.256741, 0.466041, 0.607782,
+ 0.848403, -0.256370, 0.456547, 0.638807, 0.860755, -0.254804, 0.443946, 0.670058,
+ 0.874012, -0.251834, 0.430852, 0.700749, 0.885619, -0.247867, 0.414903, 0.731446,
+ 0.896069, -0.242634, 0.397276, 0.761191, 0.906266, -0.236093, 0.378535, 0.791053,
+ 0.916759, -0.227543, 0.358038, 0.821298, 0.925230, -0.217830, 0.335705, 0.850747,
+ 0.934360, -0.207534, 0.313797, 0.879258, 0.941631, -0.195983, 0.289671, 0.907734,
+ 0.947564, -0.183567, 0.265319, 0.935206, 0.953681, -0.169345, 0.240815, 0.962739,
+ 0.960008, -0.154909, 0.216119, 0.989227, 0.964145, -0.140161, 0.192096, 1.014650,
+ 0.968171, -0.123411, 0.167855, 1.037370, 0.969859, -0.106525, 0.144817, 1.057670,
+ 0.972666, -0.089102, 0.121490, 1.076100, 0.977055, -0.071809, 0.097531, 1.093360,
+ 0.982527, -0.053421, 0.073022, 1.108780, 0.989001, -0.035558, 0.048337, 1.122850,
+ 0.995120, -0.017638, 0.023938, 1.135480, 1.000070, 0.000369, -0.000212, 1.147440,
+ 0.651047, -0.000010, 0.484101, 0.000013, 0.644145, -0.000241, 0.478968, 0.000325,
+ 0.643960, -0.000965, 0.478831, 0.001298, 0.643960, -0.002172, 0.478830, 0.002920,
+ 0.643968, -0.003860, 0.478835, 0.005192, 0.643974, -0.006032, 0.478838, 0.008113,
+ 0.643977, -0.008685, 0.478836, 0.011683, 0.643982, -0.011821, 0.478834, 0.015903,
+ 0.644024, -0.015437, 0.478856, 0.020774, 0.644059, -0.019534, 0.478868, 0.026298,
+ 0.644122, -0.024110, 0.478896, 0.032475, 0.644207, -0.029164, 0.478933, 0.039309,
+ 0.644320, -0.034692, 0.478981, 0.046803, 0.644481, -0.040692, 0.479053, 0.054961,
+ 0.644722, -0.047159, 0.479169, 0.063791, 0.645013, -0.054075, 0.479302, 0.073297,
+ 0.645503, -0.061200, 0.479541, 0.083490, 0.646117, -0.068730, 0.479829, 0.094387,
+ 0.646707, -0.076785, 0.480061, 0.105991, 0.647431, -0.085247, 0.480343, 0.118310,
+ 0.648310, -0.094072, 0.480660, 0.131348, 0.649486, -0.103056, 0.481083, 0.145140,
+ 0.650864, -0.112261, 0.481528, 0.159676, 0.652604, -0.121852, 0.482102, 0.174979,
+ 0.654825, -0.131505, 0.482813, 0.191079, 0.657876, -0.141189, 0.483876, 0.207927,
+ 0.661339, -0.151239, 0.484990, 0.225586, 0.665463, -0.161091, 0.486279, 0.243947,
+ 0.670542, -0.171235, 0.487968, 0.262957, 0.677361, -0.181347, 0.490530, 0.282781,
+ 0.685672, -0.191679, 0.493862, 0.303311, 0.694551, -0.201781, 0.496990, 0.324607,
+ 0.703753, -0.211164, 0.498884, 0.347916, 0.713703, -0.219675, 0.500086, 0.372628,
+ 0.725911, -0.227836, 0.501554, 0.398694, 0.738620, -0.235330, 0.502193, 0.425529,
+ 0.752118, -0.241786, 0.501811, 0.453209, 0.765790, -0.247865, 0.500185, 0.481381,
+ 0.779568, -0.252696, 0.497159, 0.510110, 0.793991, -0.256802, 0.492765, 0.539322,
+ 0.808182, -0.259942, 0.486827, 0.569078, 0.821698, -0.261703, 0.478386, 0.598818,
+ 0.836009, -0.262006, 0.468772, 0.629762, 0.849824, -0.260333, 0.456352, 0.661366,
+ 0.863888, -0.257398, 0.442533, 0.692950, 0.876585, -0.253264, 0.426573, 0.723608,
+ 0.888665, -0.248026, 0.408964, 0.754378, 0.899537, -0.241487, 0.389677, 0.784761,
+ 0.909400, -0.233463, 0.368516, 0.814688, 0.920166, -0.223397, 0.346624, 0.845009,
+ 0.928899, -0.212550, 0.322717, 0.874431, 0.937156, -0.200869, 0.298698, 0.902922,
+ 0.943861, -0.188387, 0.273491, 0.931356, 0.949557, -0.174341, 0.247866, 0.958854,
+ 0.955862, -0.158994, 0.222496, 0.986098, 0.961721, -0.143664, 0.197522, 1.012290,
+ 0.965976, -0.127412, 0.173020, 1.035710, 0.968652, -0.109798, 0.148954, 1.056990,
+ 0.971084, -0.091679, 0.125044, 1.075870, 0.975584, -0.073963, 0.100577, 1.093720,
+ 0.981220, -0.055322, 0.075367, 1.109480, 0.988253, -0.036682, 0.049890, 1.123940,
+ 0.994820, -0.018039, 0.024611, 1.136940, 1.000010, 0.000230, -0.000188, 1.149190,
+ 0.613867, -0.000010, 0.479449, 0.000012, 0.621485, -0.000245, 0.485399, 0.000313,
+ 0.621429, -0.000978, 0.485353, 0.001252, 0.621120, -0.002200, 0.485114, 0.002817,
+ 0.621119, -0.003911, 0.485112, 0.005008, 0.621122, -0.006111, 0.485112, 0.007825,
+ 0.621133, -0.008799, 0.485117, 0.011269, 0.621152, -0.011976, 0.485125, 0.015339,
+ 0.621183, -0.015640, 0.485139, 0.020038, 0.621227, -0.019790, 0.485158, 0.025366,
+ 0.621298, -0.024425, 0.485192, 0.031326, 0.621388, -0.029544, 0.485233, 0.037920,
+ 0.621507, -0.035143, 0.485286, 0.045152, 0.621693, -0.041220, 0.485378, 0.053028,
+ 0.621933, -0.047767, 0.485495, 0.061552, 0.622232, -0.054757, 0.485635, 0.070732,
+ 0.622809, -0.061942, 0.485943, 0.080588, 0.623407, -0.069625, 0.486232, 0.091127,
+ 0.624060, -0.077796, 0.486516, 0.102354, 0.624835, -0.086373, 0.486838, 0.114279,
+ 0.625758, -0.095251, 0.487188, 0.126902, 0.627043, -0.104299, 0.487695, 0.140285,
+ 0.628438, -0.113724, 0.488163, 0.154397, 0.630325, -0.123417, 0.488858, 0.169267,
+ 0.632801, -0.133137, 0.489754, 0.184941, 0.635784, -0.143052, 0.490815, 0.201360,
+ 0.639406, -0.153132, 0.492048, 0.218643, 0.643872, -0.163143, 0.493630, 0.236615,
+ 0.649900, -0.173330, 0.496009, 0.255449, 0.657201, -0.183622, 0.498994, 0.275006,
+ 0.666221, -0.194019, 0.502888, 0.295354, 0.674419, -0.204192, 0.505459, 0.316244,
+ 0.683729, -0.214060, 0.507771, 0.338490, 0.695584, -0.222854, 0.510245, 0.363166,
+ 0.708583, -0.231315, 0.512293, 0.389071, 0.721233, -0.238911, 0.512747, 0.415737,
+ 0.735134, -0.245657, 0.512482, 0.443331, 0.750179, -0.251879, 0.511526, 0.471891,
+ 0.765073, -0.256911, 0.508935, 0.500892, 0.779794, -0.261144, 0.504341, 0.530294,
+ 0.794801, -0.264316, 0.498515, 0.560144, 0.810339, -0.266276, 0.491015, 0.590213,
+ 0.824818, -0.266981, 0.481126, 0.620865, 0.839375, -0.265778, 0.468685, 0.652687,
+ 0.853043, -0.262748, 0.453925, 0.684759, 0.867335, -0.258474, 0.437912, 0.716209,
+ 0.880370, -0.253187, 0.419648, 0.747508, 0.891711, -0.246476, 0.399820, 0.777970,
+ 0.902896, -0.238735, 0.378790, 0.808586, 0.913601, -0.228850, 0.355891, 0.838843,
+ 0.923019, -0.217656, 0.331773, 0.869014, 0.933432, -0.205539, 0.307356, 0.898512,
+ 0.939691, -0.192595, 0.281321, 0.926900, 0.946938, -0.178945, 0.255441, 0.955297,
+ 0.952372, -0.163587, 0.229013, 0.983231, 0.959090, -0.147214, 0.203179, 1.009710,
+ 0.963675, -0.130640, 0.177920, 1.034380, 0.968247, -0.113121, 0.152898, 1.056250,
+ 0.970010, -0.094582, 0.128712, 1.075980, 0.974458, -0.075565, 0.103349, 1.094000,
+ 0.980168, -0.057200, 0.077673, 1.110400, 0.987295, -0.037799, 0.051444, 1.124910,
+ 0.994432, -0.018642, 0.025429, 1.138510, 0.999975, 0.000543, -0.000282, 1.151080,
+ 0.592656, -0.000010, 0.486018, 0.000012, 0.598467, -0.000247, 0.490781, 0.000302,
+ 0.597934, -0.000988, 0.490343, 0.001205, 0.597903, -0.002224, 0.490319, 0.002712,
+ 0.597913, -0.003953, 0.490327, 0.004821, 0.597919, -0.006177, 0.490329, 0.007533,
+ 0.597936, -0.008894, 0.490339, 0.010848, 0.597956, -0.012104, 0.490347, 0.014767,
+ 0.597992, -0.015807, 0.490365, 0.019290, 0.598032, -0.020002, 0.490382, 0.024420,
+ 0.598109, -0.024687, 0.490420, 0.030159, 0.598215, -0.029859, 0.490474, 0.036510,
+ 0.598330, -0.035517, 0.490524, 0.043476, 0.598525, -0.041656, 0.490624, 0.051063,
+ 0.598778, -0.048269, 0.490753, 0.059278, 0.599135, -0.055311, 0.490940, 0.068130,
+ 0.599802, -0.062542, 0.491328, 0.077647, 0.600361, -0.070364, 0.491598, 0.087818,
+ 0.601010, -0.078626, 0.491882, 0.098657, 0.601811, -0.087296, 0.492232, 0.110180,
+ 0.602861, -0.096228, 0.492684, 0.122400, 0.604167, -0.105380, 0.493213, 0.135354,
+ 0.605693, -0.114896, 0.493799, 0.149034, 0.607682, -0.124654, 0.494576, 0.163469,
+ 0.610672, -0.134560, 0.495900, 0.178747, 0.613313, -0.144581, 0.496713, 0.194723,
+ 0.617603, -0.154703, 0.498499, 0.211617, 0.622174, -0.164890, 0.500188, 0.229183,
+ 0.628855, -0.175164, 0.503072, 0.247786, 0.636963, -0.185565, 0.506798, 0.267116,
+ 0.644866, -0.195911, 0.509719, 0.287020, 0.653741, -0.206104, 0.512776, 0.307763,
+ 0.664942, -0.216447, 0.516812, 0.329631, 0.676330, -0.225520, 0.519181, 0.353515,
+ 0.690012, -0.234316, 0.521681, 0.379226, 0.704243, -0.242032, 0.523129, 0.405901,
+ 0.719396, -0.249172, 0.523768, 0.433585, 0.734471, -0.255543, 0.522541, 0.462085,
+ 0.750539, -0.260697, 0.520217, 0.491233, 0.766365, -0.265010, 0.516293, 0.521094,
+ 0.781677, -0.268409, 0.509708, 0.551014, 0.797132, -0.270399, 0.501944, 0.581463,
+ 0.812655, -0.271247, 0.492025, 0.612402, 0.828592, -0.270708, 0.480424, 0.643798,
+ 0.844044, -0.268085, 0.465955, 0.676820, 0.857305, -0.263459, 0.448425, 0.708496,
+ 0.871140, -0.258151, 0.430243, 0.740460, 0.884936, -0.251171, 0.410578, 0.771583,
+ 0.895772, -0.243305, 0.388620, 0.802234, 0.906961, -0.234037, 0.365214, 0.833179,
+ 0.917775, -0.222714, 0.341160, 0.863530, 0.927883, -0.210175, 0.315720, 0.893557,
+ 0.936617, -0.196925, 0.289159, 0.922976, 0.943384, -0.182788, 0.261996, 0.951606,
+ 0.949713, -0.167965, 0.235324, 0.979958, 0.955818, -0.151109, 0.208408, 1.007650,
+ 0.961344, -0.133834, 0.182591, 1.033290, 0.965469, -0.115987, 0.156958, 1.055700,
+ 0.968693, -0.097460, 0.132239, 1.075830, 0.973165, -0.077851, 0.106195, 1.094510,
+ 0.979387, -0.058507, 0.079767, 1.111370, 0.986710, -0.039041, 0.053026, 1.126430,
+ 0.994093, -0.019408, 0.026316, 1.140160, 1.000020, 0.000540, -0.000194, 1.152990,
+ 0.574483, -0.000010, 0.494533, 0.000011, 0.574478, -0.000249, 0.494528, 0.000289,
+ 0.574607, -0.000997, 0.494637, 0.001158, 0.574396, -0.002242, 0.494458, 0.002605,
+ 0.574377, -0.003986, 0.494440, 0.004631, 0.574386, -0.006228, 0.494445, 0.007236,
+ 0.574401, -0.008968, 0.494453, 0.010421, 0.574419, -0.012206, 0.494460, 0.014186,
+ 0.574459, -0.015940, 0.494481, 0.018532, 0.574525, -0.020169, 0.494520, 0.023462,
+ 0.574587, -0.024892, 0.494547, 0.028976, 0.574697, -0.030107, 0.494604, 0.035080,
+ 0.574853, -0.035811, 0.494688, 0.041777, 0.575027, -0.041999, 0.494772, 0.049072,
+ 0.575294, -0.048662, 0.494915, 0.056973, 0.575733, -0.055715, 0.495173, 0.065495,
+ 0.576356, -0.063049, 0.495537, 0.074661, 0.576944, -0.070929, 0.495836, 0.084461,
+ 0.577650, -0.079272, 0.496177, 0.094914, 0.578491, -0.088017, 0.496563, 0.106030,
+ 0.579639, -0.096946, 0.497096, 0.117841, 0.580989, -0.106220, 0.497684, 0.130367,
+ 0.582587, -0.115861, 0.498337, 0.143609, 0.584951, -0.125605, 0.499414, 0.157625,
+ 0.587602, -0.135608, 0.500518, 0.172413, 0.590760, -0.145742, 0.501767, 0.187999,
+ 0.594992, -0.155934, 0.503542, 0.204450, 0.600656, -0.166303, 0.506135, 0.221764,
+ 0.607816, -0.176681, 0.509542, 0.240020, 0.615220, -0.187071, 0.512630, 0.258992,
+ 0.623702, -0.197465, 0.516021, 0.278773, 0.634192, -0.207816, 0.520422, 0.299377,
+ 0.644936, -0.218183, 0.524073, 0.320802, 0.657888, -0.227800, 0.528049, 0.343840,
+ 0.670666, -0.236747, 0.529860, 0.369160, 0.685626, -0.244840, 0.531892, 0.395867,
+ 0.701304, -0.252071, 0.532727, 0.423488, 0.717727, -0.258714, 0.532146, 0.452201,
+ 0.733914, -0.264211, 0.529883, 0.481579, 0.750529, -0.268590, 0.525900, 0.511558,
+ 0.767470, -0.272046, 0.519990, 0.542042, 0.785189, -0.274225, 0.513083, 0.572799,
+ 0.800954, -0.275189, 0.502936, 0.603816, 0.816962, -0.274946, 0.490921, 0.635461,
+ 0.833360, -0.272695, 0.476840, 0.667600, 0.848143, -0.268223, 0.459405, 0.700510,
+ 0.861818, -0.262768, 0.440319, 0.732902, 0.876828, -0.255872, 0.420123, 0.765084,
+ 0.889312, -0.247703, 0.398379, 0.796391, 0.900412, -0.238381, 0.374496, 0.827333,
+ 0.912251, -0.227783, 0.349874, 0.858385, 0.921792, -0.214832, 0.323181, 0.888652,
+ 0.931273, -0.200949, 0.296624, 0.917763, 0.940295, -0.186537, 0.269211, 0.947878,
+ 0.946812, -0.171538, 0.241447, 0.977016, 0.953588, -0.155254, 0.213829, 1.005010,
+ 0.958841, -0.137156, 0.186807, 1.031790, 0.963746, -0.118699, 0.160706, 1.055020,
+ 0.966468, -0.099836, 0.135504, 1.075680, 0.971178, -0.080519, 0.109131, 1.094790,
+ 0.978310, -0.059935, 0.081829, 1.112300, 0.985886, -0.039966, 0.054587, 1.127710,
+ 0.994021, -0.019868, 0.026940, 1.141860, 1.000090, 0.000271, -0.000130, 1.155140,
+ 0.538716, -0.000010, 0.486732, 0.000011, 0.550656, -0.000251, 0.497518, 0.000277,
+ 0.550570, -0.001003, 0.497441, 0.001110, 0.550903, -0.002257, 0.497733, 0.002498,
+ 0.550568, -0.004010, 0.497438, 0.004439, 0.550574, -0.006266, 0.497440, 0.006936,
+ 0.550591, -0.009023, 0.497449, 0.009989, 0.550623, -0.012280, 0.497469, 0.013598,
+ 0.550667, -0.016036, 0.497495, 0.017765, 0.550724, -0.020291, 0.497526, 0.022492,
+ 0.550792, -0.025042, 0.497557, 0.027779, 0.550918, -0.030288, 0.497630, 0.033633,
+ 0.551058, -0.036024, 0.497701, 0.040057, 0.551276, -0.042247, 0.497824, 0.047059,
+ 0.551551, -0.048944, 0.497977, 0.054643, 0.552074, -0.055960, 0.498312, 0.062837,
+ 0.552681, -0.063398, 0.498679, 0.071646, 0.553324, -0.071318, 0.499031, 0.081075,
+ 0.554011, -0.079727, 0.499365, 0.091129, 0.554880, -0.088524, 0.499779, 0.101837,
+ 0.556171, -0.097442, 0.500444, 0.113239, 0.557498, -0.106841, 0.501025, 0.125316,
+ 0.559299, -0.116533, 0.501864, 0.138128, 0.561647, -0.126298, 0.502967, 0.151695,
+ 0.564347, -0.136388, 0.504129, 0.166040, 0.567863, -0.146576, 0.505713, 0.181207,
+ 0.572569, -0.156832, 0.507953, 0.197259, 0.578919, -0.167323, 0.511186, 0.214258,
+ 0.585387, -0.177712, 0.514042, 0.232038, 0.593134, -0.188184, 0.517484, 0.250733,
+ 0.603295, -0.198717, 0.522345, 0.270454, 0.613854, -0.209177, 0.526751, 0.290807,
+ 0.626092, -0.219644, 0.531595, 0.312202, 0.637868, -0.229494, 0.534721, 0.334435,
+ 0.652458, -0.238718, 0.538304, 0.359184, 0.666985, -0.247061, 0.539875, 0.385637,
+ 0.683301, -0.254652, 0.541042, 0.413280, 0.699980, -0.261376, 0.540735, 0.441903,
+ 0.717824, -0.267085, 0.539139, 0.471609, 0.734617, -0.271465, 0.534958, 0.501446,
+ 0.753663, -0.275280, 0.530320, 0.532571, 0.770512, -0.277617, 0.522134, 0.563641,
+ 0.787356, -0.278525, 0.512060, 0.595067, 0.806252, -0.278512, 0.501190, 0.627226,
+ 0.822061, -0.277023, 0.486791, 0.659402, 0.838959, -0.273175, 0.470467, 0.692874,
+ 0.853790, -0.267238, 0.450688, 0.725702, 0.868268, -0.260327, 0.429741, 0.758320,
+ 0.881994, -0.251946, 0.407223, 0.790189, 0.893885, -0.242432, 0.383214, 0.821625,
+ 0.905118, -0.231904, 0.357297, 0.853011, 0.916045, -0.219545, 0.330733, 0.883773,
+ 0.927614, -0.205378, 0.303916, 0.914435, 0.936005, -0.190388, 0.275941, 0.944502,
+ 0.944533, -0.174900, 0.247493, 0.974439, 0.950758, -0.158588, 0.218996, 1.002860,
+ 0.957078, -0.141027, 0.191559, 1.030400, 0.962448, -0.121507, 0.164457, 1.054660,
+ 0.964993, -0.102068, 0.138636, 1.076100, 0.970017, -0.082260, 0.111861, 1.095410,
+ 0.976610, -0.062033, 0.084344, 1.113170, 0.985073, -0.040983, 0.055850, 1.129110,
+ 0.993515, -0.020146, 0.027533, 1.143800, 1.000060, 0.000273, -0.000108, 1.157360,
+ 0.525324, -0.000010, 0.498153, 0.000011, 0.526513, -0.000252, 0.499277, 0.000265,
+ 0.526517, -0.001006, 0.499282, 0.001061, 0.526588, -0.002265, 0.499337, 0.002388,
+ 0.526539, -0.004026, 0.499302, 0.004245, 0.526547, -0.006290, 0.499306, 0.006634,
+ 0.526561, -0.009056, 0.499313, 0.009553, 0.526593, -0.012325, 0.499334, 0.013005,
+ 0.526642, -0.016096, 0.499365, 0.016991, 0.526700, -0.020366, 0.499396, 0.021512,
+ 0.526792, -0.025135, 0.499451, 0.026572, 0.526904, -0.030398, 0.499511, 0.032173,
+ 0.527079, -0.036155, 0.499617, 0.038323, 0.527285, -0.042398, 0.499731, 0.045026,
+ 0.527602, -0.049112, 0.499924, 0.052294, 0.528166, -0.056113, 0.500306, 0.060153,
+ 0.528790, -0.063599, 0.500700, 0.068606, 0.529421, -0.071581, 0.501048, 0.077652,
+ 0.530144, -0.079985, 0.501421, 0.087315, 0.531062, -0.088803, 0.501884, 0.097608,
+ 0.532374, -0.097764, 0.502590, 0.108588, 0.533828, -0.107197, 0.503290, 0.120234,
+ 0.535810, -0.116887, 0.504312, 0.132602, 0.538063, -0.126755, 0.505365, 0.145721,
+ 0.540900, -0.136819, 0.506668, 0.159617, 0.544882, -0.147117, 0.508731, 0.174369,
+ 0.550238, -0.157446, 0.511601, 0.190028, 0.556038, -0.167988, 0.514431, 0.206587,
+ 0.563031, -0.178364, 0.517808, 0.224046, 0.571543, -0.189007, 0.521937, 0.242503,
+ 0.582255, -0.199546, 0.527415, 0.261977, 0.592720, -0.210084, 0.531682, 0.282162,
+ 0.605648, -0.220448, 0.537123, 0.303426, 0.617850, -0.230593, 0.540664, 0.325323,
+ 0.632223, -0.240238, 0.544467, 0.348993, 0.648819, -0.248870, 0.547594, 0.375462,
+ 0.665825, -0.256657, 0.549120, 0.403024, 0.683389, -0.263711, 0.549294, 0.431773,
+ 0.701495, -0.269666, 0.547649, 0.461494, 0.719197, -0.274169, 0.543786, 0.491623,
+ 0.737906, -0.278124, 0.538644, 0.522994, 0.756652, -0.280632, 0.531057, 0.554775,
+ 0.775279, -0.281741, 0.521972, 0.586441, 0.792688, -0.281652, 0.509613, 0.618596,
+ 0.811894, -0.280345, 0.496497, 0.651462, 0.827938, -0.277128, 0.479680, 0.684023,
+ 0.844837, -0.271646, 0.460688, 0.718024, 0.859239, -0.264397, 0.438872, 0.751207,
+ 0.874088, -0.256144, 0.415770, 0.784232, 0.887693, -0.246311, 0.391369, 0.816191,
+ 0.899402, -0.235497, 0.365872, 0.847828, 0.910973, -0.223631, 0.338618, 0.879340,
+ 0.922040, -0.209874, 0.310803, 0.910325, 0.930987, -0.194265, 0.281802, 0.940695,
+ 0.940000, -0.178125, 0.252836, 0.970958, 0.948018, -0.161479, 0.224239, 1.000780,
+ 0.955141, -0.144038, 0.195857, 1.028800, 0.960513, -0.124915, 0.168487, 1.053710,
+ 0.963964, -0.104284, 0.141495, 1.075960, 0.968713, -0.083873, 0.114437, 1.096280,
+ 0.975524, -0.063558, 0.086310, 1.114480, 0.984310, -0.042291, 0.057477, 1.130690,
+ 0.992916, -0.020913, 0.028434, 1.145680, 0.999926, 0.000743, -0.000379, 1.159550,
+ 0.501042, -0.000010, 0.498726, 0.000010, 0.502992, -0.000252, 0.500665, 0.000253,
+ 0.502417, -0.001008, 0.500092, 0.001013, 0.502965, -0.002269, 0.500621, 0.002280,
+ 0.502318, -0.004031, 0.499994, 0.004050, 0.502333, -0.006298, 0.500005, 0.006329,
+ 0.502362, -0.009069, 0.500027, 0.009114, 0.502369, -0.012342, 0.500023, 0.012408,
+ 0.502430, -0.016118, 0.500066, 0.016211, 0.502493, -0.020394, 0.500103, 0.020526,
+ 0.502592, -0.025168, 0.500166, 0.025355, 0.502707, -0.030439, 0.500230, 0.030703,
+ 0.502881, -0.036201, 0.500335, 0.036575, 0.503124, -0.042451, 0.500488, 0.042980,
+ 0.503443, -0.049158, 0.500686, 0.049927, 0.504083, -0.056148, 0.501155, 0.057454,
+ 0.504668, -0.063685, 0.501524, 0.065541, 0.505319, -0.071683, 0.501904, 0.074207,
+ 0.506090, -0.080092, 0.502321, 0.083470, 0.507122, -0.088843, 0.502896, 0.093360,
+ 0.508414, -0.097855, 0.503603, 0.103910, 0.509955, -0.107304, 0.504416, 0.115113,
+ 0.512061, -0.116921, 0.505565, 0.127054, 0.514419, -0.126890, 0.506732, 0.139709,
+ 0.517529, -0.136934, 0.508338, 0.153173, 0.522085, -0.147327, 0.510987, 0.167528,
+ 0.526986, -0.157612, 0.513527, 0.182708, 0.533122, -0.168213, 0.516717, 0.198881,
+ 0.540807, -0.178688, 0.520832, 0.215986, 0.550687, -0.189511, 0.526320, 0.234335,
+ 0.560567, -0.199998, 0.531009, 0.253375, 0.571698, -0.210652, 0.535839, 0.273499,
+ 0.584364, -0.220917, 0.541091, 0.294355, 0.599066, -0.231370, 0.546875, 0.316525,
+ 0.614148, -0.241206, 0.551306, 0.339671, 0.631157, -0.250379, 0.555187, 0.365310,
+ 0.647919, -0.258397, 0.556595, 0.392767, 0.666112, -0.265528, 0.556949, 0.421397,
+ 0.686158, -0.271827, 0.556617, 0.451433, 0.704838, -0.276740, 0.552975, 0.482131,
+ 0.723957, -0.280733, 0.547814, 0.513458, 0.742620, -0.283359, 0.539970, 0.545446,
+ 0.762009, -0.284541, 0.530422, 0.577750, 0.781314, -0.284507, 0.518546, 0.610434,
+ 0.799116, -0.283309, 0.504178, 0.643178, 0.817604, -0.280378, 0.488430, 0.676248,
+ 0.834590, -0.275619, 0.469457, 0.709698, 0.850974, -0.268560, 0.447698, 0.744245,
+ 0.866747, -0.260094, 0.424791, 0.777695, 0.881412, -0.249929, 0.399913, 0.810392,
+ 0.893600, -0.239137, 0.373080, 0.842872, 0.905943, -0.226818, 0.345705, 0.874677,
+ 0.916408, -0.213699, 0.317060, 0.906257, 0.927215, -0.198428, 0.288444, 0.936881,
+ 0.935625, -0.181643, 0.258329, 0.967950, 0.944076, -0.164386, 0.228488, 0.998216,
+ 0.951229, -0.146339, 0.199763, 1.026890, 0.958793, -0.127709, 0.172153, 1.053500,
+ 0.963219, -0.107244, 0.144989, 1.076460, 0.967562, -0.085776, 0.116850, 1.096750,
+ 0.974866, -0.064538, 0.088057, 1.115760, 0.983353, -0.043173, 0.058735, 1.132270,
+ 0.992503, -0.021836, 0.029418, 1.147800, 1.000030, 0.000605, -0.000231, 1.162070,
+ 0.482935, -0.000010, 0.504695, 0.000010, 0.477554, -0.000252, 0.499071, 0.000241,
+ 0.477904, -0.001007, 0.499436, 0.000963, 0.478368, -0.002266, 0.499899, 0.002169,
+ 0.477977, -0.004027, 0.499513, 0.003854, 0.477993, -0.006292, 0.499525, 0.006022,
+ 0.478011, -0.009060, 0.499536, 0.008673, 0.478051, -0.012330, 0.499566, 0.011807,
+ 0.478089, -0.016102, 0.499587, 0.015427, 0.478171, -0.020374, 0.499645, 0.019534,
+ 0.478254, -0.025143, 0.499692, 0.024132, 0.478390, -0.030407, 0.499779, 0.029225,
+ 0.478588, -0.036163, 0.499911, 0.034820, 0.478812, -0.042402, 0.500046, 0.040923,
+ 0.479208, -0.049072, 0.500326, 0.047552, 0.479841, -0.056072, 0.500805, 0.054738,
+ 0.480392, -0.063613, 0.501152, 0.062461, 0.481068, -0.071613, 0.501561, 0.070747,
+ 0.481898, -0.080006, 0.502054, 0.079612, 0.483022, -0.088657, 0.502728, 0.089097,
+ 0.484332, -0.097755, 0.503479, 0.099210, 0.486126, -0.107173, 0.504546, 0.109990,
+ 0.488066, -0.116770, 0.505570, 0.121476, 0.490521, -0.126725, 0.506849, 0.133672,
+ 0.494232, -0.136793, 0.509110, 0.146731, 0.498302, -0.147116, 0.511345, 0.160577,
+ 0.503565, -0.157446, 0.514344, 0.175335, 0.510902, -0.168121, 0.518824, 0.191207,
+ 0.519263, -0.178799, 0.523666, 0.208058, 0.528204, -0.189407, 0.528296, 0.225875,
+ 0.538854, -0.200145, 0.533724, 0.244782, 0.551278, -0.210701, 0.539833, 0.264753,
+ 0.565222, -0.221303, 0.546131, 0.285745, 0.579403, -0.231688, 0.551496, 0.307592,
+ 0.595469, -0.241718, 0.556809, 0.330582, 0.610929, -0.250992, 0.559641, 0.354995,
+ 0.629433, -0.259602, 0.562379, 0.382471, 0.648504, -0.267038, 0.563676, 0.411126,
+ 0.667560, -0.273388, 0.562092, 0.440924, 0.689143, -0.278788, 0.560807, 0.472118,
+ 0.709056, -0.282783, 0.555701, 0.503774, 0.729855, -0.285836, 0.548698, 0.536364,
+ 0.748954, -0.287078, 0.538544, 0.568950, 0.768373, -0.287133, 0.526711, 0.601991,
+ 0.788270, -0.285839, 0.512511, 0.635403, 0.807465, -0.283238, 0.496323, 0.668797,
+ 0.825194, -0.279060, 0.477638, 0.702584, 0.842203, -0.272286, 0.456253, 0.736393,
+ 0.857749, -0.263854, 0.432412, 0.770960, 0.874799, -0.253943, 0.407806, 0.804890,
+ 0.887497, -0.242370, 0.380330, 0.837710, 0.899660, -0.230278, 0.352446, 0.870376,
+ 0.911753, -0.216460, 0.323268, 0.902256, 0.923011, -0.202071, 0.294314, 0.933306,
+ 0.932375, -0.185519, 0.264104, 0.965177, 0.940537, -0.167604, 0.234035, 0.996303,
+ 0.948904, -0.149068, 0.204120, 1.026100, 0.955263, -0.129539, 0.175431, 1.053040,
+ 0.960303, -0.109932, 0.148116, 1.076170, 0.965512, -0.088057, 0.119693, 1.097420,
+ 0.973466, -0.066055, 0.090162, 1.117210, 0.982840, -0.043923, 0.059987, 1.134360,
+ 0.992216, -0.021959, 0.029898, 1.150060, 0.999946, 0.000119, -0.000021, 1.164710,
+ 0.447827, -0.000010, 0.491543, 0.000009, 0.454778, -0.000251, 0.499172, 0.000229,
+ 0.453519, -0.001003, 0.497787, 0.000914, 0.453570, -0.002258, 0.497847, 0.002057,
+ 0.453578, -0.004014, 0.497855, 0.003657, 0.453570, -0.006271, 0.497841, 0.005715,
+ 0.453598, -0.009030, 0.497864, 0.008230, 0.453627, -0.012289, 0.497882, 0.011205,
+ 0.453684, -0.016047, 0.497923, 0.014641, 0.453764, -0.020304, 0.497980, 0.018539,
+ 0.453866, -0.025058, 0.498049, 0.022905, 0.453996, -0.030303, 0.498130, 0.027742,
+ 0.454196, -0.036038, 0.498267, 0.033059, 0.454457, -0.042252, 0.498445, 0.038861,
+ 0.454926, -0.048839, 0.498812, 0.045177, 0.455525, -0.055865, 0.499272, 0.052015,
+ 0.456074, -0.063377, 0.499625, 0.059375, 0.456752, -0.071361, 0.500049, 0.067275,
+ 0.457648, -0.079710, 0.500615, 0.075745, 0.458849, -0.088303, 0.501399, 0.084823,
+ 0.460290, -0.097409, 0.502293, 0.094514, 0.462000, -0.106729, 0.503301, 0.104848,
+ 0.464121, -0.116354, 0.504533, 0.115884, 0.466889, -0.126214, 0.506172, 0.127652,
+ 0.470744, -0.136324, 0.508667, 0.140240, 0.474880, -0.146595, 0.510995, 0.153673,
+ 0.480845, -0.157027, 0.514832, 0.168053, 0.488262, -0.167658, 0.519506, 0.183508,
+ 0.496547, -0.178343, 0.524347, 0.199948, 0.506254, -0.188916, 0.529830, 0.217503,
+ 0.517961, -0.199975, 0.536357, 0.236272, 0.531484, -0.210624, 0.543641, 0.256096,
+ 0.545496, -0.221227, 0.550048, 0.277085, 0.559497, -0.231568, 0.555076, 0.298615,
+ 0.575752, -0.241698, 0.560541, 0.321547, 0.591999, -0.251172, 0.564156, 0.345602,
+ 0.610654, -0.260178, 0.567607, 0.371851, 0.630484, -0.268094, 0.569230, 0.400760,
+ 0.651807, -0.274661, 0.569779, 0.430801, 0.672390, -0.280331, 0.566791, 0.461939,
+ 0.693024, -0.284501, 0.562007, 0.493854, 0.715473, -0.287852, 0.555791, 0.526992,
+ 0.736323, -0.289290, 0.546345, 0.560102, 0.755771, -0.289405, 0.534000, 0.593543,
+ 0.775424, -0.288100, 0.519114, 0.627256, 0.795447, -0.285562, 0.502543, 0.661464,
+ 0.815319, -0.281416, 0.484773, 0.695206, 0.831769, -0.275523, 0.463445, 0.729044,
+ 0.849464, -0.267516, 0.440269, 0.764069, 0.866775, -0.257584, 0.415049, 0.799089,
+ 0.881252, -0.245817, 0.388049, 0.831948, 0.894209, -0.233127, 0.358890, 0.865526,
+ 0.906922, -0.219579, 0.329915, 0.898180, 0.919686, -0.204491, 0.300441, 0.930013,
+ 0.929044, -0.188962, 0.269445, 0.962061, 0.938393, -0.171079, 0.238402, 0.994214,
+ 0.946610, -0.151990, 0.208204, 1.025330, 0.953095, -0.131953, 0.178653, 1.052900,
+ 0.958644, -0.111233, 0.150684, 1.077100, 0.963925, -0.090310, 0.122359, 1.098550,
+ 0.971995, -0.068050, 0.092334, 1.118740, 0.981658, -0.044851, 0.061420, 1.136350,
+ 0.991649, -0.022193, 0.030358, 1.152380, 0.999985, 0.000393, -0.000111, 1.167720,
+ 0.396806, -0.000010, 0.457671, 0.000008, 0.429186, -0.000249, 0.495017, 0.000216,
+ 0.429324, -0.000998, 0.495173, 0.000865, 0.429175, -0.002245, 0.494999, 0.001946,
+ 0.429129, -0.003990, 0.494952, 0.003460, 0.429153, -0.006235, 0.494974, 0.005407,
+ 0.429168, -0.008977, 0.494983, 0.007787, 0.429207, -0.012217, 0.495012, 0.010602,
+ 0.429257, -0.015954, 0.495047, 0.013853, 0.429338, -0.020186, 0.495106, 0.017544,
+ 0.429431, -0.024910, 0.495165, 0.021677, 0.429587, -0.030125, 0.495279, 0.026259,
+ 0.429796, -0.035825, 0.495432, 0.031297, 0.430065, -0.041997, 0.495621, 0.036798,
+ 0.430588, -0.048514, 0.496061, 0.042798, 0.431130, -0.055503, 0.496472, 0.049291,
+ 0.431743, -0.062985, 0.496904, 0.056291, 0.432448, -0.070926, 0.497369, 0.063806,
+ 0.433414, -0.079194, 0.498032, 0.071885, 0.434638, -0.087735, 0.498854, 0.080552,
+ 0.436110, -0.096806, 0.499812, 0.089805, 0.437859, -0.106002, 0.500891, 0.099714,
+ 0.440017, -0.115648, 0.502198, 0.110289, 0.443236, -0.125427, 0.504389, 0.121644,
+ 0.446970, -0.135492, 0.506809, 0.133769, 0.451689, -0.145746, 0.509858, 0.146787,
+ 0.458110, -0.156219, 0.514247, 0.160793, 0.465305, -0.166834, 0.518816, 0.175791,
+ 0.474085, -0.177546, 0.524331, 0.191906, 0.484808, -0.188262, 0.531040, 0.209199,
+ 0.497320, -0.199346, 0.538511, 0.227825, 0.509693, -0.209951, 0.544554, 0.247269,
+ 0.524367, -0.220533, 0.551616, 0.267978, 0.539228, -0.231082, 0.557368, 0.289672,
+ 0.556440, -0.241342, 0.563782, 0.312680, 0.574204, -0.250964, 0.568851, 0.336510,
+ 0.593388, -0.260306, 0.573120, 0.362219, 0.613358, -0.268667, 0.574916, 0.390322,
+ 0.634512, -0.275591, 0.575053, 0.420478, 0.655630, -0.281328, 0.572404, 0.451614,
+ 0.678265, -0.285948, 0.568893, 0.484112, 0.700110, -0.289408, 0.561878, 0.517348,
+ 0.723005, -0.291328, 0.553590, 0.551355, 0.743744, -0.291418, 0.541099, 0.585109,
+ 0.763949, -0.290252, 0.526489, 0.619487, 0.784186, -0.287648, 0.509496, 0.654040,
+ 0.804304, -0.283782, 0.491484, 0.688649, 0.823629, -0.278067, 0.470517, 0.723133,
+ 0.840940, -0.270588, 0.447050, 0.757163, 0.857852, -0.261188, 0.421252, 0.792816,
+ 0.874934, -0.249313, 0.394191, 0.827248, 0.888709, -0.236492, 0.365359, 0.861074,
+ 0.902589, -0.222185, 0.336016, 0.894417, 0.914201, -0.207314, 0.305270, 0.926825,
+ 0.925978, -0.191146, 0.274532, 0.959500, 0.935120, -0.174135, 0.243393, 0.991583,
+ 0.943656, -0.155231, 0.212414, 1.023560, 0.951719, -0.134403, 0.182005, 1.052390,
+ 0.957164, -0.113023, 0.153043, 1.077540, 0.962656, -0.091449, 0.124186, 1.099840,
+ 0.970695, -0.069418, 0.094165, 1.120000, 0.980749, -0.046620, 0.062967, 1.138490,
+ 0.991205, -0.022703, 0.031115, 1.154940, 0.999884, 0.000632, -0.000254, 1.170600,
+ 0.379821, -0.000010, 0.460637, 0.000008, 0.405188, -0.000247, 0.491396, 0.000204,
+ 0.404796, -0.000989, 0.490914, 0.000816, 0.404830, -0.002226, 0.490949, 0.001836,
+ 0.404730, -0.003957, 0.490840, 0.003263, 0.404731, -0.006183, 0.490836, 0.005099,
+ 0.404768, -0.008903, 0.490871, 0.007345, 0.404791, -0.012116, 0.490883, 0.010000,
+ 0.404857, -0.015821, 0.490938, 0.013068, 0.404943, -0.020018, 0.491004, 0.016550,
+ 0.405059, -0.024703, 0.491093, 0.020452, 0.405213, -0.029873, 0.491205, 0.024779,
+ 0.405399, -0.035523, 0.491333, 0.029537, 0.405731, -0.041635, 0.491604, 0.034741,
+ 0.406303, -0.048081, 0.492116, 0.040426, 0.406814, -0.055046, 0.492506, 0.046573,
+ 0.407404, -0.062465, 0.492926, 0.053206, 0.408149, -0.070296, 0.493442, 0.060344,
+ 0.409128, -0.078462, 0.494136, 0.068030, 0.410408, -0.087007, 0.495054, 0.076279,
+ 0.411813, -0.095964, 0.495962, 0.085105, 0.413735, -0.105075, 0.497257, 0.094588,
+ 0.416137, -0.114646, 0.498882, 0.104725, 0.419340, -0.124394, 0.501132, 0.115630,
+ 0.423326, -0.134328, 0.503883, 0.127325, 0.428419, -0.144580, 0.507470, 0.139911,
+ 0.434840, -0.154979, 0.511964, 0.153481, 0.442641, -0.165628, 0.517328, 0.168114,
+ 0.452511, -0.176365, 0.524258, 0.183995, 0.463473, -0.187298, 0.531248, 0.200953,
+ 0.475564, -0.198244, 0.538367, 0.219176, 0.488664, -0.208938, 0.545175, 0.238514,
+ 0.504073, -0.219599, 0.553227, 0.259129, 0.520832, -0.230378, 0.560653, 0.280997,
+ 0.538455, -0.240703, 0.567523, 0.303821, 0.557090, -0.250548, 0.573287, 0.327948,
+ 0.576646, -0.259964, 0.577795, 0.353362, 0.596705, -0.268721, 0.580077, 0.380336,
+ 0.618053, -0.276054, 0.580180, 0.410100, 0.640303, -0.282176, 0.578747, 0.441610,
+ 0.662365, -0.286931, 0.574294, 0.474106, 0.684542, -0.290521, 0.567035, 0.507549,
+ 0.707984, -0.292672, 0.558687, 0.541853, 0.730913, -0.293189, 0.547606, 0.576581,
+ 0.752948, -0.292199, 0.533471, 0.611720, 0.773452, -0.289508, 0.516395, 0.646339,
+ 0.794715, -0.285716, 0.497873, 0.682131, 0.814251, -0.280051, 0.476845, 0.716396,
+ 0.833057, -0.272873, 0.453449, 0.751503, 0.849590, -0.263982, 0.427857, 0.786085,
+ 0.867022, -0.252745, 0.400335, 0.821355, 0.882277, -0.239655, 0.371304, 0.856460,
+ 0.895375, -0.225386, 0.340397, 0.890828, 0.909347, -0.209587, 0.310005, 0.923532,
+ 0.921885, -0.193433, 0.279600, 0.956419, 0.932127, -0.176135, 0.247276, 0.989445,
+ 0.941869, -0.157872, 0.216186, 1.022210, 0.949735, -0.137577, 0.185602, 1.051950,
+ 0.956617, -0.115285, 0.155767, 1.078220, 0.961974, -0.092842, 0.126103, 1.101490,
+ 0.969720, -0.070059, 0.095676, 1.122070, 0.980120, -0.047467, 0.064327, 1.140800,
+ 0.990825, -0.023811, 0.032086, 1.157700, 0.999876, 0.000382, -0.000081, 1.174030,
+ 0.367636, -0.000010, 0.469176, 0.000008, 0.380377, -0.000245, 0.485434, 0.000192,
+ 0.380416, -0.000979, 0.485475, 0.000767, 0.380376, -0.002202, 0.485435, 0.001725,
+ 0.380419, -0.003914, 0.485487, 0.003067, 0.380438, -0.006115, 0.485505, 0.004793,
+ 0.380462, -0.008806, 0.485525, 0.006904, 0.380496, -0.011984, 0.485551, 0.009400,
+ 0.380560, -0.015649, 0.485605, 0.012285, 0.380640, -0.019799, 0.485666, 0.015560,
+ 0.380767, -0.024432, 0.485770, 0.019231, 0.380909, -0.029544, 0.485871, 0.023303,
+ 0.381142, -0.035132, 0.486060, 0.027786, 0.381472, -0.041154, 0.486336, 0.032694,
+ 0.382015, -0.047541, 0.486833, 0.038057, 0.382523, -0.054440, 0.487231, 0.043861,
+ 0.383129, -0.061784, 0.487683, 0.050133, 0.383952, -0.069509, 0.488313, 0.056900,
+ 0.384980, -0.077582, 0.489077, 0.064195, 0.386331, -0.086044, 0.490113, 0.072032,
+ 0.387788, -0.094841, 0.491099, 0.080438, 0.389808, -0.103899, 0.492566, 0.089490,
+ 0.392520, -0.113313, 0.494601, 0.099210, 0.395493, -0.123007, 0.496619, 0.109641,
+ 0.399826, -0.132859, 0.499912, 0.120919, 0.405341, -0.143077, 0.504061, 0.133107,
+ 0.411932, -0.153465, 0.508905, 0.146263, 0.420591, -0.164108, 0.515482, 0.160544,
+ 0.431010, -0.174893, 0.523191, 0.176123, 0.441881, -0.185839, 0.530260, 0.192757,
+ 0.453919, -0.196633, 0.537295, 0.210535, 0.468715, -0.207611, 0.546156, 0.229886,
+ 0.485182, -0.218517, 0.555173, 0.250543, 0.501926, -0.229249, 0.562728, 0.272210,
+ 0.517850, -0.239481, 0.567494, 0.294892, 0.536947, -0.249395, 0.573889, 0.318987,
+ 0.557115, -0.259000, 0.578831, 0.344348, 0.577966, -0.268075, 0.582055, 0.371223,
+ 0.599489, -0.276115, 0.583307, 0.399834, 0.624790, -0.282523, 0.583902, 0.431415,
+ 0.647504, -0.287663, 0.579530, 0.464301, 0.670601, -0.291538, 0.573103, 0.498123,
+ 0.693539, -0.293842, 0.563731, 0.532662, 0.717385, -0.294681, 0.553169, 0.567925,
+ 0.741533, -0.293717, 0.539908, 0.603502, 0.762142, -0.291156, 0.521902, 0.639074,
+ 0.783014, -0.287190, 0.502815, 0.674439, 0.805158, -0.281773, 0.482598, 0.710497,
+ 0.823646, -0.274682, 0.458949, 0.745600, 0.841879, -0.266184, 0.433129, 0.781085,
+ 0.859515, -0.255682, 0.406064, 0.816000, 0.875335, -0.242849, 0.376509, 0.851074,
+ 0.890147, -0.228329, 0.345502, 0.886473, 0.903144, -0.212491, 0.314280, 0.920751,
+ 0.916618, -0.195695, 0.282994, 0.954606, 0.927953, -0.178267, 0.251091, 0.988402,
+ 0.937414, -0.159549, 0.219107, 1.021410, 0.946823, -0.140022, 0.188960, 1.051670,
+ 0.954651, -0.118154, 0.158667, 1.078190, 0.959955, -0.094664, 0.128808, 1.102500,
+ 0.968580, -0.071179, 0.097379, 1.123910, 0.979380, -0.047505, 0.065097, 1.143220,
+ 0.990498, -0.024059, 0.032627, 1.160770, 0.999844, -0.000051, 0.000112, 1.177270,
+ 0.316912, -0.000009, 0.425996, 0.000007, 0.356423, -0.000241, 0.479108, 0.000180,
+ 0.356272, -0.000965, 0.478897, 0.000718, 0.356262, -0.002172, 0.478894, 0.001616,
+ 0.356265, -0.003861, 0.478895, 0.002873, 0.356278, -0.006032, 0.478905, 0.004489,
+ 0.356293, -0.008686, 0.478914, 0.006466, 0.356346, -0.011821, 0.478965, 0.008804,
+ 0.356395, -0.015435, 0.479001, 0.011507, 0.356484, -0.019529, 0.479075, 0.014576,
+ 0.356609, -0.024099, 0.479180, 0.018018, 0.356766, -0.029141, 0.479305, 0.021838,
+ 0.357009, -0.034650, 0.479512, 0.026045, 0.357424, -0.040546, 0.479909, 0.030666,
+ 0.357899, -0.046883, 0.480337, 0.035705, 0.358424, -0.053689, 0.480771, 0.041173,
+ 0.359041, -0.060942, 0.481242, 0.047084, 0.359903, -0.068524, 0.481943, 0.053483,
+ 0.360932, -0.076488, 0.482741, 0.060380, 0.362196, -0.084836, 0.483688, 0.067803,
+ 0.363847, -0.093500, 0.484947, 0.075809, 0.365972, -0.102471, 0.486588, 0.084417,
+ 0.368741, -0.111751, 0.488787, 0.093720, 0.372146, -0.121334, 0.491405, 0.103732,
+ 0.377114, -0.131147, 0.495604, 0.114608, 0.382260, -0.141213, 0.499436, 0.126345,
+ 0.389609, -0.151632, 0.505334, 0.139116, 0.397925, -0.162073, 0.511680, 0.152995,
+ 0.407824, -0.172819, 0.518876, 0.168071, 0.420014, -0.183929, 0.527639, 0.184495,
+ 0.434266, -0.195032, 0.537588, 0.202320, 0.447352, -0.205792, 0.544379, 0.221189,
+ 0.463726, -0.216704, 0.553422, 0.241616, 0.481406, -0.227531, 0.562074, 0.263298,
+ 0.498707, -0.238017, 0.568227, 0.286116, 0.518039, -0.247936, 0.574473, 0.310100,
+ 0.538277, -0.257437, 0.579191, 0.335401, 0.561166, -0.266829, 0.584807, 0.362246,
+ 0.583189, -0.275329, 0.586476, 0.390609, 0.606024, -0.282340, 0.585578, 0.420998,
+ 0.632419, -0.287924, 0.584496, 0.454357, 0.656128, -0.291972, 0.577766, 0.488233,
+ 0.679953, -0.294560, 0.568750, 0.523248, 0.704654, -0.295816, 0.558388, 0.559168,
+ 0.729016, -0.295157, 0.544826, 0.595326, 0.752062, -0.292779, 0.528273, 0.631864,
+ 0.773138, -0.288681, 0.508482, 0.667793, 0.794869, -0.283358, 0.487341, 0.704035,
+ 0.815101, -0.276080, 0.463540, 0.739925, 0.834212, -0.267670, 0.438672, 0.775539,
+ 0.852368, -0.257397, 0.411239, 0.810895, 0.870207, -0.245689, 0.382900, 0.846472,
+ 0.884063, -0.231452, 0.351496, 0.881788, 0.898284, -0.215561, 0.318950, 0.917438,
+ 0.912964, -0.198208, 0.287367, 0.952422, 0.924666, -0.180426, 0.254487, 0.987551,
+ 0.934429, -0.161525, 0.222226, 1.021420, 0.943485, -0.141197, 0.191143, 1.052180,
+ 0.952100, -0.120085, 0.161112, 1.079370, 0.957876, -0.097588, 0.130982, 1.104030,
+ 0.966943, -0.072684, 0.099055, 1.126160, 0.978313, -0.048370, 0.066282, 1.146190,
+ 0.990048, -0.023907, 0.032924, 1.164130, 0.999984, 0.000462, -0.000077, 1.180990,
+ 0.321287, -0.000009, 0.455413, 0.000007, 0.332595, -0.000238, 0.471437, 0.000168,
+ 0.332729, -0.000950, 0.471618, 0.000670, 0.332305, -0.002136, 0.471028, 0.001507,
+ 0.332326, -0.003798, 0.471055, 0.002680, 0.332344, -0.005934, 0.471072, 0.004188,
+ 0.332356, -0.008543, 0.471077, 0.006032, 0.332403, -0.011627, 0.471121, 0.008214,
+ 0.332461, -0.015182, 0.471170, 0.010736, 0.332552, -0.019209, 0.471251, 0.013601,
+ 0.332657, -0.023702, 0.471330, 0.016815, 0.332835, -0.028661, 0.471487, 0.020385,
+ 0.333083, -0.034077, 0.471708, 0.024321, 0.333547, -0.039856, 0.472190, 0.028652,
+ 0.333989, -0.046092, 0.472587, 0.033376, 0.334532, -0.052790, 0.473054, 0.038508,
+ 0.335167, -0.059928, 0.473568, 0.044064, 0.336080, -0.067351, 0.474362, 0.050096,
+ 0.337146, -0.075224, 0.475231, 0.056602, 0.338462, -0.083418, 0.476282, 0.063627,
+ 0.340140, -0.091938, 0.477615, 0.071215, 0.342341, -0.100741, 0.479404, 0.079417,
+ 0.345088, -0.109905, 0.481618, 0.088263, 0.349049, -0.119369, 0.485081, 0.097885,
+ 0.353939, -0.129033, 0.489317, 0.108336, 0.359893, -0.139038, 0.494309, 0.119698,
+ 0.366945, -0.149411, 0.499983, 0.132024, 0.375814, -0.159843, 0.507185, 0.145558,
+ 0.387112, -0.170664, 0.516392, 0.160433, 0.400230, -0.181897, 0.526519, 0.176648,
+ 0.412555, -0.192785, 0.534230, 0.193922, 0.427023, -0.203663, 0.542741, 0.212662,
+ 0.443685, -0.214695, 0.552066, 0.232944, 0.461499, -0.225561, 0.560762, 0.254495,
+ 0.480975, -0.236257, 0.569421, 0.277531, 0.501000, -0.246390, 0.576101, 0.301724,
+ 0.521691, -0.256101, 0.581493, 0.327112, 0.543478, -0.265289, 0.585221, 0.353917,
+ 0.566094, -0.273938, 0.587614, 0.381941, 0.589578, -0.281679, 0.587991, 0.411720,
+ 0.614583, -0.287655, 0.585928, 0.444148, 0.641813, -0.292228, 0.582092, 0.478617,
+ 0.666189, -0.295172, 0.573980, 0.513970, 0.690475, -0.296480, 0.561676, 0.550118,
+ 0.715543, -0.296203, 0.548758, 0.586933, 0.740405, -0.293999, 0.532792, 0.623840,
+ 0.762183, -0.289980, 0.512735, 0.660723, 0.786069, -0.284780, 0.492402, 0.698070,
+ 0.806812, -0.277568, 0.469058, 0.734422, 0.826987, -0.268951, 0.443017, 0.770946,
+ 0.844588, -0.259049, 0.415501, 0.806990, 0.863725, -0.247100, 0.387328, 0.842107,
+ 0.879137, -0.234157, 0.356108, 0.878078, 0.894634, -0.218719, 0.324315, 0.914058,
+ 0.909162, -0.201293, 0.291813, 0.949922, 0.920720, -0.182670, 0.258474, 0.985337,
+ 0.931580, -0.163212, 0.225593, 1.020500, 0.941238, -0.142771, 0.193986, 1.052730,
+ 0.949293, -0.120956, 0.163392, 1.080750, 0.956226, -0.098574, 0.132934, 1.105590,
+ 0.965460, -0.075118, 0.101255, 1.128230, 0.977403, -0.049792, 0.067544, 1.149000,
+ 0.989648, -0.024157, 0.033468, 1.167650, 1.000010, 0.000576, -0.000185, 1.185190,
+ 0.303474, -0.000009, 0.454200, 0.000006, 0.308894, -0.000233, 0.462306, 0.000156,
+ 0.309426, -0.000932, 0.463093, 0.000622, 0.308643, -0.002095, 0.461933, 0.001400,
+ 0.308651, -0.003724, 0.461941, 0.002489, 0.308662, -0.005819, 0.461950, 0.003889,
+ 0.308687, -0.008378, 0.461974, 0.005602, 0.308728, -0.011402, 0.462011, 0.007629,
+ 0.308789, -0.014888, 0.462067, 0.009973, 0.308882, -0.018837, 0.462151, 0.012637,
+ 0.309007, -0.023244, 0.462263, 0.015627, 0.309180, -0.028105, 0.462417, 0.018950,
+ 0.309442, -0.033406, 0.462667, 0.022617, 0.309901, -0.039059, 0.463162, 0.026661,
+ 0.310331, -0.045204, 0.463555, 0.031071, 0.310858, -0.051774, 0.464019, 0.035870,
+ 0.311576, -0.058736, 0.464669, 0.041085, 0.312436, -0.066038, 0.465406, 0.046745,
+ 0.313526, -0.073727, 0.466339, 0.052872, 0.314903, -0.081757, 0.467504, 0.059504,
+ 0.316814, -0.090167, 0.469226, 0.066689, 0.318965, -0.098755, 0.470981, 0.074466,
+ 0.322077, -0.107792, 0.473814, 0.082912, 0.325947, -0.117098, 0.477241, 0.092085,
+ 0.331008, -0.126602, 0.481840, 0.102137, 0.337893, -0.136619, 0.488334, 0.113135,
+ 0.345106, -0.146838, 0.494415, 0.125110, 0.355111, -0.157357, 0.503275, 0.138356,
+ 0.365095, -0.167955, 0.510966, 0.152686, 0.378344, -0.179157, 0.521508, 0.168560,
+ 0.391599, -0.190143, 0.530455, 0.185610, 0.407786, -0.201230, 0.541275, 0.204308,
+ 0.425294, -0.212456, 0.551784, 0.224623, 0.444021, -0.223568, 0.561493, 0.246172,
+ 0.463418, -0.234154, 0.569886, 0.268979, 0.484077, -0.244546, 0.577116, 0.293411,
+ 0.505513, -0.254301, 0.582914, 0.318936, 0.527672, -0.263564, 0.587208, 0.345856,
+ 0.550565, -0.272332, 0.589277, 0.374054, 0.573656, -0.280011, 0.588426, 0.403276,
+ 0.598270, -0.286924, 0.587504, 0.434740, 0.624731, -0.291994, 0.583401, 0.468767,
+ 0.652396, -0.295159, 0.576997, 0.504411, 0.677320, -0.296954, 0.565863, 0.541140,
+ 0.703147, -0.296877, 0.552316, 0.578160, 0.728715, -0.295147, 0.536773, 0.616124,
+ 0.752448, -0.291275, 0.517710, 0.653885, 0.775169, -0.285905, 0.496087, 0.691537,
+ 0.799307, -0.279064, 0.474232, 0.729251, 0.819482, -0.270294, 0.447676, 0.766267,
+ 0.837659, -0.260032, 0.419656, 0.802616, 0.856903, -0.248497, 0.391328, 0.838583,
+ 0.873325, -0.235252, 0.360285, 0.874711, 0.889788, -0.221126, 0.329215, 0.910770,
+ 0.904486, -0.204304, 0.296392, 0.946530, 0.917711, -0.185562, 0.262159, 0.983828,
+ 0.928969, -0.165635, 0.229142, 1.019550, 0.939707, -0.144420, 0.196730, 1.053170,
+ 0.948167, -0.122147, 0.165095, 1.082300, 0.955222, -0.099098, 0.134510, 1.107910,
+ 0.964401, -0.075533, 0.102476, 1.131200, 0.976605, -0.051382, 0.068967, 1.152180,
+ 0.989085, -0.025850, 0.034506, 1.171290, 0.999908, 0.000618, -0.000271, 1.189610,
+ 0.285803, -0.000009, 0.452348, 0.000006, 0.284689, -0.000227, 0.450581, 0.000144,
+ 0.285263, -0.000910, 0.451482, 0.000575, 0.285302, -0.002048, 0.451553, 0.001294,
+ 0.285318, -0.003641, 0.451574, 0.002301, 0.285330, -0.005688, 0.451585, 0.003595,
+ 0.285361, -0.008190, 0.451618, 0.005179, 0.285397, -0.011146, 0.451650, 0.007054,
+ 0.285447, -0.014554, 0.451688, 0.009222, 0.285527, -0.018413, 0.451758, 0.011687,
+ 0.285688, -0.022721, 0.451929, 0.014455, 0.285840, -0.027471, 0.452055, 0.017534,
+ 0.286136, -0.032628, 0.452369, 0.020941, 0.286574, -0.038179, 0.452853, 0.024696,
+ 0.287012, -0.044188, 0.453272, 0.028800, 0.287542, -0.050610, 0.453752, 0.033268,
+ 0.288299, -0.057363, 0.454488, 0.038150, 0.289186, -0.064546, 0.455294, 0.043445,
+ 0.290302, -0.072040, 0.456301, 0.049197, 0.291776, -0.079905, 0.457648, 0.055445,
+ 0.293720, -0.088117, 0.459483, 0.062231, 0.296052, -0.096533, 0.461571, 0.069599,
+ 0.299563, -0.105409, 0.465085, 0.077658, 0.303350, -0.114553, 0.468506, 0.086418,
+ 0.309167, -0.123917, 0.474423, 0.096108, 0.315290, -0.133810, 0.479950, 0.106643,
+ 0.324163, -0.144021, 0.488592, 0.118322, 0.333272, -0.154382, 0.496461, 0.131133,
+ 0.344224, -0.165015, 0.505620, 0.145208, 0.357733, -0.176168, 0.516719, 0.160730,
+ 0.373046, -0.187468, 0.528513, 0.177807, 0.387880, -0.198488, 0.537713, 0.196072,
+ 0.405133, -0.209545, 0.547999, 0.216050, 0.423845, -0.220724, 0.557590, 0.237484,
+ 0.443777, -0.231518, 0.566246, 0.260390, 0.464824, -0.242035, 0.574326, 0.284835,
+ 0.486635, -0.251898, 0.580370, 0.310518, 0.510120, -0.261304, 0.585680, 0.337678,
+ 0.535301, -0.270384, 0.590197, 0.366242, 0.559193, -0.278410, 0.590569, 0.395873,
+ 0.583544, -0.285325, 0.588161, 0.426857, 0.608834, -0.291113, 0.584249, 0.459477,
+ 0.635753, -0.294882, 0.577630, 0.494734, 0.664367, -0.297088, 0.569479, 0.532023,
+ 0.689688, -0.297364, 0.555064, 0.569629, 0.715732, -0.295949, 0.539522, 0.608124,
+ 0.741307, -0.292259, 0.521613, 0.646231, 0.764949, -0.287063, 0.499690, 0.684938,
+ 0.788599, -0.280120, 0.476747, 0.723548, 0.810480, -0.271530, 0.451160, 0.761135,
+ 0.831372, -0.261289, 0.424101, 0.798916, 0.850092, -0.249559, 0.394430, 0.835952,
+ 0.867777, -0.236348, 0.363849, 0.871606, 0.884632, -0.221569, 0.332477, 0.907843,
+ 0.900470, -0.206180, 0.300667, 0.944187, 0.914524, -0.188771, 0.266552, 0.981371,
+ 0.926892, -0.168362, 0.232349, 1.018410, 0.937951, -0.146761, 0.199359, 1.053080,
+ 0.947236, -0.123813, 0.167500, 1.083900, 0.954367, -0.099984, 0.136166, 1.110470,
+ 0.963907, -0.075928, 0.103808, 1.134140, 0.976218, -0.051137, 0.069706, 1.155750,
+ 0.988772, -0.026742, 0.035253, 1.175310, 0.999888, -0.000521, 0.000290, 1.193890,
+ 0.263546, -0.000009, 0.441896, 0.000005, 0.262352, -0.000222, 0.439889, 0.000132,
+ 0.262325, -0.000887, 0.439848, 0.000529, 0.262280, -0.001995, 0.439765, 0.001190,
+ 0.262372, -0.003547, 0.439922, 0.002116, 0.262390, -0.005541, 0.439941, 0.003307,
+ 0.262412, -0.007979, 0.439961, 0.004763, 0.262453, -0.010858, 0.440002, 0.006488,
+ 0.262528, -0.014179, 0.440085, 0.008483, 0.262615, -0.017938, 0.440166, 0.010753,
+ 0.262744, -0.022135, 0.440291, 0.013304, 0.262939, -0.026762, 0.440493, 0.016144,
+ 0.263277, -0.031757, 0.440889, 0.019297, 0.263680, -0.037183, 0.441338, 0.022770,
+ 0.264106, -0.043037, 0.441753, 0.026570, 0.264624, -0.049304, 0.442227, 0.030718,
+ 0.265378, -0.055867, 0.442985, 0.035262, 0.266253, -0.062872, 0.443795, 0.040197,
+ 0.267478, -0.070157, 0.445008, 0.045590, 0.269062, -0.077845, 0.446599, 0.051454,
+ 0.270926, -0.085794, 0.448349, 0.057838, 0.273693, -0.094077, 0.451221, 0.064836,
+ 0.276746, -0.102704, 0.454097, 0.072439, 0.281693, -0.111735, 0.459517, 0.080874,
+ 0.287335, -0.121004, 0.465310, 0.090155, 0.294480, -0.130734, 0.472605, 0.100371,
+ 0.302570, -0.140777, 0.480251, 0.111644, 0.312465, -0.151110, 0.489444, 0.124111,
+ 0.324856, -0.161890, 0.500919, 0.137979, 0.337740, -0.172946, 0.511317, 0.153163,
+ 0.352550, -0.184152, 0.522684, 0.169817, 0.367786, -0.195220, 0.532480, 0.187886,
+ 0.385474, -0.206320, 0.543326, 0.207634, 0.404976, -0.217744, 0.554109, 0.229165,
+ 0.425203, -0.228691, 0.563395, 0.252068, 0.446704, -0.239299, 0.571565, 0.276471,
+ 0.468951, -0.249348, 0.577935, 0.302323, 0.493487, -0.258933, 0.584309, 0.329882,
+ 0.517861, -0.268009, 0.587730, 0.358525, 0.543309, -0.276238, 0.589612, 0.388585,
+ 0.569704, -0.283560, 0.589294, 0.419787, 0.594871, -0.289497, 0.585137, 0.452114,
+ 0.622555, -0.294452, 0.580356, 0.486466, 0.651167, -0.296918, 0.571850, 0.523079,
+ 0.677332, -0.297647, 0.558428, 0.561100, 0.703718, -0.296321, 0.542232, 0.599592,
+ 0.730262, -0.293339, 0.524541, 0.639138, 0.754304, -0.288036, 0.502691, 0.677978,
+ 0.778051, -0.281018, 0.479212, 0.716537, 0.801557, -0.272414, 0.454071, 0.755860,
+ 0.822559, -0.262419, 0.425952, 0.794477, 0.843051, -0.250702, 0.397313, 0.832664,
+ 0.862320, -0.237264, 0.366534, 0.869876, 0.879044, -0.222716, 0.334816, 0.906973,
+ 0.896362, -0.206827, 0.303143, 0.943558, 0.910342, -0.189659, 0.269699, 0.979759,
+ 0.924119, -0.171108, 0.236411, 1.017180, 0.935374, -0.149579, 0.202224, 1.052890,
+ 0.944295, -0.126295, 0.169890, 1.084960, 0.952227, -0.101511, 0.138089, 1.112560,
+ 0.962041, -0.076639, 0.105053, 1.137500, 0.975280, -0.051197, 0.070329, 1.159830,
+ 0.988476, -0.025463, 0.035127, 1.179870, 0.999962, 0.000029, 0.000015, 1.199010,
+ 0.227089, -0.000008, 0.404216, 0.000005, 0.239725, -0.000215, 0.426708, 0.000121,
+ 0.239904, -0.000861, 0.427028, 0.000484, 0.239911, -0.001937, 0.427039, 0.001088,
+ 0.239914, -0.003443, 0.427040, 0.001935, 0.239933, -0.005379, 0.427064, 0.003024,
+ 0.239944, -0.007745, 0.427065, 0.004356, 0.239993, -0.010540, 0.427122, 0.005934,
+ 0.240052, -0.013763, 0.427179, 0.007760, 0.240148, -0.017411, 0.427279, 0.009839,
+ 0.240278, -0.021484, 0.427410, 0.012176, 0.240472, -0.025973, 0.427618, 0.014783,
+ 0.240839, -0.030813, 0.428086, 0.017684, 0.241201, -0.036089, 0.428482, 0.020878,
+ 0.241626, -0.041772, 0.428907, 0.024382, 0.242207, -0.047834, 0.429520, 0.028223,
+ 0.242980, -0.054220, 0.430332, 0.032433, 0.243881, -0.061002, 0.431222, 0.037025,
+ 0.245123, -0.068087, 0.432512, 0.042054, 0.246670, -0.075548, 0.434088, 0.047541,
+ 0.248779, -0.083287, 0.436323, 0.053554, 0.251665, -0.091355, 0.439509, 0.060172,
+ 0.255305, -0.099849, 0.443478, 0.067428, 0.260049, -0.108576, 0.448713, 0.075467,
+ 0.266192, -0.117754, 0.455524, 0.084339, 0.273158, -0.127294, 0.462700, 0.094168,
+ 0.282131, -0.137311, 0.472068, 0.105150, 0.293332, -0.147736, 0.483565, 0.117402,
+ 0.304667, -0.158357, 0.493702, 0.130824, 0.317785, -0.169274, 0.504708, 0.145724,
+ 0.333245, -0.180595, 0.517107, 0.162150, 0.349843, -0.191892, 0.528849, 0.180149,
+ 0.367944, -0.203168, 0.540301, 0.199746, 0.387579, -0.214443, 0.551514, 0.221047,
+ 0.408247, -0.225624, 0.560906, 0.243981, 0.430140, -0.236422, 0.569590, 0.268513,
+ 0.452669, -0.246540, 0.576098, 0.294409, 0.476196, -0.256157, 0.580925, 0.322002,
+ 0.501157, -0.265289, 0.584839, 0.351052, 0.527632, -0.273671, 0.587614, 0.381200,
+ 0.555754, -0.281254, 0.589119, 0.412994, 0.581682, -0.287448, 0.585204, 0.445498,
+ 0.608196, -0.292614, 0.579006, 0.479505, 0.635661, -0.296068, 0.571297, 0.514643,
+ 0.664999, -0.297395, 0.560855, 0.552213, 0.691039, -0.296645, 0.544525, 0.591365,
+ 0.717900, -0.293785, 0.526535, 0.630883, 0.744059, -0.289089, 0.505450, 0.670932,
+ 0.768630, -0.282239, 0.482514, 0.710904, 0.793273, -0.273688, 0.457246, 0.750259,
+ 0.814731, -0.263280, 0.428872, 0.789480, 0.835603, -0.251526, 0.399384, 0.828597,
+ 0.854890, -0.238339, 0.368811, 0.866892, 0.872828, -0.223607, 0.336617, 0.905630,
+ 0.889462, -0.207538, 0.303997, 0.943538, 0.904929, -0.190297, 0.270812, 0.980591,
+ 0.919101, -0.172034, 0.237453, 1.019350, 0.930536, -0.152058, 0.204431, 1.054980,
+ 0.941223, -0.129515, 0.172495, 1.087170, 0.949820, -0.104263, 0.140175, 1.115510,
+ 0.960592, -0.078194, 0.106465, 1.140980, 0.974629, -0.051688, 0.071159, 1.164180,
+ 0.988110, -0.025393, 0.035443, 1.184650, 1.000040, 0.000804, -0.000331, 1.204620,
+ 0.214668, -0.000008, 0.406619, 0.000004, 0.218053, -0.000208, 0.413025, 0.000110,
+ 0.217987, -0.000832, 0.412901, 0.000439, 0.217971, -0.001872, 0.412876, 0.000989,
+ 0.217968, -0.003329, 0.412860, 0.001758, 0.217985, -0.005201, 0.412882, 0.002747,
+ 0.218014, -0.007488, 0.412916, 0.003958, 0.218054, -0.010190, 0.412957, 0.005393,
+ 0.218106, -0.013306, 0.413005, 0.007053, 0.218217, -0.016834, 0.413139, 0.008946,
+ 0.218338, -0.020771, 0.413258, 0.011075, 0.218550, -0.025100, 0.413509, 0.013455,
+ 0.218913, -0.029786, 0.413992, 0.016108, 0.219265, -0.034896, 0.414383, 0.019031,
+ 0.219696, -0.040391, 0.414839, 0.022246, 0.220329, -0.046200, 0.415567, 0.025792,
+ 0.220989, -0.052421, 0.416210, 0.029664, 0.222027, -0.058948, 0.417385, 0.033932,
+ 0.223301, -0.065821, 0.418779, 0.038606, 0.224988, -0.073035, 0.420665, 0.043735,
+ 0.227211, -0.080527, 0.423198, 0.049384, 0.230131, -0.088395, 0.426566, 0.055614,
+ 0.233908, -0.096621, 0.430910, 0.062483, 0.239092, -0.105223, 0.437148, 0.070164,
+ 0.245315, -0.114240, 0.444302, 0.078695, 0.253166, -0.123680, 0.453262, 0.088238,
+ 0.262374, -0.133569, 0.463211, 0.098868, 0.273145, -0.143836, 0.474271, 0.110727,
+ 0.285512, -0.154577, 0.486300, 0.123945, 0.299512, -0.165501, 0.498817, 0.138581,
+ 0.314287, -0.176698, 0.510341, 0.154676, 0.331083, -0.188066, 0.522583, 0.172459,
+ 0.349615, -0.199597, 0.534879, 0.191979, 0.369318, -0.210843, 0.546083, 0.213090,
+ 0.390377, -0.222068, 0.556200, 0.235998, 0.412411, -0.233059, 0.564704, 0.260518,
+ 0.435715, -0.243570, 0.572314, 0.286795, 0.461196, -0.253356, 0.579395, 0.314559,
+ 0.485587, -0.262362, 0.581985, 0.343581, 0.511908, -0.270895, 0.584347, 0.374367,
+ 0.539798, -0.278452, 0.585050, 0.406015, 0.567974, -0.284877, 0.583344, 0.439168,
+ 0.594303, -0.290124, 0.577348, 0.473005, 0.622951, -0.294183, 0.570751, 0.508534,
+ 0.652404, -0.296389, 0.561541, 0.544764, 0.679291, -0.296605, 0.546426, 0.582927,
+ 0.706437, -0.294095, 0.528599, 0.622681, 0.734485, -0.289780, 0.508676, 0.663567,
+ 0.758841, -0.283363, 0.484768, 0.704092, 0.785370, -0.275015, 0.460434, 0.745101,
+ 0.807315, -0.264689, 0.432166, 0.784712, 0.827100, -0.252597, 0.401807, 0.824241,
+ 0.849191, -0.239154, 0.371458, 0.863803, 0.867046, -0.224451, 0.338873, 0.903063,
+ 0.885200, -0.208342, 0.306175, 0.942763, 0.901771, -0.190684, 0.272759, 0.981559,
+ 0.915958, -0.172105, 0.239306, 1.020480, 0.928046, -0.152214, 0.206071, 1.057650,
+ 0.939961, -0.130247, 0.173670, 1.089990, 0.948711, -0.106720, 0.142201, 1.118290,
+ 0.959305, -0.080869, 0.108454, 1.144670, 0.973009, -0.053914, 0.072811, 1.168390,
+ 0.987631, -0.026295, 0.036062, 1.190040, 0.999978, 0.001328, -0.000559, 1.210580,
+ 0.193925, -0.000008, 0.391974, 0.000004, 0.196746, -0.000200, 0.397675, 0.000099,
+ 0.196670, -0.000801, 0.397521, 0.000396, 0.196633, -0.001802, 0.397445, 0.000892,
+ 0.196654, -0.003204, 0.397482, 0.001586, 0.196659, -0.005006, 0.397480, 0.002479,
+ 0.196683, -0.007209, 0.397506, 0.003572, 0.196728, -0.009810, 0.397562, 0.004867,
+ 0.196792, -0.012810, 0.397633, 0.006367, 0.196890, -0.016206, 0.397746, 0.008078,
+ 0.197017, -0.019994, 0.397884, 0.010005, 0.197290, -0.024139, 0.398270, 0.012169,
+ 0.197583, -0.028667, 0.398639, 0.014575, 0.197927, -0.033586, 0.399034, 0.017236,
+ 0.198383, -0.038881, 0.399554, 0.020172, 0.199002, -0.044474, 0.400289, 0.023419,
+ 0.199739, -0.050458, 0.401111, 0.026984, 0.200784, -0.056729, 0.402349, 0.030922,
+ 0.202075, -0.063364, 0.403841, 0.035250, 0.203898, -0.070325, 0.406076, 0.040031,
+ 0.206199, -0.077557, 0.408841, 0.045328, 0.209252, -0.085184, 0.412590, 0.051179,
+ 0.213638, -0.093199, 0.418288, 0.057746, 0.218810, -0.101617, 0.424681, 0.065051,
+ 0.225642, -0.110520, 0.433429, 0.073276, 0.233717, -0.119772, 0.442897, 0.082468,
+ 0.242823, -0.129505, 0.452888, 0.092748, 0.254772, -0.139906, 0.466407, 0.104417,
+ 0.266603, -0.150402, 0.477413, 0.117211, 0.280730, -0.161395, 0.490519, 0.131598,
+ 0.295399, -0.172465, 0.502010, 0.147407, 0.312705, -0.183982, 0.515311, 0.165031,
+ 0.331335, -0.195532, 0.527860, 0.184336, 0.351037, -0.206971, 0.539200, 0.205361,
+ 0.372175, -0.218117, 0.549410, 0.228043, 0.394548, -0.229327, 0.558642, 0.252670,
+ 0.419598, -0.240052, 0.567861, 0.279071, 0.443922, -0.249937, 0.573332, 0.306882,
+ 0.471495, -0.259407, 0.580130, 0.336610, 0.496769, -0.267749, 0.580564, 0.367328,
+ 0.524951, -0.275524, 0.581696, 0.399753, 0.553180, -0.282148, 0.579885, 0.433134,
+ 0.581577, -0.287533, 0.575471, 0.467534, 0.609231, -0.291612, 0.567445, 0.502943,
+ 0.637478, -0.293911, 0.557657, 0.538710, 0.667795, -0.295096, 0.546535, 0.576568,
+ 0.694272, -0.294073, 0.529561, 0.614929, 0.722937, -0.290386, 0.510561, 0.655909,
+ 0.749682, -0.284481, 0.487846, 0.697663, 0.774754, -0.276188, 0.462487, 0.738515,
+ 0.799301, -0.266215, 0.434810, 0.779802, 0.820762, -0.254116, 0.404879, 0.820045,
+ 0.843231, -0.240393, 0.374559, 0.860294, 0.861857, -0.225503, 0.341582, 0.900965,
+ 0.880815, -0.209382, 0.308778, 0.941727, 0.897660, -0.191550, 0.275232, 0.980916,
+ 0.912926, -0.172346, 0.240938, 1.021620, 0.926391, -0.151799, 0.207223, 1.059700,
+ 0.938429, -0.129968, 0.174840, 1.092910, 0.947834, -0.106510, 0.142984, 1.122480,
+ 0.958432, -0.082410, 0.109902, 1.149000, 0.972402, -0.056524, 0.074445, 1.173300,
+ 0.987191, -0.028427, 0.037379, 1.195380, 0.999975, 0.000039, -0.000042, 1.216760,
+ 0.178114, -0.000008, 0.385418, 0.000004, 0.176074, -0.000192, 0.381002, 0.000089,
+ 0.176010, -0.000768, 0.380861, 0.000355, 0.175980, -0.001727, 0.380798, 0.000798,
+ 0.175994, -0.003070, 0.380824, 0.001419, 0.176017, -0.004797, 0.380858, 0.002219,
+ 0.176019, -0.006906, 0.380839, 0.003197, 0.176072, -0.009399, 0.380913, 0.004357,
+ 0.176131, -0.012273, 0.380979, 0.005702, 0.176239, -0.015526, 0.381120, 0.007237,
+ 0.176371, -0.019155, 0.381272, 0.008969, 0.176638, -0.023117, 0.381669, 0.010919,
+ 0.176912, -0.027463, 0.382015, 0.013090, 0.177279, -0.032173, 0.382476, 0.015495,
+ 0.177740, -0.037222, 0.383041, 0.018167, 0.178344, -0.042613, 0.383780, 0.021121,
+ 0.179153, -0.048331, 0.384773, 0.024390, 0.180197, -0.054345, 0.386076, 0.028006,
+ 0.181581, -0.060712, 0.387809, 0.032004, 0.183440, -0.067386, 0.390205, 0.036453,
+ 0.186139, -0.074399, 0.393944, 0.041416, 0.189432, -0.081773, 0.398320, 0.046939,
+ 0.193795, -0.089546, 0.404188, 0.053144, 0.199641, -0.097826, 0.412100, 0.060137,
+ 0.206679, -0.106499, 0.421425, 0.068008, 0.214865, -0.115654, 0.431504, 0.076919,
+ 0.224406, -0.125268, 0.442526, 0.086884, 0.235876, -0.135475, 0.455465, 0.098187,
+ 0.248335, -0.146023, 0.468100, 0.110759, 0.262868, -0.157016, 0.482069, 0.124885,
+ 0.278962, -0.168245, 0.496182, 0.140645, 0.295082, -0.179580, 0.507401, 0.157838,
+ 0.313738, -0.191227, 0.520252, 0.176950, 0.333573, -0.202718, 0.531708, 0.197817,
+ 0.356433, -0.214424, 0.544509, 0.220785, 0.378853, -0.225492, 0.553730, 0.245306,
+ 0.402717, -0.236236, 0.561348, 0.271593, 0.428375, -0.246568, 0.568538, 0.299776,
+ 0.454724, -0.255941, 0.573462, 0.329433, 0.482291, -0.264511, 0.576356, 0.360598,
+ 0.509706, -0.272129, 0.576446, 0.393204, 0.538805, -0.278979, 0.575298, 0.427227,
+ 0.568919, -0.284528, 0.572154, 0.462157, 0.596804, -0.288801, 0.564691, 0.497997,
+ 0.625987, -0.291334, 0.555134, 0.534467, 0.656414, -0.292722, 0.545051, 0.571736,
+ 0.683916, -0.292185, 0.528813, 0.610158, 0.711809, -0.290043, 0.511060, 0.649061,
+ 0.739547, -0.285246, 0.490103, 0.690081, 0.766914, -0.277647, 0.465523, 0.732554,
+ 0.791375, -0.267603, 0.437718, 0.773982, 0.814772, -0.256109, 0.408820, 0.816090,
+ 0.836691, -0.242281, 0.377823, 0.856849, 0.856984, -0.227155, 0.344960, 0.898363,
+ 0.876332, -0.210395, 0.311335, 0.939471, 0.894988, -0.192612, 0.277703, 0.980799,
+ 0.911113, -0.173236, 0.243019, 1.022150, 0.924092, -0.152258, 0.209037, 1.061390,
+ 0.936828, -0.129575, 0.175909, 1.096350, 0.946869, -0.105940, 0.143852, 1.127070,
+ 0.958284, -0.081318, 0.110289, 1.154190, 0.972325, -0.055613, 0.074723, 1.179090,
+ 0.986878, -0.029790, 0.038315, 1.201630, 0.999936, -0.001972, 0.000912, 1.223380,
+ 0.151174, -0.000007, 0.351531, 0.000003, 0.155594, -0.000183, 0.361806, 0.000079,
+ 0.156099, -0.000732, 0.362982, 0.000315, 0.156053, -0.001646, 0.362869, 0.000708,
+ 0.156093, -0.002926, 0.362961, 0.001259, 0.156099, -0.004572, 0.362959, 0.001968,
+ 0.156120, -0.006582, 0.362982, 0.002836, 0.156168, -0.008958, 0.363048, 0.003866,
+ 0.156221, -0.011696, 0.363101, 0.005061, 0.156324, -0.014797, 0.363241, 0.006427,
+ 0.156476, -0.018250, 0.363448, 0.007972, 0.156731, -0.022027, 0.363840, 0.009715,
+ 0.156994, -0.026176, 0.364179, 0.011657, 0.157341, -0.030670, 0.364620, 0.013821,
+ 0.157867, -0.035459, 0.365364, 0.016236, 0.158460, -0.040614, 0.366111, 0.018909,
+ 0.159308, -0.046052, 0.367248, 0.021885, 0.160426, -0.051810, 0.368767, 0.025200,
+ 0.161877, -0.057891, 0.370745, 0.028882, 0.163995, -0.064281, 0.373831, 0.033014,
+ 0.166550, -0.071007, 0.377366, 0.037628, 0.170237, -0.078152, 0.382799, 0.042849,
+ 0.175096, -0.085717, 0.389915, 0.048732, 0.181069, -0.093802, 0.398487, 0.055421,
+ 0.188487, -0.102363, 0.408799, 0.063019, 0.197029, -0.111343, 0.419991, 0.071634,
+ 0.206684, -0.120812, 0.431455, 0.081280, 0.218698, -0.131033, 0.445746, 0.092365,
+ 0.230726, -0.141373, 0.457471, 0.104545, 0.245516, -0.152387, 0.472388, 0.118449,
+ 0.261551, -0.163628, 0.486671, 0.133923, 0.277437, -0.174814, 0.497620, 0.150849,
+ 0.296662, -0.186713, 0.511620, 0.169924, 0.317950, -0.198513, 0.525435, 0.190848,
+ 0.339422, -0.210119, 0.536267, 0.213504, 0.362143, -0.221354, 0.545982, 0.237947,
+ 0.387198, -0.232240, 0.555364, 0.264427, 0.412349, -0.242570, 0.561489, 0.292519,
+ 0.439274, -0.252284, 0.566903, 0.322561, 0.466779, -0.261023, 0.569614, 0.353952,
+ 0.496011, -0.268990, 0.571589, 0.387278, 0.524964, -0.275498, 0.570325, 0.421356,
+ 0.556518, -0.281449, 0.568792, 0.457314, 0.584363, -0.285526, 0.560268, 0.493199,
+ 0.614214, -0.288440, 0.552050, 0.530276, 0.645684, -0.289777, 0.541906, 0.568550,
+ 0.673446, -0.289722, 0.526464, 0.606927, 0.701924, -0.287792, 0.509872, 0.645945,
+ 0.730370, -0.284315, 0.490649, 0.685564, 0.757405, -0.278804, 0.467964, 0.726511,
+ 0.784025, -0.269543, 0.441468, 0.768601, 0.808255, -0.258117, 0.412160, 0.811321,
+ 0.830739, -0.244728, 0.380606, 0.853496, 0.851914, -0.229428, 0.348111, 0.895374,
+ 0.872586, -0.212508, 0.314732, 0.937674, 0.891581, -0.194025, 0.280338, 0.979869,
+ 0.907641, -0.174711, 0.245203, 1.022530, 0.922233, -0.153509, 0.210770, 1.063710,
+ 0.935878, -0.130418, 0.177399, 1.099720, 0.946338, -0.105558, 0.144507, 1.131240,
+ 0.957265, -0.080059, 0.110508, 1.159730, 0.971668, -0.053977, 0.074231, 1.185150,
+ 0.986600, -0.027710, 0.037522, 1.208580, 1.000210, -0.000516, 0.000135, 1.231350,
+ 0.137468, -0.000007, 0.345041, 0.000003, 0.137030, -0.000173, 0.343936, 0.000069,
+ 0.136986, -0.000693, 0.343830, 0.000276, 0.136964, -0.001559, 0.343761, 0.000621,
+ 0.137003, -0.002772, 0.343863, 0.001105, 0.137012, -0.004331, 0.343868, 0.001727,
+ 0.137043, -0.006236, 0.343916, 0.002490, 0.137090, -0.008487, 0.343986, 0.003396,
+ 0.137145, -0.011081, 0.344045, 0.004447, 0.137242, -0.014019, 0.344177, 0.005650,
+ 0.137431, -0.017271, 0.344491, 0.007019, 0.137644, -0.020861, 0.344805, 0.008560,
+ 0.137910, -0.024792, 0.345172, 0.010286, 0.138295, -0.029046, 0.345734, 0.012219,
+ 0.138764, -0.033596, 0.346371, 0.014377, 0.139415, -0.038467, 0.347298, 0.016789,
+ 0.140272, -0.043618, 0.348527, 0.019489, 0.141457, -0.049102, 0.350276, 0.022504,
+ 0.143030, -0.054876, 0.352646, 0.025896, 0.145289, -0.061010, 0.356206, 0.029717,
+ 0.148502, -0.067478, 0.361488, 0.034056, 0.152188, -0.074345, 0.367103, 0.038953,
+ 0.157359, -0.081744, 0.375247, 0.044554, 0.163790, -0.089633, 0.385064, 0.050953,
+ 0.171376, -0.098005, 0.396082, 0.058261, 0.179901, -0.106817, 0.407418, 0.066540,
+ 0.189892, -0.116239, 0.420031, 0.075994, 0.201838, -0.126270, 0.434321, 0.086724,
+ 0.214311, -0.136701, 0.447631, 0.098752, 0.228902, -0.147616, 0.462046, 0.112353,
+ 0.245107, -0.158871, 0.476942, 0.127605, 0.262292, -0.170261, 0.490285, 0.144469,
+ 0.281215, -0.182017, 0.503783, 0.163282, 0.301058, -0.193729, 0.515505, 0.183873,
+ 0.322752, -0.205512, 0.526820, 0.206466, 0.347547, -0.217214, 0.539473, 0.231194,
+ 0.370969, -0.227966, 0.546625, 0.257288, 0.397533, -0.238555, 0.554720, 0.285789,
+ 0.423980, -0.248278, 0.559468, 0.315746, 0.452928, -0.257422, 0.564095, 0.347724,
+ 0.482121, -0.265306, 0.565426, 0.380922, 0.510438, -0.272043, 0.563205, 0.415639,
+ 0.541188, -0.277614, 0.561087, 0.451702, 0.571667, -0.281927, 0.554922, 0.488450,
+ 0.602432, -0.285015, 0.546838, 0.526442, 0.634126, -0.286512, 0.537415, 0.564896,
+ 0.662816, -0.286388, 0.522906, 0.604037, 0.692411, -0.284734, 0.507003, 0.643795,
+ 0.720946, -0.281297, 0.488398, 0.682980, 0.748293, -0.276262, 0.466353, 0.723466,
+ 0.776931, -0.269978, 0.443573, 0.764565, 0.801065, -0.260305, 0.415279, 0.805838,
+ 0.825843, -0.247426, 0.384773, 0.849985, 0.848070, -0.232437, 0.352555, 0.893174,
+ 0.869122, -0.215806, 0.318642, 0.936564, 0.888963, -0.197307, 0.283810, 0.980253,
+ 0.905547, -0.177203, 0.247888, 1.024630, 0.918554, -0.155542, 0.212904, 1.067140,
+ 0.931395, -0.131948, 0.178700, 1.104510, 0.941749, -0.106723, 0.145902, 1.136940,
+ 0.954551, -0.080494, 0.111193, 1.166600, 0.970279, -0.053424, 0.074470, 1.192490,
+ 0.986117, -0.025745, 0.036879, 1.216650, 0.999938, 0.001906, -0.001029, 1.239810,
+ 0.118493, -0.000006, 0.322720, 0.000002, 0.118765, -0.000163, 0.323456, 0.000060,
+ 0.118772, -0.000652, 0.323477, 0.000239, 0.118843, -0.001467, 0.323657, 0.000539,
+ 0.118804, -0.002608, 0.323553, 0.000958, 0.118826, -0.004076, 0.323595, 0.001498,
+ 0.118846, -0.005868, 0.323617, 0.002160, 0.118886, -0.007986, 0.323670, 0.002947,
+ 0.118947, -0.010427, 0.323753, 0.003861, 0.119055, -0.013191, 0.323922, 0.004910,
+ 0.119241, -0.016244, 0.324251, 0.006108, 0.119440, -0.019634, 0.324544, 0.007458,
+ 0.119739, -0.023338, 0.325026, 0.008978, 0.120110, -0.027318, 0.325586, 0.010689,
+ 0.120571, -0.031614, 0.326231, 0.012607, 0.121240, -0.036194, 0.327264, 0.014765,
+ 0.122162, -0.041051, 0.328733, 0.017200, 0.123378, -0.046223, 0.330659, 0.019938,
+ 0.125183, -0.051711, 0.333754, 0.023050, 0.127832, -0.057565, 0.338507, 0.026597,
+ 0.130909, -0.063744, 0.343666, 0.030634, 0.135221, -0.070430, 0.351063, 0.035273,
+ 0.140820, -0.077636, 0.360604, 0.040614, 0.146781, -0.085229, 0.369638, 0.046679,
+ 0.155121, -0.093535, 0.382700, 0.053763, 0.163980, -0.102234, 0.395220, 0.061798,
+ 0.173926, -0.111465, 0.407930, 0.070970, 0.185137, -0.121296, 0.421050, 0.081343,
+ 0.198260, -0.131690, 0.435735, 0.093160, 0.212938, -0.142614, 0.450932, 0.106547,
+ 0.229046, -0.153884, 0.465726, 0.121575, 0.246246, -0.165382, 0.479461, 0.138286,
+ 0.264637, -0.176806, 0.492106, 0.156660, 0.284959, -0.188793, 0.504774, 0.177280,
+ 0.308157, -0.200763, 0.518805, 0.199880, 0.330951, -0.212390, 0.528231, 0.224293,
+ 0.354900, -0.223521, 0.536376, 0.250541, 0.381502, -0.234169, 0.544846, 0.278902,
+ 0.409529, -0.244077, 0.551717, 0.309227, 0.437523, -0.253363, 0.555170, 0.341426,
+ 0.467624, -0.261659, 0.557772, 0.375180, 0.497268, -0.268498, 0.556442, 0.410070,
+ 0.528294, -0.274018, 0.553915, 0.446445, 0.559053, -0.278169, 0.549153, 0.483779,
+ 0.589329, -0.281229, 0.539878, 0.522249, 0.622503, -0.282902, 0.531620, 0.561754,
+ 0.652382, -0.282815, 0.518119, 0.601544, 0.681847, -0.281247, 0.502187, 0.641574,
+ 0.712285, -0.277986, 0.484824, 0.682633, 0.740094, -0.273017, 0.463483, 0.723426,
+ 0.768478, -0.266692, 0.441299, 0.763747, 0.794556, -0.258358, 0.415238, 0.805565,
+ 0.819408, -0.248807, 0.386912, 0.847254, 0.843411, -0.236214, 0.356165, 0.891091,
+ 0.862397, -0.219794, 0.320562, 0.936174, 0.883113, -0.201768, 0.285322, 0.982562,
+ 0.900230, -0.181672, 0.249713, 1.028620, 0.915192, -0.159279, 0.214546, 1.071630,
+ 0.928458, -0.134725, 0.180285, 1.109950, 0.940690, -0.109130, 0.147119, 1.143540,
+ 0.953409, -0.082131, 0.112492, 1.173720, 0.969537, -0.054268, 0.075201, 1.200430,
+ 0.985612, -0.025910, 0.037036, 1.225280, 0.999835, 0.002982, -0.001518, 1.249590,
+ 0.100970, -0.000006, 0.300277, 0.000002, 0.101577, -0.000152, 0.302077, 0.000051,
+ 0.101572, -0.000609, 0.302066, 0.000205, 0.101566, -0.001370, 0.302047, 0.000461,
+ 0.101592, -0.002436, 0.302114, 0.000819, 0.101608, -0.003805, 0.302140, 0.001282,
+ 0.101627, -0.005479, 0.302160, 0.001848, 0.101669, -0.007456, 0.302224, 0.002522,
+ 0.101732, -0.009736, 0.302318, 0.003307, 0.101844, -0.012310, 0.302513, 0.004211,
+ 0.102025, -0.015168, 0.302850, 0.005245, 0.102224, -0.018333, 0.303166, 0.006415,
+ 0.102515, -0.021782, 0.303654, 0.007741, 0.102886, -0.025507, 0.304243, 0.009240,
+ 0.103395, -0.029514, 0.305089, 0.010934, 0.104109, -0.033791, 0.306301, 0.012856,
+ 0.105074, -0.038357, 0.307980, 0.015034, 0.106540, -0.043213, 0.310726, 0.017523,
+ 0.108478, -0.048424, 0.314351, 0.020365, 0.111015, -0.053934, 0.319032, 0.023633,
+ 0.114682, -0.059888, 0.326050, 0.027419, 0.119110, -0.066337, 0.334109, 0.031790,
+ 0.124736, -0.073301, 0.344013, 0.036850, 0.131479, -0.080774, 0.355358, 0.042710,
+ 0.139283, -0.088820, 0.367614, 0.049479, 0.148054, -0.097339, 0.380072, 0.057237,
+ 0.159037, -0.106650, 0.395678, 0.066270, 0.169794, -0.116221, 0.407950, 0.076319,
+ 0.183140, -0.126632, 0.423546, 0.087956, 0.197515, -0.137383, 0.438213, 0.101042,
+ 0.213514, -0.148641, 0.453248, 0.115827, 0.230650, -0.160117, 0.466880, 0.132283,
+ 0.249148, -0.171807, 0.479962, 0.150644, 0.270219, -0.183695, 0.494618, 0.171073,
+ 0.292338, -0.195574, 0.506937, 0.193378, 0.314999, -0.207205, 0.516463, 0.217585,
+ 0.340991, -0.218955, 0.528123, 0.244280, 0.367982, -0.229917, 0.537025, 0.272784,
+ 0.394320, -0.239737, 0.541627, 0.302742, 0.423364, -0.249048, 0.546466, 0.335112,
+ 0.453751, -0.257329, 0.549466, 0.369032, 0.484160, -0.264623, 0.549503, 0.404577,
+ 0.515262, -0.270411, 0.547008, 0.441337, 0.547036, -0.274581, 0.542249, 0.479162,
+ 0.576614, -0.277266, 0.533015, 0.517904, 0.611143, -0.279144, 0.525512, 0.558508,
+ 0.640989, -0.279001, 0.511540, 0.598995, 0.671182, -0.277324, 0.495641, 0.639935,
+ 0.700848, -0.273908, 0.477526, 0.681017, 0.729862, -0.269063, 0.457955, 0.722764,
+ 0.758273, -0.262282, 0.434846, 0.764349, 0.784121, -0.254281, 0.409203, 0.806206,
+ 0.809798, -0.245050, 0.382694, 0.848617, 0.834953, -0.233861, 0.354034, 0.892445,
+ 0.856817, -0.221308, 0.321764, 0.936263, 0.877609, -0.205996, 0.288118, 0.982401,
+ 0.897489, -0.186702, 0.253277, 1.029750, 0.913792, -0.164618, 0.217963, 1.074880,
+ 0.927850, -0.140023, 0.183221, 1.114870, 0.940378, -0.113280, 0.149385, 1.149470,
+ 0.952730, -0.085396, 0.114152, 1.180700, 0.969059, -0.056870, 0.076984, 1.209120,
+ 0.985574, -0.027650, 0.038119, 1.234980, 0.999943, 0.002391, -0.001269, 1.259870,
+ 0.085272, -0.000006, 0.279021, 0.000002, 0.085414, -0.000141, 0.279483, 0.000043,
+ 0.085419, -0.000563, 0.279500, 0.000172, 0.085419, -0.001268, 0.279493, 0.000387,
+ 0.085423, -0.002253, 0.279501, 0.000689, 0.085444, -0.003521, 0.279549, 0.001078,
+ 0.085470, -0.005070, 0.279591, 0.001555, 0.085509, -0.006899, 0.279652, 0.002124,
+ 0.085572, -0.009008, 0.279752, 0.002787, 0.085699, -0.011380, 0.280011, 0.003555,
+ 0.085855, -0.014031, 0.280297, 0.004434, 0.086068, -0.016963, 0.280682, 0.005436,
+ 0.086344, -0.020144, 0.281159, 0.006579, 0.086743, -0.023600, 0.281886, 0.007880,
+ 0.087239, -0.027307, 0.282745, 0.009361, 0.087982, -0.031269, 0.284139, 0.011056,
+ 0.089126, -0.035531, 0.286470, 0.013007, 0.090691, -0.040095, 0.289708, 0.015249,
+ 0.092762, -0.044964, 0.293904, 0.017845, 0.095838, -0.050243, 0.300471, 0.020892,
+ 0.099583, -0.055951, 0.308060, 0.024425, 0.104526, -0.062215, 0.317874, 0.028572,
+ 0.110532, -0.069005, 0.329332, 0.033423, 0.117385, -0.076307, 0.341217, 0.039047,
+ 0.125220, -0.084184, 0.353968, 0.045579, 0.134037, -0.092525, 0.366797, 0.053077,
+ 0.144014, -0.101487, 0.380209, 0.061742, 0.156013, -0.111273, 0.395956, 0.071777,
+ 0.168872, -0.121431, 0.410530, 0.083090, 0.183089, -0.132105, 0.425073, 0.095934,
+ 0.198763, -0.143286, 0.439833, 0.110448, 0.216159, -0.154841, 0.454507, 0.126769,
+ 0.234859, -0.166588, 0.468368, 0.144950, 0.255879, -0.178626, 0.482846, 0.165233,
+ 0.276770, -0.190218, 0.493489, 0.187217, 0.301184, -0.202227, 0.506549, 0.211659,
+ 0.325852, -0.213764, 0.515800, 0.237922, 0.352824, -0.224870, 0.525442, 0.266320,
+ 0.380882, -0.235246, 0.532487, 0.296691, 0.410137, -0.244847, 0.537703, 0.329179,
+ 0.439787, -0.253122, 0.540361, 0.363135, 0.472291, -0.260517, 0.542734, 0.399222,
+ 0.501856, -0.266519, 0.538826, 0.436352, 0.534816, -0.270905, 0.535152, 0.474505,
+ 0.565069, -0.273826, 0.525979, 0.513988, 0.597154, -0.275333, 0.516394, 0.554852,
+ 0.630473, -0.275314, 0.506206, 0.596592, 0.660574, -0.273323, 0.489769, 0.638117,
+ 0.692015, -0.270008, 0.472578, 0.680457, 0.720647, -0.265001, 0.452134, 0.723008,
+ 0.750528, -0.258311, 0.430344, 0.765954, 0.777568, -0.250046, 0.405624, 0.809012,
+ 0.803870, -0.240114, 0.378339, 0.852425, 0.828439, -0.228737, 0.349877, 0.895346,
+ 0.851472, -0.216632, 0.318968, 0.940695, 0.873906, -0.202782, 0.287489, 0.987235,
+ 0.894670, -0.187059, 0.254394, 1.033480, 0.912281, -0.168818, 0.221294, 1.078120,
+ 0.927358, -0.146494, 0.186750, 1.119280, 0.940385, -0.120009, 0.152322, 1.156090,
+ 0.952672, -0.091718, 0.117514, 1.188750, 0.968496, -0.062032, 0.079741, 1.218210,
+ 0.985236, -0.031495, 0.040238, 1.245230, 0.999980, -0.000575, 0.000111, 1.271330,
+ 0.070243, -0.000005, 0.255273, 0.000001, 0.070298, -0.000129, 0.255469, 0.000035,
+ 0.070369, -0.000516, 0.255727, 0.000142, 0.070380, -0.001160, 0.255754, 0.000319,
+ 0.070396, -0.002062, 0.255813, 0.000568, 0.070410, -0.003222, 0.255839, 0.000889,
+ 0.070430, -0.004639, 0.255863, 0.001283, 0.070476, -0.006314, 0.255953, 0.001753,
+ 0.070543, -0.008243, 0.256079, 0.002303, 0.070669, -0.010412, 0.256360, 0.002944,
+ 0.070819, -0.012844, 0.256647, 0.003680, 0.071036, -0.015518, 0.257084, 0.004526,
+ 0.071322, -0.018437, 0.257637, 0.005497, 0.071718, -0.021600, 0.258416, 0.006612,
+ 0.072321, -0.024997, 0.259699, 0.007901, 0.073145, -0.028657, 0.261475, 0.009388,
+ 0.074335, -0.032589, 0.264132, 0.011119, 0.076068, -0.036843, 0.268150, 0.013145,
+ 0.078454, -0.041429, 0.273636, 0.015525, 0.081862, -0.046463, 0.281653, 0.018353,
+ 0.085738, -0.051948, 0.289992, 0.021664, 0.090813, -0.057984, 0.300660, 0.025596,
+ 0.096751, -0.064512, 0.312204, 0.030195, 0.103717, -0.071651, 0.325001, 0.035602,
+ 0.111596, -0.079323, 0.338129, 0.041896, 0.120933, -0.087645, 0.352853, 0.049245,
+ 0.130787, -0.096492, 0.366192, 0.057675, 0.142311, -0.105973, 0.380864, 0.067397,
+ 0.155344, -0.116182, 0.396575, 0.078590, 0.169535, -0.126815, 0.411443, 0.091238,
+ 0.185173, -0.138015, 0.426256, 0.105607, 0.201755, -0.149325, 0.439607, 0.121551,
+ 0.221334, -0.161207, 0.455467, 0.139608, 0.241461, -0.173162, 0.469096, 0.159591,
+ 0.262940, -0.185040, 0.481014, 0.181560, 0.286776, -0.196881, 0.493291, 0.205781,
+ 0.311596, -0.208311, 0.503556, 0.231819, 0.338667, -0.219671, 0.513268, 0.260274,
+ 0.366021, -0.230451, 0.519414, 0.290862, 0.395875, -0.240131, 0.526766, 0.323196,
+ 0.425564, -0.248566, 0.529050, 0.357071, 0.457094, -0.256195, 0.530796, 0.393262,
+ 0.488286, -0.262331, 0.528703, 0.430797, 0.522291, -0.267141, 0.527270, 0.470231,
+ 0.554172, -0.270411, 0.519848, 0.510477, 0.586427, -0.271986, 0.510307, 0.551594,
+ 0.619638, -0.271920, 0.499158, 0.593849, 0.650656, -0.269817, 0.483852, 0.636314,
+ 0.682840, -0.266267, 0.467515, 0.679679, 0.714356, -0.261130, 0.449310, 0.723884,
+ 0.742717, -0.254067, 0.425789, 0.767245, 0.770894, -0.245652, 0.401144, 0.811819,
+ 0.797358, -0.235554, 0.374224, 0.856315, 0.823377, -0.223896, 0.346167, 0.901077,
+ 0.847456, -0.210865, 0.316056, 0.946502, 0.870697, -0.196574, 0.284503, 0.993711,
+ 0.891068, -0.180814, 0.251628, 1.041340, 0.909267, -0.163314, 0.219065, 1.086090,
+ 0.925653, -0.143304, 0.186446, 1.127020, 0.940017, -0.121322, 0.153416, 1.163710,
+ 0.952398, -0.097387, 0.120334, 1.197120, 0.967568, -0.069878, 0.083520, 1.227910,
+ 0.984772, -0.039003, 0.043921, 1.256720, 1.000260, -0.007009, 0.003157, 1.284280,
+ 0.055665, -0.000005, 0.227325, 0.000001, 0.056524, -0.000116, 0.230826, 0.000028,
+ 0.056572, -0.000466, 0.231026, 0.000114, 0.056586, -0.001048, 0.231079, 0.000257,
+ 0.056576, -0.001863, 0.231025, 0.000457, 0.056591, -0.002910, 0.231058, 0.000715,
+ 0.056611, -0.004190, 0.231085, 0.001032, 0.056653, -0.005702, 0.231169, 0.001412,
+ 0.056747, -0.007437, 0.231417, 0.001860, 0.056857, -0.009403, 0.231661, 0.002383,
+ 0.056986, -0.011599, 0.231895, 0.002987, 0.057222, -0.014010, 0.232456, 0.003690,
+ 0.057519, -0.016651, 0.233096, 0.004503, 0.057953, -0.019510, 0.234094, 0.005449,
+ 0.058592, -0.022599, 0.235629, 0.006556, 0.059565, -0.025942, 0.238106, 0.007857,
+ 0.060911, -0.029566, 0.241557, 0.009391, 0.062875, -0.033513, 0.246652, 0.011220,
+ 0.065691, -0.037860, 0.254091, 0.013417, 0.069135, -0.042654, 0.262666, 0.016037,
+ 0.073217, -0.047897, 0.272029, 0.019151, 0.078286, -0.053672, 0.283007, 0.022860,
+ 0.084397, -0.060068, 0.295732, 0.027283, 0.091360, -0.067009, 0.308779, 0.032484,
+ 0.099441, -0.074552, 0.322886, 0.038589, 0.108189, -0.082712, 0.336408, 0.045713,
+ 0.118574, -0.091493, 0.351692, 0.053983, 0.129989, -0.100854, 0.366502, 0.063516,
+ 0.142722, -0.110837, 0.381675, 0.074439, 0.156654, -0.121353, 0.396300, 0.086848,
+ 0.172151, -0.132414, 0.411477, 0.100963, 0.188712, -0.143809, 0.425080, 0.116795,
+ 0.208093, -0.155765, 0.441328, 0.134715, 0.227936, -0.167608, 0.454328, 0.154396,
+ 0.249495, -0.179579, 0.467235, 0.176179, 0.273620, -0.191488, 0.480248, 0.200193,
+ 0.296371, -0.202618, 0.487886, 0.225775, 0.324234, -0.214133, 0.499632, 0.254410,
+ 0.353049, -0.225212, 0.509532, 0.285077, 0.381785, -0.234875, 0.514265, 0.317047,
+ 0.414038, -0.244205, 0.521282, 0.351874, 0.445251, -0.252145, 0.522931, 0.388279,
+ 0.476819, -0.258433, 0.520947, 0.425825, 0.509209, -0.263411, 0.517669, 0.465104,
+ 0.542759, -0.266732, 0.512841, 0.505741, 0.574822, -0.268263, 0.503317, 0.547611,
+ 0.609324, -0.268489, 0.493035, 0.590953, 0.641772, -0.266941, 0.478816, 0.634880,
+ 0.674049, -0.263297, 0.462863, 0.679072, 0.705071, -0.257618, 0.442931, 0.723487,
+ 0.734709, -0.250625, 0.421299, 0.768708, 0.763704, -0.241790, 0.397085, 0.814375,
+ 0.791818, -0.231115, 0.370577, 0.859907, 0.817439, -0.219220, 0.342320, 0.906715,
+ 0.843202, -0.205658, 0.312627, 0.953943, 0.866639, -0.190563, 0.280933, 1.001850,
+ 0.888129, -0.173978, 0.248393, 1.051050, 0.907239, -0.155485, 0.216007, 1.097040,
+ 0.923893, -0.134782, 0.183233, 1.138570, 0.938882, -0.112490, 0.150376, 1.175390,
+ 0.952464, -0.089071, 0.117177, 1.209240, 0.968529, -0.064652, 0.081310, 1.240550,
+ 0.984763, -0.038606, 0.043938, 1.270180, 1.000530, -0.012380, 0.005987, 1.298730,
+ 0.043793, -0.000004, 0.204012, 0.000001, 0.044017, -0.000103, 0.205049, 0.000022,
+ 0.044053, -0.000414, 0.205225, 0.000089, 0.044049, -0.000931, 0.205200, 0.000200,
+ 0.043988, -0.001654, 0.204901, 0.000355, 0.044072, -0.002585, 0.205255, 0.000557,
+ 0.044097, -0.003722, 0.205311, 0.000805, 0.044136, -0.005065, 0.205391, 0.001103,
+ 0.044223, -0.006604, 0.205638, 0.001458, 0.044325, -0.008352, 0.205877, 0.001873,
+ 0.044483, -0.010299, 0.206270, 0.002359, 0.044700, -0.012445, 0.206796, 0.002930,
+ 0.045017, -0.014793, 0.207593, 0.003600, 0.045482, -0.017336, 0.208819, 0.004392,
+ 0.046245, -0.020116, 0.211036, 0.005339, 0.047369, -0.023157, 0.214388, 0.006470,
+ 0.049019, -0.026494, 0.219357, 0.007839, 0.051278, -0.030184, 0.226061, 0.009502,
+ 0.054128, -0.034266, 0.234094, 0.011516, 0.057899, -0.038854, 0.244297, 0.013969,
+ 0.062083, -0.043874, 0.254457, 0.016901, 0.067350, -0.049510, 0.266706, 0.020455,
+ 0.073176, -0.055626, 0.278753, 0.024661, 0.080394, -0.062459, 0.293090, 0.029713,
+ 0.087929, -0.069756, 0.305856, 0.035587, 0.097067, -0.077880, 0.321059, 0.042577,
+ 0.106508, -0.086354, 0.333873, 0.050560, 0.117760, -0.095593, 0.349008, 0.059897,
+ 0.130081, -0.105438, 0.363776, 0.070631, 0.144454, -0.115899, 0.380112, 0.082882,
+ 0.159600, -0.126827, 0.394843, 0.096761, 0.176097, -0.138161, 0.409033, 0.112381,
+ 0.194726, -0.149904, 0.424257, 0.129952, 0.213944, -0.161675, 0.436945, 0.149333,
+ 0.235516, -0.173659, 0.450176, 0.170892, 0.260564, -0.185963, 0.466305, 0.194984,
+ 0.285183, -0.197582, 0.477328, 0.220805, 0.311095, -0.208697, 0.486566, 0.248694,
+ 0.338924, -0.219519, 0.494811, 0.279015, 0.369757, -0.229766, 0.504065, 0.311725,
+ 0.399600, -0.238879, 0.507909, 0.345844, 0.430484, -0.246802, 0.509805, 0.381749,
+ 0.464130, -0.253924, 0.511436, 0.420251, 0.497077, -0.259319, 0.508787, 0.459957,
+ 0.530434, -0.263297, 0.503940, 0.501356, 0.565725, -0.265619, 0.498040, 0.544252,
+ 0.599254, -0.265842, 0.487346, 0.587856, 0.631251, -0.263978, 0.472975, 0.631969,
+ 0.663972, -0.260430, 0.457135, 0.677471, 0.697724, -0.255358, 0.439844, 0.723744,
+ 0.727725, -0.248308, 0.417872, 0.770653, 0.756417, -0.239181, 0.392730, 0.817357,
+ 0.785419, -0.228140, 0.367839, 0.864221, 0.812660, -0.215681, 0.339449, 0.912701,
+ 0.839391, -0.201623, 0.309279, 0.962419, 0.863660, -0.185624, 0.278029, 1.012200,
+ 0.885028, -0.167970, 0.245294, 1.061860, 0.904639, -0.148336, 0.212689, 1.109340,
+ 0.922048, -0.126370, 0.179616, 1.150630, 0.936952, -0.102928, 0.146749, 1.188850,
+ 0.951895, -0.078527, 0.112733, 1.223520, 0.967198, -0.053015, 0.076006, 1.256810,
+ 0.984405, -0.026490, 0.038318, 1.287620, 1.000210, 0.000700, -0.000200, 1.316560,
+ 0.032596, -0.000004, 0.176706, 0.000001, 0.032933, -0.000090, 0.178527, 0.000017,
+ 0.032918, -0.000360, 0.178453, 0.000066, 0.032909, -0.000809, 0.178383, 0.000149,
+ 0.032918, -0.001438, 0.178394, 0.000266, 0.032942, -0.002247, 0.178517, 0.000417,
+ 0.032951, -0.003236, 0.178490, 0.000603, 0.033011, -0.004399, 0.178695, 0.000829,
+ 0.033073, -0.005741, 0.178843, 0.001099, 0.033186, -0.007259, 0.179176, 0.001419,
+ 0.033344, -0.008953, 0.179618, 0.001800, 0.033567, -0.010822, 0.180238, 0.002253,
+ 0.033939, -0.012869, 0.181417, 0.002798, 0.034524, -0.015114, 0.183395, 0.003456,
+ 0.035446, -0.017596, 0.186616, 0.004259, 0.036831, -0.020352, 0.191547, 0.005249,
+ 0.038611, -0.023411, 0.197508, 0.006470, 0.041030, -0.026851, 0.205395, 0.007981,
+ 0.044224, -0.030748, 0.215365, 0.009856, 0.047866, -0.035086, 0.225595, 0.012142,
+ 0.052242, -0.039951, 0.236946, 0.014939, 0.057451, -0.045357, 0.249442, 0.018319,
+ 0.063121, -0.051286, 0.261222, 0.022364, 0.070112, -0.057927, 0.275418, 0.027242,
+ 0.077733, -0.065065, 0.288989, 0.032946, 0.086271, -0.072881, 0.302546, 0.039682,
+ 0.096103, -0.081363, 0.317164, 0.047570, 0.106976, -0.090446, 0.331733, 0.056701,
+ 0.119175, -0.100105, 0.346610, 0.067202, 0.132919, -0.110375, 0.362249, 0.079259,
+ 0.147727, -0.121115, 0.376978, 0.092867, 0.163618, -0.132299, 0.390681, 0.108228,
+ 0.182234, -0.143887, 0.406571, 0.125502, 0.201809, -0.155827, 0.420420, 0.144836,
+ 0.225041, -0.168357, 0.438411, 0.166706, 0.247621, -0.180040, 0.450368, 0.189909,
+ 0.270970, -0.191536, 0.460083, 0.215251, 0.296658, -0.203024, 0.469765, 0.243164,
+ 0.325892, -0.214056, 0.481837, 0.273388, 0.354060, -0.224104, 0.487474, 0.305344,
+ 0.384372, -0.233489, 0.492773, 0.339741, 0.417490, -0.241874, 0.498451, 0.376287,
+ 0.450130, -0.248834, 0.499632, 0.414195, 0.481285, -0.254658, 0.495233, 0.454077,
+ 0.519183, -0.259367, 0.496401, 0.496352, 0.551544, -0.261818, 0.487686, 0.538798,
+ 0.587349, -0.262964, 0.479453, 0.583626, 0.621679, -0.262128, 0.467709, 0.629451,
+ 0.654991, -0.258998, 0.452123, 0.675660, 0.686873, -0.254119, 0.433495, 0.723248,
+ 0.719801, -0.246946, 0.413657, 0.771156, 0.750355, -0.237709, 0.390366, 0.819890,
+ 0.780033, -0.226549, 0.364947, 0.868601, 0.809254, -0.214186, 0.337256, 0.920034,
+ 0.836576, -0.199639, 0.307395, 0.971706, 0.861774, -0.183169, 0.275431, 1.024790,
+ 0.885707, -0.165111, 0.243431, 1.078370, 0.904742, -0.144363, 0.210921, 1.127830,
+ 0.915604, -0.121305, 0.176470, 1.172540, 0.930959, -0.096212, 0.143106, 1.210120,
+ 0.948404, -0.069969, 0.108112, 1.244740, 0.967012, -0.042759, 0.070848, 1.277180,
+ 0.984183, -0.014704, 0.032335, 1.308300, 0.999577, 0.014216, -0.007269, 1.338200,
+ 0.022923, -0.000003, 0.148623, 0.000000, 0.023219, -0.000076, 0.150540, 0.000012,
+ 0.023231, -0.000304, 0.150630, 0.000047, 0.023235, -0.000683, 0.150624, 0.000105,
+ 0.023209, -0.001214, 0.150445, 0.000188, 0.023252, -0.001898, 0.150679, 0.000295,
+ 0.023283, -0.002732, 0.150789, 0.000428, 0.023337, -0.003713, 0.150995, 0.000591,
+ 0.023401, -0.004848, 0.151180, 0.000788, 0.023514, -0.006129, 0.151562, 0.001025,
+ 0.023679, -0.007561, 0.152116, 0.001314, 0.023956, -0.009147, 0.153162, 0.001666,
+ 0.024433, -0.010904, 0.155133, 0.002102, 0.025139, -0.012861, 0.158035, 0.002644,
+ 0.026260, -0.015063, 0.162751, 0.003329, 0.027787, -0.017553, 0.168944, 0.004198,
+ 0.029847, -0.020398, 0.176835, 0.005300, 0.032544, -0.023655, 0.186686, 0.006698,
+ 0.035558, -0.027298, 0.196248, 0.008427, 0.039284, -0.031446, 0.207352, 0.010585,
+ 0.043681, -0.036116, 0.219279, 0.013246, 0.048527, -0.041293, 0.230728, 0.016474,
+ 0.054157, -0.047034, 0.242994, 0.020372, 0.060948, -0.053500, 0.257042, 0.025095,
+ 0.068523, -0.060541, 0.271020, 0.030686, 0.076804, -0.068055, 0.284060, 0.037193,
+ 0.086484, -0.076501, 0.299186, 0.044979, 0.096941, -0.085267, 0.313200, 0.053832,
+ 0.108478, -0.094733, 0.327138, 0.064115, 0.121705, -0.104810, 0.342345, 0.075918,
+ 0.136743, -0.115474, 0.358472, 0.089412, 0.152986, -0.126536, 0.374067, 0.104562,
+ 0.170397, -0.138061, 0.388267, 0.121632, 0.191392, -0.150203, 0.406467, 0.140996,
+ 0.211566, -0.161751, 0.418641, 0.161696, 0.233567, -0.173407, 0.430418, 0.184557,
+ 0.257769, -0.185397, 0.442770, 0.210092, 0.285310, -0.197048, 0.457191, 0.237827,
+ 0.311726, -0.207840, 0.464712, 0.267253, 0.340537, -0.218345, 0.472539, 0.299332,
+ 0.372921, -0.228306, 0.482331, 0.333988, 0.402924, -0.236665, 0.484378, 0.369722,
+ 0.434475, -0.244097, 0.484717, 0.407836, 0.469736, -0.250547, 0.487093, 0.448465,
+ 0.505045, -0.255110, 0.485575, 0.490263, 0.540262, -0.258444, 0.481225, 0.534495,
+ 0.576347, -0.259903, 0.473481, 0.579451, 0.608656, -0.259572, 0.460300, 0.625604,
+ 0.646679, -0.257908, 0.450341, 0.674511, 0.679902, -0.253663, 0.431561, 0.723269,
+ 0.714159, -0.247419, 0.412684, 0.773263, 0.745345, -0.239122, 0.389388, 0.824182,
+ 0.778248, -0.228837, 0.365361, 0.876634, 0.807208, -0.216197, 0.337667, 0.929450,
+ 0.835019, -0.201772, 0.307197, 0.985261, 0.860261, -0.185291, 0.274205, 1.042990,
+ 0.877601, -0.165809, 0.240178, 1.098160, 0.898211, -0.143897, 0.207571, 1.146940,
+ 0.915789, -0.119513, 0.174904, 1.190080, 0.931831, -0.093292, 0.141423, 1.229700,
+ 0.949244, -0.065653, 0.105603, 1.265530, 0.967527, -0.037026, 0.067955, 1.299860,
+ 0.984139, -0.007301, 0.028313, 1.332520, 0.999713, 0.023465, -0.012179, 1.363970,
+ 0.015213, -0.000002, 0.122795, 0.000000, 0.015165, -0.000062, 0.122399, 0.000008,
+ 0.015118, -0.000246, 0.122023, 0.000030, 0.015120, -0.000553, 0.122030, 0.000069,
+ 0.015125, -0.000984, 0.122037, 0.000122, 0.015143, -0.001538, 0.122140, 0.000193,
+ 0.015171, -0.002210, 0.122237, 0.000281, 0.015211, -0.003007, 0.122380, 0.000391,
+ 0.015288, -0.003925, 0.122700, 0.000526, 0.015412, -0.004966, 0.123244, 0.000694,
+ 0.015620, -0.006133, 0.124228, 0.000905, 0.015966, -0.007441, 0.125945, 0.001173,
+ 0.016567, -0.008925, 0.129098, 0.001519, 0.017487, -0.010627, 0.133865, 0.001970,
+ 0.018839, -0.012604, 0.140682, 0.002564, 0.020554, -0.014881, 0.148534, 0.003336,
+ 0.022673, -0.017512, 0.157381, 0.004337, 0.025188, -0.020527, 0.166685, 0.005617,
+ 0.028363, -0.024032, 0.177796, 0.007256, 0.031869, -0.027943, 0.188251, 0.009288,
+ 0.036104, -0.032431, 0.200038, 0.011835, 0.040666, -0.037353, 0.210685, 0.014915,
+ 0.046385, -0.043013, 0.224182, 0.018725, 0.052570, -0.049101, 0.236340, 0.023228,
+ 0.059808, -0.055918, 0.250013, 0.028652, 0.067944, -0.063366, 0.263981, 0.035063,
+ 0.077118, -0.071460, 0.278072, 0.042588, 0.088127, -0.080350, 0.295110, 0.051449,
+ 0.099663, -0.089690, 0.309976, 0.061577, 0.112702, -0.099644, 0.325611, 0.073214,
+ 0.126488, -0.109829, 0.339321, 0.086232, 0.142625, -0.120859, 0.355740, 0.101275,
+ 0.159530, -0.131956, 0.369845, 0.117892, 0.176991, -0.143145, 0.381460, 0.136205,
+ 0.199715, -0.155292, 0.400520, 0.157252, 0.220787, -0.167066, 0.412055, 0.179966,
+ 0.243697, -0.178396, 0.423133, 0.204418, 0.272106, -0.190433, 0.439524, 0.232141,
+ 0.297637, -0.201265, 0.447041, 0.261109, 0.325273, -0.211834, 0.454488, 0.292627,
+ 0.357219, -0.221889, 0.465004, 0.326669, 0.387362, -0.230729, 0.468527, 0.362426,
+ 0.423131, -0.239240, 0.475836, 0.401533, 0.455430, -0.246067, 0.475017, 0.441902,
+ 0.493393, -0.251557, 0.478017, 0.484239, 0.526253, -0.255571, 0.470900, 0.528586,
+ 0.560554, -0.257752, 0.463167, 0.574346, 0.599306, -0.258076, 0.456452, 0.621655,
+ 0.634541, -0.256471, 0.443725, 0.670492, 0.668907, -0.253283, 0.428719, 0.721943,
+ 0.705619, -0.247562, 0.411348, 0.772477, 0.739034, -0.240626, 0.388939, 0.826400,
+ 0.771408, -0.231493, 0.364250, 0.881702, 0.803312, -0.220125, 0.337321, 0.938500,
+ 0.828457, -0.206645, 0.305364, 0.997437, 0.854819, -0.190664, 0.273715, 1.056930,
+ 0.878666, -0.171429, 0.242218, 1.112510, 0.898404, -0.149235, 0.209556, 1.163980,
+ 0.917416, -0.124350, 0.176863, 1.210140, 0.933133, -0.097270, 0.142775, 1.251780,
+ 0.950660, -0.068361, 0.106735, 1.290280, 0.968589, -0.037872, 0.068161, 1.327030,
+ 0.984776, -0.006057, 0.027397, 1.361580, 0.999940, 0.026328, -0.013812, 1.394300,
+ 0.008674, -0.000002, 0.092898, 0.000000, 0.008640, -0.000047, 0.092524, 0.000004,
+ 0.008646, -0.000187, 0.092581, 0.000017, 0.008641, -0.000420, 0.092490, 0.000039,
+ 0.008639, -0.000746, 0.092459, 0.000070, 0.008685, -0.001165, 0.092900, 0.000111,
+ 0.008697, -0.001677, 0.092853, 0.000164, 0.008743, -0.002281, 0.093091, 0.000231,
+ 0.008827, -0.002979, 0.093568, 0.000317, 0.008989, -0.003776, 0.094617, 0.000430,
+ 0.009293, -0.004692, 0.096741, 0.000580, 0.009783, -0.005755, 0.100084, 0.000784,
+ 0.010575, -0.007015, 0.105447, 0.001063, 0.011695, -0.008518, 0.112494, 0.001447,
+ 0.013042, -0.010276, 0.119876, 0.001964, 0.014837, -0.012381, 0.129034, 0.002664,
+ 0.016872, -0.014820, 0.137812, 0.003584, 0.019369, -0.017656, 0.147696, 0.004781,
+ 0.022269, -0.020921, 0.157795, 0.006317, 0.025689, -0.024665, 0.168431, 0.008263,
+ 0.029469, -0.028860, 0.178587, 0.010671, 0.034041, -0.033644, 0.190251, 0.013663,
+ 0.039392, -0.039033, 0.202999, 0.017327, 0.045395, -0.045009, 0.215655, 0.021745,
+ 0.052194, -0.051546, 0.228686, 0.026994, 0.060028, -0.058817, 0.242838, 0.033272,
+ 0.069240, -0.066723, 0.258145, 0.040646, 0.079383, -0.075240, 0.273565, 0.049224,
+ 0.090230, -0.084185, 0.287735, 0.059011, 0.102014, -0.093648, 0.301161, 0.070202,
+ 0.116054, -0.103967, 0.317438, 0.083200, 0.131910, -0.114622, 0.334166, 0.097795,
+ 0.148239, -0.125452, 0.348192, 0.113985, 0.165809, -0.136453, 0.361094, 0.131928,
+ 0.184616, -0.147648, 0.373534, 0.151811, 0.207491, -0.159607, 0.391010, 0.174476,
+ 0.230106, -0.171119, 0.402504, 0.198798, 0.257036, -0.182906, 0.418032, 0.225796,
+ 0.281172, -0.193605, 0.425468, 0.254027, 0.312034, -0.204771, 0.440379, 0.285713,
+ 0.340402, -0.214988, 0.445406, 0.319196, 0.370231, -0.224711, 0.449680, 0.355370,
+ 0.407105, -0.233516, 0.460747, 0.393838, 0.439037, -0.240801, 0.460624, 0.433747,
+ 0.477810, -0.247620, 0.465957, 0.477234, 0.510655, -0.251823, 0.460054, 0.520440,
+ 0.550584, -0.255552, 0.459172, 0.567853, 0.585872, -0.257036, 0.450311, 0.615943,
+ 0.620466, -0.257535, 0.437763, 0.667693, 0.660496, -0.255248, 0.426639, 0.718988,
+ 0.695578, -0.251141, 0.409185, 0.772503, 0.732176, -0.244718, 0.390150, 0.827023,
+ 0.760782, -0.236782, 0.362594, 0.885651, 0.794220, -0.225923, 0.337110, 0.943756,
+ 0.824521, -0.213855, 0.308272, 1.008740, 0.854964, -0.197723, 0.278529, 1.067640,
+ 0.878065, -0.179209, 0.246208, 1.128360, 0.899834, -0.157569, 0.213290, 1.183180,
+ 0.918815, -0.133206, 0.181038, 1.231610, 0.934934, -0.106545, 0.146993, 1.276440,
+ 0.952115, -0.078057, 0.111175, 1.318420, 0.969060, -0.047828, 0.072855, 1.358390,
+ 0.985178, -0.016001, 0.032579, 1.396970, 1.000390, 0.017313, -0.009526, 1.433120,
+ 0.003841, -0.000001, 0.061358, 0.000000, 0.003900, -0.000031, 0.062292, 0.000002,
+ 0.003900, -0.000126, 0.062263, 0.000008, 0.003895, -0.000282, 0.062066, 0.000018,
+ 0.003916, -0.000503, 0.062469, 0.000032, 0.003927, -0.000784, 0.062511, 0.000052,
+ 0.003961, -0.001129, 0.062817, 0.000078, 0.004019, -0.001538, 0.063329, 0.000114,
+ 0.004150, -0.002021, 0.064644, 0.000164, 0.004412, -0.002600, 0.067389, 0.000238,
+ 0.004844, -0.003310, 0.071653, 0.000346, 0.005491, -0.004190, 0.077500, 0.000506,
+ 0.006363, -0.005273, 0.084476, 0.000739, 0.007466, -0.006604, 0.092133, 0.001073,
+ 0.008766, -0.008188, 0.099707, 0.001537, 0.010313, -0.010081, 0.107433, 0.002172,
+ 0.012331, -0.012364, 0.117088, 0.003034, 0.014627, -0.015001, 0.126438, 0.004160,
+ 0.017229, -0.018053, 0.135672, 0.005615, 0.020425, -0.021596, 0.146244, 0.007478,
+ 0.024160, -0.025623, 0.157481, 0.009810, 0.028469, -0.030221, 0.169125, 0.012715,
+ 0.033445, -0.035333, 0.181659, 0.016245, 0.039125, -0.041085, 0.194400, 0.020542,
+ 0.045472, -0.047345, 0.207082, 0.025633, 0.053098, -0.054286, 0.221656, 0.031704,
+ 0.061536, -0.061838, 0.236036, 0.038832, 0.070336, -0.069763, 0.248398, 0.046974,
+ 0.081039, -0.078476, 0.263611, 0.056525, 0.092014, -0.087349, 0.275857, 0.067172,
+ 0.105584, -0.097365, 0.292555, 0.079811, 0.119506, -0.107271, 0.306333, 0.093594,
+ 0.134434, -0.117608, 0.318888, 0.109106, 0.153399, -0.128938, 0.337552, 0.127074,
+ 0.171258, -0.139944, 0.349955, 0.146430, 0.191059, -0.151288, 0.361545, 0.168000,
+ 0.215069, -0.163018, 0.378421, 0.192082, 0.237838, -0.174226, 0.388790, 0.217838,
+ 0.266965, -0.186063, 0.405857, 0.246931, 0.292827, -0.196909, 0.414146, 0.277505,
+ 0.324352, -0.207473, 0.426955, 0.310711, 0.354427, -0.217713, 0.433429, 0.346794,
+ 0.389854, -0.227183, 0.443966, 0.385237, 0.420749, -0.235131, 0.444710, 0.424955,
+ 0.459597, -0.242786, 0.451729, 0.468446, 0.495316, -0.248767, 0.450720, 0.513422,
+ 0.534903, -0.253351, 0.450924, 0.560618, 0.572369, -0.256277, 0.445266, 0.609677,
+ 0.612383, -0.257600, 0.438798, 0.660995, 0.644037, -0.256931, 0.421693, 0.713807,
+ 0.686749, -0.254036, 0.410900, 0.767616, 0.719814, -0.249785, 0.390151, 0.825330,
+ 0.754719, -0.244283, 0.367847, 0.888311, 0.792022, -0.235076, 0.345013, 0.948177,
+ 0.822404, -0.225061, 0.316193, 1.016610, 0.853084, -0.211113, 0.287013, 1.080750,
+ 0.879871, -0.194490, 0.255424, 1.145010, 0.901655, -0.174023, 0.222879, 1.202030,
+ 0.919957, -0.150900, 0.189890, 1.256980, 0.938412, -0.124923, 0.156060, 1.305880,
+ 0.953471, -0.096814, 0.120512, 1.352900, 0.970451, -0.066734, 0.082851, 1.398600,
+ 0.985522, -0.034734, 0.042446, 1.441480, 1.000990, -0.001022, 0.000679, 1.483980,
+ 0.000965, -0.000001, 0.030641, 0.000000, 0.000992, -0.000016, 0.031464, 0.000000,
+ 0.000991, -0.000063, 0.031363, 0.000002, 0.000975, -0.000141, 0.030360, 0.000005,
+ 0.000998, -0.000253, 0.031496, 0.000009, 0.001022, -0.000397, 0.031996, 0.000015,
+ 0.001079, -0.000578, 0.033138, 0.000025, 0.001216, -0.000817, 0.035940, 0.000042,
+ 0.001445, -0.001138, 0.039965, 0.000072, 0.001788, -0.001570, 0.045056, 0.000124,
+ 0.002257, -0.002141, 0.050803, 0.000209, 0.002856, -0.002877, 0.056844, 0.000342,
+ 0.003599, -0.003803, 0.063089, 0.000544, 0.004555, -0.004963, 0.070220, 0.000842,
+ 0.005691, -0.006379, 0.077343, 0.001267, 0.007169, -0.008135, 0.086084, 0.001866,
+ 0.008853, -0.010195, 0.094408, 0.002670, 0.010932, -0.012639, 0.103951, 0.003740,
+ 0.013370, -0.015488, 0.113786, 0.005130, 0.016153, -0.018732, 0.123477, 0.006889,
+ 0.019427, -0.022465, 0.133986, 0.009106, 0.023097, -0.026598, 0.143979, 0.011807,
+ 0.027363, -0.031285, 0.154645, 0.015127, 0.032390, -0.036595, 0.166765, 0.019179,
+ 0.037922, -0.042291, 0.177932, 0.023924, 0.044750, -0.048747, 0.191670, 0.029657,
+ 0.051939, -0.055640, 0.203224, 0.036292, 0.059946, -0.063165, 0.215652, 0.044059,
+ 0.070243, -0.071431, 0.232089, 0.053162, 0.080690, -0.080061, 0.245258, 0.063456,
+ 0.092319, -0.089281, 0.258609, 0.075248, 0.106938, -0.099310, 0.276654, 0.088891,
+ 0.121238, -0.109575, 0.289847, 0.104055, 0.138817, -0.120461, 0.307566, 0.121266,
+ 0.155950, -0.131209, 0.320117, 0.139944, 0.178418, -0.143049, 0.339677, 0.161591,
+ 0.197875, -0.154074, 0.349886, 0.184303, 0.224368, -0.166307, 0.369352, 0.210669,
+ 0.252213, -0.178051, 0.386242, 0.238895, 0.277321, -0.189335, 0.395294, 0.269182,
+ 0.310332, -0.200683, 0.412148, 0.302508, 0.338809, -0.210856, 0.418266, 0.337264,
+ 0.372678, -0.220655, 0.428723, 0.374881, 0.405632, -0.230053, 0.433887, 0.415656,
+ 0.442293, -0.237993, 0.439911, 0.457982, 0.477256, -0.244897, 0.440175, 0.502831,
+ 0.515592, -0.250657, 0.441079, 0.550277, 0.550969, -0.255459, 0.435219, 0.601102,
+ 0.592883, -0.257696, 0.432882, 0.651785, 0.629092, -0.259894, 0.421054, 0.708961,
+ 0.672033, -0.258592, 0.411770, 0.763806, 0.709147, -0.256525, 0.395267, 0.824249,
+ 0.745367, -0.254677, 0.375013, 0.895100, 0.784715, -0.247892, 0.353906, 0.959317,
+ 0.818107, -0.240162, 0.327801, 1.031530, 0.847895, -0.229741, 0.298821, 1.106010,
+ 0.879603, -0.213084, 0.269115, 1.164000, 0.902605, -0.195242, 0.236606, 1.228540,
+ 0.922788, -0.174505, 0.203442, 1.290170, 0.944831, -0.150169, 0.169594, 1.341570,
+ 0.959656, -0.124099, 0.135909, 1.395600, 0.972399, -0.096063, 0.099056, 1.451280,
+ 0.986549, -0.065710, 0.060235, 1.503120, 1.000130, -0.033356, 0.018669, 1.553640,
+ 0.000006, -0.000000, 0.007783, 0.000000, 0.000000, -0.000000, 0.000028, 0.000000,
+ 0.000001, -0.000002, 0.000250, 0.000000, 0.000004, -0.000006, 0.000357, 0.000000,
+ 0.000008, -0.000017, 0.000516, 0.000000, 0.000024, -0.000045, 0.001022, 0.000001,
+ 0.000046, -0.000089, 0.001443, 0.000004, 0.000097, -0.000178, 0.002419, 0.000010,
+ 0.000171, -0.000314, 0.003549, 0.000024, 0.000293, -0.000520, 0.005138, 0.000050,
+ 0.000790, -0.001182, 0.023862, 0.000139, 0.001141, -0.001718, 0.028669, 0.000244,
+ 0.001761, -0.002497, 0.036857, 0.000421, 0.002223, -0.003337, 0.040047, 0.000657,
+ 0.003434, -0.004820, 0.053575, 0.001093, 0.004276, -0.006008, 0.057099, 0.001553,
+ 0.004614, -0.007376, 0.055108, 0.002150, 0.006957, -0.009714, 0.071577, 0.003165,
+ 0.008676, -0.012094, 0.079331, 0.004370, 0.010669, -0.014820, 0.086939, 0.005896,
+ 0.014035, -0.018350, 0.101572, 0.007988, 0.016894, -0.022006, 0.110180, 0.010423,
+ 0.020197, -0.026157, 0.119041, 0.013417, 0.025470, -0.031278, 0.135404, 0.017301,
+ 0.029838, -0.036247, 0.143700, 0.021543, 0.035159, -0.042237, 0.155120, 0.026888,
+ 0.042769, -0.048871, 0.171280, 0.033235, 0.049485, -0.055800, 0.181813, 0.040444,
+ 0.059239, -0.063558, 0.198745, 0.049004, 0.068146, -0.071838, 0.210497, 0.058824,
+ 0.080475, -0.080930, 0.228864, 0.070283, 0.094220, -0.090649, 0.247008, 0.083401,
+ 0.106777, -0.100216, 0.258812, 0.097595, 0.124471, -0.110827, 0.278617, 0.114162,
+ 0.138389, -0.121193, 0.287049, 0.131983, 0.159543, -0.132530, 0.307151, 0.152541,
+ 0.176432, -0.143611, 0.315640, 0.174673, 0.201723, -0.155480, 0.335380, 0.199842,
+ 0.229721, -0.167166, 0.355256, 0.227097, 0.250206, -0.178238, 0.360047, 0.256014,
+ 0.282118, -0.189905, 0.378761, 0.288550, 0.312821, -0.201033, 0.391810, 0.323348,
+ 0.341482, -0.211584, 0.397716, 0.360564, 0.377368, -0.221314, 0.410141, 0.400004,
+ 0.418229, -0.230474, 0.423485, 0.442371, 0.444881, -0.239443, 0.418874, 0.488796,
+ 0.488899, -0.245987, 0.427545, 0.535012, 0.520317, -0.253948, 0.422147, 0.589678,
+ 0.568566, -0.256616, 0.427190, 0.637683, 0.599607, -0.263760, 0.415114, 0.703363,
+ 0.642220, -0.268687, 0.408715, 0.771363, 0.685698, -0.269400, 0.399722, 0.835740,
+ 0.732327, -0.266642, 0.388651, 0.897764, 0.769873, -0.267712, 0.369198, 0.983312,
+ 0.806733, -0.263479, 0.346802, 1.062220, 0.843466, -0.254575, 0.321368, 1.134770,
+ 0.873008, -0.242749, 0.292110, 1.207120, 0.908438, -0.227250, 0.262143, 1.274650,
+ 0.936321, -0.207621, 0.228876, 1.332030, 0.950353, -0.187932, 0.194840, 1.404390,
+ 0.964420, -0.165154, 0.163178, 1.473200, 0.979856, -0.139302, 0.127531, 1.535740,
+ 0.982561, -0.111340, 0.090346, 1.599820, 0.996389, -0.080812, 0.048901, 1.657700,
};
-static float ltc_mag_ggx[64 * 64] = {
- 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
- 1.000000, 1.000000, 1.000000, 0.999995, 0.999990, 0.999971, 0.999937, 0.999853, 0.999670,
- 0.999138, 0.996746, 0.979578, 0.979309, 0.978836, 0.977972, 0.976223, 0.972205, 0.962466,
- 0.953919, 0.949829, 0.942492, 0.929870, 0.921319, 0.911112, 0.896015, 0.885105, 0.869971,
- 0.855017, 0.838328, 0.821241, 0.802352, 0.783873, 0.763309, 0.743058, 0.721929, 0.699755,
- 0.677721, 0.655456, 0.632681, 0.609629, 0.586831, 0.564287, 0.541772, 0.519428, 0.497353,
- 0.475624, 0.454606, 0.434099, 0.414085, 0.394605, 0.375698, 0.357386, 0.339871, 0.323085,
- 0.306905, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
- 0.999999, 0.999999, 0.999998, 0.999995, 0.999990, 0.999980, 0.999959, 0.999923, 0.999842,
- 0.999660, 0.999119, 0.996613, 0.981824, 0.979298, 0.978826, 0.977957, 0.976184, 0.972091,
- 0.962188, 0.953875, 0.949746, 0.942335, 0.930166, 0.921211, 0.910927, 0.896979, 0.884940,
- 0.869864, 0.854835, 0.838200, 0.821049, 0.802552, 0.783659, 0.763512, 0.742927, 0.721715,
- 0.699938, 0.677775, 0.655246, 0.632555, 0.609805, 0.586996, 0.564225, 0.541606, 0.519346,
- 0.497419, 0.475863, 0.454738, 0.434099, 0.414003, 0.394547, 0.375747, 0.357564, 0.340012,
- 0.323099, 0.306861, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
- 1.000000, 1.000000, 0.999999, 0.999998, 0.999995, 0.999991, 0.999979, 0.999959, 0.999917,
- 0.999839, 0.999648, 0.999074, 0.996168, 0.983770, 0.979279, 0.978800, 0.977905, 0.976058,
- 0.971727, 0.962120, 0.953901, 0.949485, 0.941859, 0.930911, 0.920853, 0.910394, 0.897600,
- 0.884427, 0.870101, 0.854522, 0.838325, 0.820754, 0.802707, 0.783223, 0.763605, 0.742872,
- 0.721565, 0.699935, 0.677726, 0.655242, 0.632580, 0.609766, 0.586946, 0.564275, 0.541759,
- 0.519467, 0.497478, 0.475886, 0.454794, 0.434233, 0.414207, 0.394751, 0.375892, 0.357683,
- 0.340146, 0.323287, 0.307095, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
- 1.000000, 0.999999, 0.999999, 0.999998, 0.999996, 0.999992, 0.999987, 0.999975, 0.999953,
- 0.999913, 0.999830, 0.999630, 0.998993, 0.995279, 0.985142, 0.979252, 0.978754, 0.977821,
- 0.975838, 0.971088, 0.962563, 0.954785, 0.949048, 0.941052, 0.931420, 0.920812, 0.909750,
- 0.897867, 0.883856, 0.870091, 0.854353, 0.838166, 0.820661, 0.802465, 0.783308, 0.763346,
- 0.742734, 0.721608, 0.699747, 0.677626, 0.655245, 0.632547, 0.609793, 0.587044, 0.564340,
- 0.541779, 0.519529, 0.497633, 0.476114, 0.455030, 0.434430, 0.414406, 0.394974, 0.376154,
- 0.357979, 0.340443, 0.323572, 0.307379, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
- 1.000000, 1.000000, 1.000000, 0.999998, 0.999998, 0.999996, 0.999991, 0.999984, 0.999970,
- 0.999946, 0.999905, 0.999815, 0.999599, 0.998856, 0.993704, 0.986135, 0.979212, 0.978690,
- 0.977691, 0.975504, 0.970133, 0.962951, 0.955649, 0.948405, 0.940418, 0.931660, 0.920881,
- 0.909376, 0.897785, 0.883844, 0.869756, 0.854326, 0.837732, 0.820617, 0.802053, 0.783195,
- 0.763119, 0.742610, 0.721344, 0.699709, 0.677624, 0.655114, 0.632523, 0.609812, 0.587052,
- 0.564417, 0.541966, 0.519751, 0.497824, 0.476309, 0.455271, 0.434735, 0.414736, 0.395317,
- 0.376524, 0.358364, 0.340852, 0.323988, 0.307786, 1.000000, 1.000000, 1.000000, 1.000000,
- 1.000000, 1.000000, 0.999999, 0.999999, 0.999997, 0.999996, 0.999994, 0.999989, 0.999980,
- 0.999965, 0.999940, 0.999895, 0.999796, 0.999559, 0.998638, 0.992774, 0.986878, 0.980297,
- 0.978602, 0.977514, 0.975026, 0.969169, 0.963214, 0.956267, 0.947689, 0.940054, 0.931637,
- 0.920678, 0.908990, 0.897349, 0.883905, 0.869139, 0.854177, 0.837476, 0.820295, 0.801977,
- 0.782798, 0.762978, 0.742418, 0.721193, 0.699560, 0.677402, 0.655108, 0.632543, 0.609804,
- 0.587158, 0.564557, 0.542096, 0.519908, 0.498088, 0.476632, 0.455623, 0.435104, 0.415161,
- 0.395783, 0.377005, 0.358843, 0.341345, 0.324529, 0.308355, 1.000000, 1.000000, 1.000000,
- 1.000000, 1.000000, 0.999999, 0.999999, 0.999998, 0.999997, 0.999992, 0.999991, 0.999985,
- 0.999977, 0.999959, 0.999935, 0.999878, 0.999773, 0.999505, 0.998284, 0.992353, 0.987457,
- 0.981665, 0.978492, 0.977277, 0.974360, 0.968716, 0.963373, 0.956629, 0.947397, 0.939657,
- 0.931339, 0.920588, 0.908975, 0.896712, 0.883763, 0.868890, 0.853731, 0.837333, 0.819702,
- 0.801738, 0.782454, 0.762712, 0.742024, 0.721037, 0.699325, 0.677359, 0.655030, 0.632439,
- 0.609869, 0.587221, 0.564663, 0.542328, 0.520220, 0.498400, 0.476997, 0.456053, 0.435593,
- 0.415658, 0.396300, 0.377577, 0.359473, 0.342004, 0.325170, 0.308997, 1.000000, 1.000000,
- 1.000000, 1.000000, 1.000000, 0.999999, 0.999998, 0.999998, 0.999996, 0.999993, 0.999988,
- 0.999981, 0.999971, 0.999951, 0.999921, 0.999863, 0.999748, 0.999433, 0.997681, 0.992120,
- 0.987920, 0.982864, 0.978353, 0.976961, 0.973451, 0.968396, 0.963400, 0.956680, 0.947529,
- 0.939151, 0.930747, 0.920511, 0.908867, 0.896142, 0.883335, 0.868764, 0.853025, 0.837015,
- 0.819452, 0.801249, 0.782176, 0.762345, 0.741843, 0.720721, 0.699135, 0.677194, 0.654889,
- 0.632487, 0.609902, 0.587328, 0.564891, 0.542567, 0.520501, 0.498793, 0.477442, 0.456528,
- 0.436131, 0.416273, 0.396980, 0.378276, 0.360176, 0.342738, 0.325950, 0.309803, 1.000000,
- 1.000000, 1.000000, 1.000000, 0.999999, 0.999998, 0.999999, 0.999997, 0.999995, 0.999991,
- 0.999985, 0.999978, 0.999963, 0.999942, 0.999907, 0.999844, 0.999715, 0.999332, 0.996612,
- 0.991974, 0.988297, 0.983843, 0.978349, 0.976540, 0.972351, 0.968109, 0.963280, 0.956464,
- 0.947779, 0.938754, 0.929952, 0.920253, 0.908530, 0.895785, 0.882679, 0.868456, 0.852669,
- 0.836406, 0.819138, 0.800708, 0.781803, 0.761855, 0.741534, 0.720405, 0.698959, 0.676964,
- 0.654827, 0.632411, 0.609922, 0.587477, 0.565051, 0.542829, 0.520889, 0.499225, 0.477951,
- 0.457148, 0.436792, 0.416963, 0.397723, 0.379068, 0.361025, 0.343608, 0.326842, 0.310718,
- 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999999, 0.999998, 0.999995, 0.999994,
- 0.999990, 0.999983, 0.999971, 0.999954, 0.999932, 0.999892, 0.999820, 0.999675, 0.999190,
- 0.995492, 0.991911, 0.988610, 0.984662, 0.979221, 0.975975, 0.971671, 0.967788, 0.963002,
- 0.955938, 0.947965, 0.938692, 0.929309, 0.919781, 0.908268, 0.895518, 0.882022, 0.867884,
- 0.852346, 0.835746, 0.818607, 0.800261, 0.781335, 0.761539, 0.741063, 0.720116, 0.698617,
- 0.676815, 0.654700, 0.632389, 0.610037, 0.587591, 0.565328, 0.543205, 0.521293, 0.499745,
- 0.478562, 0.457776, 0.437515, 0.417776, 0.398586, 0.379963, 0.361984, 0.344616, 0.327857,
- 0.311751, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999999, 0.999997, 0.999996,
- 0.999992, 0.999986, 0.999977, 0.999965, 0.999947, 0.999916, 0.999873, 0.999794, 0.999628,
- 0.998966, 0.994914, 0.991849, 0.988873, 0.985288, 0.980170, 0.975207, 0.971156, 0.967476,
- 0.962538, 0.955601, 0.947978, 0.938542, 0.928618, 0.919056, 0.907890, 0.895098, 0.881352,
- 0.867263, 0.851806, 0.835168, 0.818003, 0.799785, 0.780633, 0.761080, 0.740618, 0.719795,
- 0.698332, 0.676629, 0.654544, 0.632411, 0.610042, 0.587805, 0.565593, 0.543549, 0.521793,
- 0.500309, 0.479195, 0.458546, 0.438353, 0.418669, 0.399557, 0.381012, 0.363049, 0.345710,
- 0.329006, 0.312948, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999999, 0.999997,
- 0.999993, 0.999990, 0.999984, 0.999972, 0.999960, 0.999939, 0.999906, 0.999853, 0.999765,
- 0.999567, 0.998603, 0.994519, 0.991794, 0.989089, 0.985781, 0.980956, 0.974161, 0.970688,
- 0.967064, 0.961890, 0.955292, 0.947848, 0.938359, 0.928226, 0.918214, 0.907361, 0.894702,
- 0.880834, 0.866500, 0.851209, 0.834627, 0.817211, 0.799250, 0.780131, 0.760512, 0.740218,
- 0.719264, 0.698063, 0.676325, 0.654450, 0.632316, 0.610170, 0.587988, 0.565891, 0.544013,
- 0.522305, 0.500958, 0.479971, 0.459376, 0.439271, 0.419699, 0.400620, 0.382126, 0.364246,
- 0.346967, 0.330273, 0.314236, 1.000000, 1.000000, 1.000000, 1.000000, 0.999999, 0.999998,
- 0.999996, 0.999994, 0.999988, 0.999979, 0.999967, 0.999952, 0.999924, 0.999888, 0.999833,
- 0.999733, 0.999490, 0.997946, 0.994192, 0.991812, 0.989274, 0.986224, 0.981547, 0.974000,
- 0.970269, 0.966545, 0.961031, 0.954921, 0.947416, 0.938226, 0.928003, 0.917390, 0.906553,
- 0.894191, 0.880329, 0.865540, 0.850476, 0.834058, 0.816467, 0.798509, 0.779561, 0.759828,
- 0.739738, 0.718878, 0.697718, 0.676138, 0.654342, 0.632317, 0.610292, 0.588207, 0.566289,
- 0.544443, 0.522927, 0.501674, 0.480765, 0.460314, 0.440304, 0.420782, 0.401824, 0.383410,
- 0.365538, 0.348312, 0.331692, 0.315688, 1.000000, 1.000000, 1.000000, 1.000000, 0.999999,
- 0.999998, 0.999996, 0.999993, 0.999985, 0.999976, 0.999961, 0.999943, 0.999913, 0.999872,
- 0.999807, 0.999691, 0.999390, 0.996859, 0.994003, 0.991808, 0.989423, 0.986523, 0.981783,
- 0.974511, 0.969791, 0.965933, 0.960377, 0.954434, 0.946803, 0.938026, 0.927620, 0.916545,
- 0.905639, 0.893489, 0.879820, 0.864852, 0.849513, 0.833311, 0.815878, 0.797621, 0.778938,
- 0.759253, 0.739142, 0.718479, 0.697274, 0.675902, 0.654135, 0.632357, 0.610364, 0.588497,
- 0.566631, 0.545012, 0.523579, 0.502429, 0.481680, 0.461304, 0.441425, 0.422039, 0.403135,
- 0.384779, 0.366976, 0.349796, 0.333231, 0.317277, 1.000000, 1.000000, 1.000000, 1.000000,
- 0.999999, 0.999998, 0.999996, 0.999991, 0.999983, 0.999974, 0.999956, 0.999932, 0.999901,
- 0.999852, 0.999780, 0.999646, 0.999248, 0.996193, 0.993784, 0.991782, 0.989539, 0.986694,
- 0.981765, 0.975135, 0.969309, 0.965128, 0.959788, 0.953831, 0.946255, 0.937664, 0.927351,
- 0.916044, 0.904715, 0.892528, 0.879111, 0.864256, 0.848452, 0.832434, 0.815129, 0.796806,
- 0.778118, 0.758668, 0.738466, 0.718024, 0.696958, 0.675642, 0.654067, 0.632325, 0.610546,
- 0.588786, 0.567123, 0.545617, 0.524312, 0.503348, 0.482637, 0.462418, 0.442657, 0.423338,
- 0.404564, 0.386277, 0.368545, 0.351448, 0.334906, 0.318961, 1.000000, 1.000000, 1.000000,
- 0.999999, 0.999999, 0.999998, 0.999994, 0.999989, 0.999979, 0.999968, 0.999949, 0.999921,
- 0.999886, 0.999833, 0.999747, 0.999596, 0.999029, 0.995749, 0.993677, 0.991724, 0.989620,
- 0.986723, 0.981515, 0.975767, 0.969056, 0.964124, 0.959142, 0.953036, 0.945650, 0.937022,
- 0.926971, 0.915515, 0.903584, 0.891603, 0.878212, 0.863472, 0.847652, 0.831398, 0.814299,
- 0.796105, 0.777231, 0.757977, 0.737895, 0.717415, 0.696595, 0.675317, 0.653980, 0.632343,
- 0.610735, 0.589076, 0.567620, 0.546251, 0.525165, 0.504255, 0.483759, 0.463666, 0.443987,
- 0.424783, 0.406042, 0.387891, 0.370293, 0.353221, 0.336715, 0.320806, 1.000000, 1.000000,
- 1.000000, 0.999999, 0.999998, 0.999998, 0.999993, 0.999987, 0.999977, 0.999964, 0.999943,
- 0.999911, 0.999867, 0.999807, 0.999714, 0.999531, 0.998645, 0.995399, 0.993512, 0.991717,
- 0.989661, 0.986652, 0.981559, 0.976183, 0.969411, 0.963317, 0.958457, 0.952091, 0.944951,
- 0.936307, 0.926454, 0.915043, 0.902668, 0.890462, 0.877245, 0.862672, 0.846823, 0.830201,
- 0.813293, 0.795306, 0.776393, 0.757199, 0.737324, 0.716808, 0.696187, 0.675094, 0.653814,
- 0.632453, 0.610885, 0.589483, 0.568099, 0.546975, 0.525953, 0.505268, 0.484936, 0.464988,
- 0.445458, 0.426314, 0.407750, 0.389670, 0.372098, 0.355105, 0.338682, 0.322825, 1.000000,
- 1.000000, 1.000000, 1.000000, 0.999999, 0.999996, 0.999992, 0.999983, 0.999976, 0.999959,
- 0.999933, 0.999898, 0.999849, 0.999780, 0.999676, 0.999454, 0.997884, 0.995166, 0.993394,
- 0.991723, 0.989654, 0.986389, 0.981632, 0.976607, 0.969701, 0.962555, 0.957605, 0.951232,
- 0.944099, 0.935556, 0.925699, 0.914492, 0.902027, 0.889116, 0.876093, 0.861649, 0.845956,
- 0.829238, 0.812220, 0.794420, 0.775657, 0.756265, 0.736673, 0.716372, 0.695669, 0.674886,
- 0.653728, 0.632568, 0.611217, 0.589929, 0.568783, 0.547752, 0.526931, 0.506425, 0.486238,
- 0.466425, 0.446945, 0.428026, 0.409536, 0.391551, 0.374087, 0.357155, 0.340787, 0.324974,
- 1.000000, 1.000000, 1.000000, 1.000000, 0.999998, 0.999996, 0.999990, 0.999984, 0.999970,
- 0.999952, 0.999925, 0.999886, 0.999831, 0.999757, 0.999633, 0.999356, 0.997017, 0.994868,
- 0.993337, 0.991710, 0.989580, 0.985848, 0.981640, 0.976711, 0.969755, 0.962166, 0.956609,
- 0.950365, 0.943026, 0.934693, 0.924880, 0.913729, 0.901350, 0.887966, 0.874726, 0.860474,
- 0.844905, 0.828269, 0.810905, 0.793364, 0.774812, 0.755478, 0.735886, 0.715847, 0.695231,
- 0.674537, 0.653667, 0.632527, 0.611475, 0.590363, 0.569462, 0.548571, 0.527976, 0.507634,
- 0.487632, 0.467901, 0.448680, 0.429833, 0.411467, 0.393568, 0.376197, 0.359374, 0.343034,
- 0.327273, 1.000000, 1.000000, 1.000000, 0.999999, 0.999998, 0.999993, 0.999989, 0.999980,
- 0.999965, 0.999945, 0.999913, 0.999869, 0.999810, 0.999723, 0.999583, 0.999213, 0.996540,
- 0.994740, 0.993244, 0.991671, 0.989411, 0.985533, 0.981616, 0.976847, 0.969968, 0.962315,
- 0.955468, 0.949420, 0.942016, 0.933617, 0.923949, 0.912899, 0.900495, 0.887022, 0.873283,
- 0.859153, 0.843830, 0.827325, 0.809888, 0.792172, 0.773832, 0.754686, 0.735035, 0.715297,
- 0.694955, 0.674242, 0.653660, 0.632752, 0.611804, 0.590993, 0.570154, 0.549539, 0.529087,
- 0.508974, 0.489030, 0.469599, 0.450466, 0.431761, 0.413508, 0.395761, 0.378480, 0.361679,
- 0.345465, 0.329752, 1.000000, 1.000000, 1.000000, 1.000000, 0.999997, 0.999994, 0.999987,
- 0.999978, 0.999961, 0.999936, 0.999903, 0.999855, 0.999786, 0.999689, 0.999527, 0.998988,
- 0.996137, 0.994527, 0.993108, 0.991599, 0.989084, 0.985308, 0.981527, 0.976677, 0.970079,
- 0.962535, 0.954490, 0.948271, 0.940942, 0.932422, 0.922836, 0.911896, 0.899632, 0.886118,
- 0.871864, 0.857719, 0.842536, 0.826163, 0.808849, 0.790860, 0.772802, 0.753860, 0.734335,
- 0.714582, 0.694543, 0.674071, 0.653544, 0.632922, 0.612153, 0.591573, 0.570951, 0.550520,
- 0.530352, 0.510311, 0.490707, 0.471359, 0.452396, 0.433837, 0.415736, 0.398052, 0.380874,
- 0.364232, 0.348023, 0.332368, 1.000000, 1.000000, 1.000000, 0.999999, 0.999998, 0.999994,
- 0.999988, 0.999976, 0.999957, 0.999928, 0.999891, 0.999837, 0.999759, 0.999650, 0.999463,
- 0.998551, 0.995879, 0.994366, 0.992964, 0.991479, 0.988521, 0.985101, 0.981482, 0.976168,
- 0.970242, 0.962585, 0.953950, 0.946973, 0.939686, 0.931248, 0.921614, 0.910765, 0.898617,
- 0.885183, 0.870772, 0.856138, 0.841120, 0.824962, 0.807732, 0.789813, 0.771638, 0.753008,
- 0.733686, 0.713927, 0.694082, 0.673967, 0.653549, 0.633135, 0.612702, 0.592200, 0.571904,
- 0.551679, 0.531678, 0.511898, 0.492437, 0.473239, 0.454451, 0.436067, 0.418054, 0.400542,
- 0.383486, 0.366848, 0.350781, 0.335182, 1.000000, 1.000000, 1.000000, 0.999999, 0.999997,
- 0.999993, 0.999985, 0.999972, 0.999951, 0.999919, 0.999877, 0.999817, 0.999733, 0.999608,
- 0.999380, 0.997685, 0.995603, 0.994264, 0.992911, 0.991287, 0.987923, 0.984871, 0.981239,
- 0.975933, 0.970149, 0.962511, 0.953824, 0.945699, 0.938285, 0.929907, 0.920343, 0.909537,
- 0.897435, 0.884056, 0.869626, 0.854490, 0.839459, 0.823511, 0.806511, 0.788752, 0.770440,
- 0.751995, 0.732962, 0.713424, 0.693525, 0.673798, 0.653622, 0.633301, 0.613224, 0.592938,
- 0.572833, 0.552904, 0.533030, 0.513556, 0.494215, 0.475279, 0.456673, 0.438411, 0.420583,
- 0.403178, 0.386178, 0.369728, 0.353688, 0.338147, 1.000000, 1.000000, 1.000000, 0.999999,
- 0.999997, 0.999991, 0.999984, 0.999967, 0.999944, 0.999912, 0.999863, 0.999796, 0.999703,
- 0.999563, 0.999279, 0.997104, 0.995394, 0.994111, 0.992825, 0.990979, 0.987529, 0.984661,
- 0.980774, 0.975758, 0.969866, 0.962465, 0.953678, 0.944489, 0.936886, 0.928356, 0.918820,
- 0.908073, 0.896092, 0.882833, 0.868463, 0.853212, 0.837744, 0.822048, 0.805333, 0.787643,
- 0.769414, 0.750830, 0.732178, 0.712972, 0.693227, 0.673569, 0.653744, 0.633739, 0.613735,
- 0.593822, 0.573916, 0.554158, 0.534652, 0.515248, 0.496233, 0.477436, 0.459009, 0.440929,
- 0.423259, 0.405951, 0.389136, 0.372690, 0.356789, 0.341329, 1.000000, 1.000000, 1.000000,
- 0.999999, 0.999996, 0.999991, 0.999981, 0.999966, 0.999939, 0.999903, 0.999847, 0.999771,
- 0.999666, 0.999510, 0.999131, 0.996690, 0.995147, 0.993882, 0.992696, 0.990474, 0.987227,
- 0.984334, 0.980153, 0.975438, 0.969406, 0.962238, 0.953598, 0.943868, 0.935356, 0.926721,
- 0.917122, 0.906430, 0.894550, 0.881354, 0.867131, 0.851954, 0.835972, 0.820331, 0.803911,
- 0.786452, 0.768420, 0.749821, 0.731298, 0.712393, 0.692979, 0.673418, 0.653859, 0.634232,
- 0.614327, 0.594732, 0.575131, 0.555584, 0.536346, 0.517175, 0.498323, 0.479744, 0.461485,
- 0.443645, 0.426061, 0.408969, 0.392155, 0.375921, 0.360060, 0.344677, 1.000000, 1.000000,
- 1.000000, 0.999999, 0.999997, 0.999991, 0.999979, 0.999960, 0.999931, 0.999891, 0.999832,
- 0.999748, 0.999629, 0.999449, 0.998880, 0.996305, 0.995024, 0.993812, 0.992508, 0.989721,
- 0.986936, 0.983936, 0.979629, 0.974979, 0.968928, 0.961970, 0.953291, 0.943458, 0.933644,
- 0.925007, 0.915388, 0.904755, 0.892932, 0.879831, 0.865794, 0.850672, 0.834591, 0.818398,
- 0.802304, 0.785151, 0.767450, 0.748987, 0.730325, 0.711758, 0.692761, 0.673417, 0.653908,
- 0.634686, 0.615168, 0.595707, 0.576393, 0.557198, 0.538018, 0.519253, 0.500555, 0.482220,
- 0.464197, 0.446414, 0.429106, 0.412035, 0.395508, 0.379284, 0.363538, 0.348220, 1.000000,
- 1.000000, 1.000000, 0.999999, 0.999995, 0.999989, 0.999977, 0.999955, 0.999924, 0.999879,
- 0.999813, 0.999722, 0.999590, 0.999381, 0.998335, 0.996088, 0.994814, 0.993709, 0.992220,
- 0.989209, 0.986575, 0.983383, 0.979084, 0.974272, 0.968359, 0.961275, 0.953025, 0.943098,
- 0.932434, 0.923101, 0.913477, 0.902861, 0.891059, 0.878072, 0.864118, 0.849188, 0.833281,
- 0.816808, 0.800596, 0.783745, 0.766331, 0.748123, 0.729686, 0.711078, 0.692527, 0.673491,
- 0.654296, 0.635113, 0.616048, 0.596847, 0.577720, 0.558879, 0.540028, 0.521371, 0.502996,
- 0.484858, 0.466997, 0.449477, 0.432217, 0.415426, 0.398924, 0.382890, 0.367206, 0.351955,
- 1.000000, 1.000000, 1.000000, 0.999998, 0.999996, 0.999988, 0.999974, 0.999953, 0.999918,
- 0.999865, 0.999791, 0.999690, 0.999542, 0.999293, 0.997535, 0.995790, 0.994609, 0.993557,
- 0.991766, 0.988767, 0.986255, 0.982544, 0.978541, 0.973528, 0.967700, 0.960596, 0.952299,
- 0.942684, 0.931653, 0.921211, 0.911489, 0.900818, 0.889018, 0.876245, 0.862406, 0.847517,
- 0.831852, 0.815367, 0.798719, 0.782224, 0.765167, 0.747304, 0.729133, 0.710485, 0.692196,
- 0.673589, 0.654770, 0.635717, 0.616986, 0.598119, 0.579298, 0.560560, 0.542163, 0.523669,
- 0.505564, 0.487642, 0.469991, 0.452658, 0.435620, 0.418937, 0.402612, 0.386633, 0.371091,
- 0.355949, 1.000000, 1.000000, 0.999999, 0.999998, 0.999995, 0.999986, 0.999973, 0.999948,
- 0.999909, 0.999852, 0.999769, 0.999656, 0.999490, 0.999186, 0.997059, 0.995624, 0.994510,
- 0.993327, 0.991020, 0.988379, 0.985771, 0.981971, 0.978051, 0.972892, 0.967020, 0.959965,
- 0.951625, 0.941902, 0.930951, 0.919370, 0.909285, 0.898562, 0.886809, 0.874251, 0.860597,
- 0.845808, 0.830365, 0.813972, 0.797260, 0.780597, 0.763854, 0.746401, 0.728519, 0.710203,
- 0.691882, 0.673687, 0.655275, 0.636621, 0.617909, 0.599473, 0.581032, 0.562560, 0.544295,
- 0.526228, 0.508293, 0.490652, 0.473242, 0.456004, 0.439212, 0.422663, 0.406476, 0.390647,
- 0.375204, 0.360129, 1.000000, 1.000000, 1.000000, 0.999999, 0.999994, 0.999984, 0.999969,
- 0.999940, 0.999898, 0.999837, 0.999746, 0.999617, 0.999438, 0.999016, 0.996703, 0.995302,
- 0.994356, 0.992993, 0.990390, 0.988072, 0.985152, 0.981447, 0.977273, 0.972234, 0.966113,
- 0.959033, 0.950869, 0.941217, 0.930175, 0.918279, 0.906941, 0.896201, 0.884509, 0.871920,
- 0.858420, 0.843906, 0.828730, 0.812524, 0.795978, 0.778979, 0.762450, 0.745459, 0.727966,
- 0.710046, 0.691808, 0.673739, 0.655756, 0.637574, 0.619153, 0.600887, 0.582796, 0.564748,
- 0.546636, 0.528904, 0.511252, 0.493791, 0.476563, 0.459695, 0.442942, 0.426632, 0.410558,
- 0.394895, 0.379517, 0.364560, 1.000000, 1.000000, 1.000000, 0.999998, 0.999994, 0.999984,
- 0.999966, 0.999934, 0.999887, 0.999819, 0.999720, 0.999578, 0.999367, 0.998696, 0.996353,
- 0.995201, 0.994115, 0.992665, 0.989948, 0.987633, 0.984331, 0.980827, 0.976390, 0.971327,
- 0.965201, 0.957977, 0.949712, 0.940128, 0.929187, 0.917237, 0.904645, 0.893711, 0.882112,
- 0.869516, 0.856236, 0.841929, 0.826924, 0.810991, 0.794686, 0.777761, 0.760980, 0.744384,
- 0.727314, 0.709877, 0.691988, 0.674098, 0.656243, 0.638603, 0.620606, 0.602574, 0.584694,
- 0.567018, 0.549311, 0.531673, 0.514403, 0.497148, 0.480177, 0.463439, 0.446998, 0.430743,
- 0.414943, 0.399304, 0.384121, 0.369251, 1.000000, 1.000000, 1.000000, 0.999997, 0.999992,
- 0.999981, 0.999962, 0.999927, 0.999874, 0.999798, 0.999691, 0.999533, 0.999291, 0.997909,
- 0.996117, 0.995029, 0.993880, 0.992142, 0.989576, 0.987185, 0.983587, 0.980055, 0.975487,
- 0.970172, 0.963998, 0.956738, 0.948637, 0.939083, 0.928169, 0.916144, 0.903147, 0.890916,
- 0.879389, 0.866895, 0.853826, 0.839729, 0.824957, 0.809472, 0.793341, 0.776743, 0.759808,
- 0.743277, 0.726643, 0.709685, 0.692249, 0.674639, 0.657008, 0.639576, 0.622114, 0.604471,
- 0.586851, 0.569340, 0.552135, 0.534806, 0.517599, 0.500765, 0.484035, 0.467440, 0.451212,
- 0.435240, 0.419399, 0.404083, 0.388944, 0.374182, 1.000000, 1.000000, 1.000000, 0.999998,
- 0.999993, 0.999979, 0.999958, 0.999919, 0.999861, 0.999774, 0.999656, 0.999482, 0.999195,
- 0.997307, 0.995837, 0.994722, 0.993707, 0.991391, 0.989169, 0.986461, 0.982904, 0.979062,
- 0.974536, 0.969035, 0.962653, 0.955486, 0.947243, 0.937747, 0.926861, 0.914936, 0.901835,
- 0.888472, 0.876571, 0.864223, 0.851252, 0.837374, 0.822985, 0.807788, 0.791927, 0.775702,
- 0.758928, 0.742347, 0.725914, 0.709495, 0.692569, 0.675363, 0.658085, 0.640639, 0.623698,
- 0.606505, 0.589267, 0.572008, 0.554939, 0.538132, 0.521211, 0.504487, 0.488048, 0.471807,
- 0.455651, 0.439858, 0.424332, 0.408983, 0.394071, 0.379402, 1.000000, 1.000000, 1.000000,
- 0.999997, 0.999992, 0.999978, 0.999954, 0.999913, 0.999844, 0.999753, 0.999618, 0.999424,
- 0.999067, 0.996875, 0.995659, 0.994603, 0.993420, 0.990874, 0.988713, 0.985585, 0.982193,
- 0.978145, 0.973416, 0.967801, 0.961483, 0.954069, 0.945704, 0.936138, 0.925374, 0.913395,
- 0.900339, 0.886675, 0.873512, 0.861326, 0.848513, 0.834956, 0.820820, 0.805943, 0.790574,
- 0.774677, 0.758279, 0.741807, 0.725271, 0.709231, 0.692874, 0.676189, 0.659352, 0.642296,
- 0.625250, 0.608700, 0.591823, 0.575012, 0.558143, 0.541491, 0.525075, 0.508558, 0.492277,
- 0.476270, 0.460459, 0.444740, 0.429400, 0.414309, 0.399421, 0.384907, 1.000000, 1.000000,
- 1.000000, 0.999997, 0.999990, 0.999977, 0.999947, 0.999902, 0.999832, 0.999730, 0.999577,
- 0.999359, 0.998845, 0.996554, 0.995328, 0.994442, 0.992919, 0.990393, 0.988170, 0.984855,
- 0.981312, 0.977149, 0.972137, 0.966207, 0.959967, 0.952454, 0.943873, 0.934434, 0.923813,
- 0.911942, 0.898928, 0.885120, 0.871043, 0.858248, 0.845666, 0.832346, 0.818482, 0.804029,
- 0.788982, 0.773571, 0.757700, 0.741484, 0.725186, 0.708915, 0.693244, 0.677028, 0.660656,
- 0.644079, 0.627377, 0.610804, 0.594542, 0.578112, 0.561650, 0.545163, 0.528962, 0.512926,
- 0.496893, 0.481007, 0.465397, 0.450042, 0.434740, 0.419831, 0.405156, 0.390692, 1.000000,
- 1.000000, 0.999999, 0.999997, 0.999989, 0.999973, 0.999942, 0.999891, 0.999813, 0.999698,
- 0.999532, 0.999285, 0.998286, 0.996295, 0.995215, 0.994182, 0.992032, 0.989855, 0.987415,
- 0.984047, 0.980050, 0.976017, 0.970845, 0.964767, 0.958269, 0.950600, 0.942033, 0.932501,
- 0.921807, 0.910017, 0.897149, 0.883414, 0.869182, 0.855055, 0.842687, 0.829548, 0.816162,
- 0.802072, 0.787436, 0.772533, 0.757043, 0.741263, 0.725330, 0.709262, 0.693497, 0.678038,
- 0.662128, 0.646068, 0.629824, 0.613437, 0.597334, 0.581401, 0.565372, 0.549288, 0.533182,
- 0.517405, 0.501765, 0.486143, 0.470675, 0.455465, 0.440532, 0.425630, 0.411113, 0.396887,
- 1.000000, 1.000000, 0.999999, 0.999996, 0.999989, 0.999970, 0.999934, 0.999879, 0.999793,
- 0.999665, 0.999481, 0.999192, 0.997506, 0.995926, 0.995009, 0.993736, 0.991298, 0.989326,
- 0.986371, 0.983199, 0.979032, 0.974596, 0.969364, 0.963198, 0.956385, 0.948509, 0.939993,
- 0.930421, 0.919590, 0.908140, 0.895349, 0.881699, 0.867456, 0.852784, 0.839500, 0.826629,
- 0.813602, 0.799983, 0.785873, 0.771340, 0.756480, 0.741190, 0.725687, 0.709997, 0.694192,
- 0.678975, 0.663673, 0.648135, 0.632442, 0.616477, 0.600565, 0.584772, 0.569202, 0.553595,
- 0.537881, 0.522193, 0.506784, 0.491554, 0.476349, 0.461278, 0.446419, 0.431913, 0.417443,
- 0.403271, 1.000000, 1.000000, 0.999999, 0.999995, 0.999986, 0.999966, 0.999927, 0.999867,
- 0.999772, 0.999629, 0.999423, 0.999075, 0.997024, 0.995773, 0.994651, 0.993353, 0.990822,
- 0.988569, 0.985596, 0.982182, 0.977871, 0.973140, 0.967584, 0.961408, 0.954294, 0.946398,
- 0.937603, 0.927937, 0.917305, 0.905833, 0.893138, 0.879770, 0.865720, 0.851023, 0.836801,
- 0.823784, 0.810909, 0.797886, 0.784177, 0.770243, 0.755925, 0.741144, 0.726214, 0.710971,
- 0.695563, 0.680212, 0.665304, 0.650297, 0.635168, 0.619796, 0.604217, 0.588692, 0.573254,
- 0.557998, 0.542839, 0.527470, 0.512162, 0.497115, 0.482296, 0.467477, 0.452812, 0.438310,
- 0.424184, 0.410163, 1.000000, 1.000000, 0.999999, 0.999996, 0.999984, 0.999962, 0.999920,
- 0.999852, 0.999745, 0.999586, 0.999354, 0.998894, 0.996686, 0.995485, 0.994493, 0.992573,
- 0.990323, 0.987772, 0.984692, 0.980887, 0.976446, 0.971625, 0.965717, 0.959421, 0.951975,
- 0.944086, 0.935066, 0.925403, 0.914814, 0.903208, 0.890958, 0.877817, 0.863828, 0.849289,
- 0.834872, 0.820889, 0.808183, 0.795660, 0.782556, 0.769066, 0.755386, 0.741229, 0.726726,
- 0.712170, 0.697209, 0.682170, 0.667203, 0.652689, 0.637938, 0.623262, 0.608190, 0.593002,
- 0.577817, 0.562737, 0.547836, 0.533036, 0.518052, 0.503135, 0.488422, 0.473986, 0.459552,
- 0.445282, 0.431149, 0.417407, 1.000000, 1.000000, 0.999999, 0.999994, 0.999983, 0.999957,
- 0.999914, 0.999835, 0.999718, 0.999538, 0.999275, 0.998454, 0.996341, 0.995246, 0.994222,
- 0.991844, 0.989829, 0.986688, 0.983562, 0.979638, 0.974932, 0.969827, 0.963621, 0.957146,
- 0.949365, 0.941398, 0.932245, 0.922556, 0.911949, 0.900627, 0.888440, 0.875544, 0.862005,
- 0.847810, 0.833372, 0.819134, 0.805508, 0.793339, 0.780916, 0.767837, 0.754858, 0.741307,
- 0.727496, 0.713386, 0.699131, 0.684542, 0.669878, 0.655261, 0.641035, 0.626685, 0.612377,
- 0.597625, 0.582805, 0.568030, 0.553204, 0.538684, 0.524269, 0.509662, 0.495119, 0.480735,
- 0.466634, 0.452593, 0.438748, 0.424915, 1.000000, 1.000000, 0.999998, 0.999994, 0.999982,
- 0.999956, 0.999901, 0.999818, 0.999683, 0.999487, 0.999185, 0.997584, 0.996004, 0.995050,
- 0.993715, 0.991212, 0.989057, 0.985879, 0.982243, 0.978206, 0.973119, 0.967919, 0.961343,
- 0.954603, 0.946712, 0.938378, 0.929266, 0.919443, 0.908911, 0.897725, 0.885589, 0.873254,
- 0.859889, 0.846123, 0.832094, 0.817898, 0.803866, 0.791061, 0.779235, 0.766885, 0.754292,
- 0.741565, 0.728331, 0.714861, 0.701179, 0.687166, 0.673012, 0.658716, 0.644442, 0.630472,
- 0.616519, 0.602514, 0.588172, 0.573689, 0.559281, 0.544768, 0.530543, 0.516485, 0.502303,
- 0.488100, 0.474095, 0.460245, 0.446598, 0.433169, 1.000000, 1.000000, 0.999997, 0.999993,
- 0.999980, 0.999947, 0.999891, 0.999794, 0.999647, 0.999425, 0.999062, 0.997049, 0.995778,
- 0.994652, 0.992778, 0.990482, 0.988004, 0.984893, 0.980881, 0.976605, 0.971199, 0.965610,
- 0.958925, 0.951746, 0.943791, 0.935200, 0.926018, 0.916028, 0.905724, 0.894528, 0.882914,
- 0.870740, 0.857802, 0.844552, 0.830857, 0.816921, 0.803102, 0.789625, 0.777480, 0.765891,
- 0.753908, 0.741795, 0.729390, 0.716440, 0.703411, 0.690068, 0.676438, 0.662586, 0.648697,
- 0.634732, 0.620997, 0.607451, 0.593765, 0.579748, 0.565661, 0.551594, 0.537396, 0.523433,
- 0.509708, 0.495972, 0.482082, 0.468427, 0.454890, 0.441623, 1.000000, 1.000000, 0.999999,
- 0.999991, 0.999977, 0.999940, 0.999875, 0.999769, 0.999605, 0.999352, 0.998882, 0.996665,
- 0.995459, 0.994380, 0.992014, 0.989912, 0.986796, 0.983537, 0.979326, 0.974792, 0.969140,
- 0.963160, 0.956222, 0.948807, 0.940518, 0.931755, 0.922452, 0.912319, 0.902227, 0.891142,
- 0.879838, 0.868047, 0.855745, 0.842718, 0.829827, 0.816398, 0.802786, 0.789396, 0.776581,
- 0.764901, 0.753710, 0.742102, 0.730448, 0.718337, 0.705768, 0.693172, 0.680153, 0.666882,
- 0.653401, 0.639837, 0.626152, 0.612676, 0.599435, 0.586109, 0.572473, 0.558715, 0.544964,
- 0.531112, 0.517416, 0.503992, 0.490653, 0.477162, 0.463832, 0.450645, 1.000000, 1.000000,
- 0.999999, 0.999992, 0.999973, 0.999933, 0.999861, 0.999741, 0.999554, 0.999267, 0.998411,
- 0.996303, 0.995191, 0.993945, 0.991406, 0.989019, 0.985720, 0.982057, 0.977501, 0.972605,
- 0.966697, 0.960340, 0.953031, 0.945347, 0.936866, 0.927917, 0.918562, 0.908598, 0.898486,
- 0.887794, 0.876545, 0.865379, 0.853428, 0.841167, 0.828649, 0.815967, 0.802957, 0.789865,
- 0.777077, 0.764695, 0.753544, 0.742694, 0.731571, 0.720304, 0.708490, 0.696351, 0.684134,
- 0.671470, 0.658541, 0.645376, 0.632209, 0.618776, 0.605511, 0.592527, 0.579546, 0.566310,
- 0.552860, 0.539492, 0.526005, 0.512564, 0.499340, 0.486360, 0.473357, 0.460306, 1.000000,
- 1.000000, 0.999998, 0.999991, 0.999970, 0.999926, 0.999842, 0.999710, 0.999498, 0.999164,
- 0.997464, 0.995870, 0.994917, 0.992911, 0.990682, 0.987816, 0.984410, 0.980551, 0.975693,
- 0.970263, 0.963946, 0.957248, 0.949765, 0.941571, 0.932941, 0.923873, 0.914332, 0.904560,
- 0.894394, 0.884127, 0.873294, 0.862503, 0.851335, 0.839566, 0.827776, 0.815708, 0.803370,
- 0.790821, 0.778386, 0.766121, 0.754193, 0.743420, 0.732975, 0.722326, 0.711376, 0.699992,
- 0.688180, 0.676354, 0.664004, 0.651449, 0.638600, 0.625776, 0.612660, 0.599603, 0.586719,
- 0.574078, 0.561273, 0.548129, 0.535155, 0.522015, 0.508851, 0.495837, 0.483190, 0.470624,
- 1.000000, 1.000000, 0.999998, 0.999988, 0.999965, 0.999916, 0.999823, 0.999669, 0.999425,
- 0.999025, 0.996874, 0.995670, 0.994415, 0.991991, 0.989766, 0.986646, 0.982812, 0.978356,
- 0.973317, 0.967612, 0.960820, 0.953603, 0.945969, 0.937323, 0.928661, 0.919507, 0.909833,
- 0.900245, 0.890390, 0.880252, 0.870000, 0.859518, 0.849163, 0.838101, 0.826960, 0.815688,
- 0.804126, 0.792234, 0.780356, 0.768474, 0.756678, 0.745159, 0.734601, 0.724624, 0.714339,
- 0.703751, 0.692766, 0.681267, 0.669799, 0.657871, 0.645577, 0.633102, 0.620560, 0.607737,
- 0.594890, 0.582143, 0.569779, 0.557360, 0.544651, 0.531942, 0.519228, 0.506467, 0.493710,
- 0.481143, 1.000000, 1.000000, 0.999998, 0.999988, 0.999961, 0.999902, 0.999798, 0.999622,
- 0.999341, 0.998801, 0.996397, 0.995225, 0.993927, 0.991338, 0.988500, 0.985327, 0.981195,
- 0.976383, 0.970726, 0.964471, 0.957386, 0.949813, 0.941694, 0.932681, 0.923974, 0.914755,
- 0.905026, 0.895649, 0.886178, 0.876277, 0.866629, 0.856890, 0.846934, 0.836887, 0.826373,
- 0.815885, 0.805169, 0.794133, 0.782812, 0.771547, 0.760175, 0.748896, 0.737687, 0.727152,
- 0.717601, 0.707670, 0.697425, 0.686788, 0.675664, 0.664513, 0.652962, 0.640965, 0.628851,
- 0.616551, 0.604168, 0.591559, 0.579009, 0.566648, 0.554597, 0.542382, 0.529999, 0.517655,
- 0.505254, 0.492894, 1.000000, 1.000000, 0.999997, 0.999986, 0.999956, 0.999889, 0.999766,
- 0.999562, 0.999240, 0.997952, 0.996094, 0.994979, 0.992773, 0.990536, 0.987214, 0.983322,
- 0.978938, 0.973714, 0.967681, 0.960981, 0.953144, 0.945475, 0.936909, 0.927734, 0.918826,
- 0.909590, 0.900085, 0.890867, 0.881801, 0.872565, 0.863236, 0.854239, 0.845060, 0.835686,
- 0.826251, 0.816284, 0.806586, 0.796419, 0.785914, 0.775210, 0.764461, 0.753599, 0.742805,
- 0.731872, 0.721370, 0.711898, 0.702337, 0.692383, 0.682137, 0.671365, 0.660479, 0.649314,
- 0.637685, 0.625899, 0.613898, 0.601865, 0.589582, 0.577285, 0.565013, 0.553106, 0.541280,
- 0.529367, 0.517320, 0.505411, 1.000000, 1.000000, 0.999997, 0.999983, 0.999948, 0.999869,
- 0.999732, 0.999499, 0.999111, 0.997167, 0.995720, 0.994349, 0.991727, 0.989197, 0.985883,
- 0.981483, 0.976618, 0.970597, 0.964122, 0.956994, 0.948639, 0.940500, 0.931606, 0.922385,
- 0.913291, 0.904205, 0.894938, 0.885890, 0.877334, 0.868754, 0.860053, 0.851683, 0.843447,
- 0.834889, 0.826304, 0.817441, 0.808285, 0.799141, 0.789570, 0.779600, 0.769510, 0.759155,
- 0.748882, 0.738346, 0.727629, 0.717273, 0.707467, 0.698283, 0.688609, 0.678748, 0.668371,
- 0.657739, 0.646951, 0.635765, 0.624254, 0.612647, 0.600900, 0.589061, 0.576998, 0.564991,
- 0.553102, 0.541517, 0.530027, 0.518495, 1.000000, 1.000000, 0.999997, 0.999983, 0.999939,
- 0.999851, 0.999684, 0.999412, 0.998925, 0.996597, 0.995207, 0.993603, 0.990903, 0.987594,
- 0.983814, 0.979016, 0.973647, 0.967048, 0.960109, 0.952123, 0.943560, 0.934900, 0.925747,
- 0.916566, 0.907305, 0.898441, 0.889629, 0.881042, 0.872874, 0.865064, 0.857225, 0.849446,
- 0.842063, 0.834561, 0.826814, 0.818875, 0.810748, 0.802316, 0.793699, 0.784704, 0.775198,
- 0.765643, 0.755735, 0.745873, 0.735526, 0.725229, 0.714892, 0.704807, 0.695502, 0.686241,
- 0.676633, 0.666688, 0.656384, 0.645871, 0.635174, 0.624113, 0.612788, 0.601426, 0.589925,
- 0.578399, 0.566612, 0.554931, 0.543383, 0.532065, 1.000000, 1.000000, 0.999996, 0.999977,
- 0.999928, 0.999824, 0.999633, 0.999306, 0.998429, 0.996133, 0.994890, 0.992316, 0.989752,
- 0.986095, 0.981564, 0.976234, 0.970081, 0.962779, 0.955232, 0.946702, 0.937716, 0.928604,
- 0.919281, 0.910167, 0.901046, 0.892446, 0.884183, 0.876253, 0.868619, 0.861545, 0.854673,
- 0.847885, 0.841074, 0.834610, 0.827984, 0.820945, 0.813648, 0.806232, 0.798444, 0.790232,
- 0.781853, 0.772897, 0.763648, 0.754227, 0.744542, 0.734689, 0.724526, 0.714204, 0.704152,
- 0.694222, 0.685143, 0.675860, 0.666319, 0.656415, 0.646273, 0.635902, 0.625399, 0.614563,
- 0.603490, 0.592413, 0.581217, 0.570000, 0.558608, 0.547242, 1.000000, 0.999999, 0.999995,
- 0.999972, 0.999915, 0.999790, 0.999562, 0.999168, 0.997237, 0.995672, 0.994074, 0.991220,
- 0.987792, 0.983822, 0.978599, 0.972804, 0.965718, 0.958053, 0.949460, 0.940503, 0.931011,
- 0.921608, 0.912409, 0.903378, 0.894606, 0.886369, 0.878756, 0.871573, 0.864862, 0.858421,
- 0.852541, 0.846802, 0.841027, 0.835206, 0.829628, 0.823730, 0.817415, 0.810655, 0.803873,
- 0.796659, 0.788887, 0.780940, 0.772537, 0.763507, 0.754487, 0.745163, 0.735572, 0.725687,
- 0.715611, 0.705398, 0.695418, 0.685592, 0.676518, 0.667304, 0.657875, 0.648182, 0.638235,
- 0.628062, 0.617813, 0.607283, 0.596552, 0.585770, 0.575033, 0.564153, 1.000000, 1.000000,
- 0.999995, 0.999970, 0.999898, 0.999748, 0.999472, 0.998969, 0.996528, 0.995102, 0.992701,
- 0.989963, 0.985981, 0.981194, 0.975183, 0.968501, 0.960502, 0.952012, 0.942861, 0.933376,
- 0.923506, 0.914042, 0.904921, 0.896282, 0.887987, 0.880341, 0.873536, 0.867293, 0.861556,
- 0.856148, 0.850987, 0.846352, 0.841684, 0.836880, 0.832036, 0.827091, 0.821900, 0.816206,
- 0.810042, 0.803629, 0.796918, 0.789653, 0.781915, 0.774014, 0.765530, 0.756526, 0.747669,
- 0.738342, 0.728770, 0.718942, 0.708942, 0.698855, 0.688933, 0.679131, 0.669855, 0.660811,
- 0.651549, 0.642127, 0.632454, 0.622651, 0.612709, 0.602606, 0.592344, 0.581877, 1.000000,
- 0.999999, 0.999993, 0.999963, 0.999874, 0.999691, 0.999350, 0.998431, 0.995873, 0.994456,
- 0.991327, 0.987798, 0.983232, 0.977500, 0.970828, 0.962815, 0.954228, 0.944752, 0.935126,
- 0.925179, 0.915102, 0.905763, 0.897087, 0.888933, 0.881452, 0.874687, 0.868716, 0.863585,
- 0.858931, 0.854662, 0.850569, 0.846719, 0.843151, 0.839426, 0.835588, 0.831443, 0.827004,
- 0.822395, 0.817254, 0.811630, 0.805464, 0.799124, 0.792382, 0.785091, 0.777315, 0.769360,
- 0.760908, 0.751957, 0.743128, 0.733917, 0.724340, 0.714713, 0.704721, 0.694835, 0.684862,
- 0.675099, 0.665570, 0.656644, 0.647651, 0.638581, 0.629337, 0.619926, 0.610358, 0.600707,
- 1.000000, 1.000000, 0.999990, 0.999953, 0.999843, 0.999613, 0.999186, 0.997025, 0.995317,
- 0.992850, 0.989760, 0.985270, 0.979807, 0.973049, 0.965228, 0.956248, 0.946394, 0.936324,
- 0.926124, 0.915808, 0.905942, 0.897060, 0.889001, 0.881755, 0.875351, 0.869688, 0.864736,
- 0.860745, 0.857305, 0.854190, 0.851261, 0.848484, 0.845642, 0.842948, 0.840060, 0.836901,
- 0.833379, 0.829393, 0.825103, 0.820431, 0.815288, 0.809575, 0.803326, 0.796949, 0.790174,
- 0.782873, 0.775048, 0.767139, 0.758772, 0.750019, 0.741120, 0.732127, 0.722743, 0.713225,
- 0.703637, 0.693768, 0.684016, 0.674277, 0.664703, 0.655328, 0.646550, 0.637812, 0.629036,
- 0.620129, 1.000000, 1.000000, 0.999988, 0.999933, 0.999800, 0.999508, 0.998917, 0.996236,
- 0.994617, 0.991176, 0.987089, 0.981880, 0.974966, 0.967156, 0.957914, 0.947585, 0.936937,
- 0.926318, 0.915662, 0.905567, 0.896223, 0.888166, 0.881117, 0.875079, 0.869981, 0.865675,
- 0.862091, 0.859183, 0.856981, 0.855065, 0.853273, 0.851572, 0.849782, 0.847768, 0.845668,
- 0.843345, 0.840703, 0.837646, 0.834094, 0.830030, 0.825631, 0.820873, 0.815619, 0.809856,
- 0.803578, 0.797096, 0.790359, 0.783152, 0.775507, 0.767504, 0.759411, 0.750982, 0.742208,
- 0.733383, 0.724445, 0.715190, 0.705827, 0.696440, 0.686773, 0.677242, 0.667735, 0.658471,
- 0.649236, 0.640305, 1.000000, 0.999999, 0.999984, 0.999918, 0.999737, 0.999350, 0.997576,
- 0.995476, 0.992614, 0.988817, 0.983601, 0.976880, 0.968694, 0.959092, 0.948297, 0.936831,
- 0.925592, 0.914494, 0.904159, 0.894643, 0.886417, 0.879620, 0.874023, 0.869533, 0.865967,
- 0.863238, 0.861113, 0.859527, 0.858367, 0.857594, 0.856882, 0.856172, 0.855316, 0.854197,
- 0.852818, 0.851062, 0.849046, 0.846747, 0.844043, 0.840842, 0.837164, 0.832985, 0.828344,
- 0.823544, 0.818276, 0.812543, 0.806374, 0.799838, 0.793170, 0.786246, 0.778956, 0.771297,
- 0.763278, 0.755252, 0.746984, 0.738445, 0.729688, 0.721045, 0.712189, 0.703099, 0.694045,
- 0.684930, 0.675601, 0.666480, 1.000000, 0.999999, 0.999978, 0.999888, 0.999639, 0.999093,
- 0.996310, 0.994405, 0.990527, 0.985186, 0.978518, 0.969748, 0.959597, 0.948104, 0.935724,
- 0.923704, 0.912023, 0.901356, 0.891850, 0.883847, 0.877280, 0.872289, 0.868583, 0.865913,
- 0.864098, 0.862993, 0.862356, 0.862125, 0.862107, 0.862168, 0.862359, 0.862490, 0.862430,
- 0.862063, 0.861431, 0.860386, 0.858950, 0.857090, 0.854848, 0.852381, 0.849503, 0.846167,
- 0.842399, 0.838194, 0.833566, 0.828579, 0.823464, 0.817951, 0.812079, 0.805873, 0.799320,
- 0.792533, 0.785715, 0.778636, 0.771260, 0.763618, 0.755719, 0.747815, 0.739825, 0.731602,
- 0.723212, 0.714845, 0.706465, 0.697933, 1.000000, 0.999998, 0.999969, 0.999836, 0.999475,
- 0.997943, 0.995219, 0.991760, 0.986663, 0.979592, 0.970218, 0.959155, 0.946575, 0.933047,
- 0.920022, 0.907749, 0.896801, 0.887506, 0.880077, 0.874322, 0.870126, 0.867481, 0.865949,
- 0.865293, 0.865287, 0.865746, 0.866502, 0.867439, 0.868442, 0.869382, 0.870161, 0.870782,
- 0.871303, 0.871511, 0.871427, 0.870978, 0.870136, 0.868892, 0.867248, 0.865209, 0.862775,
- 0.859944, 0.857004, 0.853671, 0.849984, 0.845927, 0.841518, 0.836774, 0.831750, 0.826407,
- 0.821001, 0.815333, 0.809412, 0.803238, 0.796802, 0.790204, 0.783457, 0.776713, 0.769749,
- 0.762596, 0.755239, 0.747690, 0.740127, 0.732595, 1.000000, 0.999997, 0.999950, 0.999744,
- 0.999162, 0.996124, 0.992844, 0.987757, 0.980062, 0.969642, 0.957087, 0.942735, 0.927747,
- 0.913622, 0.900889, 0.890115, 0.881584, 0.875288, 0.870926, 0.868307, 0.867033, 0.866972,
- 0.867692, 0.868950, 0.870549, 0.872320, 0.874144, 0.875947, 0.877674, 0.879192, 0.880478,
- 0.881539, 0.882307, 0.882739, 0.882902, 0.882847, 0.882461, 0.881725, 0.880636, 0.879197,
- 0.877422, 0.875296, 0.872849, 0.870076, 0.866988, 0.863637, 0.860159, 0.856475, 0.852525,
- 0.848328, 0.843883, 0.839198, 0.834322, 0.829221, 0.823907, 0.818461, 0.812972, 0.807316,
- 0.801474, 0.795459, 0.789276, 0.783025, 0.776615, 0.770223, 0.999999, 0.999994, 0.999909,
- 0.999536, 0.997195, 0.994123, 0.988168, 0.979344, 0.967003, 0.951763, 0.934724, 0.917948,
- 0.902918, 0.890432, 0.880902, 0.874401, 0.870394, 0.868503, 0.868209, 0.869062, 0.870725,
- 0.873006, 0.875558, 0.878230, 0.880893, 0.883445, 0.885832, 0.888059, 0.890058, 0.891782,
- 0.893247, 0.894460, 0.895397, 0.896023, 0.896380, 0.896433, 0.896198, 0.895673, 0.894865,
- 0.893908, 0.892700, 0.891224, 0.889501, 0.887539, 0.885336, 0.882903, 0.880244, 0.877373,
- 0.874296, 0.871019, 0.867549, 0.863933, 0.860153, 0.856355, 0.852395, 0.848277, 0.844006,
- 0.839587, 0.835045, 0.830378, 0.825579, 0.820649, 0.815592, 0.810432, 0.999998, 0.999988,
- 0.999795, 0.998892, 0.994635, 0.987290, 0.975397, 0.958508, 0.938352, 0.917733, 0.899800,
- 0.885878, 0.876516, 0.871200, 0.869099, 0.869317, 0.871112, 0.873870, 0.877160, 0.880682,
- 0.884228, 0.887737, 0.891076, 0.894161, 0.896981, 0.899543, 0.901847, 0.903882, 0.905672,
- 0.907188, 0.908451, 0.909480, 0.910289, 0.910878, 0.911259, 0.911430, 0.911396, 0.911154,
- 0.910712, 0.910081, 0.909266, 0.908264, 0.907094, 0.905752, 0.904244, 0.902577, 0.900799,
- 0.898931, 0.896923, 0.894782, 0.892513, 0.890117, 0.887600, 0.884968, 0.882222, 0.879369,
- 0.876408, 0.873345, 0.870183, 0.866926, 0.863575, 0.860160, 0.856672, 0.853098, 0.999991,
- 0.999947, 0.999158, 0.992842, 0.980107, 0.957230, 0.928231, 0.901539, 0.882688, 0.872588,
- 0.869394, 0.870671, 0.874458, 0.879378, 0.884639, 0.889770, 0.894601, 0.898972, 0.902930,
- 0.906456, 0.909568, 0.912329, 0.914750, 0.916893, 0.918774, 0.920429, 0.921868, 0.923110,
- 0.924185, 0.925089, 0.925842, 0.926457, 0.926934, 0.927285, 0.927522, 0.927639, 0.927650,
- 0.927553, 0.927356, 0.927061, 0.926671, 0.926187, 0.925617, 0.924962, 0.924224, 0.923409,
- 0.922519, 0.921555, 0.920521, 0.919419, 0.918252, 0.917021, 0.915729, 0.914377, 0.912967,
- 0.911503, 0.909984, 0.908414, 0.906791, 0.905122, 0.903401, 0.901637, 0.899826, 0.897972,
- 0.987461, 0.940121, 0.871507, 0.898572, 0.916705, 0.926425, 0.931922, 0.935265, 0.937431,
- 0.938899, 0.939950, 0.940717, 0.941301, 0.941754, 0.942111, 0.942397, 0.942631, 0.942823,
- 0.942983, 0.943117, 0.943231, 0.943329, 0.943412, 0.943484, 0.943545, 0.943599, 0.943644,
- 0.943682, 0.943716, 0.943744, 0.943766, 0.943785, 0.943799, 0.943808, 0.943815, 0.943818,
- 0.943818, 0.943814, 0.943807, 0.943797, 0.943784, 0.943769, 0.943751, 0.943730, 0.943707,
- 0.943681, 0.943652, 0.943623, 0.943589, 0.943554, 0.943518, 0.943479, 0.943438, 0.943396,
- 0.943351, 0.943305, 0.943257, 0.943207, 0.943156, 0.943104, 0.943049, 0.942993, 0.942936,
- 0.942877,
+static float ltc_mag_ggx[64 * 64 * 2] = {
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.999998, 0.000000,
+ 0.999994, 0.000000, 0.999989, 0.000000, 0.999973, 0.000000, 0.999947, 0.000000,
+ 0.999894, 0.000001, 0.999798, 0.000001, 0.999617, 0.000003, 0.999234, 0.000008,
+ 0.998258, 0.000015, 0.995040, 0.000027, 0.980816, 0.000024, 0.967553, 0.000002,
+ 0.966877, 0.000004, 0.965752, 0.000007, 0.963820, 0.000013, 0.960306, 0.000020,
+ 0.953619, 0.000028, 0.941103, 0.000028, 0.926619, 0.000016, 0.920983, 0.000024,
+ 0.912293, 0.000031, 0.899277, 0.000035, 0.880884, 0.000026, 0.870399, 0.000034,
+ 0.856138, 0.000039, 0.837436, 0.000037, 0.820973, 0.000039, 0.803583, 0.000043,
+ 0.782168, 0.000040, 0.764107, 0.000045, 0.743092, 0.000046, 0.721626, 0.000046,
+ 0.700375, 0.000048, 0.677334, 0.000046, 0.655702, 0.000048, 0.632059, 0.000046,
+ 0.610125, 0.000048, 0.586530, 0.000046, 0.564508, 0.000048, 0.541405, 0.000046,
+ 0.519556, 0.000046, 0.497292, 0.000045, 0.475898, 0.000045, 0.454722, 0.000043,
+ 0.434042, 0.000042, 0.414126, 0.000041, 0.394387, 0.000040, 0.375841, 0.000039,
+ 0.357219, 0.000037, 0.340084, 0.000037, 0.322714, 0.000034, 0.306974, 0.000034,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 0.999999, 0.000000, 0.999998, 0.000000, 0.999996, 0.000000,
+ 0.999991, 0.000000, 0.999983, 0.000000, 0.999968, 0.000000, 0.999940, 0.000000,
+ 0.999891, 0.000001, 0.999797, 0.000001, 0.999617, 0.000003, 0.999227, 0.000008,
+ 0.998239, 0.000016, 0.994937, 0.000027, 0.980225, 0.000021, 0.967549, 0.000002,
+ 0.966865, 0.000004, 0.965739, 0.000008, 0.963794, 0.000013, 0.960244, 0.000021,
+ 0.953495, 0.000028, 0.940876, 0.000027, 0.926569, 0.000016, 0.920905, 0.000024,
+ 0.912169, 0.000032, 0.899095, 0.000035, 0.882209, 0.000029, 0.870272, 0.000034,
+ 0.855977, 0.000039, 0.837431, 0.000037, 0.820826, 0.000040, 0.803408, 0.000044,
+ 0.782838, 0.000042, 0.763941, 0.000045, 0.742904, 0.000046, 0.721463, 0.000046,
+ 0.700197, 0.000048, 0.677501, 0.000047, 0.655527, 0.000048, 0.632400, 0.000048,
+ 0.609964, 0.000048, 0.586839, 0.000048, 0.564353, 0.000048, 0.541589, 0.000047,
+ 0.519413, 0.000046, 0.497337, 0.000045, 0.475797, 0.000045, 0.454659, 0.000044,
+ 0.434065, 0.000042, 0.414018, 0.000041, 0.394550, 0.000040, 0.375742, 0.000039,
+ 0.357501, 0.000038, 0.339996, 0.000037, 0.323069, 0.000035, 0.306897, 0.000034,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 0.999998, 0.000000, 0.999997, 0.000000, 0.999995, 0.000000,
+ 0.999991, 0.000000, 0.999981, 0.000000, 0.999967, 0.000000, 0.999938, 0.000000,
+ 0.999886, 0.000001, 0.999792, 0.000002, 0.999608, 0.000004, 0.999209, 0.000008,
+ 0.998179, 0.000017, 0.994605, 0.000027, 0.979468, 0.000017, 0.967529, 0.000002,
+ 0.966836, 0.000005, 0.965690, 0.000008, 0.963706, 0.000014, 0.960063, 0.000022,
+ 0.953113, 0.000029, 0.940192, 0.000025, 0.927731, 0.000020, 0.920669, 0.000025,
+ 0.911799, 0.000032, 0.898570, 0.000034, 0.883283, 0.000032, 0.869890, 0.000036,
+ 0.855483, 0.000040, 0.837987, 0.000039, 0.820546, 0.000041, 0.802878, 0.000044,
+ 0.783402, 0.000044, 0.763439, 0.000046, 0.742925, 0.000047, 0.721633, 0.000048,
+ 0.699850, 0.000048, 0.677830, 0.000049, 0.655126, 0.000049, 0.632697, 0.000050,
+ 0.609613, 0.000049, 0.587098, 0.000049, 0.564119, 0.000048, 0.541813, 0.000048,
+ 0.519342, 0.000047, 0.497514, 0.000047, 0.475879, 0.000046, 0.454789, 0.000045,
+ 0.434217, 0.000044, 0.414086, 0.000042, 0.394744, 0.000041, 0.375782, 0.000040,
+ 0.357707, 0.000039, 0.340038, 0.000037, 0.323284, 0.000036, 0.306954, 0.000034,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 0.999999, 0.000000, 0.999998, 0.000000, 0.999997, 0.000000, 0.999993, 0.000000,
+ 0.999988, 0.000000, 0.999979, 0.000000, 0.999962, 0.000000, 0.999933, 0.000000,
+ 0.999881, 0.000001, 0.999783, 0.000002, 0.999594, 0.000004, 0.999178, 0.000009,
+ 0.998073, 0.000018, 0.993993, 0.000028, 0.979982, 0.000015, 0.968145, 0.000004,
+ 0.966786, 0.000005, 0.965611, 0.000009, 0.963557, 0.000016, 0.959752, 0.000024,
+ 0.952461, 0.000029, 0.940193, 0.000024, 0.929042, 0.000023, 0.920266, 0.000027,
+ 0.911178, 0.000034, 0.897873, 0.000033, 0.884053, 0.000035, 0.869455, 0.000038,
+ 0.854655, 0.000040, 0.838347, 0.000042, 0.820693, 0.000044, 0.802277, 0.000045,
+ 0.783634, 0.000047, 0.763159, 0.000048, 0.742914, 0.000049, 0.721662, 0.000050,
+ 0.699668, 0.000050, 0.677839, 0.000051, 0.655091, 0.000051, 0.632665, 0.000052,
+ 0.609734, 0.000051, 0.587043, 0.000051, 0.564298, 0.000051, 0.541769, 0.000050,
+ 0.519529, 0.000049, 0.497574, 0.000048, 0.476028, 0.000047, 0.454961, 0.000046,
+ 0.434341, 0.000045, 0.414364, 0.000044, 0.394832, 0.000042, 0.376109, 0.000041,
+ 0.357790, 0.000040, 0.340379, 0.000038, 0.323385, 0.000037, 0.307295, 0.000036,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 1.000000, 0.000000, 0.999999, 0.000000, 0.999999, 0.000000,
+ 0.999998, 0.000000, 0.999997, 0.000000, 0.999996, 0.000000, 0.999992, 0.000000,
+ 0.999986, 0.000000, 0.999975, 0.000000, 0.999959, 0.000000, 0.999927, 0.000000,
+ 0.999871, 0.000001, 0.999771, 0.000002, 0.999572, 0.000005, 0.999133, 0.000011,
+ 0.997912, 0.000020, 0.993008, 0.000028, 0.980645, 0.000014, 0.970057, 0.000006,
+ 0.966717, 0.000007, 0.965497, 0.000011, 0.963340, 0.000018, 0.959294, 0.000026,
+ 0.951519, 0.000029, 0.940517, 0.000025, 0.930140, 0.000027, 0.919720, 0.000030,
+ 0.910294, 0.000035, 0.897701, 0.000035, 0.884522, 0.000039, 0.869489, 0.000041,
+ 0.853983, 0.000042, 0.838425, 0.000045, 0.820656, 0.000047, 0.801875, 0.000048,
+ 0.783521, 0.000051, 0.763131, 0.000051, 0.742610, 0.000052, 0.721480, 0.000053,
+ 0.699696, 0.000054, 0.677592, 0.000054, 0.655250, 0.000055, 0.632452, 0.000054,
+ 0.609903, 0.000054, 0.586928, 0.000054, 0.564464, 0.000054, 0.541801, 0.000052,
+ 0.519681, 0.000052, 0.497685, 0.000051, 0.476220, 0.000050, 0.455135, 0.000049,
+ 0.434600, 0.000047, 0.414564, 0.000046, 0.395165, 0.000044, 0.376333, 0.000043,
+ 0.358197, 0.000042, 0.340640, 0.000040, 0.323816, 0.000039, 0.307581, 0.000037,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 1.000000, 0.000000, 0.999999, 0.000000, 0.999999, 0.000000,
+ 0.999998, 0.000000, 0.999997, 0.000000, 0.999994, 0.000000, 0.999990, 0.000000,
+ 0.999984, 0.000000, 0.999972, 0.000000, 0.999952, 0.000000, 0.999919, 0.000001,
+ 0.999860, 0.000001, 0.999753, 0.000003, 0.999546, 0.000006, 0.999074, 0.000013,
+ 0.997671, 0.000023, 0.991504, 0.000026, 0.981148, 0.000013, 0.971965, 0.000009,
+ 0.966624, 0.000008, 0.965344, 0.000014, 0.963048, 0.000021, 0.958673, 0.000029,
+ 0.950262, 0.000028, 0.940836, 0.000027, 0.930996, 0.000031, 0.919848, 0.000035,
+ 0.909136, 0.000037, 0.897554, 0.000038, 0.884691, 0.000043, 0.869414, 0.000045,
+ 0.853462, 0.000045, 0.838187, 0.000050, 0.820381, 0.000050, 0.801844, 0.000052,
+ 0.783061, 0.000054, 0.763205, 0.000055, 0.742362, 0.000056, 0.721393, 0.000057,
+ 0.699676, 0.000058, 0.677395, 0.000058, 0.655208, 0.000059, 0.632451, 0.000058,
+ 0.609839, 0.000058, 0.587093, 0.000058, 0.564467, 0.000057, 0.542043, 0.000056,
+ 0.519826, 0.000055, 0.497952, 0.000054, 0.476477, 0.000053, 0.455412, 0.000051,
+ 0.434926, 0.000050, 0.414900, 0.000049, 0.395552, 0.000047, 0.376712, 0.000045,
+ 0.358622, 0.000044, 0.341048, 0.000042, 0.324262, 0.000041, 0.308013, 0.000039,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.999998, 0.000000,
+ 0.999997, 0.000000, 0.999995, 0.000000, 0.999994, 0.000000, 0.999988, 0.000000,
+ 0.999979, 0.000000, 0.999965, 0.000000, 0.999945, 0.000000, 0.999908, 0.000001,
+ 0.999846, 0.000002, 0.999733, 0.000004, 0.999511, 0.000008, 0.998993, 0.000016,
+ 0.997326, 0.000027, 0.989706, 0.000021, 0.981713, 0.000013, 0.973636, 0.000011,
+ 0.966509, 0.000010, 0.965149, 0.000017, 0.962669, 0.000025, 0.957860, 0.000032,
+ 0.949334, 0.000028, 0.941041, 0.000030, 0.931575, 0.000036, 0.920102, 0.000040,
+ 0.908002, 0.000038, 0.897269, 0.000043, 0.884559, 0.000048, 0.869161, 0.000048,
+ 0.853342, 0.000051, 0.837633, 0.000054, 0.820252, 0.000055, 0.801872, 0.000058,
+ 0.782418, 0.000059, 0.763100, 0.000061, 0.742183, 0.000061, 0.721098, 0.000063,
+ 0.699512, 0.000063, 0.677372, 0.000064, 0.655059, 0.000063, 0.632567, 0.000064,
+ 0.609784, 0.000063, 0.587237, 0.000063, 0.564525, 0.000062, 0.542181, 0.000061,
+ 0.520017, 0.000060, 0.498204, 0.000058, 0.476742, 0.000057, 0.455803, 0.000055,
+ 0.435251, 0.000054, 0.415374, 0.000052, 0.395921, 0.000050, 0.377253, 0.000049,
+ 0.359021, 0.000047, 0.341637, 0.000045, 0.324700, 0.000043, 0.308625, 0.000042,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 0.999999, 0.000000, 0.999999, 0.000000, 0.999998, 0.000000,
+ 0.999996, 0.000000, 0.999993, 0.000000, 0.999989, 0.000000, 0.999983, 0.000000,
+ 0.999974, 0.000000, 0.999959, 0.000000, 0.999936, 0.000000, 0.999896, 0.000001,
+ 0.999830, 0.000002, 0.999709, 0.000005, 0.999469, 0.000010, 0.998886, 0.000019,
+ 0.996819, 0.000030, 0.988837, 0.000019, 0.982178, 0.000013, 0.975017, 0.000013,
+ 0.967101, 0.000014, 0.964905, 0.000021, 0.962180, 0.000030, 0.956821, 0.000034,
+ 0.948829, 0.000031, 0.941092, 0.000035, 0.931883, 0.000041, 0.920211, 0.000044,
+ 0.907307, 0.000043, 0.896840, 0.000049, 0.884119, 0.000053, 0.869148, 0.000054,
+ 0.853377, 0.000058, 0.836753, 0.000059, 0.820063, 0.000062, 0.801694, 0.000065,
+ 0.782116, 0.000065, 0.762673, 0.000067, 0.742133, 0.000068, 0.720779, 0.000069,
+ 0.699386, 0.000070, 0.677320, 0.000070, 0.654888, 0.000070, 0.632499, 0.000069,
+ 0.609825, 0.000069, 0.587287, 0.000068, 0.564743, 0.000067, 0.542409, 0.000066,
+ 0.520282, 0.000065, 0.498506, 0.000063, 0.477102, 0.000062, 0.456167, 0.000060,
+ 0.435728, 0.000058, 0.415809, 0.000056, 0.396517, 0.000054, 0.377737, 0.000053,
+ 0.359698, 0.000051, 0.342164, 0.000049, 0.325417, 0.000047, 0.309186, 0.000045,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 1.000000, 0.000000, 0.999999, 0.000000, 0.999997, 0.000000,
+ 0.999994, 0.000000, 0.999993, 0.000000, 0.999987, 0.000000, 0.999981, 0.000000,
+ 0.999969, 0.000000, 0.999953, 0.000000, 0.999925, 0.000001, 0.999881, 0.000001,
+ 0.999810, 0.000003, 0.999680, 0.000007, 0.999418, 0.000013, 0.998748, 0.000023,
+ 0.996066, 0.000033, 0.988379, 0.000018, 0.982567, 0.000014, 0.976097, 0.000015,
+ 0.968475, 0.000018, 0.964606, 0.000025, 0.961564, 0.000035, 0.955517, 0.000036,
+ 0.948381, 0.000034, 0.941095, 0.000041, 0.931923, 0.000048, 0.919960, 0.000048,
+ 0.907419, 0.000050, 0.896180, 0.000056, 0.883370, 0.000059, 0.869046, 0.000062,
+ 0.853278, 0.000066, 0.836091, 0.000066, 0.819644, 0.000070, 0.801246, 0.000071,
+ 0.782031, 0.000074, 0.762066, 0.000075, 0.741964, 0.000077, 0.720554, 0.000077,
+ 0.699098, 0.000078, 0.677189, 0.000077, 0.654840, 0.000078, 0.632496, 0.000077,
+ 0.609908, 0.000076, 0.587312, 0.000075, 0.564938, 0.000074, 0.542577, 0.000073,
+ 0.520620, 0.000071, 0.498819, 0.000069, 0.477555, 0.000068, 0.456568, 0.000065,
+ 0.436278, 0.000064, 0.416370, 0.000061, 0.397144, 0.000059, 0.378412, 0.000057,
+ 0.360376, 0.000055, 0.342906, 0.000053, 0.326136, 0.000051, 0.309970, 0.000048,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 0.999999, 0.000000, 0.999998, 0.000000, 0.999997, 0.000000,
+ 0.999994, 0.000000, 0.999991, 0.000000, 0.999985, 0.000000, 0.999977, 0.000000,
+ 0.999964, 0.000000, 0.999945, 0.000000, 0.999912, 0.000001, 0.999866, 0.000002,
+ 0.999786, 0.000004, 0.999647, 0.000009, 0.999356, 0.000016, 0.998563, 0.000028,
+ 0.994928, 0.000034, 0.987999, 0.000018, 0.982893, 0.000016, 0.977044, 0.000018,
+ 0.969972, 0.000023, 0.964237, 0.000031, 0.960791, 0.000041, 0.954292, 0.000037,
+ 0.948052, 0.000040, 0.940938, 0.000048, 0.931689, 0.000055, 0.919870, 0.000054,
+ 0.907665, 0.000059, 0.895281, 0.000064, 0.882621, 0.000066, 0.868730, 0.000071,
+ 0.853008, 0.000074, 0.835944, 0.000076, 0.818949, 0.000080, 0.800951, 0.000081,
+ 0.781847, 0.000084, 0.761649, 0.000085, 0.741520, 0.000086, 0.720495, 0.000087,
+ 0.698742, 0.000087, 0.677096, 0.000087, 0.654782, 0.000086, 0.632335, 0.000086,
+ 0.610031, 0.000085, 0.587457, 0.000084, 0.565130, 0.000082, 0.542877, 0.000080,
+ 0.520900, 0.000079, 0.499291, 0.000077, 0.477971, 0.000074, 0.457221, 0.000072,
+ 0.436803, 0.000070, 0.417083, 0.000068, 0.397749, 0.000065, 0.379177, 0.000063,
+ 0.361061, 0.000060, 0.343713, 0.000058, 0.326894, 0.000055, 0.310816, 0.000053,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 0.999999, 0.000000, 0.999999, 0.000000, 0.999996, 0.000000,
+ 0.999992, 0.000000, 0.999989, 0.000000, 0.999980, 0.000000, 0.999971, 0.000000,
+ 0.999955, 0.000000, 0.999933, 0.000001, 0.999901, 0.000001, 0.999847, 0.000003,
+ 0.999761, 0.000006, 0.999607, 0.000011, 0.999282, 0.000020, 0.998310, 0.000034,
+ 0.993288, 0.000029, 0.987855, 0.000019, 0.983167, 0.000018, 0.977908, 0.000022,
+ 0.971194, 0.000029, 0.963867, 0.000039, 0.959820, 0.000046, 0.953497, 0.000042,
+ 0.947621, 0.000048, 0.940611, 0.000057, 0.931174, 0.000062, 0.919919, 0.000063,
+ 0.907856, 0.000069, 0.894509, 0.000074, 0.881954, 0.000076, 0.868309, 0.000082,
+ 0.852511, 0.000084, 0.835821, 0.000088, 0.817981, 0.000090, 0.800504, 0.000093,
+ 0.781410, 0.000095, 0.761427, 0.000096, 0.740940, 0.000097, 0.720233, 0.000098,
+ 0.698592, 0.000098, 0.676763, 0.000098, 0.654808, 0.000097, 0.632326, 0.000096,
+ 0.610049, 0.000095, 0.587630, 0.000093, 0.565261, 0.000092, 0.543244, 0.000090,
+ 0.521273, 0.000087, 0.499818, 0.000085, 0.478536, 0.000082, 0.457826, 0.000080,
+ 0.437549, 0.000077, 0.417760, 0.000074, 0.398630, 0.000072, 0.379954, 0.000069,
+ 0.362025, 0.000066, 0.344581, 0.000063, 0.327909, 0.000061, 0.311736, 0.000058,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 1.000000, 0.000000, 0.999999, 0.000000, 0.999997, 0.000000, 0.999995, 0.000000,
+ 0.999992, 0.000000, 0.999985, 0.000000, 0.999977, 0.000000, 0.999966, 0.000000,
+ 0.999948, 0.000000, 0.999923, 0.000001, 0.999884, 0.000002, 0.999826, 0.000004,
+ 0.999732, 0.000008, 0.999561, 0.000014, 0.999191, 0.000026, 0.997955, 0.000041,
+ 0.992228, 0.000028, 0.987638, 0.000021, 0.983395, 0.000022, 0.978614, 0.000027,
+ 0.972389, 0.000037, 0.964392, 0.000047, 0.958610, 0.000051, 0.952806, 0.000049,
+ 0.947120, 0.000057, 0.940104, 0.000067, 0.930398, 0.000069, 0.919866, 0.000074,
+ 0.907853, 0.000081, 0.894078, 0.000083, 0.881177, 0.000089, 0.867575, 0.000094,
+ 0.852107, 0.000097, 0.835502, 0.000101, 0.817560, 0.000103, 0.799840, 0.000107,
+ 0.780998, 0.000108, 0.761132, 0.000110, 0.740429, 0.000110, 0.719836, 0.000111,
+ 0.698467, 0.000111, 0.676446, 0.000110, 0.654635, 0.000110, 0.632411, 0.000109,
+ 0.609986, 0.000107, 0.587872, 0.000105, 0.565528, 0.000103, 0.543563, 0.000101,
+ 0.521760, 0.000098, 0.500188, 0.000095, 0.479204, 0.000092, 0.458413, 0.000089,
+ 0.438314, 0.000086, 0.418573, 0.000082, 0.399470, 0.000079, 0.380892, 0.000076,
+ 0.362953, 0.000073, 0.345601, 0.000070, 0.328895, 0.000066, 0.312808, 0.000063,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 0.999999, 0.000000, 0.999998, 0.000000, 0.999997, 0.000000, 0.999995, 0.000000,
+ 0.999989, 0.000000, 0.999983, 0.000000, 0.999974, 0.000000, 0.999959, 0.000000,
+ 0.999939, 0.000001, 0.999911, 0.000001, 0.999868, 0.000003, 0.999804, 0.000005,
+ 0.999700, 0.000010, 0.999510, 0.000019, 0.999078, 0.000032, 0.997428, 0.000047,
+ 0.991620, 0.000029, 0.987479, 0.000023, 0.983582, 0.000026, 0.979186, 0.000034,
+ 0.973250, 0.000045, 0.965221, 0.000057, 0.957262, 0.000054, 0.952211, 0.000059,
+ 0.946631, 0.000069, 0.939391, 0.000079, 0.929795, 0.000079, 0.919650, 0.000088,
+ 0.907737, 0.000095, 0.893899, 0.000097, 0.880239, 0.000105, 0.866562, 0.000108,
+ 0.851640, 0.000113, 0.835021, 0.000117, 0.817311, 0.000120, 0.798845, 0.000122,
+ 0.780479, 0.000125, 0.760694, 0.000125, 0.740142, 0.000127, 0.719248, 0.000126,
+ 0.698209, 0.000127, 0.676398, 0.000126, 0.654378, 0.000124, 0.632484, 0.000123,
+ 0.610113, 0.000121, 0.587931, 0.000118, 0.565872, 0.000116, 0.543814, 0.000113,
+ 0.522265, 0.000110, 0.500835, 0.000106, 0.479818, 0.000103, 0.459258, 0.000099,
+ 0.439061, 0.000095, 0.419552, 0.000092, 0.400399, 0.000088, 0.381976, 0.000084,
+ 0.364009, 0.000081, 0.346761, 0.000077, 0.330049, 0.000074, 0.314018, 0.000070,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 0.999999, 0.000000, 0.999998, 0.000000, 0.999997, 0.000000, 0.999992, 0.000000,
+ 0.999989, 0.000000, 0.999980, 0.000000, 0.999969, 0.000000, 0.999953, 0.000001,
+ 0.999929, 0.000001, 0.999898, 0.000002, 0.999849, 0.000004, 0.999778, 0.000007,
+ 0.999661, 0.000013, 0.999451, 0.000024, 0.998936, 0.000040, 0.996620, 0.000052,
+ 0.991094, 0.000030, 0.987487, 0.000028, 0.983731, 0.000032, 0.979647, 0.000042,
+ 0.973837, 0.000056, 0.965840, 0.000068, 0.956309, 0.000062, 0.951523, 0.000070,
+ 0.946003, 0.000084, 0.938454, 0.000091, 0.929279, 0.000094, 0.919239, 0.000104,
+ 0.907293, 0.000110, 0.893936, 0.000115, 0.879674, 0.000122, 0.865668, 0.000126,
+ 0.850998, 0.000132, 0.834498, 0.000135, 0.816903, 0.000139, 0.798235, 0.000141,
+ 0.779724, 0.000144, 0.760251, 0.000145, 0.739808, 0.000145, 0.718762, 0.000145,
+ 0.697815, 0.000144, 0.676310, 0.000144, 0.654278, 0.000142, 0.632347, 0.000139,
+ 0.610296, 0.000137, 0.588039, 0.000134, 0.566218, 0.000131, 0.544346, 0.000127,
+ 0.522701, 0.000123, 0.501542, 0.000119, 0.480508, 0.000115, 0.460092, 0.000111,
+ 0.440021, 0.000107, 0.420446, 0.000102, 0.401512, 0.000098, 0.382990, 0.000094,
+ 0.365232, 0.000090, 0.347865, 0.000085, 0.331342, 0.000082, 0.315202, 0.000077,
+ 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
+ 0.999999, 0.000000, 0.999998, 0.000000, 0.999995, 0.000000, 0.999992, 0.000000,
+ 0.999986, 0.000000, 0.999976, 0.000001, 0.999964, 0.000001, 0.999945, 0.000001,
+ 0.999919, 0.000002, 0.999882, 0.000003, 0.999829, 0.000005, 0.999749, 0.000010,
+ 0.999620, 0.000018, 0.999382, 0.000031, 0.998751, 0.000050, 0.995344, 0.000051,
+ 0.990768, 0.000035, 0.987464, 0.000034, 0.983846, 0.000040, 0.980007, 0.000053,
+ 0.974494, 0.000070, 0.966220, 0.000078, 0.956273, 0.000075, 0.950952, 0.000086,
+ 0.945215, 0.000100, 0.937287, 0.000104, 0.928649, 0.000112, 0.918791, 0.000124,
+ 0.906685, 0.000127, 0.893706, 0.000136, 0.879248, 0.000142, 0.864685, 0.000148,
+ 0.850032, 0.000154, 0.833853, 0.000157, 0.816353, 0.000161, 0.797834, 0.000164,
+ 0.778831, 0.000165, 0.759756, 0.000167, 0.739419, 0.000167, 0.718491, 0.000167,
+ 0.697392, 0.000166, 0.676102, 0.000164, 0.654243, 0.000162, 0.632176, 0.000159,
+ 0.610407, 0.000155, 0.588394, 0.000152, 0.566450, 0.000148, 0.544900, 0.000144,
+ 0.523276, 0.000139, 0.502179, 0.000134, 0.481359, 0.000129, 0.460920, 0.000125,
+ 0.441084, 0.000120, 0.421517, 0.000115, 0.402721, 0.000110, 0.384222, 0.000105,
+ 0.366534, 0.000100, 0.349205, 0.000095, 0.332702, 0.000091, 0.316599, 0.000086,
+ 1.000000, 0.000001, 1.000000, 0.000001, 1.000000, 0.000001, 0.999999, 0.000001,
+ 0.999999, 0.000001, 0.999998, 0.000001, 0.999995, 0.000001, 0.999990, 0.000001,
+ 0.999984, 0.000001, 0.999973, 0.000001, 0.999959, 0.000001, 0.999936, 0.000002,
+ 0.999907, 0.000003, 0.999866, 0.000004, 0.999806, 0.000008, 0.999716, 0.000013,
+ 0.999576, 0.000023, 0.999300, 0.000039, 0.998498, 0.000061, 0.994132, 0.000049,
+ 0.990310, 0.000038, 0.987409, 0.000042, 0.983981, 0.000050, 0.980268, 0.000067,
+ 0.974875, 0.000085, 0.966063, 0.000086, 0.956779, 0.000090, 0.950259, 0.000106,
+ 0.944239, 0.000119, 0.936341, 0.000122, 0.928047, 0.000135, 0.918065, 0.000146,
+ 0.906267, 0.000151, 0.893419, 0.000162, 0.878758, 0.000166, 0.863699, 0.000174,
+ 0.848876, 0.000178, 0.833032, 0.000184, 0.815557, 0.000186, 0.797323, 0.000191,
+ 0.778124, 0.000192, 0.758929, 0.000193, 0.738979, 0.000193, 0.718213, 0.000192,
+ 0.696947, 0.000190, 0.675807, 0.000188, 0.654147, 0.000184, 0.632290, 0.000181,
+ 0.610499, 0.000177, 0.588747, 0.000173, 0.566783, 0.000167, 0.545359, 0.000163,
+ 0.523984, 0.000157, 0.502917, 0.000152, 0.482294, 0.000146, 0.461945, 0.000140,
+ 0.442133, 0.000134, 0.422705, 0.000128, 0.403916, 0.000123, 0.385540, 0.000117,
+ 0.367909, 0.000112, 0.350651, 0.000106, 0.334208, 0.000101, 0.318123, 0.000096,
+ 1.000000, 0.000001, 1.000000, 0.000001, 1.000000, 0.000001, 1.000000, 0.000001,
+ 0.999999, 0.000001, 0.999997, 0.000001, 0.999995, 0.000001, 0.999989, 0.000001,
+ 0.999981, 0.000001, 0.999969, 0.000002, 0.999952, 0.000002, 0.999928, 0.000003,
+ 0.999895, 0.000004, 0.999848, 0.000007, 0.999781, 0.000011, 0.999682, 0.000018,
+ 0.999523, 0.000031, 0.999205, 0.000050, 0.998131, 0.000073, 0.993334, 0.000051,
+ 0.990160, 0.000047, 0.987321, 0.000052, 0.984099, 0.000064, 0.980432, 0.000084,
+ 0.974976, 0.000103, 0.966429, 0.000100, 0.957633, 0.000111, 0.949422, 0.000129,
+ 0.943045, 0.000140, 0.935448, 0.000146, 0.927225, 0.000162, 0.917033, 0.000169,
+ 0.905762, 0.000180, 0.892879, 0.000190, 0.878435, 0.000196, 0.863114, 0.000205,
+ 0.847760, 0.000209, 0.832084, 0.000215, 0.814915, 0.000218, 0.796711, 0.000220,
+ 0.777603, 0.000223, 0.757991, 0.000222, 0.738371, 0.000223, 0.717872, 0.000221,
+ 0.696619, 0.000218, 0.675379, 0.000216, 0.654110, 0.000212, 0.632410, 0.000207,
+ 0.610460, 0.000202, 0.589030, 0.000197, 0.567267, 0.000190, 0.545886, 0.000185,
+ 0.524714, 0.000177, 0.503789, 0.000171, 0.483204, 0.000165, 0.462976, 0.000157,
+ 0.443294, 0.000151, 0.423988, 0.000144, 0.405325, 0.000138, 0.386981, 0.000131,
+ 0.369436, 0.000125, 0.352190, 0.000118, 0.335804, 0.000113, 0.319749, 0.000107,
+ 1.000000, 0.000002, 1.000000, 0.000002, 1.000000, 0.000002, 0.999999, 0.000002,
+ 0.999999, 0.000002, 0.999997, 0.000002, 0.999993, 0.000002, 0.999987, 0.000002,
+ 0.999979, 0.000003, 0.999965, 0.000003, 0.999947, 0.000003, 0.999918, 0.000005,
+ 0.999881, 0.000006, 0.999828, 0.000010, 0.999753, 0.000015, 0.999642, 0.000025,
+ 0.999464, 0.000040, 0.999089, 0.000064, 0.997567, 0.000086, 0.992903, 0.000059,
+ 0.990011, 0.000058, 0.987192, 0.000065, 0.984180, 0.000082, 0.980491, 0.000106,
+ 0.974779, 0.000122, 0.966750, 0.000119, 0.958248, 0.000136, 0.948884, 0.000155,
+ 0.941673, 0.000162, 0.934521, 0.000177, 0.926205, 0.000193, 0.916089, 0.000200,
+ 0.904963, 0.000214, 0.892089, 0.000222, 0.878028, 0.000233, 0.862490, 0.000239,
+ 0.846587, 0.000247, 0.830988, 0.000251, 0.814165, 0.000256, 0.796135, 0.000258,
+ 0.777052, 0.000259, 0.757201, 0.000258, 0.737655, 0.000257, 0.717477, 0.000255,
+ 0.696433, 0.000252, 0.675084, 0.000247, 0.653907, 0.000242, 0.632561, 0.000237,
+ 0.610658, 0.000229, 0.589322, 0.000224, 0.567857, 0.000216, 0.546520, 0.000209,
+ 0.525433, 0.000202, 0.504679, 0.000193, 0.484203, 0.000186, 0.464203, 0.000178,
+ 0.444549, 0.000170, 0.425346, 0.000162, 0.406706, 0.000154, 0.388576, 0.000147,
+ 0.370940, 0.000139, 0.353996, 0.000133, 0.337391, 0.000126, 0.321648, 0.000120,
+ 1.000000, 0.000004, 1.000000, 0.000004, 1.000000, 0.000004, 0.999999, 0.000004,
+ 0.999998, 0.000004, 0.999996, 0.000004, 0.999992, 0.000004, 0.999986, 0.000004,
+ 0.999976, 0.000004, 0.999961, 0.000005, 0.999938, 0.000006, 0.999908, 0.000007,
+ 0.999865, 0.000010, 0.999807, 0.000014, 0.999723, 0.000022, 0.999602, 0.000034,
+ 0.999398, 0.000053, 0.998946, 0.000081, 0.996647, 0.000094, 0.992298, 0.000067,
+ 0.989802, 0.000072, 0.987019, 0.000082, 0.984219, 0.000105, 0.980425, 0.000131,
+ 0.974241, 0.000140, 0.967006, 0.000146, 0.958930, 0.000167, 0.949157, 0.000188,
+ 0.940620, 0.000195, 0.933509, 0.000214, 0.925088, 0.000230, 0.915178, 0.000240,
+ 0.904093, 0.000255, 0.891337, 0.000264, 0.877326, 0.000275, 0.861794, 0.000281,
+ 0.845758, 0.000290, 0.829792, 0.000294, 0.813037, 0.000297, 0.795285, 0.000300,
+ 0.776323, 0.000300, 0.756673, 0.000300, 0.736856, 0.000298, 0.716883, 0.000294,
+ 0.696089, 0.000289, 0.675050, 0.000285, 0.653509, 0.000277, 0.632580, 0.000272,
+ 0.611040, 0.000263, 0.589567, 0.000255, 0.568322, 0.000246, 0.547235, 0.000237,
+ 0.526160, 0.000228, 0.505716, 0.000219, 0.485274, 0.000210, 0.465411, 0.000201,
+ 0.445854, 0.000191, 0.426911, 0.000183, 0.408222, 0.000174, 0.390307, 0.000165,
+ 0.372624, 0.000157, 0.355804, 0.000149, 0.339240, 0.000141, 0.323534, 0.000134,
+ 1.000000, 0.000006, 1.000000, 0.000006, 1.000000, 0.000006, 0.999999, 0.000006,
+ 0.999998, 0.000006, 0.999996, 0.000006, 0.999991, 0.000007, 0.999984, 0.000007,
+ 0.999973, 0.000007, 0.999955, 0.000008, 0.999931, 0.000009, 0.999896, 0.000011,
+ 0.999847, 0.000015, 0.999784, 0.000021, 0.999692, 0.000030, 0.999554, 0.000045,
+ 0.999326, 0.000069, 0.998757, 0.000102, 0.995367, 0.000096, 0.992090, 0.000083,
+ 0.989517, 0.000089, 0.987008, 0.000106, 0.984210, 0.000133, 0.980210, 0.000162,
+ 0.973676, 0.000162, 0.967052, 0.000179, 0.959385, 0.000207, 0.949461, 0.000225,
+ 0.939578, 0.000236, 0.932416, 0.000259, 0.923759, 0.000271, 0.914223, 0.000289,
+ 0.902942, 0.000301, 0.890419, 0.000314, 0.876639, 0.000324, 0.861316, 0.000332,
+ 0.844960, 0.000338, 0.828427, 0.000346, 0.811871, 0.000348, 0.794397, 0.000350,
+ 0.775726, 0.000350, 0.756170, 0.000347, 0.736091, 0.000344, 0.716213, 0.000341,
+ 0.695736, 0.000332, 0.674961, 0.000328, 0.653518, 0.000319, 0.632574, 0.000310,
+ 0.611340, 0.000301, 0.590017, 0.000291, 0.568752, 0.000280, 0.548061, 0.000270,
+ 0.527110, 0.000259, 0.506682, 0.000248, 0.486524, 0.000237, 0.466812, 0.000227,
+ 0.447320, 0.000216, 0.428473, 0.000206, 0.409921, 0.000196, 0.392028, 0.000185,
+ 0.374606, 0.000176, 0.357601, 0.000167, 0.341348, 0.000158, 0.325420, 0.000149,
+ 1.000000, 0.000010, 1.000000, 0.000010, 1.000000, 0.000010, 0.999999, 0.000010,
+ 0.999998, 0.000010, 0.999995, 0.000011, 0.999991, 0.000011, 0.999982, 0.000011,
+ 0.999968, 0.000012, 0.999950, 0.000013, 0.999922, 0.000015, 0.999884, 0.000018,
+ 0.999830, 0.000022, 0.999758, 0.000030, 0.999654, 0.000042, 0.999503, 0.000061,
+ 0.999237, 0.000090, 0.998491, 0.000127, 0.994594, 0.000108, 0.991780, 0.000103,
+ 0.989265, 0.000112, 0.986998, 0.000136, 0.984137, 0.000169, 0.979798, 0.000197,
+ 0.973370, 0.000197, 0.967239, 0.000223, 0.959543, 0.000254, 0.949466, 0.000266,
+ 0.939074, 0.000288, 0.931118, 0.000311, 0.922525, 0.000326, 0.912983, 0.000346,
+ 0.901617, 0.000356, 0.889487, 0.000374, 0.875787, 0.000383, 0.860654, 0.000394,
+ 0.844417, 0.000400, 0.827410, 0.000405, 0.810545, 0.000407, 0.793312, 0.000407,
+ 0.774847, 0.000407, 0.755621, 0.000405, 0.735511, 0.000397, 0.715435, 0.000394,
+ 0.695403, 0.000385, 0.674681, 0.000376, 0.653590, 0.000366, 0.632471, 0.000355,
+ 0.611510, 0.000344, 0.590640, 0.000332, 0.569386, 0.000319, 0.548785, 0.000307,
+ 0.528146, 0.000294, 0.507872, 0.000282, 0.487805, 0.000269, 0.468196, 0.000256,
+ 0.448922, 0.000244, 0.430093, 0.000232, 0.411845, 0.000220, 0.393808, 0.000209,
+ 0.376615, 0.000198, 0.359655, 0.000187, 0.343452, 0.000177, 0.327650, 0.000168,
+ 1.000000, 0.000017, 1.000000, 0.000017, 1.000000, 0.000017, 0.999999, 0.000017,
+ 0.999998, 0.000017, 0.999995, 0.000017, 0.999990, 0.000018, 0.999979, 0.000018,
+ 0.999966, 0.000019, 0.999944, 0.000021, 0.999912, 0.000023, 0.999869, 0.000027,
+ 0.999811, 0.000033, 0.999730, 0.000043, 0.999617, 0.000059, 0.999445, 0.000083,
+ 0.999138, 0.000118, 0.998095, 0.000157, 0.993919, 0.000125, 0.991333, 0.000126,
+ 0.989226, 0.000145, 0.986954, 0.000176, 0.983982, 0.000214, 0.979128, 0.000235,
+ 0.973327, 0.000244, 0.967416, 0.000277, 0.959729, 0.000309, 0.949758, 0.000322,
+ 0.939173, 0.000350, 0.929600, 0.000370, 0.921181, 0.000391, 0.911640, 0.000414,
+ 0.900435, 0.000427, 0.888183, 0.000441, 0.874772, 0.000455, 0.859566, 0.000462,
+ 0.843579, 0.000472, 0.826453, 0.000474, 0.809164, 0.000477, 0.792179, 0.000478,
+ 0.773866, 0.000473, 0.754944, 0.000470, 0.735133, 0.000462, 0.714858, 0.000454,
+ 0.694829, 0.000444, 0.674453, 0.000432, 0.653685, 0.000420, 0.632666, 0.000407,
+ 0.611676, 0.000392, 0.591193, 0.000379, 0.570145, 0.000363, 0.549566, 0.000349,
+ 0.529278, 0.000334, 0.509026, 0.000318, 0.489186, 0.000304, 0.469662, 0.000289,
+ 0.450691, 0.000275, 0.431841, 0.000261, 0.413752, 0.000248, 0.395951, 0.000235,
+ 0.378633, 0.000222, 0.361940, 0.000211, 0.345599, 0.000198, 0.329999, 0.000188,
+ 1.000000, 0.000027, 1.000000, 0.000027, 1.000000, 0.000027, 0.999999, 0.000027,
+ 0.999998, 0.000027, 0.999994, 0.000027, 0.999988, 0.000028, 0.999977, 0.000029,
+ 0.999961, 0.000030, 0.999937, 0.000032, 0.999904, 0.000036, 0.999854, 0.000041,
+ 0.999790, 0.000049, 0.999699, 0.000062, 0.999572, 0.000082, 0.999381, 0.000112,
+ 0.999016, 0.000154, 0.997437, 0.000188, 0.993545, 0.000156, 0.991135, 0.000161,
+ 0.989157, 0.000188, 0.986874, 0.000226, 0.983714, 0.000269, 0.978301, 0.000277,
+ 0.973227, 0.000303, 0.967317, 0.000342, 0.959477, 0.000371, 0.950012, 0.000393,
+ 0.939484, 0.000428, 0.928135, 0.000444, 0.919819, 0.000473, 0.910049, 0.000492,
+ 0.899181, 0.000513, 0.886881, 0.000524, 0.873590, 0.000540, 0.858613, 0.000547,
+ 0.842809, 0.000555, 0.825727, 0.000558, 0.808086, 0.000558, 0.790728, 0.000556,
+ 0.772987, 0.000553, 0.754100, 0.000544, 0.734669, 0.000536, 0.714411, 0.000523,
+ 0.694196, 0.000512, 0.674252, 0.000497, 0.653570, 0.000481, 0.632999, 0.000467,
+ 0.611994, 0.000449, 0.591604, 0.000432, 0.571134, 0.000415, 0.550528, 0.000396,
+ 0.530292, 0.000379, 0.510364, 0.000361, 0.490749, 0.000344, 0.471266, 0.000328,
+ 0.452462, 0.000311, 0.433907, 0.000295, 0.415659, 0.000279, 0.398138, 0.000265,
+ 0.380833, 0.000250, 0.364247, 0.000236, 0.348041, 0.000223, 0.332389, 0.000211,
+ 1.000000, 0.000042, 1.000000, 0.000042, 1.000000, 0.000042, 0.999999, 0.000042,
+ 0.999997, 0.000042, 0.999993, 0.000043, 0.999986, 0.000043, 0.999974, 0.000044,
+ 0.999956, 0.000046, 0.999930, 0.000049, 0.999892, 0.000054, 0.999838, 0.000061,
+ 0.999767, 0.000072, 0.999666, 0.000088, 0.999525, 0.000113, 0.999311, 0.000150,
+ 0.998865, 0.000200, 0.996278, 0.000211, 0.992956, 0.000190, 0.991017, 0.000210,
+ 0.989055, 0.000244, 0.986741, 0.000290, 0.983288, 0.000334, 0.977784, 0.000340,
+ 0.973037, 0.000378, 0.967181, 0.000424, 0.958971, 0.000444, 0.950093, 0.000483,
+ 0.939552, 0.000518, 0.927678, 0.000539, 0.918278, 0.000569, 0.908449, 0.000589,
+ 0.897713, 0.000612, 0.885533, 0.000626, 0.872131, 0.000639, 0.857517, 0.000647,
+ 0.841796, 0.000652, 0.824726, 0.000654, 0.807297, 0.000656, 0.789058, 0.000647,
+ 0.771890, 0.000644, 0.753082, 0.000630, 0.734100, 0.000622, 0.714094, 0.000605,
+ 0.693839, 0.000589, 0.673891, 0.000573, 0.653565, 0.000553, 0.633326, 0.000533,
+ 0.612582, 0.000515, 0.592050, 0.000493, 0.571918, 0.000472, 0.551572, 0.000452,
+ 0.531553, 0.000430, 0.511750, 0.000410, 0.492380, 0.000390, 0.473143, 0.000370,
+ 0.454230, 0.000351, 0.435963, 0.000332, 0.417870, 0.000315, 0.400387, 0.000297,
+ 0.383332, 0.000281, 0.366665, 0.000265, 0.350633, 0.000251, 0.334964, 0.000236,
+ 1.000000, 0.000064, 1.000000, 0.000064, 1.000000, 0.000064, 0.999999, 0.000064,
+ 0.999997, 0.000065, 0.999994, 0.000065, 0.999985, 0.000066, 0.999972, 0.000068,
+ 0.999952, 0.000070, 0.999922, 0.000074, 0.999880, 0.000080, 0.999820, 0.000090,
+ 0.999741, 0.000104, 0.999629, 0.000125, 0.999474, 0.000156, 0.999229, 0.000201,
+ 0.998662, 0.000259, 0.995299, 0.000245, 0.992732, 0.000245, 0.990847, 0.000273,
+ 0.988911, 0.000316, 0.986540, 0.000372, 0.982636, 0.000410, 0.977346, 0.000422,
+ 0.972909, 0.000476, 0.966821, 0.000522, 0.958686, 0.000545, 0.949754, 0.000589,
+ 0.939184, 0.000620, 0.927505, 0.000654, 0.916606, 0.000682, 0.906707, 0.000704,
+ 0.895937, 0.000726, 0.883913, 0.000744, 0.870642, 0.000755, 0.856241, 0.000764,
+ 0.840690, 0.000771, 0.823728, 0.000766, 0.806481, 0.000768, 0.787924, 0.000754,
+ 0.770588, 0.000750, 0.751991, 0.000732, 0.733407, 0.000718, 0.713688, 0.000701,
+ 0.693595, 0.000679, 0.673426, 0.000657, 0.653590, 0.000636, 0.633576, 0.000612,
+ 0.613144, 0.000586, 0.592711, 0.000563, 0.572722, 0.000538, 0.552762, 0.000513,
+ 0.532985, 0.000490, 0.513219, 0.000464, 0.493992, 0.000442, 0.475090, 0.000419,
+ 0.456287, 0.000397, 0.438152, 0.000376, 0.420294, 0.000355, 0.402749, 0.000335,
+ 0.385879, 0.000316, 0.369352, 0.000298, 0.353301, 0.000281, 0.337781, 0.000265,
+ 1.000000, 0.000097, 1.000000, 0.000097, 1.000000, 0.000097, 0.999999, 0.000097,
+ 0.999997, 0.000097, 0.999993, 0.000098, 0.999984, 0.000099, 0.999969, 0.000101,
+ 0.999946, 0.000105, 0.999913, 0.000110, 0.999868, 0.000118, 0.999801, 0.000130,
+ 0.999712, 0.000149, 0.999589, 0.000175, 0.999416, 0.000214, 0.999136, 0.000269,
+ 0.998367, 0.000333, 0.994701, 0.000305, 0.992497, 0.000318, 0.990608, 0.000354,
+ 0.988715, 0.000409, 0.986241, 0.000473, 0.981696, 0.000495, 0.977097, 0.000533,
+ 0.972583, 0.000594, 0.966142, 0.000637, 0.958230, 0.000670, 0.949677, 0.000719,
+ 0.939226, 0.000751, 0.927501, 0.000793, 0.915199, 0.000820, 0.904980, 0.000848,
+ 0.894243, 0.000869, 0.882154, 0.000884, 0.869161, 0.000898, 0.854751, 0.000901,
+ 0.839368, 0.000907, 0.822874, 0.000902, 0.805514, 0.000897, 0.787160, 0.000882,
+ 0.769061, 0.000870, 0.751000, 0.000852, 0.732614, 0.000831, 0.713171, 0.000807,
+ 0.693472, 0.000783, 0.673528, 0.000756, 0.653397, 0.000727, 0.633781, 0.000700,
+ 0.613877, 0.000671, 0.593506, 0.000640, 0.573667, 0.000614, 0.553932, 0.000583,
+ 0.534345, 0.000554, 0.515042, 0.000528, 0.495674, 0.000499, 0.477132, 0.000474,
+ 0.458609, 0.000448, 0.440354, 0.000424, 0.422765, 0.000400, 0.405472, 0.000378,
+ 0.388482, 0.000355, 0.372191, 0.000336, 0.356099, 0.000315, 0.340737, 0.000298,
+ 1.000000, 0.000143, 1.000000, 0.000143, 1.000000, 0.000143, 0.999999, 0.000144,
+ 0.999996, 0.000144, 0.999991, 0.000145, 0.999981, 0.000147, 0.999966, 0.000149,
+ 0.999941, 0.000154, 0.999905, 0.000161, 0.999852, 0.000172, 0.999780, 0.000187,
+ 0.999681, 0.000210, 0.999546, 0.000244, 0.999352, 0.000292, 0.999027, 0.000357,
+ 0.997886, 0.000422, 0.994190, 0.000385, 0.992140, 0.000410, 0.990274, 0.000456,
+ 0.988455, 0.000527, 0.985804, 0.000598, 0.981030, 0.000613, 0.976674, 0.000668,
+ 0.972021, 0.000737, 0.965274, 0.000774, 0.958046, 0.000831, 0.949333, 0.000876,
+ 0.939135, 0.000917, 0.927119, 0.000952, 0.914690, 0.000991, 0.903006, 0.001013,
+ 0.892368, 0.001038, 0.880231, 0.001050, 0.867432, 0.001063, 0.853208, 0.001068,
+ 0.837956, 0.001065, 0.821772, 0.001059, 0.804328, 0.001047, 0.786465, 0.001032,
+ 0.768004, 0.001011, 0.749720, 0.000986, 0.731682, 0.000963, 0.712813, 0.000932,
+ 0.693139, 0.000899, 0.673566, 0.000870, 0.653483, 0.000836, 0.633891, 0.000800,
+ 0.614433, 0.000767, 0.594586, 0.000732, 0.574769, 0.000696, 0.555149, 0.000664,
+ 0.535898, 0.000630, 0.516753, 0.000596, 0.497816, 0.000567, 0.479034, 0.000534,
+ 0.460975, 0.000507, 0.442935, 0.000477, 0.425263, 0.000451, 0.408248, 0.000425,
+ 0.391339, 0.000400, 0.375130, 0.000378, 0.359172, 0.000354, 0.343876, 0.000335,
+ 1.000000, 0.000209, 1.000000, 0.000209, 1.000000, 0.000209, 0.999999, 0.000209,
+ 0.999996, 0.000210, 0.999991, 0.000211, 0.999979, 0.000213, 0.999963, 0.000217,
+ 0.999933, 0.000223, 0.999894, 0.000232, 0.999837, 0.000246, 0.999756, 0.000266,
+ 0.999648, 0.000295, 0.999499, 0.000337, 0.999283, 0.000396, 0.998896, 0.000474,
+ 0.997006, 0.000520, 0.993819, 0.000497, 0.991632, 0.000524, 0.989875, 0.000587,
+ 0.988109, 0.000676, 0.985155, 0.000748, 0.980479, 0.000769, 0.976271, 0.000841,
+ 0.971347, 0.000911, 0.964528, 0.000953, 0.957632, 0.001022, 0.948681, 0.001061,
+ 0.938716, 0.001119, 0.926629, 0.001148, 0.914025, 0.001190, 0.901026, 0.001212,
+ 0.890358, 0.001239, 0.878283, 0.001253, 0.865459, 0.001255, 0.851407, 0.001261,
+ 0.836276, 0.001248, 0.820436, 0.001244, 0.803253, 0.001221, 0.785562, 0.001201,
+ 0.767180, 0.001178, 0.748551, 0.001143, 0.730564, 0.001109, 0.712253, 0.001076,
+ 0.692867, 0.001036, 0.673695, 0.000997, 0.653912, 0.000957, 0.634129, 0.000917,
+ 0.615004, 0.000874, 0.595587, 0.000833, 0.575965, 0.000795, 0.556600, 0.000752,
+ 0.537428, 0.000716, 0.518623, 0.000677, 0.499964, 0.000641, 0.481356, 0.000606,
+ 0.463279, 0.000570, 0.445673, 0.000540, 0.428032, 0.000507, 0.411112, 0.000480,
+ 0.394444, 0.000451, 0.378247, 0.000424, 0.362415, 0.000399, 0.347103, 0.000375,
+ 1.000000, 0.000301, 1.000000, 0.000301, 1.000000, 0.000301, 0.999998, 0.000301,
+ 0.999996, 0.000302, 0.999989, 0.000303, 0.999977, 0.000306, 0.999958, 0.000311,
+ 0.999927, 0.000319, 0.999884, 0.000331, 0.999820, 0.000348, 0.999733, 0.000374,
+ 0.999613, 0.000410, 0.999447, 0.000462, 0.999204, 0.000533, 0.998725, 0.000625,
+ 0.995871, 0.000632, 0.993194, 0.000632, 0.991541, 0.000689, 0.989773, 0.000767,
+ 0.987647, 0.000864, 0.984193, 0.000922, 0.980016, 0.000971, 0.975859, 0.001060,
+ 0.970514, 0.001122, 0.963625, 0.001172, 0.956959, 0.001252, 0.947956, 0.001294,
+ 0.938090, 0.001359, 0.926590, 0.001393, 0.913829, 0.001433, 0.900050, 0.001458,
+ 0.888129, 0.001475, 0.876070, 0.001488, 0.863461, 0.001487, 0.849594, 0.001489,
+ 0.834531, 0.001465, 0.819030, 0.001458, 0.802122, 0.001430, 0.784450, 0.001397,
+ 0.766434, 0.001363, 0.747816, 0.001326, 0.729519, 0.001283, 0.711454, 0.001238,
+ 0.692699, 0.001191, 0.673723, 0.001146, 0.654386, 0.001096, 0.634673, 0.001046,
+ 0.615554, 0.001000, 0.596462, 0.000948, 0.577385, 0.000902, 0.558257, 0.000856,
+ 0.539200, 0.000810, 0.520543, 0.000769, 0.502206, 0.000724, 0.484020, 0.000686,
+ 0.465779, 0.000645, 0.448455, 0.000610, 0.431091, 0.000572, 0.414147, 0.000540,
+ 0.397650, 0.000507, 0.381576, 0.000478, 0.365881, 0.000448, 0.350582, 0.000421,
+ 1.000000, 0.000427, 1.000000, 0.000427, 1.000000, 0.000427, 0.999998, 0.000428,
+ 0.999995, 0.000429, 0.999988, 0.000431, 0.999976, 0.000434, 0.999952, 0.000441,
+ 0.999919, 0.000451, 0.999871, 0.000466, 0.999801, 0.000488, 0.999704, 0.000520,
+ 0.999572, 0.000566, 0.999389, 0.000629, 0.999114, 0.000715, 0.998488, 0.000819,
+ 0.995234, 0.000804, 0.993021, 0.000830, 0.991407, 0.000903, 0.989625, 0.000997,
+ 0.987064, 0.001097, 0.983265, 0.001144, 0.979535, 0.001227, 0.975224, 0.001326,
+ 0.969574, 0.001381, 0.963021, 0.001459, 0.956046, 0.001528, 0.947136, 0.001582,
+ 0.937313, 0.001635, 0.926073, 0.001684, 0.913121, 0.001716, 0.899165, 0.001742,
+ 0.885891, 0.001761, 0.873783, 0.001764, 0.861331, 0.001762, 0.847569, 0.001753,
+ 0.832785, 0.001728, 0.817442, 0.001702, 0.800613, 0.001666, 0.783597, 0.001629,
+ 0.765710, 0.001583, 0.747021, 0.001531, 0.728593, 0.001480, 0.710661, 0.001428,
+ 0.692426, 0.001369, 0.673623, 0.001311, 0.654940, 0.001256, 0.635448, 0.001195,
+ 0.616221, 0.001138, 0.597531, 0.001082, 0.578795, 0.001027, 0.559892, 0.000971,
+ 0.541307, 0.000920, 0.522608, 0.000868, 0.504484, 0.000821, 0.486603, 0.000773,
+ 0.468802, 0.000730, 0.451172, 0.000685, 0.434348, 0.000648, 0.417445, 0.000606,
+ 0.401077, 0.000572, 0.385039, 0.000536, 0.369483, 0.000504, 0.354272, 0.000473,
+ 1.000000, 0.000600, 1.000000, 0.000600, 1.000000, 0.000600, 0.999998, 0.000600,
+ 0.999994, 0.000601, 0.999987, 0.000604, 0.999972, 0.000609, 0.999949, 0.000617,
+ 0.999912, 0.000630, 0.999857, 0.000649, 0.999781, 0.000677, 0.999674, 0.000717,
+ 0.999528, 0.000773, 0.999326, 0.000850, 0.999009, 0.000953, 0.998112, 0.001064,
+ 0.994496, 0.001022, 0.992806, 0.001086, 0.991211, 0.001176, 0.989415, 0.001290,
+ 0.986499, 0.001390, 0.982679, 0.001445, 0.978839, 0.001540, 0.974295, 0.001644,
+ 0.968784, 0.001715, 0.962324, 0.001803, 0.954956, 0.001864, 0.946240, 0.001938,
+ 0.936517, 0.001982, 0.925186, 0.002030, 0.912520, 0.002066, 0.898441, 0.002078,
+ 0.884394, 0.002099, 0.871273, 0.002087, 0.859057, 0.002087, 0.845243, 0.002055,
+ 0.830723, 0.002029, 0.815801, 0.001995, 0.799140, 0.001942, 0.782372, 0.001888,
+ 0.764820, 0.001837, 0.746586, 0.001774, 0.728100, 0.001706, 0.709842, 0.001641,
+ 0.692019, 0.001574, 0.673640, 0.001503, 0.655277, 0.001435, 0.636438, 0.001364,
+ 0.617364, 0.001299, 0.598603, 0.001230, 0.580195, 0.001166, 0.561786, 0.001104,
+ 0.543377, 0.001041, 0.525093, 0.000984, 0.506791, 0.000927, 0.489291, 0.000874,
+ 0.471811, 0.000822, 0.454435, 0.000775, 0.437493, 0.000727, 0.420977, 0.000684,
+ 0.404729, 0.000644, 0.388756, 0.000603, 0.373344, 0.000568, 0.358191, 0.000532,
+ 1.000000, 0.000832, 1.000000, 0.000832, 1.000000, 0.000832, 0.999998, 0.000833,
+ 0.999995, 0.000834, 0.999985, 0.000838, 0.999969, 0.000844, 0.999944, 0.000854,
+ 0.999903, 0.000870, 0.999843, 0.000894, 0.999759, 0.000929, 0.999643, 0.000978,
+ 0.999480, 0.001047, 0.999255, 0.001140, 0.998885, 0.001262, 0.997405, 0.001359,
+ 0.994240, 0.001336, 0.992458, 0.001409, 0.990929, 0.001523, 0.989116, 0.001659,
+ 0.985624, 0.001741, 0.982003, 0.001821, 0.978336, 0.001945, 0.973184, 0.002027,
+ 0.967800, 0.002122, 0.961348, 0.002214, 0.953841, 0.002282, 0.945340, 0.002357,
+ 0.935552, 0.002406, 0.924064, 0.002444, 0.911827, 0.002476, 0.897731, 0.002484,
+ 0.883409, 0.002499, 0.868625, 0.002467, 0.856529, 0.002465, 0.842999, 0.002424,
+ 0.828505, 0.002374, 0.813825, 0.002326, 0.797813, 0.002267, 0.781097, 0.002197,
+ 0.764038, 0.002124, 0.746067, 0.002048, 0.727687, 0.001967, 0.709571, 0.001888,
+ 0.691503, 0.001805, 0.673673, 0.001718, 0.655732, 0.001641, 0.637399, 0.001559,
+ 0.618616, 0.001476, 0.600050, 0.001401, 0.581713, 0.001324, 0.563546, 0.001250,
+ 0.545605, 0.001182, 0.527559, 0.001112, 0.509764, 0.001050, 0.491930, 0.000986,
+ 0.475011, 0.000929, 0.457878, 0.000873, 0.440979, 0.000820, 0.424613, 0.000772,
+ 0.408549, 0.000722, 0.392771, 0.000680, 0.377317, 0.000637, 0.362352, 0.000598,
+ 1.000000, 0.001143, 1.000000, 0.001143, 0.999999, 0.001143, 0.999998, 0.001144,
+ 0.999994, 0.001146, 0.999984, 0.001150, 0.999967, 0.001158, 0.999937, 0.001171,
+ 0.999894, 0.001191, 0.999828, 0.001220, 0.999735, 0.001263, 0.999606, 0.001324,
+ 0.999426, 0.001407, 0.999173, 0.001519, 0.998730, 0.001661, 0.996243, 0.001702,
+ 0.993779, 0.001728, 0.991900, 0.001811, 0.990524, 0.001960, 0.988680, 0.002120,
+ 0.984663, 0.002176, 0.981457, 0.002306, 0.977608, 0.002440, 0.972215, 0.002513,
+ 0.966798, 0.002629, 0.960241, 0.002714, 0.952489, 0.002784, 0.944127, 0.002854,
+ 0.934282, 0.002910, 0.923271, 0.002946, 0.910803, 0.002963, 0.896705, 0.002968,
+ 0.882380, 0.002966, 0.867116, 0.002932, 0.853636, 0.002894, 0.840469, 0.002847,
+ 0.826390, 0.002786, 0.811759, 0.002716, 0.796113, 0.002632, 0.779518, 0.002546,
+ 0.763142, 0.002460, 0.745464, 0.002365, 0.727491, 0.002265, 0.709414, 0.002164,
+ 0.691396, 0.002071, 0.673680, 0.001971, 0.656049, 0.001870, 0.638188, 0.001776,
+ 0.620177, 0.001685, 0.601506, 0.001589, 0.583620, 0.001506, 0.565496, 0.001418,
+ 0.547890, 0.001337, 0.530323, 0.001260, 0.512795, 0.001186, 0.495199, 0.001115,
+ 0.478101, 0.001049, 0.461511, 0.000984, 0.444879, 0.000926, 0.428424, 0.000867,
+ 0.412495, 0.000814, 0.396975, 0.000764, 0.381614, 0.000716, 0.366732, 0.000672,
+ 1.000000, 0.001555, 1.000000, 0.001555, 1.000000, 0.001555, 0.999998, 0.001556,
+ 0.999994, 0.001559, 0.999983, 0.001564, 0.999963, 0.001573, 0.999932, 0.001589,
+ 0.999882, 0.001614, 0.999810, 0.001650, 0.999708, 0.001703, 0.999565, 0.001777,
+ 0.999368, 0.001877, 0.999081, 0.002010, 0.998520, 0.002172, 0.995490, 0.002174,
+ 0.993252, 0.002224, 0.991727, 0.002350, 0.989951, 0.002506, 0.988029, 0.002688,
+ 0.984029, 0.002750, 0.980683, 0.002898, 0.976554, 0.003033, 0.971390, 0.003133,
+ 0.965544, 0.003237, 0.959120, 0.003334, 0.951183, 0.003404, 0.942974, 0.003475,
+ 0.932642, 0.003504, 0.922158, 0.003545, 0.909404, 0.003539, 0.896071, 0.003544,
+ 0.881206, 0.003499, 0.866077, 0.003473, 0.850930, 0.003415, 0.837703, 0.003334,
+ 0.823878, 0.003249, 0.809449, 0.003163, 0.794379, 0.003064, 0.778138, 0.002950,
+ 0.761997, 0.002841, 0.744938, 0.002721, 0.727212, 0.002607, 0.709549, 0.002489,
+ 0.691704, 0.002368, 0.673689, 0.002252, 0.656453, 0.002138, 0.639128, 0.002022,
+ 0.621512, 0.001914, 0.603598, 0.001810, 0.585590, 0.001705, 0.567852, 0.001609,
+ 0.550300, 0.001514, 0.533033, 0.001425, 0.515942, 0.001340, 0.498814, 0.001260,
+ 0.481595, 0.001182, 0.465117, 0.001112, 0.448865, 0.001041, 0.432711, 0.000977,
+ 0.416822, 0.000919, 0.401272, 0.000858, 0.386226, 0.000807, 0.371321, 0.000755,
+ 1.000000, 0.002096, 1.000000, 0.002096, 1.000000, 0.002096, 0.999997, 0.002097,
+ 0.999991, 0.002100, 0.999979, 0.002107, 0.999959, 0.002118, 0.999925, 0.002138,
+ 0.999870, 0.002168, 0.999791, 0.002213, 0.999677, 0.002277, 0.999521, 0.002365,
+ 0.999301, 0.002485, 0.998977, 0.002642, 0.998191, 0.002817, 0.994801, 0.002785,
+ 0.993091, 0.002888, 0.991571, 0.003039, 0.989700, 0.003216, 0.987023, 0.003373,
+ 0.983289, 0.003461, 0.979892, 0.003637, 0.975111, 0.003736, 0.970351, 0.003884,
+ 0.964131, 0.003971, 0.957747, 0.004081, 0.949536, 0.004135, 0.941372, 0.004203,
+ 0.931049, 0.004228, 0.920647, 0.004250, 0.908033, 0.004228, 0.895028, 0.004220,
+ 0.879968, 0.004150, 0.864875, 0.004088, 0.849180, 0.004009, 0.834934, 0.003912,
+ 0.821397, 0.003801, 0.807135, 0.003680, 0.792363, 0.003552, 0.776661, 0.003411,
+ 0.760705, 0.003281, 0.744408, 0.003140, 0.726994, 0.002991, 0.709598, 0.002850,
+ 0.692112, 0.002712, 0.674435, 0.002572, 0.656760, 0.002434, 0.639982, 0.002304,
+ 0.622983, 0.002178, 0.605471, 0.002050, 0.587960, 0.001938, 0.570463, 0.001820,
+ 0.553058, 0.001715, 0.535894, 0.001611, 0.519089, 0.001514, 0.502454, 0.001421,
+ 0.485681, 0.001335, 0.468935, 0.001250, 0.452951, 0.001173, 0.437139, 0.001102,
+ 0.421446, 0.001031, 0.405951, 0.000966, 0.391003, 0.000908, 0.376198, 0.000848,
+ 1.000000, 0.002801, 1.000000, 0.002801, 0.999999, 0.002801, 0.999997, 0.002802,
+ 0.999992, 0.002806, 0.999979, 0.002814, 0.999956, 0.002828, 0.999916, 0.002852,
+ 0.999857, 0.002889, 0.999768, 0.002943, 0.999645, 0.003019, 0.999470, 0.003125,
+ 0.999229, 0.003267, 0.998852, 0.003450, 0.997558, 0.003611, 0.994417, 0.003590,
+ 0.992824, 0.003724, 0.991344, 0.003907, 0.989337, 0.004104, 0.985811, 0.004210,
+ 0.982772, 0.004375, 0.979001, 0.004551, 0.974102, 0.004645, 0.969197, 0.004806,
+ 0.962759, 0.004878, 0.956207, 0.004982, 0.947909, 0.005034, 0.939596, 0.005075,
+ 0.929642, 0.005098, 0.918807, 0.005085, 0.906921, 0.005056, 0.893312, 0.004988,
+ 0.878933, 0.004913, 0.863986, 0.004826, 0.847936, 0.004708, 0.832253, 0.004569,
+ 0.818619, 0.004427, 0.804788, 0.004277, 0.790241, 0.004119, 0.775162, 0.003948,
+ 0.759463, 0.003774, 0.743598, 0.003610, 0.726970, 0.003436, 0.709646, 0.003264,
+ 0.692770, 0.003097, 0.675371, 0.002936, 0.657863, 0.002777, 0.640772, 0.002617,
+ 0.624441, 0.002474, 0.607497, 0.002331, 0.590438, 0.002190, 0.573224, 0.002066,
+ 0.556168, 0.001935, 0.539232, 0.001825, 0.522352, 0.001707, 0.506172, 0.001606,
+ 0.489842, 0.001505, 0.473463, 0.001409, 0.457266, 0.001326, 0.441609, 0.001238,
+ 0.426348, 0.001163, 0.411002, 0.001089, 0.396045, 0.001019, 0.381448, 0.000956,
+ 1.000000, 0.003712, 1.000000, 0.003712, 1.000000, 0.003713, 0.999997, 0.003714,
+ 0.999990, 0.003719, 0.999977, 0.003728, 0.999950, 0.003745, 0.999908, 0.003774,
+ 0.999843, 0.003818, 0.999745, 0.003883, 0.999608, 0.003974, 0.999415, 0.004100,
+ 0.999143, 0.004267, 0.998700, 0.004476, 0.996363, 0.004553, 0.994021, 0.004611,
+ 0.992372, 0.004764, 0.991007, 0.004991, 0.988767, 0.005197, 0.984872, 0.005284,
+ 0.982004, 0.005489, 0.977714, 0.005644, 0.973076, 0.005769, 0.967565, 0.005892,
+ 0.961384, 0.005996, 0.954435, 0.006060, 0.946303, 0.006113, 0.937662, 0.006120,
+ 0.927867, 0.006122, 0.916475, 0.006048, 0.905410, 0.006031, 0.891591, 0.005922,
+ 0.877573, 0.005789, 0.862511, 0.005666, 0.846861, 0.005515, 0.830680, 0.005338,
+ 0.815725, 0.005155, 0.802321, 0.004966, 0.787826, 0.004754, 0.773454, 0.004560,
+ 0.758224, 0.004347, 0.742650, 0.004144, 0.726729, 0.003937, 0.710155, 0.003736,
+ 0.693312, 0.003537, 0.676530, 0.003344, 0.659444, 0.003160, 0.642051, 0.002978,
+ 0.625758, 0.002806, 0.609615, 0.002643, 0.592919, 0.002485, 0.576298, 0.002333,
+ 0.559489, 0.002195, 0.542891, 0.002054, 0.526255, 0.001934, 0.509853, 0.001807,
+ 0.494131, 0.001698, 0.478114, 0.001591, 0.462274, 0.001490, 0.446412, 0.001395,
+ 0.431274, 0.001310, 0.416350, 0.001224, 0.401476, 0.001148, 0.386993, 0.001076,
+ 1.000000, 0.004882, 1.000000, 0.004882, 1.000000, 0.004883, 0.999997, 0.004885,
+ 0.999988, 0.004890, 0.999974, 0.004901, 0.999946, 0.004922, 0.999897, 0.004956,
+ 0.999825, 0.005009, 0.999718, 0.005086, 0.999565, 0.005194, 0.999352, 0.005341,
+ 0.999046, 0.005535, 0.998492, 0.005770, 0.995564, 0.005785, 0.993339, 0.005864,
+ 0.991834, 0.006060, 0.990496, 0.006333, 0.987826, 0.006519, 0.983830, 0.006608,
+ 0.981090, 0.006855, 0.976131, 0.006958, 0.971922, 0.007142, 0.965901, 0.007214,
+ 0.959606, 0.007320, 0.952504, 0.007358, 0.944365, 0.007385, 0.935652, 0.007380,
+ 0.925813, 0.007336, 0.914397, 0.007231, 0.903257, 0.007140, 0.890015, 0.007001,
+ 0.876014, 0.006828, 0.861436, 0.006656, 0.845752, 0.006445, 0.829169, 0.006216,
+ 0.813435, 0.005978, 0.799701, 0.005757, 0.785726, 0.005499, 0.771520, 0.005250,
+ 0.756830, 0.004996, 0.741951, 0.004754, 0.726367, 0.004508, 0.710537, 0.004268,
+ 0.693965, 0.004035, 0.677724, 0.003808, 0.661170, 0.003594, 0.644274, 0.003384,
+ 0.627449, 0.003182, 0.611645, 0.002997, 0.595614, 0.002810, 0.579426, 0.002643,
+ 0.563016, 0.002475, 0.546728, 0.002326, 0.530539, 0.002178, 0.514164, 0.002042,
+ 0.498344, 0.001914, 0.482957, 0.001792, 0.467336, 0.001677, 0.451994, 0.001576,
+ 0.436514, 0.001471, 0.421780, 0.001380, 0.407271, 0.001292, 0.392822, 0.001210,
+ 1.000000, 0.006374, 1.000000, 0.006374, 0.999999, 0.006375, 0.999996, 0.006377,
+ 0.999987, 0.006384, 0.999971, 0.006397, 0.999939, 0.006421, 0.999888, 0.006462,
+ 0.999807, 0.006524, 0.999689, 0.006615, 0.999520, 0.006742, 0.999283, 0.006913,
+ 0.998936, 0.007136, 0.998165, 0.007385, 0.994847, 0.007344, 0.993182, 0.007500,
+ 0.991665, 0.007725, 0.989708, 0.007976, 0.986663, 0.008130, 0.983288, 0.008304,
+ 0.980104, 0.008535, 0.974855, 0.008610, 0.970450, 0.008791, 0.964509, 0.008864,
+ 0.957594, 0.008903, 0.950546, 0.008933, 0.942225, 0.008901, 0.933365, 0.008868,
+ 0.923202, 0.008732, 0.912605, 0.008631, 0.901099, 0.008474, 0.888177, 0.008258,
+ 0.873955, 0.008018, 0.860091, 0.007790, 0.844340, 0.007525, 0.828517, 0.007241,
+ 0.812390, 0.006938, 0.797210, 0.006648, 0.783489, 0.006348, 0.769514, 0.006042,
+ 0.755419, 0.005736, 0.741083, 0.005444, 0.726059, 0.005155, 0.710809, 0.004871,
+ 0.695052, 0.004598, 0.678886, 0.004334, 0.663042, 0.004080, 0.646634, 0.003843,
+ 0.630117, 0.003609, 0.613804, 0.003389, 0.598338, 0.003185, 0.582687, 0.002984,
+ 0.566809, 0.002801, 0.550817, 0.002623, 0.534937, 0.002458, 0.519151, 0.002306,
+ 0.503118, 0.002155, 0.487723, 0.002020, 0.472725, 0.001894, 0.457599, 0.001771,
+ 0.442558, 0.001658, 0.427624, 0.001555, 0.413171, 0.001453, 0.399122, 0.001365,
+ 1.000000, 0.008265, 1.000000, 0.008265, 1.000000, 0.008266, 0.999996, 0.008268,
+ 0.999987, 0.008276, 0.999967, 0.008292, 0.999933, 0.008320, 0.999876, 0.008368,
+ 0.999786, 0.008440, 0.999655, 0.008546, 0.999468, 0.008693, 0.999203, 0.008891,
+ 0.998803, 0.009144, 0.997480, 0.009358, 0.994446, 0.009333, 0.992920, 0.009531,
+ 0.991414, 0.009789, 0.989049, 0.010023, 0.985820, 0.010166, 0.982441, 0.010358,
+ 0.978595, 0.010529, 0.973495, 0.010627, 0.968405, 0.010726, 0.962717, 0.010823,
+ 0.955478, 0.010810, 0.948275, 0.010791, 0.940006, 0.010716, 0.930831, 0.010631,
+ 0.920648, 0.010408, 0.910205, 0.010231, 0.898445, 0.010005, 0.885986, 0.009719,
+ 0.872204, 0.009407, 0.858436, 0.009109, 0.843454, 0.008766, 0.827437, 0.008398,
+ 0.811488, 0.008037, 0.796039, 0.007674, 0.781083, 0.007310, 0.767642, 0.006940,
+ 0.753901, 0.006575, 0.740131, 0.006227, 0.725845, 0.005884, 0.710991, 0.005556,
+ 0.696002, 0.005231, 0.680461, 0.004925, 0.664875, 0.004635, 0.649273, 0.004354,
+ 0.633020, 0.004087, 0.617050, 0.003841, 0.601154, 0.003596, 0.586008, 0.003376,
+ 0.570699, 0.003160, 0.555166, 0.002960, 0.539645, 0.002776, 0.524159, 0.002595,
+ 0.508682, 0.002433, 0.493163, 0.002279, 0.478004, 0.002131, 0.463470, 0.001995,
+ 0.448778, 0.001870, 0.434105, 0.001747, 0.419576, 0.001639, 0.405541, 0.001533,
+ 1.000000, 0.010646, 1.000000, 0.010646, 0.999999, 0.010647, 0.999995, 0.010650,
+ 0.999985, 0.010659, 0.999964, 0.010677, 0.999925, 0.010711, 0.999861, 0.010766,
+ 0.999763, 0.010850, 0.999616, 0.010972, 0.999408, 0.011141, 0.999112, 0.011366,
+ 0.998637, 0.011647, 0.996223, 0.011723, 0.994006, 0.011806, 0.992444, 0.012025,
+ 0.991028, 0.012331, 0.988030, 0.012495, 0.984816, 0.012654, 0.981399, 0.012854,
+ 0.977085, 0.012969, 0.972154, 0.013091, 0.966617, 0.013117, 0.960628, 0.013158,
+ 0.953295, 0.013109, 0.945750, 0.012997, 0.937654, 0.012880, 0.927716, 0.012648,
+ 0.917932, 0.012389, 0.907719, 0.012131, 0.895840, 0.011801, 0.883526, 0.011414,
+ 0.870301, 0.011007, 0.856272, 0.010602, 0.842251, 0.010194, 0.826466, 0.009733,
+ 0.810859, 0.009285, 0.795051, 0.008833, 0.780053, 0.008403, 0.765750, 0.007964,
+ 0.752298, 0.007525, 0.739153, 0.007115, 0.725514, 0.006704, 0.711473, 0.006327,
+ 0.696936, 0.005952, 0.682126, 0.005592, 0.667027, 0.005254, 0.651875, 0.004938,
+ 0.636463, 0.004628, 0.620641, 0.004339, 0.604931, 0.004070, 0.589549, 0.003809,
+ 0.574712, 0.003570, 0.559775, 0.003345, 0.544514, 0.003125, 0.529555, 0.002932,
+ 0.514402, 0.002742, 0.499302, 0.002566, 0.484114, 0.002399, 0.469308, 0.002251,
+ 0.455133, 0.002102, 0.440939, 0.001973, 0.426627, 0.001844, 0.412509, 0.001725,
+ 1.000000, 0.013628, 1.000000, 0.013628, 0.999999, 0.013629, 0.999995, 0.013633,
+ 0.999983, 0.013643, 0.999960, 0.013664, 0.999917, 0.013702, 0.999846, 0.013765,
+ 0.999736, 0.013862, 0.999573, 0.014001, 0.999340, 0.014193, 0.999004, 0.014446,
+ 0.998407, 0.014749, 0.995464, 0.014731, 0.993328, 0.014828, 0.991799, 0.015080,
+ 0.990397, 0.015432, 0.986835, 0.015501, 0.983938, 0.015731, 0.980154, 0.015875,
+ 0.975659, 0.015958, 0.970171, 0.015983, 0.964803, 0.016008, 0.958366, 0.015948,
+ 0.950613, 0.015800, 0.942874, 0.015584, 0.935005, 0.015429, 0.924991, 0.015074,
+ 0.914814, 0.014676, 0.904743, 0.014310, 0.893216, 0.013869, 0.880769, 0.013371,
+ 0.868136, 0.012861, 0.854690, 0.012340, 0.840593, 0.011809, 0.825808, 0.011253,
+ 0.810090, 0.010710, 0.795040, 0.010164, 0.779757, 0.009640, 0.764697, 0.009119,
+ 0.750913, 0.008595, 0.738175, 0.008116, 0.725242, 0.007645, 0.711864, 0.007189,
+ 0.698009, 0.006758, 0.683841, 0.006350, 0.669391, 0.005955, 0.654731, 0.005587,
+ 0.639805, 0.005236, 0.624789, 0.004908, 0.609325, 0.004594, 0.593975, 0.004303,
+ 0.578983, 0.004030, 0.564442, 0.003771, 0.549835, 0.003532, 0.535039, 0.003303,
+ 0.520403, 0.003089, 0.505687, 0.002893, 0.490939, 0.002708, 0.476233, 0.002534,
+ 0.461624, 0.002371, 0.447833, 0.002221, 0.433992, 0.002076, 0.420147, 0.001950,
+ 1.000000, 0.017341, 1.000000, 0.017342, 0.999999, 0.017343, 0.999995, 0.017347,
+ 0.999983, 0.017358, 0.999954, 0.017382, 0.999908, 0.017426, 0.999828, 0.017497,
+ 0.999705, 0.017606, 0.999524, 0.017763, 0.999263, 0.017978, 0.998878, 0.018258,
+ 0.998012, 0.018555, 0.994614, 0.018426, 0.993132, 0.018638, 0.991563, 0.018907,
+ 0.989298, 0.019158, 0.986036, 0.019252, 0.982558, 0.019406, 0.978531, 0.019486,
+ 0.974198, 0.019585, 0.968148, 0.019475, 0.962565, 0.019428, 0.956041, 0.019299,
+ 0.947749, 0.018989, 0.940180, 0.018704, 0.931650, 0.018346, 0.921798, 0.017878,
+ 0.911573, 0.017362, 0.901569, 0.016848, 0.890341, 0.016265, 0.877835, 0.015620,
+ 0.865472, 0.014952, 0.852905, 0.014327, 0.838906, 0.013664, 0.824888, 0.012990,
+ 0.809977, 0.012322, 0.794697, 0.011657, 0.780028, 0.011031, 0.765124, 0.010424,
+ 0.750411, 0.009822, 0.737264, 0.009244, 0.724799, 0.008687, 0.712253, 0.008165,
+ 0.699267, 0.007673, 0.685618, 0.007197, 0.671736, 0.006739, 0.657777, 0.006319,
+ 0.643497, 0.005924, 0.628890, 0.005539, 0.614299, 0.005193, 0.599197, 0.004860,
+ 0.584175, 0.004544, 0.569541, 0.004258, 0.555193, 0.003979, 0.540947, 0.003724,
+ 0.526593, 0.003486, 0.512335, 0.003261, 0.498017, 0.003051, 0.483609, 0.002855,
+ 0.469368, 0.002675, 0.455037, 0.002499, 0.441493, 0.002348, 0.428147, 0.002199,
+ 1.000000, 0.021942, 1.000000, 0.021942, 0.999998, 0.021943, 0.999993, 0.021948,
+ 0.999981, 0.021961, 0.999949, 0.021988, 0.999896, 0.022037, 0.999808, 0.022117,
+ 0.999670, 0.022238, 0.999466, 0.022412, 0.999174, 0.022649, 0.998725, 0.022953,
+ 0.996979, 0.023112, 0.994317, 0.023074, 0.992781, 0.023290, 0.991191, 0.023573,
+ 0.987787, 0.023615, 0.985092, 0.023799, 0.981121, 0.023855, 0.976924, 0.023871,
+ 0.972180, 0.023870, 0.965956, 0.023660, 0.959998, 0.023474, 0.953245, 0.023228,
+ 0.944445, 0.022697, 0.937087, 0.022353, 0.928341, 0.021814, 0.918400, 0.021152,
+ 0.907959, 0.020455, 0.898080, 0.019767, 0.887047, 0.018992, 0.875221, 0.018208,
+ 0.862690, 0.017358, 0.850735, 0.016572, 0.837545, 0.015752, 0.823639, 0.014948,
+ 0.809699, 0.014143, 0.794797, 0.013353, 0.780578, 0.012619, 0.766019, 0.011891,
+ 0.751447, 0.011184, 0.737275, 0.010514, 0.724545, 0.009873, 0.712644, 0.009266,
+ 0.700432, 0.008690, 0.687664, 0.008147, 0.674288, 0.007630, 0.660966, 0.007144,
+ 0.647264, 0.006685, 0.633431, 0.006266, 0.619133, 0.005856, 0.604935, 0.005482,
+ 0.590236, 0.005133, 0.575473, 0.004791, 0.561228, 0.004489, 0.547054, 0.004202,
+ 0.533175, 0.003929, 0.519163, 0.003674, 0.505328, 0.003441, 0.491446, 0.003220,
+ 0.477356, 0.003013, 0.463560, 0.002826, 0.449623, 0.002650, 0.436068, 0.002470,
+ 1.000000, 0.027613, 1.000000, 0.027614, 0.999998, 0.027615, 0.999993, 0.027620,
+ 0.999976, 0.027634, 0.999945, 0.027664, 0.999884, 0.027718, 0.999784, 0.027806,
+ 0.999630, 0.027939, 0.999401, 0.028130, 0.999066, 0.028386, 0.998524, 0.028703,
+ 0.995702, 0.028626, 0.993593, 0.028673, 0.992067, 0.028899, 0.990548, 0.029213,
+ 0.986775, 0.029130, 0.984054, 0.029310, 0.979481, 0.029188, 0.975297, 0.029160,
+ 0.969810, 0.028954, 0.963524, 0.028628, 0.957398, 0.028313, 0.950088, 0.027847,
+ 0.941538, 0.027180, 0.933332, 0.026539, 0.924392, 0.025778, 0.914581, 0.024916,
+ 0.904347, 0.024024, 0.894324, 0.023123, 0.883724, 0.022153, 0.872207, 0.021136,
+ 0.859927, 0.020105, 0.848373, 0.019126, 0.836023, 0.018131, 0.822890, 0.017172,
+ 0.809324, 0.016220, 0.795361, 0.015262, 0.781253, 0.014390, 0.767338, 0.013533,
+ 0.753156, 0.012724, 0.739122, 0.011945, 0.725358, 0.011205, 0.712949, 0.010487,
+ 0.701621, 0.009840, 0.689703, 0.009215, 0.677216, 0.008625, 0.664217, 0.008069,
+ 0.651370, 0.007559, 0.638000, 0.007057, 0.624530, 0.006613, 0.610601, 0.006184,
+ 0.596760, 0.005780, 0.582433, 0.005409, 0.568026, 0.005061, 0.554140, 0.004735,
+ 0.540178, 0.004429, 0.526513, 0.004144, 0.512954, 0.003882, 0.499403, 0.003629,
+ 0.486026, 0.003408, 0.472345, 0.003186, 0.458828, 0.002976, 0.445379, 0.002794,
+ 1.000000, 0.034572, 1.000000, 0.034572, 0.999999, 0.034573, 0.999991, 0.034579,
+ 0.999974, 0.034594, 0.999937, 0.034626, 0.999869, 0.034685, 0.999757, 0.034780,
+ 0.999582, 0.034923, 0.999322, 0.035126, 0.998939, 0.035397, 0.998219, 0.035702,
+ 0.994974, 0.035473, 0.993201, 0.035562, 0.991573, 0.035764, 0.989301, 0.035925,
+ 0.985712, 0.035802, 0.982411, 0.035835, 0.977827, 0.035617, 0.973278, 0.035440,
+ 0.967397, 0.035048, 0.960696, 0.034480, 0.954349, 0.033986, 0.946066, 0.033132,
+ 0.938012, 0.032359, 0.929413, 0.031441, 0.920355, 0.030410, 0.910586, 0.029278,
+ 0.900609, 0.028139, 0.890093, 0.026910, 0.880013, 0.025727, 0.869001, 0.024467,
+ 0.857510, 0.023225, 0.845820, 0.022012, 0.834383, 0.020827, 0.822158, 0.019663,
+ 0.809056, 0.018531, 0.795832, 0.017417, 0.782547, 0.016376, 0.768900, 0.015391,
+ 0.755526, 0.014449, 0.741681, 0.013537, 0.728178, 0.012696, 0.714642, 0.011881,
+ 0.702756, 0.011116, 0.691750, 0.010415, 0.680159, 0.009744, 0.668073, 0.009119,
+ 0.655405, 0.008514, 0.642921, 0.007976, 0.629993, 0.007451, 0.616828, 0.006970,
+ 0.603305, 0.006524, 0.589833, 0.006102, 0.575945, 0.005708, 0.561745, 0.005334,
+ 0.548277, 0.005000, 0.534467, 0.004676, 0.521032, 0.004381, 0.507877, 0.004103,
+ 0.494654, 0.003836, 0.481592, 0.003587, 0.468509, 0.003373, 0.455293, 0.003162,
+ 1.000000, 0.043070, 1.000000, 0.043070, 0.999998, 0.043071, 0.999991, 0.043077,
+ 0.999970, 0.043094, 0.999928, 0.043128, 0.999852, 0.043189, 0.999724, 0.043290,
+ 0.999527, 0.043440, 0.999230, 0.043651, 0.998783, 0.043925, 0.997507, 0.044110,
+ 0.994418, 0.043823, 0.992864, 0.043940, 0.991127, 0.044096, 0.987331, 0.043841,
+ 0.984819, 0.043899, 0.980384, 0.043591, 0.975846, 0.043254, 0.970748, 0.042829,
+ 0.964303, 0.042153, 0.957720, 0.041411, 0.950747, 0.040589, 0.942533, 0.039489,
+ 0.934045, 0.038354, 0.924942, 0.037057, 0.915811, 0.035699, 0.906120, 0.034240,
+ 0.896434, 0.032808, 0.886021, 0.031288, 0.876081, 0.029778, 0.865608, 0.028233,
+ 0.854924, 0.026749, 0.843607, 0.025260, 0.832456, 0.023821, 0.821342, 0.022468,
+ 0.809303, 0.021130, 0.796468, 0.019839, 0.784046, 0.018623, 0.771262, 0.017456,
+ 0.758118, 0.016381, 0.745075, 0.015329, 0.731926, 0.014365, 0.718630, 0.013436,
+ 0.705414, 0.012560, 0.693792, 0.011751, 0.683108, 0.011002, 0.671830, 0.010276,
+ 0.660150, 0.009620, 0.647907, 0.008980, 0.635734, 0.008408, 0.623208, 0.007862,
+ 0.610438, 0.007350, 0.597345, 0.006877, 0.584138, 0.006435, 0.570700, 0.006022,
+ 0.556966, 0.005632, 0.543607, 0.005283, 0.530213, 0.004940, 0.516912, 0.004623,
+ 0.503916, 0.004331, 0.491146, 0.004069, 0.478439, 0.003814, 0.465834, 0.003580,
+ 1.000000, 0.053404, 1.000000, 0.053404, 0.999998, 0.053406, 0.999989, 0.053412,
+ 0.999968, 0.053428, 0.999918, 0.053463, 0.999830, 0.053526, 0.999685, 0.053628,
+ 0.999461, 0.053780, 0.999119, 0.053990, 0.998582, 0.054252, 0.995919, 0.054032,
+ 0.993735, 0.053891, 0.992126, 0.053956, 0.990266, 0.054040, 0.986317, 0.053606,
+ 0.983213, 0.053442, 0.978303, 0.052862, 0.973665, 0.052336, 0.968091, 0.051617,
+ 0.961026, 0.050543, 0.954333, 0.049523, 0.946372, 0.048170, 0.938254, 0.046767,
+ 0.929516, 0.045234, 0.920106, 0.043508, 0.910899, 0.041740, 0.901532, 0.039939,
+ 0.891919, 0.038090, 0.882006, 0.036234, 0.871965, 0.034344, 0.862145, 0.032483,
+ 0.852058, 0.030668, 0.841610, 0.028910, 0.830806, 0.027208, 0.820476, 0.025609,
+ 0.809514, 0.024039, 0.797865, 0.022538, 0.785621, 0.021123, 0.773765, 0.019791,
+ 0.761629, 0.018523, 0.748891, 0.017336, 0.736437, 0.016230, 0.723707, 0.015178,
+ 0.710606, 0.014179, 0.698019, 0.013259, 0.686203, 0.012389, 0.675692, 0.011598,
+ 0.664826, 0.010833, 0.653490, 0.010135, 0.641774, 0.009478, 0.629794, 0.008861,
+ 0.617647, 0.008285, 0.605340, 0.007753, 0.592718, 0.007260, 0.579746, 0.006797,
+ 0.566763, 0.006361, 0.553515, 0.005952, 0.540118, 0.005569, 0.527325, 0.005231,
+ 0.514265, 0.004907, 0.501406, 0.004603, 0.488922, 0.004312, 0.476541, 0.004047,
+ 1.000000, 0.065918, 1.000000, 0.065919, 0.999998, 0.065920, 0.999988, 0.065926,
+ 0.999963, 0.065942, 0.999907, 0.065976, 0.999806, 0.066038, 0.999639, 0.066136,
+ 0.999378, 0.066281, 0.998985, 0.066478, 0.998285, 0.066691, 0.995071, 0.066199,
+ 0.993172, 0.066045, 0.991438, 0.066010, 0.988428, 0.065687, 0.985218, 0.065291,
+ 0.981128, 0.064711, 0.976015, 0.063849, 0.970970, 0.062993, 0.964582, 0.061793,
+ 0.957383, 0.060363, 0.949969, 0.058813, 0.941843, 0.057027, 0.933624, 0.055189,
+ 0.924543, 0.053122, 0.914919, 0.050890, 0.905773, 0.048642, 0.896434, 0.046336,
+ 0.887195, 0.044062, 0.877706, 0.041780, 0.867719, 0.039450, 0.858587, 0.037243,
+ 0.849317, 0.035096, 0.839585, 0.032985, 0.829856, 0.031003, 0.819589, 0.029095,
+ 0.809714, 0.027274, 0.799340, 0.025563, 0.788224, 0.023918, 0.776619, 0.022383,
+ 0.765210, 0.020930, 0.753716, 0.019579, 0.741564, 0.018300, 0.729413, 0.017126,
+ 0.717146, 0.015993, 0.704360, 0.014949, 0.692190, 0.013968, 0.680289, 0.013058,
+ 0.669611, 0.012220, 0.659113, 0.011417, 0.648148, 0.010673, 0.636905, 0.009990,
+ 0.625154, 0.009343, 0.613481, 0.008748, 0.601540, 0.008183, 0.589430, 0.007669,
+ 0.576828, 0.007172, 0.564194, 0.006727, 0.551501, 0.006309, 0.538635, 0.005922,
+ 0.525724, 0.005549, 0.513209, 0.005202, 0.500457, 0.004882, 0.487990, 0.004572,
+ 1.000000, 0.081013, 1.000000, 0.081013, 0.999997, 0.081015, 0.999985, 0.081020,
+ 0.999956, 0.081035, 0.999893, 0.081066, 0.999777, 0.081120, 0.999583, 0.081208,
+ 0.999281, 0.081334, 0.998813, 0.081497, 0.997597, 0.081522, 0.994379, 0.080850,
+ 0.992744, 0.080679, 0.990745, 0.080459, 0.986646, 0.079611, 0.983611, 0.079091,
+ 0.978869, 0.078075, 0.973475, 0.076822, 0.967845, 0.075493, 0.960778, 0.073706,
+ 0.953333, 0.071805, 0.945274, 0.069595, 0.936955, 0.067249, 0.928319, 0.064773,
+ 0.919075, 0.062095, 0.909114, 0.059182, 0.900137, 0.056392, 0.891069, 0.053539,
+ 0.882262, 0.050764, 0.873232, 0.047979, 0.864042, 0.045226, 0.855002, 0.042541,
+ 0.846569, 0.040013, 0.837714, 0.037527, 0.828918, 0.035203, 0.819783, 0.033001,
+ 0.810129, 0.030891, 0.800866, 0.028911, 0.790930, 0.027026, 0.780593, 0.025276,
+ 0.769511, 0.023618, 0.758558, 0.022065, 0.747632, 0.020629, 0.736146, 0.019287,
+ 0.724093, 0.018033, 0.712340, 0.016826, 0.700201, 0.015746, 0.687949, 0.014703,
+ 0.676163, 0.013751, 0.665001, 0.012866, 0.654720, 0.012037, 0.644213, 0.011260,
+ 0.633382, 0.010541, 0.622120, 0.009865, 0.610631, 0.009233, 0.599078, 0.008642,
+ 0.587519, 0.008118, 0.575505, 0.007612, 0.563148, 0.007139, 0.550828, 0.006684,
+ 0.538458, 0.006277, 0.525905, 0.005883, 0.513517, 0.005527, 0.501395, 0.005197,
+ 1.000000, 0.099151, 1.000000, 0.099150, 0.999996, 0.099152, 0.999984, 0.099156,
+ 0.999947, 0.099167, 0.999874, 0.099191, 0.999739, 0.099233, 0.999514, 0.099298,
+ 0.999159, 0.099388, 0.998586, 0.099484, 0.995731, 0.098842, 0.993384, 0.098276,
+ 0.991615, 0.097927, 0.989029, 0.097343, 0.985373, 0.096354, 0.981278, 0.095231,
+ 0.975777, 0.093623, 0.970526, 0.092022, 0.963755, 0.089891, 0.956676, 0.087606,
+ 0.948099, 0.084775, 0.939718, 0.081864, 0.931305, 0.078857, 0.922342, 0.075613,
+ 0.912842, 0.072147, 0.903304, 0.068619, 0.894110, 0.065059, 0.885512, 0.061602,
+ 0.877193, 0.058243, 0.868770, 0.054898, 0.860267, 0.051610, 0.851915, 0.048468,
+ 0.843912, 0.045445, 0.836040, 0.042561, 0.828245, 0.039875, 0.820159, 0.037320,
+ 0.811670, 0.034916, 0.802659, 0.032640, 0.793921, 0.030490, 0.784713, 0.028486,
+ 0.774946, 0.026619, 0.764480, 0.024859, 0.753793, 0.023211, 0.743506, 0.021704,
+ 0.732555, 0.020284, 0.720965, 0.018965, 0.709422, 0.017719, 0.697756, 0.016563,
+ 0.685565, 0.015483, 0.673987, 0.014489, 0.662440, 0.013561, 0.651675, 0.012696,
+ 0.641598, 0.011879, 0.631210, 0.011126, 0.620514, 0.010437, 0.609366, 0.009787,
+ 0.598137, 0.009173, 0.586966, 0.008598, 0.575549, 0.008068, 0.563797, 0.007573,
+ 0.551758, 0.007106, 0.539894, 0.006684, 0.527901, 0.006279, 0.515819, 0.005905,
+ 1.000000, 0.120864, 1.000000, 0.120864, 0.999996, 0.120864, 0.999980, 0.120867,
+ 0.999940, 0.120872, 0.999852, 0.120884, 0.999693, 0.120903, 0.999426, 0.120929,
+ 0.999002, 0.120955, 0.998235, 0.120918, 0.994608, 0.119764, 0.992997, 0.119265,
+ 0.990968, 0.118630, 0.987002, 0.117261, 0.983524, 0.116009, 0.978750, 0.114252,
+ 0.972652, 0.111930, 0.966613, 0.109555, 0.959275, 0.106612, 0.951272, 0.103375,
+ 0.942323, 0.099659, 0.933679, 0.095884, 0.924822, 0.091926, 0.915742, 0.087806,
+ 0.906348, 0.083489, 0.896883, 0.079085, 0.887740, 0.074675, 0.879860, 0.070577,
+ 0.871998, 0.066501, 0.864325, 0.062541, 0.856685, 0.058678, 0.849250, 0.055006,
+ 0.841719, 0.051473, 0.834755, 0.048140, 0.827853, 0.045017, 0.820888, 0.042097,
+ 0.813616, 0.039370, 0.805767, 0.036777, 0.797338, 0.034327, 0.789122, 0.032053,
+ 0.780601, 0.029948, 0.771424, 0.027981, 0.761502, 0.026105, 0.751166, 0.024394,
+ 0.741276, 0.022809, 0.730898, 0.021327, 0.719878, 0.019931, 0.708379, 0.018657,
+ 0.697165, 0.017445, 0.685554, 0.016314, 0.673631, 0.015276, 0.662385, 0.014300,
+ 0.651059, 0.013411, 0.640451, 0.012579, 0.630536, 0.011793, 0.620316, 0.011055,
+ 0.609722, 0.010367, 0.598804, 0.009730, 0.587871, 0.009128, 0.577121, 0.008589,
+ 0.566019, 0.008073, 0.554664, 0.007597, 0.543101, 0.007148, 0.531558, 0.006734,
+ 1.000000, 0.146767, 1.000000, 0.146767, 0.999997, 0.146767, 0.999977, 0.146765,
+ 0.999929, 0.146762, 0.999823, 0.146753, 0.999633, 0.146735, 0.999314, 0.146699,
+ 0.998796, 0.146620, 0.997124, 0.146107, 0.994062, 0.144857, 0.992154, 0.144011,
+ 0.989186, 0.142712, 0.985279, 0.140926, 0.980826, 0.138850, 0.975056, 0.136168,
+ 0.969005, 0.133217, 0.961554, 0.129590, 0.954206, 0.125886, 0.945046, 0.121335,
+ 0.935678, 0.116492, 0.926748, 0.111635, 0.917764, 0.106625, 0.908358, 0.101325,
+ 0.899219, 0.096025, 0.890089, 0.090653, 0.881488, 0.085390, 0.874031, 0.080418,
+ 0.866932, 0.075601, 0.859976, 0.070902, 0.853375, 0.066439, 0.846971, 0.062201,
+ 0.840483, 0.058129, 0.833969, 0.054276, 0.828060, 0.050704, 0.822128, 0.047368,
+ 0.815989, 0.044272, 0.809336, 0.041344, 0.802177, 0.038601, 0.794410, 0.036023,
+ 0.786573, 0.033638, 0.778619, 0.031432, 0.770000, 0.029362, 0.760698, 0.027410,
+ 0.750932, 0.025615, 0.740993, 0.023974, 0.731159, 0.022418, 0.720836, 0.020989,
+ 0.709913, 0.019641, 0.698415, 0.018382, 0.687450, 0.017222, 0.676154, 0.016151,
+ 0.664383, 0.015140, 0.653300, 0.014187, 0.642072, 0.013310, 0.631412, 0.012493,
+ 0.621622, 0.011741, 0.611681, 0.011036, 0.601420, 0.010377, 0.590830, 0.009756,
+ 0.580254, 0.009181, 0.569841, 0.008647, 0.559224, 0.008157, 0.548315, 0.007679,
+ 1.000000, 0.177563, 1.000000, 0.177563, 0.999994, 0.177562, 0.999972, 0.177555,
+ 0.999914, 0.177536, 0.999787, 0.177496, 0.999556, 0.177420, 0.999165, 0.177285,
+ 0.998500, 0.177037, 0.995388, 0.175634, 0.993102, 0.174375, 0.990992, 0.173121,
+ 0.986932, 0.170896, 0.982786, 0.168470, 0.977592, 0.165455, 0.971075, 0.161676,
+ 0.963967, 0.157458, 0.956397, 0.152836, 0.947489, 0.147467, 0.937564, 0.141450,
+ 0.928182, 0.135383, 0.919027, 0.129212, 0.909618, 0.122760, 0.900492, 0.116273,
+ 0.891671, 0.109800, 0.883146, 0.103362, 0.875151, 0.097080, 0.868338, 0.091173,
+ 0.862033, 0.085497, 0.856107, 0.080069, 0.850644, 0.074962, 0.845261, 0.070079,
+ 0.839885, 0.065432, 0.834609, 0.061097, 0.829083, 0.056974, 0.824040, 0.053174,
+ 0.818968, 0.049665, 0.813496, 0.046386, 0.807533, 0.043322, 0.800990, 0.040440,
+ 0.793891, 0.037758, 0.786281, 0.035262, 0.778773, 0.032958, 0.770737, 0.030808,
+ 0.762094, 0.028796, 0.752898, 0.026925, 0.743306, 0.025193, 0.733416, 0.023595,
+ 0.723742, 0.022115, 0.713542, 0.020744, 0.702755, 0.019434, 0.691484, 0.018205,
+ 0.680531, 0.017077, 0.669530, 0.016034, 0.658126, 0.015068, 0.646933, 0.014155,
+ 0.636107, 0.013318, 0.625271, 0.012528, 0.615225, 0.011794, 0.605678, 0.011118,
+ 0.595830, 0.010476, 0.585704, 0.009867, 0.575413, 0.009297, 0.565373, 0.008767,
+ 1.000000, 0.214058, 0.999999, 0.214058, 0.999994, 0.214055, 0.999966, 0.214039,
+ 0.999893, 0.213998, 0.999737, 0.213910, 0.999449, 0.213745, 0.998960, 0.213458,
+ 0.997900, 0.212855, 0.994278, 0.210779, 0.992254, 0.209260, 0.988810, 0.206908,
+ 0.984715, 0.204009, 0.979738, 0.200471, 0.972884, 0.195813, 0.965996, 0.190856,
+ 0.957974, 0.185077, 0.949155, 0.178680, 0.939288, 0.171513, 0.928996, 0.163838,
+ 0.919563, 0.156246, 0.910004, 0.148359, 0.900791, 0.140417, 0.892135, 0.132569,
+ 0.883803, 0.124741, 0.876034, 0.117091, 0.869219, 0.109835, 0.863062, 0.102859,
+ 0.857795, 0.096293, 0.853009, 0.090072, 0.848603, 0.084210, 0.844335, 0.078653,
+ 0.840208, 0.073440, 0.836035, 0.068533, 0.831720, 0.063927, 0.827135, 0.059591,
+ 0.822797, 0.055620, 0.818387, 0.051939, 0.813565, 0.048532, 0.808142, 0.045314,
+ 0.802212, 0.042335, 0.795730, 0.039555, 0.788741, 0.036988, 0.781093, 0.034569,
+ 0.773597, 0.032330, 0.765622, 0.030272, 0.757083, 0.028348, 0.747992, 0.026556,
+ 0.738591, 0.024884, 0.728719, 0.023334, 0.719146, 0.021908, 0.709165, 0.020571,
+ 0.698750, 0.019325, 0.687884, 0.018158, 0.676818, 0.017075, 0.666247, 0.016072,
+ 0.655284, 0.015126, 0.644010, 0.014256, 0.633353, 0.013433, 0.622674, 0.012653,
+ 0.612265, 0.011935, 0.602455, 0.011253, 0.593147, 0.010623, 0.583592, 0.010021,
+ 1.000000, 0.257170, 1.000000, 0.257170, 0.999992, 0.257164, 0.999958, 0.257135,
+ 0.999864, 0.257060, 0.999666, 0.256897, 0.999302, 0.256596, 0.998663, 0.256070,
+ 0.995607, 0.254123, 0.993094, 0.252081, 0.990700, 0.249867, 0.985940, 0.246118,
+ 0.981214, 0.242049, 0.974966, 0.236869, 0.967589, 0.230724, 0.959150, 0.223635,
+ 0.950257, 0.215960, 0.940165, 0.207296, 0.929396, 0.197901, 0.919288, 0.188437,
+ 0.909428, 0.178762, 0.900105, 0.169072, 0.891418, 0.159478, 0.883347, 0.150020,
+ 0.875992, 0.140813, 0.869466, 0.131960, 0.863699, 0.123501, 0.858553, 0.115436,
+ 0.854379, 0.107901, 0.850894, 0.100880, 0.847632, 0.094230, 0.844571, 0.087986,
+ 0.841630, 0.082153, 0.838542, 0.076641, 0.835412, 0.071532, 0.831899, 0.066688,
+ 0.828177, 0.062218, 0.824160, 0.058045, 0.820393, 0.054267, 0.816068, 0.050717,
+ 0.811201, 0.047404, 0.805785, 0.044317, 0.799878, 0.041456, 0.793469, 0.038815,
+ 0.786473, 0.036345, 0.778874, 0.034022, 0.771277, 0.031860, 0.763426, 0.029886,
+ 0.755044, 0.028036, 0.746161, 0.026298, 0.737124, 0.024730, 0.727610, 0.023251,
+ 0.717822, 0.021875, 0.708279, 0.020594, 0.698333, 0.019395, 0.688020, 0.018272,
+ 0.677321, 0.017204, 0.666504, 0.016212, 0.656184, 0.015292, 0.645560, 0.014433,
+ 0.634636, 0.013616, 0.624124, 0.012861, 0.613914, 0.012143, 0.603589, 0.011489,
+ 1.000000, 0.307946, 0.999999, 0.307945, 0.999988, 0.307934, 0.999944, 0.307886,
+ 0.999824, 0.307756, 0.999565, 0.307480, 0.999085, 0.306966, 0.998103, 0.306004,
+ 0.994249, 0.303028, 0.991807, 0.300435, 0.987773, 0.296554, 0.982673, 0.291600,
+ 0.976623, 0.285641, 0.968757, 0.278150, 0.959849, 0.269529, 0.950663, 0.260248,
+ 0.940129, 0.249704, 0.928950, 0.238291, 0.917996, 0.226501, 0.907813, 0.214669,
+ 0.898305, 0.202835, 0.889626, 0.191158, 0.881750, 0.179695, 0.874715, 0.168548,
+ 0.868746, 0.157920, 0.863703, 0.147807, 0.859315, 0.138149, 0.855538, 0.128993,
+ 0.852428, 0.120414, 0.850168, 0.112498, 0.848132, 0.105054, 0.846291, 0.098109,
+ 0.844431, 0.091594, 0.842493, 0.085506, 0.840368, 0.079820, 0.837980, 0.074510,
+ 0.835230, 0.069542, 0.832091, 0.064909, 0.828667, 0.060629, 0.824805, 0.056652,
+ 0.820988, 0.053023, 0.816635, 0.049636, 0.811725, 0.046466, 0.806316, 0.043508,
+ 0.800469, 0.040787, 0.794107, 0.038255, 0.787218, 0.035882, 0.779872, 0.033679,
+ 0.772097, 0.031638, 0.764484, 0.029738, 0.756428, 0.027958, 0.748022, 0.026315,
+ 0.739268, 0.024780, 0.730240, 0.023339, 0.720893, 0.022003, 0.711190, 0.020755,
+ 0.701791, 0.019584, 0.692184, 0.018489, 0.682258, 0.017454, 0.672060, 0.016487,
+ 0.661717, 0.015596, 0.651462, 0.014752, 0.641467, 0.013973, 0.631229, 0.013236,
+ 1.000000, 0.367573, 0.999999, 0.367571, 0.999984, 0.367553, 0.999925, 0.367473,
+ 0.999759, 0.367259, 0.999410, 0.366801, 0.998739, 0.365946, 0.995529, 0.363191,
+ 0.992875, 0.360171, 0.989135, 0.355981, 0.984166, 0.350401, 0.977871, 0.343348,
+ 0.969510, 0.334341, 0.959964, 0.323862, 0.950162, 0.312521, 0.938882, 0.299577,
+ 0.926992, 0.285573, 0.915589, 0.271212, 0.904791, 0.256611, 0.895177, 0.242224,
+ 0.886403, 0.227952, 0.878957, 0.214192, 0.872418, 0.200795, 0.867029, 0.188015,
+ 0.862835, 0.175975, 0.859411, 0.164526, 0.856655, 0.153693, 0.854519, 0.143520,
+ 0.852828, 0.133970, 0.851412, 0.124984, 0.850609, 0.116748, 0.849855, 0.109050,
+ 0.849017, 0.101839, 0.848079, 0.095136, 0.846911, 0.088877, 0.845445, 0.083038,
+ 0.843620, 0.077584, 0.841411, 0.072505, 0.838768, 0.067769, 0.835801, 0.063402,
+ 0.832341, 0.059310, 0.828424, 0.055512, 0.824312, 0.052024, 0.819918, 0.048786,
+ 0.815072, 0.045780, 0.809863, 0.043018, 0.804164, 0.040425, 0.798034, 0.038015,
+ 0.791436, 0.035744, 0.784498, 0.033647, 0.777125, 0.031667, 0.769365, 0.029812,
+ 0.761579, 0.028100, 0.753746, 0.026505, 0.745573, 0.025007, 0.737083, 0.023603,
+ 0.728545, 0.022330, 0.719691, 0.021124, 0.710569, 0.019998, 0.701216, 0.018957,
+ 0.692094, 0.017970, 0.682909, 0.017042, 0.673509, 0.016173, 0.663863, 0.015341,
+ 1.000000, 0.437395, 0.999998, 0.437394, 0.999980, 0.437363, 0.999891, 0.437232,
+ 0.999656, 0.436877, 0.999148, 0.436121, 0.997959, 0.434564, 0.993464, 0.430134,
+ 0.990606, 0.426077, 0.985027, 0.419397, 0.978491, 0.411180, 0.969643, 0.400480,
+ 0.959189, 0.387690, 0.948223, 0.373575, 0.935955, 0.357622, 0.923237, 0.340430,
+ 0.911074, 0.322735, 0.899724, 0.304790, 0.890189, 0.287392, 0.881796, 0.270248,
+ 0.874781, 0.253659, 0.869166, 0.237786, 0.864725, 0.222618, 0.861565, 0.208356,
+ 0.859284, 0.194867, 0.857677, 0.182120, 0.856714, 0.170180, 0.856155, 0.158969,
+ 0.855800, 0.148413, 0.855672, 0.138578, 0.855538, 0.129345, 0.855689, 0.120861,
+ 0.855767, 0.112969, 0.855618, 0.105593, 0.855250, 0.098745, 0.854583, 0.092373,
+ 0.853534, 0.086414, 0.852061, 0.080834, 0.850253, 0.075677, 0.848004, 0.070861,
+ 0.845333, 0.066378, 0.842376, 0.062263, 0.838956, 0.058411, 0.835121, 0.054833,
+ 0.830842, 0.051484, 0.826212, 0.048355, 0.821522, 0.045471, 0.816551, 0.042826,
+ 0.811211, 0.040361, 0.805479, 0.038039, 0.799409, 0.035874, 0.793060, 0.033873,
+ 0.786395, 0.031998, 0.779416, 0.030241, 0.772140, 0.028595, 0.764636, 0.027075,
+ 0.756836, 0.025635, 0.749315, 0.024303, 0.741561, 0.023050, 0.733589, 0.021880,
+ 0.725479, 0.020784, 0.717255, 0.019770, 0.708829, 0.018817, 0.700191, 0.017911,
+ 1.000000, 0.518937, 0.999998, 0.518933, 0.999967, 0.518883, 0.999832, 0.518660,
+ 0.999466, 0.518057, 0.998644, 0.516752, 0.994458, 0.512347, 0.991223, 0.507675,
+ 0.985515, 0.500188, 0.978308, 0.490408, 0.968359, 0.477357, 0.956820, 0.461752,
+ 0.943929, 0.443796, 0.930224, 0.423893, 0.916514, 0.402682, 0.903653, 0.380914,
+ 0.892315, 0.359212, 0.882942, 0.338102, 0.875438, 0.317730, 0.869642, 0.298186,
+ 0.865304, 0.279491, 0.862382, 0.261804, 0.860666, 0.245146, 0.859788, 0.229406,
+ 0.859608, 0.214605, 0.859912, 0.200691, 0.860530, 0.187623, 0.861368, 0.175390,
+ 0.862237, 0.163901, 0.863127, 0.153175, 0.863923, 0.143147, 0.864567, 0.133781,
+ 0.865013, 0.125042, 0.865390, 0.116952, 0.865591, 0.109476, 0.865517, 0.102542,
+ 0.865084, 0.096069, 0.864309, 0.090050, 0.863151, 0.084433, 0.861649, 0.079222,
+ 0.859742, 0.074348, 0.857446, 0.069796, 0.854757, 0.065536, 0.851783, 0.061608,
+ 0.848516, 0.057970, 0.844897, 0.054574, 0.840956, 0.051417, 0.836676, 0.048460,
+ 0.832075, 0.045693, 0.827191, 0.043118, 0.822295, 0.040772, 0.817294, 0.038603,
+ 0.812013, 0.036568, 0.806465, 0.034655, 0.800691, 0.032872, 0.794709, 0.031211,
+ 0.788493, 0.029650, 0.782049, 0.028178, 0.775403, 0.026797, 0.768570, 0.025500,
+ 0.761536, 0.024276, 0.754303, 0.023114, 0.746920, 0.022031, 0.739745, 0.021019,
+ 1.000000, 0.613914, 0.999996, 0.613907, 0.999942, 0.613814, 0.999704, 0.613407,
+ 0.999046, 0.612302, 0.995516, 0.608266, 0.991726, 0.602863, 0.985157, 0.593956,
+ 0.976420, 0.581748, 0.964404, 0.565183, 0.950601, 0.545273, 0.935158, 0.522129,
+ 0.919364, 0.496782, 0.904754, 0.470571, 0.891760, 0.444037, 0.881492, 0.418322,
+ 0.873656, 0.393522, 0.868053, 0.369795, 0.864336, 0.347171, 0.862259, 0.325737,
+ 0.861556, 0.305532, 0.861776, 0.286416, 0.862661, 0.268355, 0.864015, 0.251334,
+ 0.865711, 0.235352, 0.867519, 0.220302, 0.869351, 0.206161, 0.871144, 0.192908,
+ 0.872839, 0.180505, 0.874307, 0.168848, 0.875667, 0.158021, 0.876758, 0.147877,
+ 0.877640, 0.138441, 0.878237, 0.129627, 0.878563, 0.121415, 0.878572, 0.113741,
+ 0.878420, 0.106652, 0.878057, 0.100097, 0.877413, 0.094013, 0.876460, 0.088346,
+ 0.875233, 0.083092, 0.873700, 0.078198, 0.871873, 0.073640, 0.869780, 0.069410,
+ 0.867405, 0.065470, 0.864751, 0.061791, 0.861818, 0.058349, 0.858645, 0.055144,
+ 0.855307, 0.052189, 0.851736, 0.049433, 0.847927, 0.046850, 0.843888, 0.044426,
+ 0.839629, 0.042150, 0.835158, 0.040008, 0.830509, 0.038008, 0.825714, 0.036149,
+ 0.820729, 0.034396, 0.815751, 0.032778, 0.810752, 0.031275, 0.805587, 0.029854,
+ 0.800317, 0.028540, 0.794890, 0.027295, 0.789314, 0.026114, 0.783593, 0.024994,
+ 1.000000, 0.724258, 0.999992, 0.724243, 0.999870, 0.724044, 0.999336, 0.723170,
+ 0.996271, 0.719432, 0.991159, 0.712576, 0.982465, 0.700927, 0.970490, 0.684297,
+ 0.953973, 0.661244, 0.935546, 0.633804, 0.916596, 0.603071, 0.899353, 0.571050,
+ 0.885216, 0.539206, 0.875076, 0.508714, 0.868334, 0.479571, 0.864414, 0.451796,
+ 0.862678, 0.425328, 0.862835, 0.400352, 0.864067, 0.376532, 0.866086, 0.353910,
+ 0.868557, 0.332424, 0.871271, 0.312053, 0.874058, 0.292764, 0.876800, 0.274530,
+ 0.879390, 0.257297, 0.881900, 0.241140, 0.884187, 0.225934, 0.886262, 0.211669,
+ 0.888119, 0.198311, 0.889709, 0.185783, 0.891054, 0.174063, 0.892196, 0.163143,
+ 0.893101, 0.152952, 0.893803, 0.143475, 0.894277, 0.134647, 0.894532, 0.126434,
+ 0.894576, 0.118800, 0.894393, 0.111694, 0.893976, 0.105069, 0.893346, 0.098908,
+ 0.892502, 0.093172, 0.891441, 0.087828, 0.890276, 0.082903, 0.888972, 0.078351,
+ 0.887469, 0.074108, 0.885785, 0.070163, 0.883914, 0.066484, 0.881872, 0.063057,
+ 0.879651, 0.059853, 0.877267, 0.056862, 0.874717, 0.054060, 0.872012, 0.051438,
+ 0.869157, 0.048981, 0.866155, 0.046673, 0.863014, 0.044506, 0.859748, 0.042473,
+ 0.856416, 0.040596, 0.852958, 0.038827, 0.849382, 0.037162, 0.845694, 0.035596,
+ 0.841893, 0.034115, 0.837981, 0.032714, 0.833963, 0.031386, 0.829847, 0.030128,
+ 1.000000, 0.852140, 0.999969, 0.852095, 0.999483, 0.851408, 0.994545, 0.845790,
+ 0.986188, 0.835231, 0.969847, 0.814687, 0.945951, 0.783735, 0.919170, 0.746074,
+ 0.895488, 0.706938, 0.878232, 0.669534, 0.868252, 0.635168, 0.863873, 0.603069,
+ 0.863369, 0.572514, 0.865450, 0.543169, 0.868803, 0.514578, 0.872794, 0.486762,
+ 0.877020, 0.459811, 0.881054, 0.433654, 0.884974, 0.408574, 0.888587, 0.384525,
+ 0.891877, 0.361560, 0.894793, 0.339661, 0.897430, 0.318913, 0.899796, 0.299302,
+ 0.901943, 0.280843, 0.903858, 0.263481, 0.905574, 0.247197, 0.907069, 0.231915,
+ 0.908379, 0.217614, 0.909520, 0.204250, 0.910483, 0.191758, 0.911280, 0.180092,
+ 0.911936, 0.169222, 0.912454, 0.159098, 0.912835, 0.149668, 0.913078, 0.140884,
+ 0.913192, 0.132709, 0.913175, 0.125095, 0.913040, 0.118012, 0.912781, 0.111417,
+ 0.912410, 0.105281, 0.911924, 0.099569, 0.911331, 0.094253, 0.910637, 0.089308,
+ 0.909840, 0.084700, 0.908941, 0.080404, 0.907944, 0.076398, 0.906857, 0.072664,
+ 0.905680, 0.069178, 0.904416, 0.065922, 0.903067, 0.062878, 0.901637, 0.060031,
+ 0.900128, 0.057365, 0.898544, 0.054867, 0.896890, 0.052527, 0.895165, 0.050331,
+ 0.893371, 0.048267, 0.891572, 0.046360, 0.889763, 0.044600, 0.887894, 0.042945,
+ 0.885967, 0.041388, 0.883984, 0.039922, 0.881945, 0.038540, 0.879854, 0.037236,
+ 0.999804, 0.995833, 0.938155, 0.933611, 0.864755, 0.854311, 0.888594, 0.865264,
+ 0.905575, 0.863922, 0.915125, 0.850558, 0.920665, 0.829254, 0.924073, 0.802578,
+ 0.926304, 0.772211, 0.927829, 0.739366, 0.928924, 0.705033, 0.929730, 0.670019,
+ 0.930339, 0.634993, 0.930811, 0.600485, 0.931191, 0.566897, 0.931490, 0.534485,
+ 0.931737, 0.503429, 0.931939, 0.473811, 0.932108, 0.445668, 0.932250, 0.418993,
+ 0.932371, 0.393762, 0.932474, 0.369939, 0.932562, 0.347479, 0.932638, 0.326336,
+ 0.932703, 0.306462, 0.932760, 0.287805, 0.932809, 0.270313, 0.932851, 0.253933,
+ 0.932887, 0.238610, 0.932917, 0.224289, 0.932943, 0.210917, 0.932965, 0.198440,
+ 0.932982, 0.186807, 0.932995, 0.175966, 0.933005, 0.165869, 0.933011, 0.156468,
+ 0.933013, 0.147719, 0.933013, 0.139579, 0.933010, 0.132007, 0.933004, 0.124965,
+ 0.932994, 0.118416, 0.932982, 0.112326, 0.932968, 0.106663, 0.932950, 0.101397,
+ 0.932931, 0.096499, 0.932908, 0.091944, 0.932883, 0.087706, 0.932856, 0.083762,
+ 0.932827, 0.080092, 0.932796, 0.076675, 0.932762, 0.073494, 0.932727, 0.070530,
+ 0.932689, 0.067768, 0.932650, 0.065193, 0.932609, 0.062792, 0.932565, 0.060552,
+ 0.932521, 0.058461, 0.932474, 0.056508, 0.932427, 0.054684, 0.932377, 0.052979,
+ 0.932326, 0.051385, 0.932274, 0.049894, 0.932220, 0.048497, 0.932164, 0.047190,
};
static float bsdf_split_sum_ggx[64 * 64 * 2] = {
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 5a808f2a01f..99a3c0c06cc 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -38,6 +38,8 @@
#include "GPU_material.h"
+#include "DEG_depsgraph_query.h"
+
#include "eevee_engine.h"
#include "eevee_lut.h"
#include "eevee_private.h"
@@ -135,7 +137,7 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
- tex = DRW_texture_create_2D(w, h, GPU_RG16F, DRW_TEX_FILTER, (float *)texels);
+ tex = DRW_texture_create_2d(w, h, GPU_RG16F, DRW_TEX_FILTER, (float *)texels);
DRWFboTexture tex_filter = {&tex, GPU_RG16F, DRW_TEX_FILTER};
GPU_framebuffer_init(&fb, &draw_engine_eevee_type, w, h, &tex_filter, 1);
@@ -197,7 +199,7 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
- tex = DRW_texture_create_2D(w, h, GPU_R16F, DRW_TEX_FILTER, (float *)texels);
+ tex = DRW_texture_create_2d(w, h, GPU_R16F, DRW_TEX_FILTER, (float *)texels);
DRWFboTexture tex_filter = {&tex, GPU_R16F, DRW_TEX_FILTER};
GPU_framebuffer_init(&fb, &draw_engine_eevee_type, w, h, &tex_filter, 1);
@@ -272,58 +274,58 @@ static char *eevee_get_defines(int options)
char *str = NULL;
DynStr *ds = BLI_dynstr_new();
- BLI_dynstr_appendf(ds, SHADER_DEFINES);
+ BLI_dynstr_append(ds, SHADER_DEFINES);
if ((options & VAR_MAT_MESH) != 0) {
- BLI_dynstr_appendf(ds, "#define MESH_SHADER\n");
+ BLI_dynstr_append(ds, "#define MESH_SHADER\n");
}
if ((options & VAR_MAT_HAIR) != 0) {
- BLI_dynstr_appendf(ds, "#define HAIR_SHADER\n");
+ BLI_dynstr_append(ds, "#define HAIR_SHADER\n");
}
if ((options & VAR_MAT_PROBE) != 0) {
- BLI_dynstr_appendf(ds, "#define PROBE_CAPTURE\n");
+ BLI_dynstr_append(ds, "#define PROBE_CAPTURE\n");
}
if ((options & VAR_MAT_FLAT) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_FLAT_NORMAL\n");
+ BLI_dynstr_append(ds, "#define USE_FLAT_NORMAL\n");
}
if ((options & VAR_MAT_CLIP) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_ALPHA_CLIP\n");
+ BLI_dynstr_append(ds, "#define USE_ALPHA_CLIP\n");
}
if ((options & VAR_MAT_SHADOW) != 0) {
- BLI_dynstr_appendf(ds, "#define SHADOW_SHADER\n");
+ BLI_dynstr_append(ds, "#define SHADOW_SHADER\n");
}
if ((options & VAR_MAT_HASH) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_ALPHA_HASH\n");
+ BLI_dynstr_append(ds, "#define USE_ALPHA_HASH\n");
}
if ((options & VAR_MAT_BLEND) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_ALPHA_BLEND\n");
+ BLI_dynstr_append(ds, "#define USE_ALPHA_BLEND\n");
}
if ((options & VAR_MAT_MULT) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_MULTIPLY\n");
+ BLI_dynstr_append(ds, "#define USE_MULTIPLY\n");
}
if ((options & VAR_MAT_REFRACT) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_REFRACTION\n");
+ BLI_dynstr_append(ds, "#define USE_REFRACTION\n");
}
if ((options & VAR_MAT_SSS) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_SSS\n");
+ BLI_dynstr_append(ds, "#define USE_SSS\n");
}
if ((options & VAR_MAT_SSSALBED) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_SSS_ALBEDO\n");
+ BLI_dynstr_append(ds, "#define USE_SSS_ALBEDO\n");
}
if ((options & VAR_MAT_TRANSLUC) != 0) {
- BLI_dynstr_appendf(ds, "#define USE_TRANSLUCENCY\n");
+ BLI_dynstr_append(ds, "#define USE_TRANSLUCENCY\n");
}
if ((options & VAR_MAT_VSM) != 0) {
- BLI_dynstr_appendf(ds, "#define SHADOW_VSM\n");
+ BLI_dynstr_append(ds, "#define SHADOW_VSM\n");
}
if ((options & VAR_MAT_ESM) != 0) {
- BLI_dynstr_appendf(ds, "#define SHADOW_ESM\n");
+ BLI_dynstr_append(ds, "#define SHADOW_ESM\n");
}
if (((options & VAR_MAT_VOLUME) != 0) && ((options & VAR_MAT_BLEND) != 0)) {
- BLI_dynstr_appendf(ds, "#define USE_ALPHA_BLEND_VOLUMETRICS\n");
+ BLI_dynstr_append(ds, "#define USE_ALPHA_BLEND_VOLUMETRICS\n");
}
if ((options & VAR_MAT_LOOKDEV) != 0) {
- BLI_dynstr_appendf(ds, "#define LOOKDEV\n");
+ BLI_dynstr_append(ds, "#define LOOKDEV\n");
}
str = BLI_dynstr_get_cstring(ds);
@@ -337,11 +339,11 @@ static char *eevee_get_volume_defines(int options)
char *str = NULL;
DynStr *ds = BLI_dynstr_new();
- BLI_dynstr_appendf(ds, SHADER_DEFINES);
- BLI_dynstr_appendf(ds, "#define VOLUMETRICS\n");
+ BLI_dynstr_append(ds, SHADER_DEFINES);
+ BLI_dynstr_append(ds, "#define VOLUMETRICS\n");
if ((options & VAR_MAT_VOLUME) != 0) {
- BLI_dynstr_appendf(ds, "#define MESH_SHADER\n");
+ BLI_dynstr_append(ds, "#define MESH_SHADER\n");
}
str = BLI_dynstr_get_cstring(ds);
@@ -352,7 +354,7 @@ static char *eevee_get_volume_defines(int options)
/**
* ssr_id can be null to disable ssr contribution.
- **/
+ */
static void add_standard_uniforms(
DRWShadingGroup *shgrp, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
int *ssr_id, float *refract_depth,
@@ -436,12 +438,12 @@ static void eevee_init_dummys(void)
static void eevee_init_noise_texture(void)
{
- e_data.noise_tex = DRW_texture_create_2D(64, 64, GPU_RGBA16F, 0, (float *)blue_noise);
+ e_data.noise_tex = DRW_texture_create_2d(64, 64, GPU_RGBA16F, 0, (float *)blue_noise);
}
static void eevee_init_util_texture(void)
{
- const int layers = 3 + 16;
+ const int layers = 4 + 16;
float (*texels)[4] = MEM_mallocN(sizeof(float[4]) * 64 * 64 * layers, "utils texels");
float (*texels_layer)[4] = texels;
@@ -450,12 +452,12 @@ static void eevee_init_util_texture(void)
texels_layer += 64 * 64;
/* Copy bsdf_split_sum_ggx into 2nd layer red and green channels.
- Copy ltc_mag_ggx into 2nd layer blue channel. */
+ Copy ltc_mag_ggx into 2nd layer blue and alpha channel. */
for (int i = 0; i < 64 * 64; i++) {
texels_layer[i][0] = bsdf_split_sum_ggx[i * 2 + 0];
texels_layer[i][1] = bsdf_split_sum_ggx[i * 2 + 1];
- texels_layer[i][2] = ltc_mag_ggx[i];
- texels_layer[i][3] = ltc_disk_integral[i];
+ texels_layer[i][2] = ltc_mag_ggx[i * 2 + 0];
+ texels_layer[i][3] = ltc_mag_ggx[i * 2 + 1];
}
texels_layer += 64 * 64;
@@ -468,18 +470,27 @@ static void eevee_init_util_texture(void)
}
texels_layer += 64 * 64;
- /* Copy Refraction GGX LUT in layer 4 - 20 */
+ /* Copy ltc_disk_integral in 4th layer */
+ for (int i = 0; i < 64 * 64; i++) {
+ texels_layer[i][0] = ltc_disk_integral[i];
+ texels_layer[i][1] = 0.0; /* UNUSED */
+ texels_layer[i][2] = 0.0; /* UNUSED */
+ texels_layer[i][3] = 0.0; /* UNUSED */
+ }
+ texels_layer += 64 * 64;
+
+ /* Copy Refraction GGX LUT in layer 5 - 21 */
for (int j = 0; j < 16; ++j) {
for (int i = 0; i < 64 * 64; i++) {
texels_layer[i][0] = btdf_split_sum_ggx[j * 2][i];
- texels_layer[i][1] = btdf_split_sum_ggx[j * 2][i];
- texels_layer[i][2] = btdf_split_sum_ggx[j * 2][i];
- texels_layer[i][3] = btdf_split_sum_ggx[j * 2][i];
+ texels_layer[i][1] = 0.0; /* UNUSED */
+ texels_layer[i][2] = 0.0; /* UNUSED */
+ texels_layer[i][3] = 0.0; /* UNUSED */
}
texels_layer += 64 * 64;
}
- e_data.util_tex = DRW_texture_create_2D_array(
+ e_data.util_tex = DRW_texture_create_2d_array(
64, 64, layers, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_WRAP, (float *)texels);
MEM_freeN(texels);
@@ -497,7 +508,7 @@ void EEVEE_update_noise(EEVEE_PassList *psl, EEVEE_FramebufferList *fbl, const d
DRW_draw_pass(psl->update_noise_pass);
}
-static void EEVEE_update_viewvecs(float invproj[4][4], float winmat[4][4], float (*r_viewvecs)[4])
+void EEVEE_update_viewvecs(float invproj[4][4], float winmat[4][4], float (*r_viewvecs)[4])
{
/* view vectors for the corners of the view frustum.
* Can be used to recreate the world space position easily */
@@ -528,7 +539,7 @@ static void EEVEE_update_viewvecs(float invproj[4][4], float winmat[4][4], float
* when Z = 1, and top-left corner if Z = 1.
* view_vecs[0].z the near clip distance and view_vecs[1].z is the (signed)
* distance from the near plane to the far clip plane.
- **/
+ */
copy_v4_v4(r_viewvecs[0], view_vecs[0]);
/* we need to store the differences */
@@ -629,7 +640,7 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, E
}
else {
double r;
- BLI_halton_1D(5, 0.0, stl->effects->taa_current_sample - 1, &r);
+ BLI_halton_1d(5, 0.0, stl->effects->taa_current_sample - 1, &r);
e_data.alpha_hash_offset = (float)r;
e_data.alpha_hash_scale = 0.01f;
}
@@ -712,13 +723,27 @@ struct GPUMaterial *EEVEE_material_mesh_get(
const void *engine = &DRW_engine_viewport_eevee_type;
int options = VAR_MAT_MESH;
- if (use_blend) options |= VAR_MAT_BLEND;
- if (use_multiply) options |= VAR_MAT_MULT;
- if (use_refract) options |= VAR_MAT_REFRACT;
- if (use_sss) options |= VAR_MAT_SSS;
- if (use_sss && effects->sss_separate_albedo) options |= VAR_MAT_SSSALBED;
- if (use_translucency) options |= VAR_MAT_TRANSLUC;
- if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) options |= VAR_MAT_VOLUME;
+ if (use_blend) {
+ options |= VAR_MAT_BLEND;
+ }
+ if (use_multiply) {
+ options |= VAR_MAT_MULT;
+ }
+ if (use_refract) {
+ options |= VAR_MAT_REFRACT;
+ }
+ if (use_sss) {
+ options |= VAR_MAT_SSS;
+ }
+ if (use_sss && effects->sss_separate_albedo) {
+ options |= VAR_MAT_SSSALBED;
+ }
+ if (use_translucency) {
+ options |= VAR_MAT_TRANSLUC;
+ }
+ if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) {
+ options |= VAR_MAT_VOLUME;
+ }
options |= eevee_material_shadow_option(shadow_method);
@@ -831,7 +856,7 @@ struct GPUMaterial *EEVEE_material_hair_get(
/**
* Create a default shading group inside the given pass.
- **/
+ */
static struct DRWShadingGroup *EEVEE_default_shading_group_create(
EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWPass *pass,
bool is_hair, bool is_flat_normal, bool use_blend, bool use_ssr, int shadow_method)
@@ -841,10 +866,18 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_create(
ssr_id = (use_ssr) ? 1 : -1;
int options = VAR_MAT_MESH;
- if (is_hair) options |= VAR_MAT_HAIR;
- if (is_flat_normal) options |= VAR_MAT_FLAT;
- if (use_blend) options |= VAR_MAT_BLEND;
- if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) options |= VAR_MAT_VOLUME;
+ if (is_hair) {
+ options |= VAR_MAT_HAIR;
+ }
+ if (is_flat_normal) {
+ options |= VAR_MAT_FLAT;
+ }
+ if (use_blend) {
+ options |= VAR_MAT_BLEND;
+ }
+ if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) {
+ options |= VAR_MAT_VOLUME;
+ }
options |= eevee_material_shadow_option(shadow_method);
@@ -860,7 +893,7 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_create(
/**
* Create a default shading group inside the default pass without standard uniforms.
- **/
+ */
static struct DRWShadingGroup *EEVEE_default_shading_group_get(
EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
Object *ob, ParticleSystem *psys, ModifierData *md,
@@ -872,8 +905,12 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(
BLI_assert(!is_hair || (ob && psys && md));
- if (is_hair) options |= VAR_MAT_HAIR;
- if (is_flat_normal) options |= VAR_MAT_FLAT;
+ if (is_hair) {
+ options |= VAR_MAT_HAIR;
+ }
+ if (is_flat_normal) {
+ options |= VAR_MAT_FLAT;
+ }
options |= eevee_material_shadow_option(shadow_method);
@@ -908,7 +945,7 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(
/**
* Create a default shading group inside the lookdev pass without standard uniforms.
- **/
+ */
static struct DRWShadingGroup *EEVEE_lookdev_shading_group_get(
EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
bool use_ssr, int shadow_method)
@@ -958,7 +995,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
const float *col = G_draw.block.colorBackground;
/* LookDev */
- EEVEE_lookdev_cache_init(vedata, &grp, psl->background_pass, wo, NULL);
+ EEVEE_lookdev_cache_init(vedata, &grp, psl->background_pass, stl->g_data->background_alpha, wo, NULL);
/* END */
if (!grp && wo) {
@@ -1026,7 +1063,8 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
- psl->material_pass = DRW_pass_create("Material Shader Pass", state);
+ psl->material_pass = DRW_pass_create("Material Pass", state);
+ psl->material_pass_cull = DRW_pass_create("Material Pass Cull", state | DRW_STATE_CULL_BACK);
}
{
@@ -1064,6 +1102,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES |
DRW_STATE_WIRE | DRW_STATE_WRITE_STENCIL);
psl->sss_pass = DRW_pass_create("Subsurface Pass", state);
+ psl->sss_pass_cull = DRW_pass_create("Subsurface Pass Cull", state | DRW_STATE_CULL_BACK);
e_data.sss_count = 0;
}
@@ -1219,7 +1258,8 @@ static void material_opaque(
*shgrp = DRW_shgroup_material_create(
*gpumat,
(use_ssrefract) ? psl->refract_pass :
- (use_sss) ? psl->sss_pass : psl->material_pass);
+ (use_sss) ? ((do_cull) ? psl->sss_pass_cull : psl->sss_pass)
+ : ((do_cull) ? psl->material_pass_cull : psl->material_pass));
add_standard_uniforms(*shgrp, sldata, vedata, ssr_id, &ma->refract_depth,
use_diffuse, use_glossy, use_refract, use_ssrefract, false);
@@ -1584,34 +1624,28 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
}
/* Shadow Pass */
- if (ma->use_nodes && ma->nodetree && (ma->blend_method != MA_BM_SOLID)) {
- struct GPUMaterial *gpumat;
- switch (ma->blend_shadow) {
- case MA_BS_SOLID:
- EEVEE_lights_cache_shcaster_add(
- sldata, stl, mat_geom[i], ob);
- *cast_shadow = true;
- break;
- case MA_BS_CLIP:
- gpumat = EEVEE_material_mesh_depth_get(scene, ma, false, true);
- EEVEE_lights_cache_shcaster_material_add(
- sldata, psl, gpumat, mat_geom[i], ob, &ma->alpha_threshold);
- *cast_shadow = true;
- break;
- case MA_BS_HASHED:
- gpumat = EEVEE_material_mesh_depth_get(scene, ma, true, true);
- EEVEE_lights_cache_shcaster_material_add(
- sldata, psl, gpumat, mat_geom[i], ob, NULL);
- *cast_shadow = true;
- break;
- case MA_BS_NONE:
- default:
- break;
- }
- }
- else {
- EEVEE_lights_cache_shcaster_add(sldata, stl, mat_geom[i], ob);
- *cast_shadow = true;
+ struct GPUMaterial *gpumat;
+ switch (ma->blend_shadow) {
+ case MA_BS_SOLID:
+ EEVEE_lights_cache_shcaster_add(
+ sldata, stl, mat_geom[i], ob);
+ *cast_shadow = true;
+ break;
+ case MA_BS_CLIP:
+ gpumat = EEVEE_material_mesh_depth_get(scene, ma, false, true);
+ EEVEE_lights_cache_shcaster_material_add(
+ sldata, psl, gpumat, mat_geom[i], ob, &ma->alpha_threshold);
+ *cast_shadow = true;
+ break;
+ case MA_BS_HASHED:
+ gpumat = EEVEE_material_mesh_depth_get(scene, ma, true, true);
+ EEVEE_lights_cache_shcaster_material_add(
+ sldata, psl, gpumat, mat_geom[i], ob, NULL);
+ *cast_shadow = true;
+ break;
+ case MA_BS_NONE:
+ default:
+ break;
}
}
}
@@ -1640,9 +1674,6 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata,
continue;
}
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
- if (!psys_check_enabled(ob, psys, false)) {
- continue;
- }
if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
continue;
}
diff --git a/source/blender/draw/engines/eevee/eevee_mist.c b/source/blender/draw/engines/eevee/eevee_mist.c
index 315a87776ef..9a75ba91fa5 100644
--- a/source/blender/draw/engines/eevee/eevee_mist.c
+++ b/source/blender/draw/engines/eevee/eevee_mist.c
@@ -67,7 +67,7 @@ void EEVEE_mist_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
}
/* Create FrameBuffer. */
- DRW_texture_ensure_fullscreen_2D(&txl->mist_accum, GPU_R32F, 0); /* Should be enough precision for many samples. */
+ DRW_texture_ensure_fullscreen_2d(&txl->mist_accum, GPU_R32F, 0); /* Should be enough precision for many samples. */
GPU_framebuffer_ensure_config(&fbl->mist_accum_fb, {
GPU_ATTACHMENT_NONE,
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 9ffd2006998..bc3e4b35936 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -32,6 +32,7 @@
#include "DNA_camera_types.h"
#include "DNA_screen_types.h"
+#include "ED_screen.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -56,11 +57,16 @@ static void eevee_motion_blur_camera_get_matrix_at_time(
float obmat[4][4];
/* HACK */
- Object cam_cpy; Camera camdata_cpy;
- memcpy(&cam_cpy, camera, sizeof(cam_cpy));
- memcpy(&camdata_cpy, camera->data, sizeof(camdata_cpy));
+ Object cam_cpy = *camera;
+ Camera camdata_cpy = *(Camera *)(camera->data);
cam_cpy.data = &camdata_cpy;
+ /* Reset original pointers, so direct evaluation does not attempt to flush
+ * animation back to the original object: otherwise viewport with motion
+ * blur enabled will always loose non-keyed changes. */
+ cam_cpy.id.orig_id = NULL;
+ camdata_cpy.id.orig_id = NULL;
+
const DRWContextState *draw_ctx = DRW_context_state_get();
/* Past matrix */
@@ -116,40 +122,65 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
float delta = scene_eval->eevee.motion_blur_shutter;
Object *ob_camera_eval = DEG_get_evaluated_object(draw_ctx->depsgraph, camera);
- /* Current matrix */
- eevee_motion_blur_camera_get_matrix_at_time(
- scene,
- ar, rv3d, v3d,
- ob_camera_eval,
- ctime,
- effects->current_ndc_to_world);
-
/* Viewport Matrix */
+ /* Note: This does not have TAA jitter applied. */
DRW_viewport_matrix_get(persmat, DRW_MAT_PERS);
- /* Only continue if camera is not being keyed */
- if (DRW_state_is_image_render() ||
- compare_m4m4(persmat, effects->current_ndc_to_world, 0.0001f))
- {
- /* Past matrix */
+ bool view_is_valid = (stl->g_data->view_updated == false);
+
+ if (draw_ctx->evil_C != NULL) {
+ struct wmWindowManager *wm = CTX_wm_manager(draw_ctx->evil_C);
+ view_is_valid = view_is_valid && (ED_screen_animation_no_scrub(wm) == NULL);
+ }
+
+ /* The view is jittered by the oglrenderer. So avoid testing in this case. */
+ if (!DRW_state_is_image_render()) {
+ view_is_valid = view_is_valid && compare_m4m4(persmat, effects->prev_drw_persmat, FLT_MIN);
+ /* WATCH: assume TAA init code runs last. */
+ if (scene_eval->eevee.taa_samples == 1) {
+ /* Only if TAA is disabled. If not, TAA will update prev_drw_persmat itself. */
+ copy_m4_m4(effects->prev_drw_persmat, persmat);
+ }
+ }
+
+ effects->motion_blur_mat_cached = view_is_valid && !DRW_state_is_image_render();
+
+ /* Current matrix */
+ if (effects->motion_blur_mat_cached == false) {
eevee_motion_blur_camera_get_matrix_at_time(
scene,
ar, rv3d, v3d,
ob_camera_eval,
- ctime - delta,
- effects->past_world_to_ndc);
+ ctime,
+ effects->current_world_to_ndc);
+ }
+
+ /* Only continue if camera is not being keyed */
+ if (DRW_state_is_image_render() ||
+ compare_m4m4(persmat, effects->current_world_to_ndc, 0.0001f))
+ {
+ /* Past matrix */
+ if (effects->motion_blur_mat_cached == false) {
+ eevee_motion_blur_camera_get_matrix_at_time(
+ scene,
+ ar, rv3d, v3d,
+ ob_camera_eval,
+ ctime - delta,
+ effects->past_world_to_ndc);
#if 0 /* for future high quality blur */
- /* Future matrix */
- eevee_motion_blur_camera_get_matrix_at_time(
- scene,
- ar, rv3d, v3d,
- ob_camera_eval,
- ctime + delta,
- effects->future_world_to_ndc);
+ /* Future matrix */
+ eevee_motion_blur_camera_get_matrix_at_time(
+ scene,
+ ar, rv3d, v3d,
+ ob_camera_eval,
+ ctime + delta,
+ effects->future_world_to_ndc);
#endif
- invert_m4(effects->current_ndc_to_world);
+ invert_m4_m4(effects->current_ndc_to_world, effects->current_world_to_ndc);
+ }
+ effects->motion_blur_mat_cached = true;
effects->motion_blur_samples = scene_eval->eevee.motion_blur_samples;
if (!e_data.motion_blur_sh) {
diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c
index 050870292ab..5e95755ea76 100644
--- a/source/blender/draw/engines/eevee/eevee_occlusion.c
+++ b/source/blender/draw/engines/eevee/eevee_occlusion.c
@@ -99,7 +99,7 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
common_data->ao_bounce_fac = (scene_eval->eevee.flag & SCE_EEVEE_GTAO_BOUNCE) ? 1.0f : 0.0f;
- effects->gtao_horizons = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_RGBA8,
+ effects->gtao_horizons = DRW_texture_pool_query_2d(fs_size[0], fs_size[1], GPU_RGBA8,
&draw_engine_eevee_type);
GPU_framebuffer_ensure_config(&fbl->gtao_fb, {
GPU_ATTACHMENT_NONE,
@@ -107,7 +107,7 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
});
if (G.debug_value == 6) {
- effects->gtao_horizons_debug = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_RGBA8,
+ effects->gtao_horizons_debug = DRW_texture_pool_query_2d(fs_size[0], fs_size[1], GPU_RGBA8,
&draw_engine_eevee_type);
GPU_framebuffer_ensure_config(&fbl->gtao_debug_fb, {
GPU_ATTACHMENT_NONE,
@@ -144,7 +144,7 @@ void EEVEE_occlusion_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- DRW_texture_ensure_fullscreen_2D(&txl->ao_accum, GPU_R32F, 0); /* Should be enough precision for many samples. */
+ DRW_texture_ensure_fullscreen_2d(&txl->ao_accum, GPU_R32F, 0); /* Should be enough precision for many samples. */
GPU_framebuffer_ensure_config(&fbl->ao_accum_fb, {
GPU_ATTACHMENT_NONE,
@@ -195,7 +195,7 @@ void EEVEE_occlusion_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
* - Then we use this angle to compute occlusion with the shading normal at
* the shading stage. This let us do correct shadowing for each diffuse / specular
* lobe present in the shader using the correct normal.
- **/
+ */
psl->ao_horizon_search = DRW_pass_create("GTAO Horizon Search", DRW_STATE_WRITE_COLOR);
DRWShadingGroup *grp = DRW_shgroup_create(e_data.gtao_sh, psl->ao_horizon_search);
DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 07485167fe3..f112ae0536e 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -253,7 +253,9 @@ typedef struct EEVEE_PassList {
struct DRWPass *refract_depth_pass_clip_cull;
struct DRWPass *default_pass[VAR_MAT_MAX];
struct DRWPass *sss_pass;
+ struct DRWPass *sss_pass_cull;
struct DRWPass *material_pass;
+ struct DRWPass *material_pass_cull;
struct DRWPass *refract_pass;
struct DRWPass *transparent_pass;
struct DRWPass *background_pass;
@@ -486,8 +488,6 @@ typedef struct EEVEE_LightProbesInfo {
float visibility_blur;
float intensity_fac;
int shres;
- int studiolight_index;
- float studiolight_rot_z;
EEVEE_LightProbeVisTest planar_vis_tests[MAX_PLANAR];
/* UBO Storage : data used by UBO */
EEVEE_LightProbe probe_data[MAX_PROBE];
@@ -563,16 +563,18 @@ typedef struct EEVEE_EffectsInfo {
struct GPUTexture *gtao_horizons; /* Textures from pool */
struct GPUTexture *gtao_horizons_debug;
/* Motion Blur */
+ float current_world_to_ndc[4][4];
float current_ndc_to_world[4][4];
float past_world_to_ndc[4][4];
int motion_blur_samples;
+ bool motion_blur_mat_cached;
/* Velocity Pass */
float velocity_curr_persinv[4][4];
float velocity_past_persmat[4][4];
struct GPUTexture *velocity_tx; /* Texture from pool */
/* Depth Of Field */
float dof_near_far[2];
- float dof_params[3];
+ float dof_params[2];
float dof_bokeh[4];
float dof_bokeh_sides[4];
int dof_target_size[2];
@@ -816,6 +818,11 @@ typedef struct EEVEE_PrivateData {
/* Color Management */
bool use_color_render_settings;
+
+ /* LookDev Settings */
+ int studiolight_index;
+ float studiolight_rot_z;
+
} EEVEE_PrivateData; /* Transient data */
/* eevee_data.c */
@@ -853,6 +860,7 @@ struct GPUMaterial *EEVEE_material_hair_get(struct Scene *scene, Material *ma, i
void EEVEE_materials_free(void);
void EEVEE_draw_default_passes(EEVEE_PassList *psl);
void EEVEE_update_noise(EEVEE_PassList *psl, EEVEE_FramebufferList *fbl, const double offsets[3]);
+void EEVEE_update_viewvecs(float invproj[4][4], float winmat[4][4], float (*r_viewvecs)[4]);
/* eevee_lights.c */
void EEVEE_lights_init(EEVEE_ViewLayerData *sldata);
@@ -1001,7 +1009,9 @@ void EEVEE_render_draw(EEVEE_Data *vedata, struct RenderEngine *engine, struct R
void EEVEE_render_update_passes(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer);
/** eevee_lookdev.c */
-void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, DRWShadingGroup **grp, DRWPass *pass, struct World *world, EEVEE_LightProbesInfo *pinfo);
+void EEVEE_lookdev_cache_init(
+ EEVEE_Data *vedata, DRWShadingGroup **grp, DRWPass *pass, float background_alpha,
+ struct World *world, EEVEE_LightProbesInfo *pinfo);
void EEVEE_lookdev_draw_background(EEVEE_Data *vedata);
/** eevee_engine.c */
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c
index 0cf1d31f8b8..e563fa8b9ce 100644
--- a/source/blender/draw/engines/eevee/eevee_render.c
+++ b/source/blender/draw/engines/eevee/eevee_render.c
@@ -84,8 +84,8 @@ void EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph *
size_orig[1] + g_data->overscan_pixels * 2.0f});
/* TODO 32 bit depth */
- DRW_texture_ensure_fullscreen_2D(&dtxl->depth, GPU_DEPTH24_STENCIL8, 0);
- DRW_texture_ensure_fullscreen_2D(&txl->color, GPU_RGBA32F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
+ DRW_texture_ensure_fullscreen_2d(&dtxl->depth, GPU_DEPTH24_STENCIL8, 0);
+ DRW_texture_ensure_fullscreen_2d(&txl->color, GPU_RGBA32F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
GPU_framebuffer_ensure_config(&dfbl->default_fb, {
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
@@ -169,7 +169,10 @@ void EEVEE_render_cache(
}
}
- if (engine) {
+ /* Don't print dupli objects as this can be very verbose and
+ * increase the render time on Windows because of slow windows term.
+ * (see T59649) */
+ if (engine && (ob->base_flag & BASE_FROM_DUPLI) == 0) {
char info[42];
BLI_snprintf(info, sizeof(info), "Syncing %s", ob->id.name + 2);
RE_engine_update_stats(engine, NULL, info);
@@ -210,12 +213,6 @@ static void eevee_render_result_combined(
vedata->stl->g_data->overscan_pixels + rect->ymin,
BLI_rcti_size_x(rect), BLI_rcti_size_y(rect),
4, 0, rp->rect);
-
- /* Premult alpha */
- int pixels_len = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
- for (int i = 0; i < pixels_len * 4; i += 4) {
- mul_v3_fl(rp->rect + i, rp->rect[i + 3]);
- }
}
static void eevee_render_result_subsurface(
@@ -515,7 +512,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
/* Copy previous persmat to UBO data */
copy_m4_m4(sldata->common_data.prev_persmat, stl->effects->prev_persmat);
- BLI_halton_3D(primes, offset, stl->effects->taa_current_sample, r);
+ BLI_halton_3d(primes, offset, stl->effects->taa_current_sample, r);
EEVEE_update_noise(psl, fbl, r);
EEVEE_temporal_sampling_matrices_calc(stl->effects, g_data->viewmat, g_data->persmat, r);
EEVEE_volumes_set_jitter(sldata, stl->effects->taa_current_sample - 1);
@@ -530,13 +527,17 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
DRW_viewport_matrix_override_set(g_data->viewinv, DRW_MAT_VIEWINV);
/* Refresh Probes */
- RE_engine_update_stats(engine, NULL, "Updating Probes");
EEVEE_lightprobes_refresh(sldata, vedata);
EEVEE_lightprobes_refresh_planar(sldata, vedata);
- char info[42];
- BLI_snprintf(info, sizeof(info), "Rendering %u / %u samples", render_samples + 1, tot_sample);
- RE_engine_update_stats(engine, NULL, info);
+ /* Don't print every samples as it can lead to bad performance. (see T59649) */
+ if ((render_samples % 25) == 0 ||
+ (render_samples + 1) == tot_sample)
+ {
+ char info[42];
+ BLI_snprintf(info, sizeof(info), "Rendering %u / %u samples", render_samples + 1, tot_sample);
+ RE_engine_update_stats(engine, NULL, info);
+ }
/* Refresh Shadows */
EEVEE_lights_update(sldata, vedata);
@@ -561,6 +562,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
GPU_framebuffer_bind(fbl->main_fb);
EEVEE_draw_default_passes(psl);
DRW_draw_pass(psl->material_pass);
+ DRW_draw_pass(psl->material_pass_cull);
EEVEE_subsurface_data_render(sldata, vedata);
/* Effects pre-transparency */
EEVEE_subsurface_compute(sldata, vedata);
@@ -614,7 +616,7 @@ void EEVEE_render_update_passes(RenderEngine *engine, Scene *scene, ViewLayer *v
else if (channels == 3) type = SOCK_VECTOR; \
else type = SOCK_FLOAT; \
RE_engine_register_pass(engine, scene, view_layer, RE_PASSNAME_ ## name, channels, chanid, type); \
- }
+ } ((void)0)
CHECK_PASS(Z, 1, "Z");
CHECK_PASS(MIST, 1, "Z");
diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
index 113cd359b2e..f044d68ddb2 100644
--- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
+++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
@@ -74,19 +74,19 @@ static struct GPUShader *eevee_effects_screen_raytrace_shader_get(int options)
datatoc_effect_ssr_frag_glsl);
DynStr *ds_defines = BLI_dynstr_new();
- BLI_dynstr_appendf(ds_defines, SHADER_DEFINES);
+ BLI_dynstr_append(ds_defines, SHADER_DEFINES);
if (options & SSR_RESOLVE) {
- BLI_dynstr_appendf(ds_defines, "#define STEP_RESOLVE\n");
+ BLI_dynstr_append(ds_defines, "#define STEP_RESOLVE\n");
}
else {
- BLI_dynstr_appendf(ds_defines, "#define STEP_RAYTRACE\n");
- BLI_dynstr_appendf(ds_defines, "#define PLANAR_PROBE_RAYTRACE\n");
+ BLI_dynstr_append(ds_defines, "#define STEP_RAYTRACE\n");
+ BLI_dynstr_append(ds_defines, "#define PLANAR_PROBE_RAYTRACE\n");
}
if (options & SSR_FULL_TRACE) {
- BLI_dynstr_appendf(ds_defines, "#define FULLRES\n");
+ BLI_dynstr_append(ds_defines, "#define FULLRES\n");
}
if (options & SSR_AO) {
- BLI_dynstr_appendf(ds_defines, "#define SSR_AO\n");
+ BLI_dynstr_append(ds_defines, "#define SSR_AO\n");
}
char *ssr_define_str = BLI_dynstr_get_cstring(ds_defines);
BLI_dynstr_free(ds_defines);
@@ -121,7 +121,7 @@ int EEVEE_screen_raytrace_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
if (use_refraction) {
/* TODO: Opti: Could be shared. */
- DRW_texture_ensure_fullscreen_2D(&txl->refract_color, GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
+ DRW_texture_ensure_fullscreen_2d(&txl->refract_color, GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
GPU_framebuffer_ensure_config(&fbl->refract_fb, {
GPU_ATTACHMENT_NONE,
@@ -156,15 +156,15 @@ int EEVEE_screen_raytrace_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
const eGPUTextureFormat format = (high_qual_input) ? GPU_RGBA16F : GPU_RGBA8;
/* MRT for the shading pass in order to output needed data for the SSR pass. */
- effects->ssr_specrough_input = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], format,
+ effects->ssr_specrough_input = DRW_texture_pool_query_2d(size_fs[0], size_fs[1], format,
&draw_engine_eevee_type);
GPU_framebuffer_texture_attach(fbl->main_fb, effects->ssr_specrough_input, 2, 0);
/* Raytracing output */
- effects->ssr_hit_output = DRW_texture_pool_query_2D(tracing_res[0], tracing_res[1], GPU_RG16I,
+ effects->ssr_hit_output = DRW_texture_pool_query_2d(tracing_res[0], tracing_res[1], GPU_RG16I,
&draw_engine_eevee_type);
- effects->ssr_pdf_output = DRW_texture_pool_query_2D(tracing_res[0], tracing_res[1], GPU_R16F,
+ effects->ssr_pdf_output = DRW_texture_pool_query_2d(tracing_res[0], tracing_res[1], GPU_R16F,
&draw_engine_eevee_type);
GPU_framebuffer_ensure_config(&fbl->screen_tracing_fb, {
diff --git a/source/blender/draw/engines/eevee/eevee_subsurface.c b/source/blender/draw/engines/eevee/eevee_subsurface.c
index 49bea1fb01e..8abbaa64fd2 100644
--- a/source/blender/draw/engines/eevee/eevee_subsurface.c
+++ b/source/blender/draw/engines/eevee/eevee_subsurface.c
@@ -86,11 +86,11 @@ int EEVEE_subsurface_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
* as the depth buffer we are sampling from. This could be avoided if the stencil is
* a separate texture but that needs OpenGL 4.4 or ARB_texture_stencil8.
* OR OpenGL 4.3 / ARB_ES3_compatibility if using a renderbuffer instead */
- effects->sss_stencil = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_DEPTH24_STENCIL8,
+ effects->sss_stencil = DRW_texture_pool_query_2d(fs_size[0], fs_size[1], GPU_DEPTH24_STENCIL8,
&draw_engine_eevee_type);
- effects->sss_blur = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_RGBA16F,
+ effects->sss_blur = DRW_texture_pool_query_2d(fs_size[0], fs_size[1], GPU_RGBA16F,
&draw_engine_eevee_type);
- effects->sss_data = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_RGBA16F,
+ effects->sss_data = DRW_texture_pool_query_2d(fs_size[0], fs_size[1], GPU_RGBA16F,
&draw_engine_eevee_type);
GPUTexture *stencil_tex = effects->sss_stencil;
@@ -123,7 +123,7 @@ int EEVEE_subsurface_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
});
if (effects->sss_separate_albedo) {
- effects->sss_albedo = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_R11F_G11F_B10F,
+ effects->sss_albedo = DRW_texture_pool_query_2d(fs_size[0], fs_size[1], GPU_R11F_G11F_B10F,
&draw_engine_eevee_type);
}
else {
@@ -160,8 +160,8 @@ void EEVEE_subsurface_output_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
if (scene_eval->eevee.flag & SCE_EEVEE_SSS_ENABLED) {
- DRW_texture_ensure_fullscreen_2D(&txl->sss_dir_accum, GPU_RGBA16F, 0);
- DRW_texture_ensure_fullscreen_2D(&txl->sss_col_accum, GPU_RGBA16F, 0);
+ DRW_texture_ensure_fullscreen_2d(&txl->sss_dir_accum, GPU_RGBA16F, 0);
+ DRW_texture_ensure_fullscreen_2d(&txl->sss_col_accum, GPU_RGBA16F, 0);
GPUTexture *stencil_tex = effects->sss_stencil;
@@ -285,6 +285,7 @@ void EEVEE_subsurface_data_render(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
GPU_framebuffer_bind(fbl->main_fb);
DRW_draw_pass(psl->sss_pass);
+ DRW_draw_pass(psl->sss_pass_cull);
/* Restore */
GPU_framebuffer_ensure_config(&fbl->main_fb, {
diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
index 67ac6126148..fd3a23b36e0 100644
--- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
@@ -179,10 +179,7 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
const DRWContextState *draw_ctx = DRW_context_state_get();
const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
- if (((scene_eval->eevee.taa_samples != 1) &&
- /* FIXME the motion blur camera evaluation is tagging view_updated
- * thus making the TAA always reset and never stopping rendering. */
- (effects->enabled_effects & EFFECT_MOTION_BLUR) == 0) ||
+ if ((scene_eval->eevee.taa_samples != 1) ||
DRW_state_is_image_render())
{
float persmat[4][4], viewmat[4][4];
@@ -234,7 +231,7 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
double ht_offset[2] = {0.0, 0.0};
uint ht_primes[2] = {2, 3};
- BLI_halton_2D(ht_primes, ht_offset, effects->taa_current_sample - 1, ht_point);
+ BLI_halton_2d(ht_primes, ht_offset, effects->taa_current_sample - 1, ht_point);
EEVEE_temporal_sampling_matrices_calc(effects, viewmat, persmat, ht_point);
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index cf12863565f..7ba5e603e36 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -136,7 +136,7 @@ void EEVEE_volumes_set_jitter(EEVEE_ViewLayerData *sldata, uint current_sample)
double ht_offset[3] = {0.0, 0.0};
uint ht_primes[3] = {3, 7, 2};
- BLI_halton_3D(ht_primes, ht_offset, current_sample, ht_point);
+ BLI_halton_3d(ht_primes, ht_offset, current_sample, ht_point);
common_data->vol_jitter[0] = (float)ht_point[0];
common_data->vol_jitter[1] = (float)ht_point[1];
@@ -209,30 +209,30 @@ int EEVEE_volumes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
if (txl->volume_prop_scattering == NULL) {
/* Volume properties: We evaluate all volumetric objects
* and store their final properties into each froxel */
- txl->volume_prop_scattering = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
+ txl->volume_prop_scattering = DRW_texture_create_3d(tex_size[0], tex_size[1], tex_size[2],
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
- txl->volume_prop_extinction = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
+ txl->volume_prop_extinction = DRW_texture_create_3d(tex_size[0], tex_size[1], tex_size[2],
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
- txl->volume_prop_emission = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
+ txl->volume_prop_emission = DRW_texture_create_3d(tex_size[0], tex_size[1], tex_size[2],
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
- txl->volume_prop_phase = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
+ txl->volume_prop_phase = DRW_texture_create_3d(tex_size[0], tex_size[1], tex_size[2],
GPU_RG16F, DRW_TEX_FILTER, NULL);
/* Volume scattering: We compute for each froxel the
* Scattered light towards the view. We also resolve temporal
* super sampling during this stage. */
- txl->volume_scatter = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
+ txl->volume_scatter = DRW_texture_create_3d(tex_size[0], tex_size[1], tex_size[2],
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
- txl->volume_transmittance = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
+ txl->volume_transmittance = DRW_texture_create_3d(tex_size[0], tex_size[1], tex_size[2],
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
/* Final integration: We compute for each froxel the
* amount of scattered light and extinction coef at this
* given depth. We use theses textures as double buffer
* for the volumetric history. */
- txl->volume_scatter_history = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
+ txl->volume_scatter_history = DRW_texture_create_3d(tex_size[0], tex_size[1], tex_size[2],
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
- txl->volume_transmittance_history = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
+ txl->volume_transmittance_history = DRW_texture_create_3d(tex_size[0], tex_size[1], tex_size[2],
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
}
@@ -290,6 +290,12 @@ int EEVEE_volumes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
common_data->vol_shadow_steps = 0;
}
+ /* Update view_vecs */
+ float invproj[4][4], winmat[4][4];
+ DRW_viewport_matrix_get(winmat, DRW_MAT_WIN);
+ DRW_viewport_matrix_get(invproj, DRW_MAT_WININV);
+ EEVEE_update_viewvecs(invproj, winmat, sldata->common_data.view_vecs);
+
if (DRW_viewport_is_persp_get()) {
float sample_distribution = scene_eval->eevee.volumetric_sample_distribution;
sample_distribution = 4.0f * (1.00001f - sample_distribution);
@@ -378,7 +384,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
* for "every" positions in the frustum. We only need to sample
* them and blend the scene color with those factors. This also
* work for alpha blended materials.
- **/
+ */
/* World pass is not additive as it also clear the buffer. */
psl->volumetric_world_ps = DRW_pass_create("Volumetric World", DRW_STATE_WRITE_COLOR);
@@ -405,9 +411,10 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
if (grp == NULL) {
/* If no world or volume material is present just clear the buffer with this drawcall */
- grp = DRW_shgroup_empty_tri_batch_create(e_data.volumetric_clear_sh,
- psl->volumetric_world_ps,
- common_data->vol_tex_size[2]);
+ grp = DRW_shgroup_empty_tri_batch_create(
+ e_data.volumetric_clear_sh,
+ psl->volumetric_world_ps,
+ common_data->vol_tex_size[2]);
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
}
@@ -453,6 +460,11 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
}
}
+typedef struct EEVEE_InstanceVolumeMatrix {
+ DrawData dd;
+ float volume_mat[4][4];
+} EEVEE_InstanceVolumeMatrix;
+
void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Scene *scene, Object *ob)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -473,13 +485,28 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
return;
}
- DRWShadingGroup *grp = DRW_shgroup_material_empty_tri_batch_create(mat, vedata->psl->volumetric_objects_ps, sldata->common_data.vol_tex_size[2]);
+ DRWShadingGroup *grp = DRW_shgroup_material_empty_tri_batch_create(mat,
+ vedata->psl->volumetric_objects_ps,
+ sldata->common_data.vol_tex_size[2]);
/* Making sure it's updated. */
invert_m4_m4(ob->imat, ob->obmat);
BKE_mesh_texspace_get_reference((struct Mesh *)ob->data, NULL, &texcoloc, NULL, &texcosize);
+ float (*imat)[4] = ob->imat;
+
+ if ((ob->base_flag & BASE_FROM_DUPLI) != 0) {
+ /* TODO Remove from here and use a dedicated buffer. */
+ EEVEE_InstanceVolumeMatrix *ivm = (EEVEE_InstanceVolumeMatrix *)DRW_drawdata_ensure(
+ &ob->id,
+ (DrawEngineType *)EEVEE_volumes_cache_object_add,
+ sizeof(EEVEE_InstanceVolumeMatrix),
+ NULL, NULL);
+ copy_m4_m4(ivm->volume_mat, ob->imat);
+ imat = ivm->volume_mat;
+ }
+
/* TODO(fclem) remove those "unnecessary" UBOs */
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
@@ -488,7 +515,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
- DRW_shgroup_uniform_mat4(grp, "volumeObjectMatrix", ob->imat);
+ DRW_shgroup_uniform_mat4(grp, "volumeObjectMatrix", imat);
DRW_shgroup_uniform_vec3(grp, "volumeOrcoLoc", texcoloc, 1);
DRW_shgroup_uniform_vec3(grp, "volumeOrcoSize", texcosize, 1);
@@ -525,6 +552,13 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
DRW_shgroup_uniform_texture_ref(grp, "sampflame", &sds->tex_flame);
}
+ /* Constant Volume color. */
+ static float white[3] = {1.0f, 1.0f, 1.0f};
+ bool use_constant_color = ((sds->active_fields & SM_ACTIVE_COLORS) == 0 &&
+ (sds->active_fields & SM_ACTIVE_COLOR_SET) != 0);
+
+ DRW_shgroup_uniform_vec3(grp, "volumeColor", (use_constant_color) ? sds->active_color : white, 1);
+
/* Output is such that 0..1 maps to 0..1000K */
DRW_shgroup_uniform_vec2(grp, "unftemperature", &sds->flame_ignition, 1);
}
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 b7e03b2937e..5bd5aca576e 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -272,6 +272,14 @@ vec2 lut_coords(float cosTheta, float roughness)
return coords * (LUT_SIZE - 1.0) / LUT_SIZE + 0.5 / LUT_SIZE;
}
+vec2 lut_coords_ltc(float cosTheta, float roughness)
+{
+ vec2 coords = vec2(roughness, sqrt(1.0 - cosTheta));
+
+ /* scale and bias coordinates, for correct filtered lookup */
+ return coords * (LUT_SIZE - 1.0) / LUT_SIZE + 0.5 / LUT_SIZE;
+}
+
/* -- Tangent Space conversion -- */
vec3 tangent_to_world(vec3 vector, vec3 N, vec3 T, vec3 B)
{
@@ -572,11 +580,9 @@ vec3 F_schlick(vec3 f0, float cos_theta)
/* Fresnel approximation for LTC area lights (not MRP) */
vec3 F_area(vec3 f0, vec2 lut)
{
- vec2 fac = normalize(lut.xy); /* XXX FIXME this does not work!!! */
-
/* Unreal specular matching : if specular color is below 2% intensity,
* treat as shadowning */
- return saturate(50.0 * dot(f0, vec3(0.3, 0.6, 0.1))) * fac.y + fac.x * f0;
+ return saturate(50.0 * dot(f0, vec3(0.3, 0.6, 0.1))) * lut.y + lut.x * f0;
}
/* Fresnel approximation for IBL */
@@ -777,14 +783,16 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac)
Closure closure_add(Closure cl1, Closure cl2)
{
Closure cl = (cl1.ssr_id == outputSsrId) ? cl1 : cl2;
+ cl.radiance = cl1.radiance + cl2.radiance;
# ifdef USE_SSS
cl.sss_data = (cl1.sss_data.a > 0.0) ? cl1.sss_data : cl2.sss_data;
+ /* Add radiance that was supposed to be filtered but was rejected. */
+ cl.radiance += (cl1.sss_data.a > 0.0) ? cl2.sss_data.rgb : cl1.sss_data.rgb;
# ifdef USE_SSS_ALBEDO
/* TODO Find a solution to this. Dither? */
cl.sss_albedo = (cl1.sss_data.a > 0.0) ? cl1.sss_albedo : cl2.sss_albedo;
# endif
# endif
- cl.radiance = cl1.radiance + cl2.radiance;
cl.opacity = saturate(cl1.opacity + cl2.opacity);
return cl;
}
@@ -826,7 +834,8 @@ void main()
# if defined(USE_ALPHA_BLEND_VOLUMETRICS)
/* XXX fragile, better use real viewport resolution */
vec2 uvs = gl_FragCoord.xy / vec2(2 * textureSize(maxzBuffer, 0).xy);
- fragColor = volumetric_resolve(vec4(cl.radiance, cl.opacity), uvs, gl_FragCoord.z);
+ fragColor.rgb = volumetric_resolve(vec4(cl.radiance, cl.opacity), uvs, gl_FragCoord.z).rgb;
+ fragColor.a = cl.opacity;
# else
fragColor = vec4(cl.radiance, cl.opacity);
# endif
diff --git a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
index 126f2d9610a..7c00c9f3b73 100644
--- a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
@@ -58,5 +58,5 @@ void main() {
background_color = color;
#endif
- FragColor = vec4(clamp(background_color, vec3(0.0), vec3(1e10)), backgroundAlpha);
+ FragColor = vec4(clamp(background_color, vec3(0.0), vec3(1e10)), 1.0) * backgroundAlpha;
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
index f06a17a8e44..6ac379c3845 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
@@ -24,7 +24,7 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
- **/
+ */
uniform sampler2D sourceBuffer; /* Buffer to filter */
uniform vec2 sourceBufferTexelSize;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
index 067b0786e34..afd219fb831 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
@@ -4,11 +4,10 @@ uniform mat4 ProjectionMatrix;
uniform sampler2D colorBuffer;
uniform sampler2D depthBuffer;
-uniform vec3 dofParams;
+uniform vec2 dofParams;
-#define dof_aperturesize dofParams.x
-#define dof_distance dofParams.y
-#define dof_invsensorsize dofParams.z
+#define dof_mul dofParams.x /* distance * aperturesize * invsensorsize */
+#define dof_bias dofParams.y /* aperturesize * invsensorsize */
uniform vec4 bokehParams[2];
@@ -25,11 +24,12 @@ uniform vec2 nearFar; /* Near & far view depths values */
/* -------------- Utils ------------- */
/* divide by sensor size to get the normalized size */
-#define calculate_coc(zdepth) (dof_aperturesize * (dof_distance / zdepth - 1.0) * dof_invsensorsize)
+#define calculate_coc(zdepth) (dof_mul / zdepth - dof_bias)
-#define linear_depth(z) ((ProjectionMatrix[3][3] == 0.0) \
- ? (nearFar.x * nearFar.y) / (z * (nearFar.x - nearFar.y) + nearFar.y) \
- : (z * 2.0 - 1.0) * nearFar.y)
+#define linear_depth(z) \
+ ((ProjectionMatrix[3][3] == 0.0) ? \
+ (nearFar.x * nearFar.y) / (z * (nearFar.x - nearFar.y) + nearFar.y) : \
+ z * (nearFar.y - nearFar.x) + nearFar.x) /* Only true for camera view! */
#define weighted_sum(a, b, c, d, e) (a * e.x + b * e.y + c * e.z + d * e.w) / max(1e-6, dot(e, vec4(1.0)));
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
index 92fd36f684a..f3485f9120b 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
@@ -81,7 +81,7 @@ void main()
* | Origin \
* -1 0 --------------- 2
* -1 0 1 ex
- **/
+ */
gl_Position.x = float(v_id / 2) * extend - 1.0; /* int divisor round down */
gl_Position.y = float(v_id % 2) * extend - 1.0;
gl_Position.z = 0.0;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_downsample_cube_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_downsample_cube_frag.glsl
index 79f86cfae58..5f5d60cb3c5 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_downsample_cube_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_downsample_cube_frag.glsl
@@ -1,6 +1,6 @@
/**
* Simple downsample shader. Takes the average of the 4 texels of lower mip.
- **/
+ */
uniform samplerCube source;
uniform float texelSize;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
index 8f06e161a20..a9e850ca04d 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
@@ -1,6 +1,6 @@
/**
* Simple downsample shader. Takes the average of the 4 texels of lower mip.
- **/
+ */
uniform sampler2D source;
uniform float fireflyFactor;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
index d12b5232968..6a223ddc1fe 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
@@ -1,7 +1,7 @@
/**
* This shader only compute maximum horizon angles for each directions.
* The final integration is done at the resolve stage with the shading normal.
- **/
+ */
uniform float rotationOffset;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
index edfd0f307e9..e7b51b8fb55 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
@@ -2,7 +2,7 @@
* Shader that downsample depth buffer,
* saving min and max value of each texel in the above mipmaps.
* Adapted from http://rastergrid.com/blog/2010/10/hierarchical-z-map-based-occlusion-culling/
- **/
+ */
#ifdef LAYERED
uniform sampler2DArray depthBuffer;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
index d44cf5e3518..2178b15a753 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
@@ -18,7 +18,11 @@ vec2 decode_hit_data(vec2 hit_data, out bool has_hit, out bool is_planar)
{
is_planar = (hit_data.x < 0);
has_hit = (hit_data.y > 0);
- return vec2(abs(hit_data)) / 32767.0; /* 16bit signed int limit */
+ vec2 hit_co = vec2(abs(hit_data)) / 32767.0; /* 16bit signed int limit */
+ if (is_planar) {
+ hit_co.x = 1.0 - hit_co.x;
+ }
+ return hit_co;
}
#ifdef STEP_RAYTRACE
@@ -219,6 +223,7 @@ vec2 get_reprojected_reflection(vec3 hit, vec3 pos, vec3 N)
float get_sample_depth(vec2 hit_co, bool is_planar, float planar_index)
{
if (is_planar) {
+ hit_co.x = 1.0 - hit_co.x;
return textureLod(planarDepth, vec3(hit_co, planar_index), 0.0).r;
}
else {
@@ -237,6 +242,8 @@ vec3 get_hit_vector(
vec3 trace_pos = line_plane_intersect(worldPosition, V, pd.pl_plane_eq);
hit_vec = hit_pos - trace_pos;
hit_vec = reflect(hit_vec, pd.pl_normal);
+ /* Modify here so mip texel alignment is correct. */
+ hit_co.x = 1.0 - hit_co.x;
}
else {
/* Find hit position in previous frame. */
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
index a991e640a79..7881079e258 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
@@ -200,7 +200,8 @@ vec3 probe_evaluate_planar(
/* TODO: If we support non-ssr planar reflection, we should blur them with gaussian
* and chose the right mip depending on the cone footprint after projection */
- vec3 sample = textureLod(probePlanars, vec3(refco.xy * 0.5 + 0.5, id), 0.0).rgb;
+ /* NOTE: X is inverted here to compensate inverted drawing. */
+ vec3 sample = textureLod(probePlanars, vec3(refco.xy * vec2(-0.5, 0.5) + 0.5, id), 0.0).rgb;
return sample;
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl
index 3808b59761f..afffccc3751 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl
@@ -10,5 +10,5 @@ void main()
{
vec4 refco = ViewProjectionMatrix * vec4(worldPosition, 1.0);
refco.xy /= refco.w;
- FragColor = vec4(textureLod(probePlanars, vec3(refco.xy * 0.5 + 0.5, float(probeIdx)), 0.0).rgb, 1.0);
+ FragColor = vec4(textureLod(probePlanars, vec3(refco.xy * vec2(-0.5, 0.5) + 0.5, float(probeIdx)), 0.0).rgb, 1.0);
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl
index d629195b815..3b8a044154b 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl
@@ -1,6 +1,6 @@
/**
* Simple downsample shader. Takes the average of the 4 texels of lower mip.
- **/
+ */
uniform sampler2DArray source;
uniform float fireflyFactor;
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index 3d5b8f6f975..5ae94cb7fe4 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -164,6 +164,10 @@ void CLOSURE_NAME(
out_refr = vec3(0.0);
#endif
+#ifdef SHADOW_SHADER
+ return;
+#endif
+
/* Zero length vectors cause issues, see: T51979. */
float len = length(N);
if (isnan(len)) {
@@ -198,12 +202,12 @@ void CLOSURE_NAME(
/* ---------------------------------------------------------------- */
#ifdef CLOSURE_GLOSSY
- vec2 lut_uv = lut_coords(dot(N, V), roughness);
+ vec2 lut_uv = lut_coords_ltc(dot(N, V), roughness);
vec4 ltc_mat = texture(utilTex, vec3(lut_uv, 0.0)).rgba;
#endif
#ifdef CLOSURE_CLEARCOAT
- vec2 lut_uv_clear = lut_coords(dot(C_N, V), C_roughness);
+ vec2 lut_uv_clear = lut_coords_ltc(dot(C_N, V), C_roughness);
vec4 ltc_mat_clear = texture(utilTex, vec3(lut_uv_clear, 0.0)).rgba;
vec3 out_spec_clear = vec3(0.0);
#endif
@@ -241,13 +245,13 @@ void CLOSURE_NAME(
}
#ifdef CLOSURE_GLOSSY
- vec3 brdf_lut_lights = texture(utilTex, vec3(lut_uv, 1.0)).rgb;
- out_spec *= F_area(f0, brdf_lut_lights.xy) * brdf_lut_lights.z;
+ vec2 brdf_lut_lights = texture(utilTex, vec3(lut_uv, 1.0)).ba;
+ out_spec *= F_area(f0, brdf_lut_lights.xy);
#endif
#ifdef CLOSURE_CLEARCOAT
- vec3 brdf_lut_lights_clear = texture(utilTex, vec3(lut_uv_clear, 1.0)).rgb;
- out_spec_clear *= F_area(vec3(0.04), brdf_lut_lights_clear.xy) * brdf_lut_lights_clear.z;
+ vec2 brdf_lut_lights_clear = texture(utilTex, vec3(lut_uv_clear, 1.0)).ba;
+ out_spec_clear *= F_area(vec3(0.04), brdf_lut_lights_clear.xy);
out_spec += out_spec_clear * C_intensity;
#endif
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
index ef7213cd21e..141d3363a09 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
@@ -61,7 +61,7 @@ void main()
worldPosition = pos;
hairTangent = normalize(hairTangent);
worldNormal = cross(binor, hairTangent);
- viewNormal = normalize(mat3(ViewMatrix) * worldNormal);
+ viewNormal = mat3(ViewMatrix) * worldNormal;
#else
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
diff --git a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
index b042b7fab45..42bd486a4a5 100644
--- a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
@@ -4,7 +4,7 @@
* Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt.
* ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2016) 35(4), 2016.
* Project page: https://eheitzresearch.wordpress.com/415-2/
- **/
+ */
#define USE_LTC
@@ -15,24 +15,25 @@ uniform sampler2DArray utilTex;
#endif /* UTIL_TEX */
/* Diffuse *clipped* sphere integral. */
-float diffuse_sphere_integral_lut(float avg_dir_z, float form_factor)
+float diffuse_sphere_integral(float avg_dir_z, float form_factor)
{
+#if 1
+ /* use tabulated horizon-clipped sphere */
vec2 uv = vec2(avg_dir_z * 0.5 + 0.5, form_factor);
uv = uv * (LUT_SIZE - 1.0) / LUT_SIZE + 0.5 / LUT_SIZE;
- return texture(utilTex, vec3(uv, 1.0)).w;
-}
-
-float diffuse_sphere_integral_cheap(float avg_dir_z, float form_factor)
-{
+ return texture(utilTex, vec3(uv, 3.0)).x;
+#else
+ /* Cheap approximation. Less smooth and have energy issues. */
return max((form_factor * form_factor + avg_dir_z) / (form_factor + 1.0), 0.0);
+#endif
}
/**
* An extended version of the implementation from
* "How to solve a cubic equation, revisited"
* http://momentsingraphics.de/?p=105
- **/
+ */
vec3 solve_cubic(vec4 coefs)
{
/* Normalize the polynomial */
@@ -143,9 +144,9 @@ mat3 ltc_matrix(vec4 lut)
{
/* load inverse matrix */
mat3 Minv = mat3(
- vec3( 1, 0, lut.y),
- vec3( 0, lut.z, 0),
- vec3(lut.w, 0, lut.x)
+ vec3(lut.x, 0, lut.y),
+ vec3( 0, 1, 0),
+ vec3(lut.z, 0, lut.w)
);
return Minv;
@@ -185,12 +186,7 @@ float ltc_evaluate_quad(vec3 corners[4], vec3 N)
float form_factor = length(avg_dir);
float avg_dir_z = dot(N, avg_dir / form_factor);
-
-#if 1 /* use tabulated horizon-clipped sphere */
- return form_factor * diffuse_sphere_integral_lut(avg_dir_z, form_factor);
-#else /* Less accurate version, a bit cheaper. */
- return form_factor * diffuse_sphere_integral_cheap(avg_dir_z, form_factor);
-#endif
+ return form_factor * diffuse_sphere_integral(avg_dir_z, form_factor);
}
/* If disk does not need to be transformed and is already front facing. */
@@ -199,12 +195,7 @@ float ltc_evaluate_disk_simple(float disk_radius, float NL)
float r_sqr = disk_radius * disk_radius;
float one_r_sqr = 1.0 + r_sqr;
float form_factor = r_sqr * inversesqrt(one_r_sqr * one_r_sqr);
-
-#if 1 /* use tabulated horizon-clipped sphere */
- return form_factor * diffuse_sphere_integral_lut(NL, form_factor);
-#else /* Less accurate version, a bit cheaper. */
- return form_factor * diffuse_sphere_integral_cheap(NL, form_factor);
-#endif
+ return form_factor * diffuse_sphere_integral(NL, form_factor);
}
/* disk_points are WS vectors from the shading point to the disk "bounding domain" */
@@ -315,10 +306,5 @@ float ltc_evaluate_disk(vec3 N, vec3 V, mat3 Minv, vec3 disk_points[3])
/* Find the sphere and compute lighting. */
float form_factor = max(0.0, L1 * L2 * inversesqrt((1.0 + L1 * L1) * (1.0 + L2 * L2)));
-
-#if 1 /* use tabulated horizon-clipped sphere */
- return form_factor * diffuse_sphere_integral_lut(avg_dir.z, form_factor);
-#else /* Less accurate version, a bit cheaper. */
- return form_factor * diffuse_sphere_integral_cheap(avg_dir.z, form_factor);
-#endif
+ return form_factor * diffuse_sphere_integral(avg_dir.z, form_factor);
}
diff --git a/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl b/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl
index ec13c885bbb..dfd8fa8a56c 100644
--- a/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl
@@ -2,11 +2,12 @@
vec2 mapping_octahedron(vec3 cubevec, vec2 texel_size)
{
/* projection onto octahedron */
- cubevec /= dot( vec3(1), abs(cubevec) );
+ cubevec /= dot(vec3(1.0), abs(cubevec));
/* out-folding of the downward faces */
- if ( cubevec.z < 0.0 ) {
- cubevec.xy = (1.0 - abs(cubevec.yx)) * sign(cubevec.xy);
+ if (cubevec.z < 0.0) {
+ vec2 cubevec_sign = step(0.0, cubevec.xy) * 2.0 - 1.0;
+ cubevec.xy = (1.0 - abs(cubevec.yx)) * cubevec_sign;
}
/* mapping to [0;1]ˆ2 texture space */
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index c9f2d64f30b..85c4a02bc1e 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -59,7 +59,7 @@ float refine_isect(float prev_delta, float curr_delta)
}
void prepare_raycast(
- vec3 ray_origin, vec3 ray_dir, float thickness, out vec4 ss_step, out vec4 ss_ray, out float max_time)
+ vec3 ray_origin, vec3 ray_dir, float thickness, int index, out vec4 ss_step, out vec4 ss_ray, out float max_time)
{
/* Negate the ray direction if it goes towards the camera.
* This way we don't need to care if the projected point
@@ -91,7 +91,7 @@ void prepare_raycast(
/* If the line is degenerate, make it cover at least one pixel
* to not have to handle zero-pixel extent as a special case later */
- ss_step.xy += vec2((dot(ss_step.xy, ss_step.xy) < 0.000001) ? 0.001 : 0.0);
+ ss_step.xy += vec2((dot(ss_step.xy, ss_step.xy) < 0.00001) ? 0.001 : 0.0);
/* Make ss_step cover one pixel. */
ss_step /= max(abs(ss_step.x), abs(ss_step.y));
@@ -106,10 +106,16 @@ void prepare_raycast(
/* Convert to texture coords. Z component included
* since this is how it's stored in the depth buffer.
* 4th component how far we are on the ray */
- ss_ray = ss_start * 0.5 + 0.5;
- ss_step *= 0.5;
+#ifdef PLANAR_PROBE_RAYTRACE
+ /* Planar Reflections have X mirrored. */
+ vec2 m = (index > -1) ? vec2(-0.5, 0.5) : vec2(0.5);
+#else
+ const vec2 m = vec2(0.5);
+#endif
+ ss_ray = ss_start * m.xyyy + 0.5;
+ ss_step *= m.xyyy;
- ss_ray.xy += 0.5 * ssrPixelSize * 2.0; /* take the center of the texel. * 2 because halfres. */
+ ss_ray.xy += m * ssrPixelSize * 2.0; /* take the center of the texel. * 2 because halfres. */
}
/* See times_and_deltas. */
@@ -127,9 +133,9 @@ vec3 raycast(
{
vec4 ss_step, ss_start;
float max_time;
- prepare_raycast(ray_origin, ray_dir, thickness, ss_step, ss_start, max_time);
+ prepare_raycast(ray_origin, ray_dir, thickness, index, ss_step, ss_start, max_time);
- float max_trace_time = max(0.001, max_time - 0.01);
+ float max_trace_time = max(0.01, max_time - 0.01);
#ifdef GROUPED_FETCHES
ray_jitter *= 0.25;
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
index ae36252153f..c5c9ad543db 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
@@ -151,5 +151,8 @@ vec4 volumetric_resolve(vec4 scene_color, vec2 frag_uvs, float frag_depth)
vec3 scattering = texture(inScattering, volume_cos).rgb;
vec3 transmittance = texture(inTransmittance, volume_cos).rgb;
- return vec4(scene_color.rgb * transmittance + scattering, scene_color.a);
+ /* Approximate volume alpha by using a monochromatic transmitance
+ * and adding it to the scene alpha. */
+ float final_alpha = mix(1.0, scene_color.a, dot(transmittance, vec3(1.0 / 3.0)));
+ return vec4(scene_color.rgb * transmittance + scattering, final_alpha);
}
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl
index a99acd41fbd..17174e6d4ff 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_vert.glsl
@@ -19,9 +19,13 @@ void main()
* | \
* -1 0 --------------- 2
* -1 0 1 ex
- **/
+ */
vPos.x = float(v_id / 2) * 4.0 - 1.0; /* int divisor round down */
vPos.y = float(v_id % 2) * 4.0 - 1.0;
vPos.z = float(t_id);
vPos.w = 1.0;
+
+#ifdef USE_ATTR
+ pass_attr(vec3(0.0));
+#endif
}
diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c
index 0100fa095e6..c1da7c4585c 100644
--- a/source/blender/draw/engines/external/external_engine.c
+++ b/source/blender/draw/engines/external/external_engine.c
@@ -92,7 +92,7 @@ static void external_engine_init(void *UNUSED(vedata))
{
/* Depth prepass */
if (!e_data.depth_sh) {
- e_data.depth_sh = DRW_shader_create_3D_depth_only(GPU_SHADER_CFG_DEFAULT);
+ e_data.depth_sh = DRW_shader_create_3d_depth_only(GPU_SHADER_CFG_DEFAULT);
}
}
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 4c69965478e..b72a6ebebbd 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -155,41 +155,41 @@ void DRW_gpencil_get_stroke_geom(struct GpencilBatchCacheElem *be, bGPDstroke *g
if (i == 0) {
if (gps->flag & GP_STROKE_CYCLIC && totpoints > 2) {
gpencil_set_stroke_point(
- be->vbo, &points[totpoints - 1], be->vbo_len,
- be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
+ be->vbo, &points[totpoints - 1], be->vbo_len,
+ be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
be->vbo_len++;
}
else {
gpencil_set_stroke_point(
- be->vbo, &points[1], be->vbo_len,
- be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
+ be->vbo, &points[1], be->vbo_len,
+ be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
be->vbo_len++;
}
}
/* set point */
gpencil_set_stroke_point(
- be->vbo, pt, be->vbo_len,
- be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
+ be->vbo, pt, be->vbo_len,
+ be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
be->vbo_len++;
}
if (gps->flag & GP_STROKE_CYCLIC && totpoints > 2) {
/* draw line to first point to complete the cycle */
gpencil_set_stroke_point(
- be->vbo, &points[0], be->vbo_len,
- be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
+ be->vbo, &points[0], be->vbo_len,
+ be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
be->vbo_len++;
/* now add adjacency point (not drawn) */
gpencil_set_stroke_point(
- be->vbo, &points[1], be->vbo_len,
- be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
+ be->vbo, &points[1], be->vbo_len,
+ be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
be->vbo_len++;
}
/* last adjacency point (not drawn) */
else {
gpencil_set_stroke_point(
- be->vbo, &points[totpoints - 2], be->vbo_len,
- be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
+ be->vbo, &points[totpoints - 2], be->vbo_len,
+ be->pos_id, be->color_id, be->thickness_id, be->uvdata_id, thickness, ink);
be->vbo_len++;
}
}
@@ -202,7 +202,6 @@ void DRW_gpencil_get_fill_geom(struct GpencilBatchCacheElem *be, Object *ob, bGP
/* Calculate triangles cache for filling area (must be done only after changes) */
if ((gps->flag & GP_STROKE_RECALC_GEOMETRY) || (gps->tot_triangles == 0) || (gps->triangles == NULL)) {
DRW_gpencil_triangulate_stroke_fill(ob, gps);
- ED_gpencil_calc_stroke_uv(ob, gps);
}
BLI_assert(gps->tot_triangles >= 1);
@@ -224,8 +223,8 @@ void DRW_gpencil_get_fill_geom(struct GpencilBatchCacheElem *be, Object *ob, bGP
for (int i = 0; i < gps->tot_triangles; i++, stroke_triangle++) {
for (int j = 0; j < 3; j++) {
gpencil_set_fill_point(
- be->vbo, be->vbo_len, &gps->points[stroke_triangle->verts[j]], color, stroke_triangle->uv[j],
- be->pos_id, be->color_id, be->uvdata_id);
+ be->vbo, be->vbo_len, &gps->points[stroke_triangle->verts[j]], color, stroke_triangle->uv[j],
+ be->pos_id, be->color_id, be->uvdata_id);
be->vbo_len++;
}
}
@@ -271,22 +270,22 @@ GPUBatch *DRW_gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
for (int i = 0; i < totpoints; i++, tpt++) {
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
- ED_gp_project_point_to_plane(ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);
+ ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);
/* first point for adjacency (not drawn) */
if (i == 0) {
if (gpd->runtime.sbuffer_sflag & GP_STROKE_CYCLIC && totpoints > 2) {
ED_gpencil_tpoint_to_point(ar, origin, &points[totpoints - 1], &pt2);
gpencil_set_stroke_point(
- vbo, &pt2, idx,
- pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
+ vbo, &pt2, idx,
+ pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
idx++;
}
else {
ED_gpencil_tpoint_to_point(ar, origin, &points[1], &pt2);
gpencil_set_stroke_point(
- vbo, &pt2, idx,
- pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
+ vbo, &pt2, idx,
+ pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
idx++;
}
}
@@ -303,22 +302,22 @@ GPUBatch *DRW_gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
/* draw line to first point to complete the cycle */
ED_gpencil_tpoint_to_point(ar, origin, &points[0], &pt2);
gpencil_set_stroke_point(
- vbo, &pt2, idx,
- pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
+ vbo, &pt2, idx,
+ pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
idx++;
/* now add adjacency point (not drawn) */
ED_gpencil_tpoint_to_point(ar, origin, &points[1], &pt3);
gpencil_set_stroke_point(
- vbo, &pt3, idx,
- pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
+ vbo, &pt3, idx,
+ pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
idx++;
}
/* last adjacency point (not drawn) */
else {
ED_gpencil_tpoint_to_point(ar, origin, &points[totpoints - 2], &pt2);
gpencil_set_stroke_point(
- vbo, &pt2, idx,
- pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
+ vbo, &pt2, idx,
+ pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
idx++;
}
@@ -362,7 +361,7 @@ GPUBatch *DRW_gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
for (int i = 0; i < totpoints; i++, tpt++) {
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
- ED_gp_project_point_to_plane(ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);
+ ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);
/* set point */
gpencil_set_stroke_point(
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index a96d293c381..475a083ac97 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -421,7 +421,8 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
DRW_shgroup_uniform_int(grp, "drawmode", (const int *) &gpd->draw_mode, 1);
/* viewport x-ray */
- DRW_shgroup_uniform_int(grp, "viewport_xray", &stl->storage->is_xray, 1);
+ stl->shgroups[id].is_xray = (ob->dt == OB_WIRE) ? 1 : stl->storage->is_xray;
+ DRW_shgroup_uniform_int(grp, "viewport_xray", (const int *)&stl->shgroups[id].is_xray, 1);
/* shading type */
stl->shgroups[id].shading_type[0] = GPENCIL_USE_SOLID(stl) ? (int)OB_RENDER : shading_type[0];
@@ -505,7 +506,7 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
DRW_shgroup_uniform_float(grp, "pixsize", stl->storage->pixsize, 1);
/* avoid wrong values */
- if ((gpd) && (gpd->pixfactor == 0)) {
+ if ((gpd) && (gpd->pixfactor == 0.0f)) {
gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
}
@@ -532,7 +533,8 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
DRW_shgroup_uniform_int(grp, "caps_mode", &stl->shgroups[id].caps_mode[0], 2);
/* viewport x-ray */
- DRW_shgroup_uniform_int(grp, "viewport_xray", &stl->storage->is_xray, 1);
+ stl->shgroups[id].is_xray = (ob->dt == OB_WIRE) ? 1 : stl->storage->is_xray;
+ DRW_shgroup_uniform_int(grp, "viewport_xray", (const int *)&stl->shgroups[id].is_xray, 1);
stl->shgroups[id].shading_type[0] = (GPENCIL_USE_SOLID(stl) || onion) ? (int)OB_RENDER : shading_type[0];
if (v3d) {
@@ -625,7 +627,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
DRW_shgroup_uniform_float(grp, "pixsize", stl->storage->pixsize, 1);
/* avoid wrong values */
- if ((gpd) && (gpd->pixfactor == 0)) {
+ if ((gpd) && (gpd->pixfactor == 0.0f)) {
gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
}
@@ -650,7 +652,8 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
DRW_shgroup_uniform_float(grp, "pixfactor", &gpd->pixfactor, 1);
/* viewport x-ray */
- DRW_shgroup_uniform_int(grp, "viewport_xray", &stl->storage->is_xray, 1);
+ stl->shgroups[id].is_xray = (ob->dt == OB_WIRE) ? 1 : stl->storage->is_xray;
+ DRW_shgroup_uniform_int(grp, "viewport_xray", (const int *)&stl->shgroups[id].is_xray, 1);
stl->shgroups[id].shading_type[0] = (GPENCIL_USE_SOLID(stl) || onion) ? (int)OB_RENDER : shading_type[0];
if (v3d) {
@@ -682,7 +685,8 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
DRW_shgroup_uniform_float(grp, "pixfactor", &stl->storage->pixfactor, 1);
}
/* viewport x-ray */
- DRW_shgroup_uniform_int(grp, "viewport_xray", &stl->storage->is_xray, 1);
+ 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, "shading_type", (const int *)&stl->storage->shade_render, 2);
}
@@ -995,8 +999,8 @@ static void gpencil_draw_strokes(
((gps->flag & GP_STROKE_NOFILL) == 0))
{
gpencil_add_fill_vertexdata(
- cache, ob, gpl, derived_gpf, gps,
- opacity, tintcolor, false, custonion);
+ cache, ob, gpl, derived_gpf, gps,
+ opacity, tintcolor, false, custonion);
}
/* stroke */
/* No fill strokes, must show stroke always */
@@ -1005,9 +1009,14 @@ static void gpencil_draw_strokes(
((gp_style->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) ||
(gpl->blend_mode == eGplBlendMode_Normal)))
{
+ /* recalc strokes uv (geometry can be changed by modifiers) */
+ if (gps->flag & GP_STROKE_RECALC_GEOMETRY) {
+ ED_gpencil_calc_stroke_uv(ob, gps);
+ }
+
gpencil_add_stroke_vertexdata(
- cache, ob, gpl, derived_gpf, gps,
- opacity, tintcolor, false, custonion);
+ cache, ob, gpl, derived_gpf, gps,
+ opacity, tintcolor, false, custonion);
}
}
}
@@ -1346,7 +1355,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
float obscale = mat4_to_scale(ob->obmat);
/* use the brush material */
- Material *ma = BKE_gpencil_get_material_from_brush(brush);
+ Material *ma = BKE_gpencil_get_material_for_brush(ob, brush);
if (ma != NULL) {
gp_style = ma->gp_style;
}
@@ -1369,15 +1378,15 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
if (gpd->runtime.sbuffer_size > 1) {
if ((gp_style) && (gp_style->mode == GP_STYLE_MODE_LINE)) {
stl->g_data->shgrps_drawing_stroke = DRW_gpencil_shgroup_stroke_create(
- e_data, vedata, psl->drawing_pass, e_data->gpencil_stroke_sh, NULL,
- gpd, NULL, NULL, gp_style, -1,
- false, 1.0f, (const int *)stl->storage->shade_render);
+ e_data, vedata, psl->drawing_pass, e_data->gpencil_stroke_sh, NULL,
+ gpd, NULL, NULL, gp_style, -1,
+ false, 1.0f, (const int *)stl->storage->shade_render);
}
else {
stl->g_data->shgrps_drawing_stroke = DRW_gpencil_shgroup_point_create(
- e_data, vedata, psl->drawing_pass, e_data->gpencil_point_sh, NULL,
- gpd, NULL, gp_style, -1,
- false, 1.0f, (const int *)stl->storage->shade_render);
+ e_data, vedata, psl->drawing_pass, e_data->gpencil_point_sh, NULL,
+ gpd, NULL, gp_style, -1,
+ false, 1.0f, (const int *)stl->storage->shade_render);
}
/* clean previous version of the batch */
@@ -1390,18 +1399,18 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
/* use unit matrix because the buffer is in screen space and does not need conversion */
if (gpd->runtime.mode == GP_STYLE_MODE_LINE) {
e_data->batch_buffer_stroke = DRW_gpencil_get_buffer_stroke_geom(
- gpd, lthick);
+ gpd, lthick);
}
else {
e_data->batch_buffer_stroke = DRW_gpencil_get_buffer_point_geom(
- gpd, lthick);
+ gpd, lthick);
}
/* buffer strokes, must show stroke always */
DRW_shgroup_call_add(
- stl->g_data->shgrps_drawing_stroke,
- e_data->batch_buffer_stroke,
- stl->storage->unit_matrix);
+ stl->g_data->shgrps_drawing_stroke,
+ e_data->batch_buffer_stroke,
+ stl->storage->unit_matrix);
if ((gpd->runtime.sbuffer_size >= 3) &&
(gpd->runtime.sfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) &&
@@ -1414,7 +1423,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
gpd->runtime.sfill[3] = 0.5f;
}
stl->g_data->shgrps_drawing_fill = DRW_shgroup_create(
- e_data->gpencil_drawing_fill_sh, psl->drawing_pass);
+ e_data->gpencil_drawing_fill_sh, psl->drawing_pass);
/* clean previous version of the batch */
if (stl->storage->buffer_fill) {
@@ -1444,7 +1453,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
((gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0))
{
DRWShadingGroup *shgrp = DRW_shgroup_create(
- e_data->gpencil_edit_point_sh, psl->drawing_pass);
+ e_data->gpencil_edit_point_sh, psl->drawing_pass);
const float *viewport_size = DRW_viewport_size_get();
DRW_shgroup_uniform_vec2(shgrp, "Viewport", viewport_size, 1);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 97b81e3ba1f..1cc493dd8f5 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -79,11 +79,11 @@ void DRW_gpencil_multisample_ensure(GPENCIL_Data *vedata, int rect_w, int rect_h
fbl->multisample_fb = GPU_framebuffer_create();
if (fbl->multisample_fb) {
if (txl->multisample_color == NULL) {
- txl->multisample_color = GPU_texture_create_2D_multisample(
+ txl->multisample_color = GPU_texture_create_2d_multisample(
rect_w, rect_h, GPU_RGBA16F, NULL, samples, NULL);
}
if (txl->multisample_depth == NULL) {
- txl->multisample_depth = GPU_texture_create_2D_multisample(
+ txl->multisample_depth = GPU_texture_create_2d_multisample(
rect_w, rect_h, GPU_DEPTH_COMPONENT24, NULL, samples, NULL);
}
GPU_framebuffer_ensure_config(
@@ -118,57 +118,57 @@ static void GPENCIL_create_framebuffers(void *vedata)
/* Framebufers for basic object drawing */
if (stl->storage->framebuffer_flag & GP_FRAMEBUFFER_BASIC) {
/* temp textures for ping-pong buffers */
- e_data.temp_depth_tx_a = DRW_texture_pool_query_2D(
+ e_data.temp_depth_tx_a = DRW_texture_pool_query_2d(
size[0], size[1], GPU_DEPTH_COMPONENT24,
&draw_engine_gpencil_type);
- e_data.temp_color_tx_a = DRW_texture_pool_query_2D(
+ e_data.temp_color_tx_a = DRW_texture_pool_query_2d(
size[0], size[1], fb_format,
&draw_engine_gpencil_type);
GPU_framebuffer_ensure_config(
- &fbl->temp_fb_a, {
- GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx_a),
- GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx_a)
- });
+ &fbl->temp_fb_a, {
+ GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx_a),
+ GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx_a),
+ });
- e_data.temp_depth_tx_b = DRW_texture_pool_query_2D(
+ e_data.temp_depth_tx_b = DRW_texture_pool_query_2d(
size[0], size[1], GPU_DEPTH_COMPONENT24,
&draw_engine_gpencil_type);
- e_data.temp_color_tx_b = DRW_texture_pool_query_2D(
+ e_data.temp_color_tx_b = DRW_texture_pool_query_2d(
size[0], size[1], fb_format,
&draw_engine_gpencil_type);
GPU_framebuffer_ensure_config(
- &fbl->temp_fb_b, {
- GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx_b),
- GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx_b)
- });
+ &fbl->temp_fb_b, {
+ GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx_b),
+ GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx_b),
+ });
/* used for FX effects and Layer blending */
- e_data.temp_depth_tx_fx = DRW_texture_pool_query_2D(
+ e_data.temp_depth_tx_fx = DRW_texture_pool_query_2d(
size[0], size[1], GPU_DEPTH_COMPONENT24,
&draw_engine_gpencil_type);
- e_data.temp_color_tx_fx = DRW_texture_pool_query_2D(
+ e_data.temp_color_tx_fx = DRW_texture_pool_query_2d(
size[0], size[1], fb_format,
&draw_engine_gpencil_type);
GPU_framebuffer_ensure_config(
- &fbl->temp_fb_fx, {
- GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx_fx),
- GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx_fx),
- });
+ &fbl->temp_fb_fx, {
+ GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx_fx),
+ GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx_fx),
+ });
}
/* background framebuffer to speed up drawing process (always 16 bits) */
if (stl->storage->framebuffer_flag & GP_FRAMEBUFFER_DRAW) {
- e_data.background_depth_tx = DRW_texture_pool_query_2D(
+ e_data.background_depth_tx = DRW_texture_pool_query_2d(
size[0], size[1], GPU_DEPTH_COMPONENT24,
&draw_engine_gpencil_type);
- e_data.background_color_tx = DRW_texture_pool_query_2D(
+ e_data.background_color_tx = DRW_texture_pool_query_2d(
size[0], size[1], GPU_RGBA32F,
&draw_engine_gpencil_type);
GPU_framebuffer_ensure_config(
- &fbl->background_fb, {
- GPU_ATTACHMENT_TEXTURE(e_data.background_depth_tx),
- GPU_ATTACHMENT_TEXTURE(e_data.background_color_tx)
- });
+ &fbl->background_fb, {
+ GPU_ATTACHMENT_TEXTURE(e_data.background_depth_tx),
+ GPU_ATTACHMENT_TEXTURE(e_data.background_color_tx),
+ });
}
}
}
@@ -261,7 +261,7 @@ void GPENCIL_engine_init(void *vedata)
/* blank texture used if no texture defined for fill shader */
if (!e_data.gpencil_blank_texture) {
float rect[16][16][4] = {{{0.0f}}};
- e_data.gpencil_blank_texture = DRW_texture_create_2D(16, 16, GPU_RGBA8, DRW_TEX_FILTER, (float *)rect);
+ e_data.gpencil_blank_texture = DRW_texture_create_2d(16, 16, GPU_RGBA8, DRW_TEX_FILTER, (float *)rect);
}
}
@@ -345,8 +345,8 @@ void GPENCIL_cache_init(void *vedata)
stl->storage->shgroup_id = 0;
/* Stroke pass 3D */
psl->stroke_pass_3d = DRW_pass_create(
- "GPencil Stroke Pass",
- DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND);
+ "GPencil Stroke Pass",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND);
stl->storage->shgroup_id = 0;
/* edit pass */
@@ -414,7 +414,8 @@ void GPENCIL_cache_init(void *vedata)
bGPdata *gpd_orig = (bGPdata *)DEG_get_original_id(&obact_gpd->id);
if (((gpd_orig->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) &&
(gpd_orig->runtime.sbuffer_size > 0) &&
- ((gpd_orig->flag & GP_DATA_STROKE_POLYGON) == 0))
+ ((gpd_orig->flag & GP_DATA_STROKE_POLYGON) == 0) &&
+ !DRW_state_is_depth())
{
stl->g_data->session_flag |= GP_DRW_PAINT_PAINTING;
}
@@ -518,8 +519,8 @@ void GPENCIL_cache_init(void *vedata)
/* blend layers pass */
psl->blend_pass = DRW_pass_create(
- "GPencil Blend Layers Pass",
- DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+ "GPencil Blend Layers Pass",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
DRWShadingGroup *blend_shgrp = DRW_shgroup_create(e_data.gpencil_blend_fullscreen_sh, psl->blend_pass);
DRW_shgroup_call_add(blend_shgrp, quad, NULL);
DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeColor", &e_data.temp_color_tx_a);
@@ -549,7 +550,7 @@ static void gpencil_add_draw_data(void *vedata, Object *ob)
if (!cache_ob->is_dup_ob) {
/* fill shading groups */
- if (!is_multiedit) {
+ if ((!is_multiedit) || (stl->storage->is_render)) {
DRW_gpencil_populate_datablock(&e_data, vedata, ob, cache_ob);
}
else {
@@ -582,6 +583,7 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
Scene *scene = draw_ctx->scene;
ToolSettings *ts = scene->toolsettings;
View3D *v3d = draw_ctx->v3d;
+ const View3DCursor *cursor = &scene->cursor;
if (ob->type == OB_GPENCIL && ob->data) {
bGPdata *gpd = (bGPdata *)ob->data;
@@ -597,19 +599,21 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
}
if ((stl->g_data->session_flag & GP_DRW_PAINT_READY) == 0) {
+ /* bound box object are not visible, only external box*/
+ if (ob->dt != OB_BOUNDBOX) {
+ /* save gp objects for drawing later */
+ stl->g_data->gp_object_cache = gpencil_object_cache_add(
+ stl->g_data->gp_object_cache, ob,
+ &stl->g_data->gp_cache_size, &stl->g_data->gp_cache_used);
+
+ /* enable instance loop */
+ if (!stl->g_data->do_instances) {
+ stl->g_data->do_instances = ob->base_flag & BASE_FROM_DUPLI;
+ }
- /* save gp objects for drawing later */
- stl->g_data->gp_object_cache = gpencil_object_cache_add(
- stl->g_data->gp_object_cache, ob,
- &stl->g_data->gp_cache_size, &stl->g_data->gp_cache_used);
-
- /* enable instance loop */
- if (!stl->g_data->do_instances) {
- stl->g_data->do_instances = ob->base_flag & BASE_FROM_DUPLI;
+ /* load drawing data */
+ gpencil_add_draw_data(vedata, ob);
}
-
- /* load drawing data */
- gpencil_add_draw_data(vedata, ob);
}
/* draw current painting strokes
@@ -624,7 +628,9 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
if ((v3d) &&
((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) &&
(v3d->gp_flag & V3D_GP_SHOW_GRID) &&
- (ob->type == OB_GPENCIL) && (ob == draw_ctx->obact))
+ (ob->type == OB_GPENCIL) && (ob == draw_ctx->obact) &&
+ ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) == 0) &&
+ ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) == 0))
{
GPU_BATCH_DISCARD_SAFE(e_data.batch_grid);
MEM_SAFE_FREE(e_data.batch_grid);
@@ -632,13 +638,37 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
e_data.batch_grid = DRW_gpencil_get_grid(ob);
/* define grid orientation */
- if (ts->gp_sculpt.lock_axis != GP_LOCKAXIS_VIEW) {
- copy_m4_m4(stl->storage->grid_matrix, ob->obmat);
+ switch (ts->gp_sculpt.lock_axis) {
+ case GP_LOCKAXIS_VIEW:
+ {
+ /* align always to view */
+ invert_m4_m4(stl->storage->grid_matrix, draw_ctx->rv3d->viewmat);
+ /* copy ob location */
+ copy_v3_v3(stl->storage->grid_matrix[3], ob->obmat[3]);
+ break;
+ }
+ case GP_LOCKAXIS_CURSOR:
+ {
+ float scale[3] = { 1.0f, 1.0f, 1.0f };
+ loc_eul_size_to_mat4(
+ stl->storage->grid_matrix,
+ cursor->location,
+ cursor->rotation_euler,
+ scale);
+ break;
+ }
+ default:
+ {
+ copy_m4_m4(stl->storage->grid_matrix, ob->obmat);
+ break;
+ }
+ }
+
+ /* Move the origin to Object or Cursor */
+ if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) {
+ copy_v3_v3(stl->storage->grid_matrix[3], cursor->location);
}
else {
- /* align always to view */
- invert_m4_m4(stl->storage->grid_matrix, draw_ctx->rv3d->viewmat);
- /* copy ob location */
copy_v3_v3(stl->storage->grid_matrix[3], ob->obmat[3]);
}
@@ -681,7 +711,7 @@ void GPENCIL_cache_finish(void *vedata)
}
/* create framebuffers (only for normal drawing) */
- if (!DRW_state_is_select()) {
+ if (!DRW_state_is_select() || !DRW_state_is_depth()) {
GPENCIL_create_framebuffers(vedata);
}
}
@@ -691,8 +721,12 @@ static int gpencil_object_cache_compare_zdepth(const void *a1, const void *a2)
{
const tGPencilObjectCache *ps1 = a1, *ps2 = a2;
- if (ps1->zdepth < ps2->zdepth) return 1;
- else if (ps1->zdepth > ps2->zdepth) return -1;
+ if (ps1->zdepth < ps2->zdepth) {
+ return 1;
+ }
+ else if (ps1->zdepth > ps2->zdepth) {
+ return -1;
+ }
return 0;
}
@@ -757,8 +791,8 @@ static void gpencil_draw_pass_range(
}
DRW_draw_pass_subset(
- GPENCIL_3D_DRAWMODE(ob, gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
- init_shgrp, end_shgrp);
+ GPENCIL_3D_DRAWMODE(ob, gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
+ init_shgrp, end_shgrp);
if ((!stl->storage->is_mat_preview) && (multi)) {
MULTISAMPLE_GP_SYNC_DISABLE(stl->storage->multisamples, fbl, fb, txl);
@@ -779,7 +813,7 @@ static void drw_gpencil_select_render(GPENCIL_StorageList *stl, GPENCIL_PassList
{
/* sort by zdepth */
qsort(stl->g_data->gp_object_cache, stl->g_data->gp_cache_used,
- sizeof(tGPencilObjectCache), gpencil_object_cache_compare_zdepth);
+ sizeof(tGPencilObjectCache), gpencil_object_cache_compare_zdepth);
for (int i = 0; i < stl->g_data->gp_cache_used; i++) {
cache_ob = &stl->g_data->gp_object_cache[i];
@@ -797,8 +831,8 @@ static void drw_gpencil_select_render(GPENCIL_StorageList *stl, GPENCIL_PassList
}
/* draw group */
DRW_draw_pass_subset(
- GPENCIL_3D_DRAWMODE(ob, gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
- init_shgrp, end_shgrp);
+ GPENCIL_3D_DRAWMODE(ob, gpd) ? psl->stroke_pass_3d : psl->stroke_pass_2d,
+ init_shgrp, end_shgrp);
}
/* the cache must be dirty for next loop */
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
@@ -835,7 +869,7 @@ void GPENCIL_draw_scene(void *ved)
const bool overlay = v3d != NULL ? (bool)((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : true;
/* if the draw is for select, do a basic drawing and return */
- if (DRW_state_is_select()) {
+ if (DRW_state_is_select() || DRW_state_is_depth()) {
drw_gpencil_select_render(stl, psl);
/* free memory */
gpencil_free_obj_runtime(stl);
@@ -856,8 +890,9 @@ void GPENCIL_draw_scene(void *ved)
GPU_framebuffer_bind(dfbl->default_fb);
MULTISAMPLE_GP_SYNC_ENABLE(stl->storage->multisamples, fbl);
-
- DRW_draw_pass(psl->background_pass);
+ if (obact->dt != OB_BOUNDBOX) {
+ DRW_draw_pass(psl->background_pass);
+ }
DRW_draw_pass(psl->drawing_pass);
MULTISAMPLE_GP_SYNC_DISABLE(stl->storage->multisamples, fbl, dfbl->default_fb, txl);
@@ -915,8 +950,8 @@ void GPENCIL_draw_scene(void *ved)
use_blend = true;
/* draw pending groups */
gpencil_draw_pass_range(
- fbl, stl, psl, txl, fbl->temp_fb_a,
- ob, gpd, init_shgrp, end_shgrp, is_last);
+ fbl, stl, psl, txl, fbl->temp_fb_a,
+ ob, gpd, init_shgrp, end_shgrp, is_last);
/* draw current group in separated texture */
init_shgrp = array_elm->init_shgrp;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index fc45463fa1a..8af74ec7451 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -124,6 +124,7 @@ typedef struct GPENCIL_shgroup {
float wire_color[4];
/* shading type and mode */
int shading_type[2];
+ int is_xray;
} GPENCIL_shgroup;
typedef struct GPENCIL_Storage {
@@ -458,7 +459,7 @@ void GPENCIL_render_to_image(void *vedata, struct RenderEngine *engine, struct R
GPU_framebuffer_clear_color_depth(fbl->multisample_fb, (const float[4]){0.0f}, 1.0f); \
DRW_stats_query_end(); \
} \
-}
+} ((void)0)
#define MULTISAMPLE_GP_SYNC_DISABLE(lvl, fbl, fb, txl) { \
if ((lvl > 0) && (fbl->multisample_fb != NULL)) { \
@@ -467,7 +468,7 @@ void GPENCIL_render_to_image(void *vedata, struct RenderEngine *engine, struct R
DRW_multisamples_resolve(txl->multisample_depth, txl->multisample_color, true); \
DRW_stats_query_end(); \
} \
-}
+} ((void)0)
#define GPENCIL_3D_DRAWMODE(ob, gpd) \
((gpd) && (gpd->draw_mode == GP_DRAWMODE_3D) && \
diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c
index 2e3cb4b7b26..45fef77cbac 100644
--- a/source/blender/draw/engines/gpencil/gpencil_render.c
+++ b/source/blender/draw/engines/gpencil/gpencil_render.c
@@ -80,17 +80,17 @@ void GPENCIL_render_init(GPENCIL_Data *ved, RenderEngine *engine, struct Depsgra
DRW_gpencil_multisample_ensure(vedata, rect_w, rect_h);
}
- vedata->render_depth_tx = DRW_texture_pool_query_2D(
- size[0], size[1], GPU_DEPTH_COMPONENT24,
- &draw_engine_gpencil_type);
- vedata->render_color_tx = DRW_texture_pool_query_2D(
- size[0], size[1], GPU_RGBA32F,
- &draw_engine_gpencil_type);
+ vedata->render_depth_tx = DRW_texture_pool_query_2d(
+ size[0], size[1], GPU_DEPTH_COMPONENT24,
+ &draw_engine_gpencil_type);
+ vedata->render_color_tx = DRW_texture_pool_query_2d(
+ size[0], size[1], GPU_RGBA32F,
+ &draw_engine_gpencil_type);
GPU_framebuffer_ensure_config(
- &fbl->main, {
- GPU_ATTACHMENT_TEXTURE(vedata->render_depth_tx),
- GPU_ATTACHMENT_TEXTURE(vedata->render_color_tx)
- });
+ &fbl->main, {
+ GPU_ATTACHMENT_TEXTURE(vedata->render_depth_tx),
+ GPU_ATTACHMENT_TEXTURE(vedata->render_color_tx)
+ });
/* Alloc transient data. */
if (!stl->g_data) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index e4819f48eb1..a2632c47e7e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -58,7 +58,9 @@ static bool effect_is_active(bGPdata *gpd, ShaderFxData *fx, bool is_render)
}
bool is_edit = GPENCIL_ANY_EDIT_MODE(gpd);
- if (((fx->mode & eShaderFxMode_Editmode) == 0) && (is_edit)) {
+ if (((fx->mode & eShaderFxMode_Editmode) == 0) &&
+ (is_edit) && (!is_render))
+ {
return false;
}
@@ -457,8 +459,8 @@ static void DRW_gpencil_fx_shadow(
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
/* prepare pass */
fx_shgrp = DRW_shgroup_create(
- e_data->gpencil_fx_shadow_prepare_sh,
- psl->fx_shader_pass_blend);
+ e_data->gpencil_fx_shadow_prepare_sh,
+ psl->fx_shader_pass_blend);
DRW_shgroup_call_add(fx_shgrp, fxquad, NULL);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
@@ -494,8 +496,8 @@ static void DRW_gpencil_fx_shadow(
/* blur pass */
fx_shgrp = DRW_shgroup_create(
- e_data->gpencil_fx_blur_sh,
- psl->fx_shader_pass_blend);
+ e_data->gpencil_fx_blur_sh,
+ psl->fx_shader_pass_blend);
DRW_shgroup_call_add(fx_shgrp, fxquad, NULL);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_fx);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_fx);
@@ -510,8 +512,8 @@ static void DRW_gpencil_fx_shadow(
/* resolve pass */
fx_shgrp = DRW_shgroup_create(
- e_data->gpencil_fx_shadow_resolve_sh,
- psl->fx_shader_pass_blend);
+ e_data->gpencil_fx_shadow_resolve_sh,
+ psl->fx_shader_pass_blend);
DRW_shgroup_call_add(fx_shgrp, fxquad, NULL);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
@@ -540,8 +542,8 @@ static void DRW_gpencil_fx_glow(
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
/* prepare pass */
fx_shgrp = DRW_shgroup_create(
- e_data->gpencil_fx_glow_prepare_sh,
- psl->fx_shader_pass_blend);
+ e_data->gpencil_fx_glow_prepare_sh,
+ psl->fx_shader_pass_blend);
DRW_shgroup_call_add(fx_shgrp, fxquad, NULL);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
@@ -555,8 +557,8 @@ static void DRW_gpencil_fx_glow(
/* blur pass */
fx_shgrp = DRW_shgroup_create(
- e_data->gpencil_fx_blur_sh,
- psl->fx_shader_pass_blend);
+ e_data->gpencil_fx_blur_sh,
+ psl->fx_shader_pass_blend);
DRW_shgroup_call_add(fx_shgrp, fxquad, NULL);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_fx);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_fx);
@@ -571,8 +573,8 @@ static void DRW_gpencil_fx_glow(
/* resolve pass */
fx_shgrp = DRW_shgroup_create(
- e_data->gpencil_fx_glow_resolve_sh,
- psl->fx_shader_pass_blend);
+ e_data->gpencil_fx_glow_resolve_sh,
+ psl->fx_shader_pass_blend);
DRW_shgroup_call_add(fx_shgrp, fxquad, NULL);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
@@ -659,52 +661,52 @@ void GPENCIL_create_fx_shaders(GPENCIL_e_data *e_data)
/* fx shaders (all in screen space) */
if (!e_data->gpencil_fx_blur_sh) {
e_data->gpencil_fx_blur_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_blur_frag_glsl, NULL);
+ datatoc_gpencil_fx_blur_frag_glsl, NULL);
}
if (!e_data->gpencil_fx_colorize_sh) {
e_data->gpencil_fx_colorize_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_colorize_frag_glsl, NULL);
+ datatoc_gpencil_fx_colorize_frag_glsl, NULL);
}
if (!e_data->gpencil_fx_flip_sh) {
e_data->gpencil_fx_flip_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_flip_frag_glsl, NULL);
+ datatoc_gpencil_fx_flip_frag_glsl, NULL);
}
if (!e_data->gpencil_fx_light_sh) {
e_data->gpencil_fx_light_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_light_frag_glsl, NULL);
+ datatoc_gpencil_fx_light_frag_glsl, NULL);
}
if (!e_data->gpencil_fx_pixel_sh) {
e_data->gpencil_fx_pixel_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_pixel_frag_glsl, NULL);
+ datatoc_gpencil_fx_pixel_frag_glsl, NULL);
}
if (!e_data->gpencil_fx_rim_prepare_sh) {
e_data->gpencil_fx_rim_prepare_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_rim_prepare_frag_glsl, NULL);
+ datatoc_gpencil_fx_rim_prepare_frag_glsl, NULL);
e_data->gpencil_fx_rim_resolve_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_rim_resolve_frag_glsl, NULL);
+ datatoc_gpencil_fx_rim_resolve_frag_glsl, NULL);
}
if (!e_data->gpencil_fx_shadow_prepare_sh) {
e_data->gpencil_fx_shadow_prepare_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_shadow_prepare_frag_glsl, NULL);
+ datatoc_gpencil_fx_shadow_prepare_frag_glsl, NULL);
e_data->gpencil_fx_shadow_resolve_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_shadow_resolve_frag_glsl, NULL);
+ datatoc_gpencil_fx_shadow_resolve_frag_glsl, NULL);
}
if (!e_data->gpencil_fx_glow_prepare_sh) {
e_data->gpencil_fx_glow_prepare_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_glow_prepare_frag_glsl, NULL);
+ datatoc_gpencil_fx_glow_prepare_frag_glsl, NULL);
e_data->gpencil_fx_glow_resolve_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_glow_resolve_frag_glsl, NULL);
+ datatoc_gpencil_fx_glow_resolve_frag_glsl, NULL);
}
if (!e_data->gpencil_fx_swirl_sh) {
e_data->gpencil_fx_swirl_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_swirl_frag_glsl, NULL);
+ datatoc_gpencil_fx_swirl_frag_glsl, NULL);
}
if (!e_data->gpencil_fx_wave_sh) {
e_data->gpencil_fx_wave_sh = DRW_shader_create_fullscreen(
- datatoc_gpencil_fx_wave_frag_glsl, NULL);
+ datatoc_gpencil_fx_wave_frag_glsl, NULL);
}
}
@@ -880,8 +882,9 @@ static void draw_gpencil_midpass_blur(
GPU_framebuffer_bind(fbl->temp_fb_b);
GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
- DRW_draw_pass_subset(psl->fx_shader_pass_blend,
- runtime->fx_sh_b, runtime->fx_sh_b);
+ DRW_draw_pass_subset(
+ psl->fx_shader_pass_blend,
+ runtime->fx_sh_b, runtime->fx_sh_b);
/* copy pass from b for ping-pong frame buffers */
GPU_framebuffer_bind(fbl->temp_fb_fx);
@@ -981,8 +984,8 @@ static void draw_gpencil_shadow_passes(
GPU_framebuffer_bind(fbl->temp_fb_fx);
GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
DRW_draw_pass_subset(
- psl->fx_shader_pass_blend,
- fxd->runtime.fx_sh, fxd->runtime.fx_sh);
+ psl->fx_shader_pass_blend,
+ fxd->runtime.fx_sh, fxd->runtime.fx_sh);
/* blur shadow */
draw_gpencil_do_blur(
@@ -995,8 +998,8 @@ static void draw_gpencil_shadow_passes(
GPU_framebuffer_bind(fbl->temp_fb_b);
GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
DRW_draw_pass_subset(
- psl->fx_shader_pass_blend,
- fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
+ psl->fx_shader_pass_blend,
+ fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
/* copy pass from b to a for ping-pong frame buffers */
e_data->input_depth_tx = e_data->temp_depth_tx_b;
@@ -1026,8 +1029,8 @@ static void draw_gpencil_glow_passes(
GPU_framebuffer_bind(fbl->temp_fb_fx);
GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
DRW_draw_pass_subset(
- psl->fx_shader_pass_blend,
- fxd->runtime.fx_sh, fxd->runtime.fx_sh);
+ psl->fx_shader_pass_blend,
+ fxd->runtime.fx_sh, fxd->runtime.fx_sh);
/* blur glow */
draw_gpencil_do_blur(
@@ -1044,8 +1047,8 @@ static void draw_gpencil_glow_passes(
fxd->blur[1] = (fxd->flag & FX_GLOW_USE_ALPHA) ? 1 : 0;
DRW_draw_pass_subset(
- psl->fx_shader_pass_blend,
- fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
+ psl->fx_shader_pass_blend,
+ fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
/* copy pass from b to a for ping-pong frame buffers */
e_data->input_depth_tx = e_data->temp_depth_tx_b;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
index f0878c8bc89..7f3bbf17222 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
@@ -170,10 +170,10 @@ void main()
if (shading_type[0] == OB_WIRE) {
fragColor = wire_color;
}
-
+
/* for solid override color */
if (shading_type[0] == OB_SOLID) {
- if ((shading_type[1] != V3D_SHADING_MATERIAL_COLOR) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR)) {
+ if ((shading_type[1] != V3D_SHADING_MATERIAL_COLOR) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR)) {
fragColor = wire_color;
}
if (viewport_xray == 1) {
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
index b367d15f1f9..2606bbf878e 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
@@ -40,7 +40,7 @@ void main()
float size = (ProjectionMatrix[3][3] == 0.0) ? (thickness / (gl_Position.z * defaultpixsize)) : (thickness / defaultpixsize);
finalThickness = max(size * objscale, 4.0); /* minimum 4 pixels */
}
-
+
/* for wireframe override size and color */
if (shading_type[0] == OB_WIRE) {
finalThickness = 2.0;
@@ -48,7 +48,7 @@ void main()
}
/* for solid override color */
if (shading_type[0] == OB_SOLID) {
- if ((shading_type[1] != V3D_SHADING_MATERIAL_COLOR) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR)) {
+ if ((shading_type[1] != V3D_SHADING_MATERIAL_COLOR) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR)) {
finalColor = wire_color;
}
if (viewport_xray == 1) {
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 dad482bfa23..80fa899b13a 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
@@ -31,7 +31,7 @@ void main()
if (color_type == GPENCIL_COLOR_SOLID) {
fragColor = tColor;
}
-
+
/* texture for endcaps */
vec4 text_color;
if (uvfac[1] == ENDCAP) {
@@ -40,7 +40,7 @@ void main()
else {
text_color = texture2D(myTexture, mTexCoord);
}
-
+
/* texture */
if (color_type == GPENCIL_COLOR_TEXTURE) {
fragColor = text_color;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
index a3780a3dd4f..1ebb6797f63 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
@@ -182,24 +182,37 @@ void main(void)
EmitVertex();
}
+ float y_a = 0.0;
+ float y_b = 1.0;
+
+ /* invert uv (vertical) */
+ if (finaluvdata[2].x > 1.0) {
+ if ((finaluvdata[1].y != 0.0) && (finaluvdata[2].y != 0.0)) {
+ float d = ceil(finaluvdata[2].x) - 1.0;
+ if (floor(d / 2.0) == (d / 2.0)) {
+ y_a = 1.0;
+ y_b = 0.0;
+ }
+ }
+ }
/* generate the triangle strip */
uvfac = vec2(0.0, 0.0);
- mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 0) : vec2(finaluvdata[1].x, 0);
+ mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 0) : vec2(finaluvdata[1].x, y_a);
mColor = finalColor[1];
gl_Position = vec4((sp1 + length_a * miter_a) / Viewport, getZdepth(P1), 1.0);
EmitVertex();
- mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 1) : vec2(finaluvdata[1].x, 1);
+ mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(0, 1) : vec2(finaluvdata[1].x, y_b);
mColor = finalColor[1];
gl_Position = vec4((sp1 - length_a * miter_a) / Viewport, getZdepth(P1), 1.0);
EmitVertex();
- mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 0) : vec2(finaluvdata[2].x, 0);
+ mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 0) : vec2(finaluvdata[2].x, y_a);
mColor = finalColor[2];
gl_Position = vec4((sp2 + length_b * miter_b) / Viewport, getZdepth(P2), 1.0);
EmitVertex();
- mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 1) : vec2(finaluvdata[2].x, 1);
+ mTexCoord = (color_type == GPENCIL_COLOR_SOLID) ? vec2(1, 1) : vec2(finaluvdata[2].x, y_b);
mColor = finalColor[2];
gl_Position = vec4((sp2 - length_b * miter_b) / Viewport, getZdepth(P2), 1.0);
EmitVertex();
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
index 3c6768dd483..62740f37ae8 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
@@ -48,7 +48,7 @@ void main(void)
}
/* for solid override color */
if (shading_type[0] == OB_SOLID) {
- if ((shading_type[1] != V3D_SHADING_MATERIAL_COLOR) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR)) {
+ if ((shading_type[1] != V3D_SHADING_MATERIAL_COLOR) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR)) {
finalColor = wire_color;
}
if (viewport_xray == 1) {
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_zdepth_mix_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_zdepth_mix_frag.glsl
index a68c17031ff..a32fd87a446 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_zdepth_mix_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_zdepth_mix_frag.glsl
@@ -30,15 +30,15 @@ float linearrgb_to_srgb(float c)
bool check_borders(ivec2 uv, int size)
{
- for (int x = -size; x <= size; x++) {
- for (int y = -size; y <= size; y++) {
+ for (int x = -size; x <= size; x++) {
+ for (int y = -size; y <= size; y++) {
vec4 stroke_color = texelFetch(strokeColor, ivec2(uv.x + x, uv.y + y), 0).rgba;
if (stroke_color.a > 0) {
return true;
}
}
}
-
+
return false;
}
@@ -62,7 +62,7 @@ void main()
FragColor = clamp(stroke_color, 0.0, 1.0);
gl_FragDepth = clamp(stroke_depth, 0.0, 1.0);
-
+
if (do_select == 1) {
if (stroke_color.a == 0) {
if (check_borders(uv, 2)) {
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
index 0185e192f5c..1fb7a9cec46 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
@@ -2,7 +2,7 @@
* Separable Hexagonal Bokeh Blur by Colin Barré-Brisebois
* https://colinbarrebrisebois.com/2017/04/18/hexagonal-bokeh-blur-revisited-part-1-basic-3-pass-version/
* Converted and adapted from HLSL to GLSL by Clément Foucault
- **/
+ */
uniform mat4 ProjectionMatrix;
uniform vec2 invertedViewportSize;
@@ -31,9 +31,10 @@ float max_v4(vec4 v) { return max(max(v.x, v.y), max(v.z, v.w)); }
/* divide by sensor size to get the normalized size */
#define calculate_coc(zdepth) (dof_aperturesize * (dof_distance / zdepth - 1.0) * dof_invsensorsize)
-#define linear_depth(z) ((ProjectionMatrix[3][3] == 0.0) \
- ? (nearFar.x * nearFar.y) / (z * (nearFar.x - nearFar.y) + nearFar.y) \
- : (z * 2.0 - 1.0) * nearFar.y)
+#define linear_depth(z) \
+ ((ProjectionMatrix[3][3] == 0.0) ? \
+ (nearFar.x * nearFar.y) / (z * (nearFar.x - nearFar.y) + nearFar.y) : \
+ (z * 2.0 - 1.0) * nearFar.y)
const float MAX_COC_SIZE = 100.0;
@@ -44,7 +45,7 @@ float decode_signed_coc(vec2 cocs) { return ((cocs.x > cocs.y) ? cocs.x : -cocs.
/**
* ----------------- STEP 0 ------------------
* Custom Coc aware downsampling. Half res pass.
- **/
+ */
#ifdef PREPARE
layout(location = 0) out vec4 halfResColor;
@@ -91,7 +92,7 @@ void main()
/**
* ----------------- STEP 0.5 ------------------
* Custom Coc aware downsampling. Quater res pass.
- **/
+ */
#ifdef DOWNSAMPLE
layout(location = 0) out vec4 outColor;
@@ -135,7 +136,7 @@ void main()
/**
* ----------------- STEP 1 ------------------
* Flatten COC buffer using max filter.
- **/
+ */
#if defined(FLATTEN_VERTICAL) || defined(FLATTEN_HORIZONTAL)
layout(location = 0) out vec2 flattenedCoc;
@@ -170,7 +171,7 @@ void main()
/**
* ----------------- STEP 1.ax------------------
* Dilate COC buffer using min filter.
- **/
+ */
#if defined(DILATE_VERTICAL) || defined(DILATE_HORIZONTAL)
layout(location = 0) out vec2 dilatedCoc;
@@ -205,7 +206,7 @@ void main()
* ----------------- STEP 2 ------------------
* Blur vertically and diagonally.
* Outputs vertical blur and combined blur in MRT
- **/
+ */
#ifdef BLUR1
layout(location = 0) out vec4 blurColor;
@@ -290,7 +291,7 @@ void main()
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- **/
+ */
#ifdef BLUR2
out vec4 finalColor;
@@ -298,7 +299,7 @@ void main()
{
/* Half Res pass */
vec2 pixel_size = 1.0 / vec2(textureSize(blurTex, 0).xy);
- vec2 uv = gl_FragCoord.xy * pixel_size.xy;
+ vec2 uv = gl_FragCoord.xy * pixel_size.xy;
float coc = decode_coc(texture(inputCocTex, uv).rg);
/* Only use this filter if coc is > 9.0
* since this filter is not weighted by CoC
@@ -344,7 +345,7 @@ void main()
/**
* ----------------- STEP 4 ------------------
- **/
+ */
#ifdef RESOLVE
out vec4 finalColor;
@@ -362,4 +363,4 @@ void main()
finalColor = texture(halfResColorTex, uv);
finalColor.a = smoothstep(1.0, 3.0, abs(coc));
}
-#endif \ No newline at end of file
+#endif
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl
index b1f08cfef15..576a5e81c0d 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl
@@ -27,15 +27,16 @@ void main()
#ifndef ALPHA_COMPOSITE
vec3 bg_color = background_color(world_data, uv_viewport.y);
- vec3 color = mix(trans_color, bg_color, trans_revealage);
+ bg_color = (world_data.background_alpha == 0.0) ? trans_color : bg_color;
+ vec4 color = mix(vec4(trans_color, 1.0), vec4(bg_color, world_data.background_alpha), trans_revealage);
# ifdef V3D_SHADING_OBJECT_OUTLINE
uint object_id = texelFetch(objectId, texel, 0).r;
float outline = calculate_object_outline(objectId, texel, object_id);
- color = mix(world_data.object_outline_color.rgb, color, outline);
+ color = mix(vec4(world_data.object_outline_color.rgb, 1.0), color, outline);
# endif
- fragColor = vec4(color, 1.0);
+ fragColor = color;
#else
fragColor = vec4(trans_color, 1.0 - trans_revealage);
#endif
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
index 0d2d2187a85..c99787eaee8 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
@@ -18,6 +18,7 @@ uniform float noiseOfs = 0.0f;
uniform float stepLength; /* Step length in local space. */
uniform float densityScale; /* Simple Opacity multiplicator. */
uniform vec4 viewvecs[3];
+uniform vec3 activeColor;
uniform float slicePosition;
uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */
@@ -135,7 +136,7 @@ void volume_properties(vec3 ls_pos, out vec3 scattering, out float extinction)
float shadows = sample_volume_texture(shadowTexture, co).r;
vec4 density = sample_volume_texture(densityTexture, co); /* rgb: color, a: density */
- scattering = density.rgb * (density.a * densityScale);
+ scattering = density.rgb * (density.a * densityScale) * activeColor;
extinction = max(1e-4, dot(scattering, vec3(0.33333)));
/* Scale shadows in log space and clamp them to avoid completely black shadows. */
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index f886b88828f..4afc692455c 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -53,8 +53,13 @@
# include "draw_debug.h"
#endif
-static struct {
+typedef struct WORKBENCH_DEFERRED_Shaders {
struct GPUShader *prepass_sh_cache[MAX_PREPASS_SHADERS];
+} WORKBENCH_DEFERRED_Shaders;
+
+static struct {
+ WORKBENCH_DEFERRED_Shaders sh_data[GPU_SHADER_CFG_LEN];
+
struct GPUShader *composite_sh_cache[MAX_COMPOSITE_SHADERS];
struct GPUShader *cavity_sh[MAX_CAVITY_SHADERS];
struct GPUShader *background_sh[2];
@@ -84,11 +89,10 @@ static struct {
struct GPUUniformBuffer *sampling_ubo;
struct GPUTexture *jitter_tx;
int cached_sample_num;
-} e_data = {{NULL}};
+} e_data = {{{{NULL}}}};
/* Shaders */
extern char datatoc_common_hair_lib_glsl[];
-extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[];
extern char datatoc_workbench_prepass_vert_glsl[];
extern char datatoc_workbench_prepass_frag_glsl[];
@@ -115,8 +119,6 @@ extern char datatoc_gpu_shader_depth_only_frag_glsl[];
static char *workbench_build_composite_frag(WORKBENCH_PrivateData *wpd)
{
- char *str = NULL;
-
DynStr *ds = BLI_dynstr_new();
BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl);
@@ -135,50 +137,38 @@ static char *workbench_build_composite_frag(WORKBENCH_PrivateData *wpd)
BLI_dynstr_append(ds, datatoc_workbench_deferred_composite_frag_glsl);
- str = BLI_dynstr_get_cstring(ds);
+ char *str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
}
static char *workbench_build_prepass_frag(void)
{
- char *str = NULL;
-
DynStr *ds = BLI_dynstr_new();
BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_prepass_frag_glsl);
- str = BLI_dynstr_get_cstring(ds);
+ char *str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
}
static char *workbench_build_prepass_vert(bool is_hair)
{
- char *str = NULL;
- if (!is_hair) {
- return BLI_string_joinN(
- datatoc_gpu_shader_cfg_world_clip_lib_glsl,
- datatoc_workbench_prepass_vert_glsl);
- }
-
DynStr *ds = BLI_dynstr_new();
-
- BLI_dynstr_append(ds, datatoc_common_hair_lib_glsl);
- BLI_dynstr_append(ds, datatoc_gpu_shader_cfg_world_clip_lib_glsl);
+ if (is_hair) {
+ BLI_dynstr_append(ds, datatoc_common_hair_lib_glsl);
+ }
BLI_dynstr_append(ds, datatoc_workbench_prepass_vert_glsl);
-
- str = BLI_dynstr_get_cstring(ds);
+ char *str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
}
static char *workbench_build_cavity_frag(bool cavity, bool curvature, bool high_dpi)
{
- char *str = NULL;
-
DynStr *ds = BLI_dynstr_new();
if (cavity) {
@@ -198,7 +188,7 @@ static char *workbench_build_cavity_frag(bool cavity, bool curvature, bool high_
BLI_dynstr_append(ds, datatoc_workbench_cavity_frag_glsl);
BLI_dynstr_append(ds, datatoc_workbench_cavity_lib_glsl);
- str = BLI_dynstr_get_cstring(ds);
+ char *str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
}
@@ -220,21 +210,26 @@ static GPUShader *workbench_cavity_shader_get(bool cavity, bool curvature)
return *sh;
}
-static GPUShader *ensure_deferred_prepass_shader(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair)
+static GPUShader *ensure_deferred_prepass_shader(
+ WORKBENCH_PrivateData *wpd, bool use_textures, 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);
- if (e_data.prepass_sh_cache[index] == NULL) {
+ 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 *prepass_vert = workbench_build_prepass_vert(is_hair);
char *prepass_frag = workbench_build_prepass_frag();
- e_data.prepass_sh_cache[index] = DRW_shader_create(
- prepass_vert, NULL,
- prepass_frag, defines);
+ sh_data->prepass_sh_cache[index] = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib, prepass_vert, NULL},
+ .frag = (const char *[]){prepass_frag, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, defines, NULL},
+ });
MEM_freeN(prepass_vert);
MEM_freeN(prepass_frag);
MEM_freeN(defines);
}
- return e_data.prepass_sh_cache[index];
+ return sh_data->prepass_sh_cache[index];
}
static GPUShader *ensure_deferred_composite_shader(WORKBENCH_PrivateData *wpd)
@@ -267,12 +262,12 @@ static GPUShader *ensure_background_shader(WORKBENCH_PrivateData *wpd)
return e_data.background_sh[index];
}
-static void select_deferred_shaders(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);
- wpd->prepass_solid_hair_sh = ensure_deferred_prepass_shader(wpd, false, true);
- wpd->prepass_texture_sh = ensure_deferred_prepass_shader(wpd, true, false);
- wpd->prepass_texture_hair_sh = ensure_deferred_prepass_shader(wpd, true, true);
+ 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->composite_sh = ensure_deferred_composite_shader(wpd);
wpd->background_sh = ensure_background_shader(wpd);
}
@@ -289,7 +284,7 @@ static float *create_disk_samples(int num_samples, int num_iterations)
float it_add = (i / num_samples) * 0.499f;
float r = fmodf((i + 0.5f + it_add) * num_samples_inv, 1.0f);
double dphi;
- BLI_hammersley_1D(i, &dphi);
+ BLI_hammersley_1d(i, &dphi);
float phi = (float)dphi * 2.0f * M_PI + it_add;
texels[i][0] = cosf(phi);
@@ -321,7 +316,7 @@ static struct GPUTexture *create_jitter_texture(int num_samples)
UNUSED_VARS(bsdf_split_sum_ggx, btdf_split_sum_ggx, ltc_mag_ggx, ltc_mat_ggx, ltc_disk_integral);
- return DRW_texture_create_2D(64, 64, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_WRAP, &jitter[0][0]);
+ return DRW_texture_create_2d(64, 64, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_WRAP, &jitter[0][0]);
}
/* Functions */
@@ -336,8 +331,8 @@ static void workbench_init_object_data(DrawData *dd)
static void workbench_init_oit_framebuffer(WORKBENCH_FramebufferList *fbl, DefaultTextureList *dtxl)
{
const float *size = DRW_viewport_size_get();
- e_data.oit_accum_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_solid);
- e_data.oit_revealage_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R16F, &draw_engine_workbench_solid);
+ e_data.oit_accum_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_solid);
+ e_data.oit_revealage_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_R16F, &draw_engine_workbench_solid);
GPU_framebuffer_ensure_config(&fbl->transparent_accum_fb, {
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
@@ -375,7 +370,8 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
}
if (!e_data.next_object_id) {
- memset(e_data.prepass_sh_cache, 0, sizeof(e_data.prepass_sh_cache));
+ WORKBENCH_DEFERRED_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
+ memset(sh_data->prepass_sh_cache, 0, sizeof(sh_data->prepass_sh_cache));
memset(e_data.composite_sh_cache, 0, sizeof(e_data.composite_sh_cache));
e_data.next_object_id = 1;
#ifdef DEBUG_SHADOW_VOLUME
@@ -436,8 +432,8 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
"#define ALPHA_COMPOSITE\n");
}
- workbench_forward_choose_shaders(wpd);
- workbench_forward_outline_shaders_ensure(wpd);
+ workbench_forward_choose_shaders(wpd, draw_ctx->sh_cfg);
+ workbench_forward_outline_shaders_ensure(wpd, draw_ctx->sh_cfg);
}
{
@@ -445,6 +441,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
const eGPUTextureFormat nor_tex_format = NORMAL_ENCODING_ENABLED() ? GPU_RG16 : GPU_RGBA32F;
const eGPUTextureFormat comp_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_R11F_G11F_B10F;
+ const eGPUTextureFormat col_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_RGBA8;
const eGPUTextureFormat id_tex_format = OBJECT_ID_PASS_ENABLED(wpd) ? GPU_R32UI : GPU_R8;
e_data.object_id_tx = NULL;
@@ -453,19 +450,19 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
e_data.normal_buffer_tx = NULL;
e_data.cavity_buffer_tx = NULL;
- e_data.composite_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], comp_tex_format, &draw_engine_workbench_solid);
+ e_data.composite_buffer_tx = DRW_texture_pool_query_2d(size[0], size[1], comp_tex_format, &draw_engine_workbench_solid);
if (MATDATA_PASS_ENABLED(wpd) || GPU_unused_fb_slot_workaround()) {
- e_data.color_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
+ e_data.color_buffer_tx = DRW_texture_pool_query_2d(size[0], size[1], col_tex_format, &draw_engine_workbench_solid);
}
if (OBJECT_ID_PASS_ENABLED(wpd) || GPU_unused_fb_slot_workaround()) {
- e_data.object_id_tx = DRW_texture_pool_query_2D(size[0], size[1], id_tex_format, &draw_engine_workbench_solid);
+ e_data.object_id_tx = DRW_texture_pool_query_2d(size[0], size[1], id_tex_format, &draw_engine_workbench_solid);
}
if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
- e_data.normal_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], nor_tex_format, &draw_engine_workbench_solid);
+ e_data.normal_buffer_tx = DRW_texture_pool_query_2d(size[0], size[1], nor_tex_format, &draw_engine_workbench_solid);
}
if (CAVITY_ENABLED(wpd)) {
- e_data.cavity_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R16, &draw_engine_workbench_solid);
+ e_data.cavity_buffer_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_R16, &draw_engine_workbench_solid);
}
GPU_framebuffer_ensure_config(&fbl->prepass_fb, {
@@ -488,7 +485,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
});
if (!MATDATA_PASS_ENABLED(wpd) && !GPU_unused_fb_slot_workaround()) {
- e_data.color_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
+ e_data.color_buffer_tx = DRW_texture_pool_query_2d(size[0], size[1], col_tex_format, &draw_engine_workbench_solid);
}
GPU_framebuffer_ensure_config(&fbl->effect_fb, {
@@ -583,7 +580,7 @@ static void workbench_setup_ghost_framebuffer(WORKBENCH_FramebufferList *fbl)
const float *viewport_size = DRW_viewport_size_get();
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
- e_data.ghost_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_workbench_solid);
+ e_data.ghost_depth_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_workbench_solid);
GPU_framebuffer_ensure_config(&fbl->ghost_prepass_fb, {
GPU_ATTACHMENT_TEXTURE(e_data.ghost_depth_tx),
@@ -595,8 +592,11 @@ static void workbench_setup_ghost_framebuffer(WORKBENCH_FramebufferList *fbl)
void workbench_deferred_engine_free(void)
{
- for (int index = 0; index < MAX_PREPASS_SHADERS; index++) {
- DRW_SHADER_FREE_SAFE(e_data.prepass_sh_cache[index]);
+ for (int sh_data_index = 0; sh_data_index < ARRAY_SIZE(e_data.sh_data); sh_data_index++) {
+ WORKBENCH_DEFERRED_Shaders *sh_data = &e_data.sh_data[sh_data_index];
+ for (int index = 0; index < MAX_PREPASS_SHADERS; index++) {
+ DRW_SHADER_FREE_SAFE(sh_data->prepass_sh_cache[index]);
+ }
}
for (int index = 0; index < MAX_COMPOSITE_SHADERS; index++) {
DRW_SHADER_FREE_SAFE(e_data.composite_sh_cache[index]);
@@ -667,7 +667,7 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
workbench_volume_cache_init(vedata);
- select_deferred_shaders(wpd);
+ select_deferred_shaders(wpd, draw_ctx->sh_cfg);
/* Background Pass */
{
@@ -762,7 +762,7 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
* Similar to workbench forward. Duplicated code to avoid
* spaghetti with workbench forward. It would be great if we unify
* this in a clean way.
- **/
+ */
if (OIT_ENABLED(wpd)) {
const bool do_cull = CULL_BACKFACE_ENABLED(wpd);
const int cull_state = (do_cull) ? DRW_STATE_CULL_BACK : 0;
@@ -793,7 +793,7 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
}
static WORKBENCH_MaterialData *get_or_create_material_data(
- WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type, int interp)
+ WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, ImageUser *iuser, int color_type, int interp)
{
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PassList *psl = vedata->psl;
@@ -809,6 +809,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
material_template.object_id = OBJECT_ID_PASS_ENABLED(wpd) ? engine_object_data->object_id : 1;
material_template.color_type = color_type;
material_template.ima = ima;
+ material_template.iuser = iuser;
material_template.interp = interp;
uint hash = workbench_material_get_hash(&material_template, is_ghost);
@@ -822,11 +823,6 @@ static WORKBENCH_MaterialData *get_or_create_material_data(
DRW_shgroup_stencil_mask(material->shgrp, (ob->dtx & OB_DRAWXRAY) ? 0x00 : 0xFF);
DRW_shgroup_uniform_int(material->shgrp, "object_id", &material->object_id, 1);
workbench_material_shgroup_uniform(wpd, material->shgrp, material, ob, true, true, interp);
- if (wpd->world_clip_planes) {
- const DRWContextState *draw_ctx = DRW_context_state_get();
- RegionView3D *rv3d = draw_ctx->rv3d;
- DRW_shgroup_world_clip_planes_from_rv3d(material->shgrp, rv3d);
- }
BLI_ghash_insert(wpd->material_hash, POINTER_FROM_UINT(hash), material);
}
return material;
@@ -843,9 +839,6 @@ static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *o
continue;
}
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
- if (!psys_check_enabled(ob, psys, false)) {
- continue;
- }
if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
continue;
}
@@ -855,10 +848,11 @@ static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *o
if (draw_as == PART_DRAW_PATH) {
Material *mat;
Image *image;
+ ImageUser *iuser;
int interp;
- workbench_material_get_image_and_mat(ob, part->omat, &image, &interp, &mat);
+ workbench_material_get_image_and_mat(ob, part->omat, &image, &iuser, &interp, &mat);
int color_type = workbench_material_determine_color_type(wpd, image, ob);
- WORKBENCH_MaterialData *material = get_or_create_material_data(vedata, ob, mat, image, color_type, interp);
+ 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 :
@@ -923,10 +917,11 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (geom_array != NULL && geom_array[i] != NULL) {
Material *mat;
Image *image;
+ ImageUser *iuser;
int interp;
- workbench_material_get_image_and_mat(ob, i + 1, &image, &interp, &mat);
+ workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat);
int color_type = workbench_material_determine_color_type(wpd, image, ob);
- material = get_or_create_material_data(vedata, ob, mat, image, color_type, interp);
+ material = get_or_create_material_data(vedata, ob, mat, image, iuser, color_type, interp);
DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob);
}
}
@@ -939,12 +934,12 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
{
/* Hack */
wpd->shading.xray_alpha = ob->color[3];
- material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0);
+ material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, NULL, wpd->shading.color_type, 0);
has_transp_mat = true;
}
else {
/* Draw solid color */
- material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0);
+ material = get_or_create_material_data(vedata, ob, NULL, NULL, NULL, wpd->shading.color_type, 0);
}
if (is_sculpt_mode) {
DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat);
@@ -961,7 +956,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (is_sculpt_mode) {
/* Multiple materials are not supported in sculpt mode yet. */
Material *mat = give_current_material(ob, 1);
- material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
+ material = get_or_create_material_data(vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat);
}
else {
@@ -976,11 +971,11 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (mat != NULL && mat->a < 1.0f) {
/* Hack */
wpd->shading.xray_alpha = mat->a;
- material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
+ material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
has_transp_mat = true;
}
else {
- material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
+ material = get_or_create_material_data(vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
}
DRW_shgroup_call_object_add(material->shgrp, geoms[i], ob);
}
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c
index b12aa5f90bc..dca65355c8f 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c
@@ -47,7 +47,7 @@ extern char datatoc_workbench_effect_dof_frag_glsl[];
/**
* Transform [-1..1] square to unit circle.
- **/
+ */
static void square_to_circle(float x, float y, float *r, float *T)
{
if (x > -y) {
@@ -186,13 +186,13 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera)
int shrink_w_size[2] = {shrink_h_size[0], ceilf(size[1] / 8.0f)};
#endif
- DRW_texture_ensure_2D(&txl->dof_source_tx, size[0], size[1], GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
- DRW_texture_ensure_2D(&txl->coc_halfres_tx, size[0], size[1], GPU_RG8, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
- wpd->dof_blur_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R11F_G11F_B10F, &draw_engine_workbench_solid);
+ DRW_texture_ensure_2d(&txl->dof_source_tx, size[0], size[1], GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
+ DRW_texture_ensure_2d(&txl->coc_halfres_tx, size[0], size[1], GPU_RG8, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
+ wpd->dof_blur_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_R11F_G11F_B10F, &draw_engine_workbench_solid);
#if 0
- wpd->coc_temp_tx = DRW_texture_pool_query_2D(shrink_h_size[0], shrink_h_size[1], GPU_RG8, &draw_engine_workbench_solid);
- wpd->coc_tiles_tx[0] = DRW_texture_pool_query_2D(shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench_solid);
- wpd->coc_tiles_tx[1] = DRW_texture_pool_query_2D(shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench_solid);
+ wpd->coc_temp_tx = DRW_texture_pool_query_2d(shrink_h_size[0], shrink_h_size[1], GPU_RG8, &draw_engine_workbench_solid);
+ wpd->coc_tiles_tx[0] = DRW_texture_pool_query_2d(shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench_solid);
+ wpd->coc_tiles_tx[1] = DRW_texture_pool_query_2d(shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench_solid);
#endif
GPU_framebuffer_ensure_config(&fbl->dof_downsample_fb, {
diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c
index d1f8c0983c6..cbc0e347d7d 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_taa.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c
@@ -26,7 +26,9 @@
static struct {
struct GPUShader *effect_taa_sh;
+ float jitter_5[5][2];
float jitter_8[8][2];
+ float jitter_11[11][2];
float jitter_16[16][2];
float jitter_32[32][2];
} e_data = {NULL};
@@ -79,7 +81,9 @@ static void workbench_taa_jitter_init_order(float (*table)[2], int num)
static void workbench_taa_jitter_init(void)
{
+ workbench_taa_jitter_init_order(e_data.jitter_5, 5);
workbench_taa_jitter_init_order(e_data.jitter_8, 8);
+ workbench_taa_jitter_init_order(e_data.jitter_11, 11);
workbench_taa_jitter_init_order(e_data.jitter_16, 16);
workbench_taa_jitter_init_order(e_data.jitter_32, 32);
}
@@ -169,8 +173,8 @@ DRWPass *workbench_taa_create_pass(WORKBENCH_Data *vedata, GPUTexture **color_bu
{
const eGPUTextureFormat hist_buffer_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_RGBA8;
- DRW_texture_ensure_fullscreen_2D(&txl->history_buffer_tx, hist_buffer_format, 0);
- DRW_texture_ensure_fullscreen_2D(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0);
+ DRW_texture_ensure_fullscreen_2d(&txl->history_buffer_tx, hist_buffer_format, 0);
+ DRW_texture_ensure_fullscreen_2d(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0);
}
{
@@ -212,9 +216,15 @@ void workbench_taa_draw_scene_start(WORKBENCH_Data *vedata)
num_samples = workbench_taa_calculate_num_iterations(vedata);
switch (num_samples) {
default:
+ case 5:
+ samples = e_data.jitter_5;
+ break;
case 8:
samples = e_data.jitter_8;
break;
+ case 11:
+ samples = e_data.jitter_11;
+ break;
case 16:
samples = e_data.jitter_16;
break;
@@ -225,10 +235,9 @@ void workbench_taa_draw_scene_start(WORKBENCH_Data *vedata)
mix_factor = 1.0f / (effect_info->jitter_index + 1);
- const int bitmask = num_samples - 1;
const int jitter_index = effect_info->jitter_index;
const float *transform_offset = samples[jitter_index];
- effect_info->jitter_index = (jitter_index + 1) & bitmask;
+ effect_info->jitter_index = (jitter_index + 1) % num_samples;
/* construct new matrices from transform delta */
float viewmat[4][4];
diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c
index ef9e1682a8b..45f1c632a05 100644
--- a/source/blender/draw/engines/workbench/workbench_forward.c
+++ b/source/blender/draw/engines/workbench/workbench_forward.c
@@ -44,12 +44,18 @@
/* *********** STATIC *********** */
-static struct {
- struct GPUShader *composite_sh_cache[2];
+
+typedef struct WORKBENCH_FORWARD_Shaders {
struct GPUShader *transparent_accum_sh_cache[MAX_ACCUM_SHADERS];
struct GPUShader *object_outline_sh;
struct GPUShader *object_outline_texture_sh;
struct GPUShader *object_outline_hair_sh;
+} WORKBENCH_FORWARD_Shaders;
+
+static struct {
+ WORKBENCH_FORWARD_Shaders sh_data[GPU_SHADER_CFG_LEN];
+
+ struct GPUShader *composite_sh_cache[2];
struct GPUShader *checker_depth_sh;
struct GPUTexture *object_id_tx; /* ref only, not alloced */
@@ -58,10 +64,9 @@ static struct {
struct GPUTexture *composite_buffer_tx; /* ref only, not alloced */
int next_object_id;
-} e_data = {{NULL}};
+} e_data = {{{{NULL}}}};
/* Shaders */
-extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[];
extern char datatoc_common_hair_lib_glsl[];
extern char datatoc_workbench_forward_composite_frag_glsl[];
@@ -79,28 +84,19 @@ extern char datatoc_workbench_world_light_lib_glsl[];
/* static functions */
static char *workbench_build_forward_vert(bool is_hair)
{
- char *str = NULL;
- if (!is_hair) {
- return BLI_string_joinN(
- datatoc_gpu_shader_cfg_world_clip_lib_glsl,
- datatoc_workbench_prepass_vert_glsl);
- }
-
DynStr *ds = BLI_dynstr_new();
-
- BLI_dynstr_append(ds, datatoc_common_hair_lib_glsl);
- BLI_dynstr_append(ds, datatoc_gpu_shader_cfg_world_clip_lib_glsl);
+ if (is_hair) {
+ BLI_dynstr_append(ds, datatoc_common_hair_lib_glsl);
+ }
BLI_dynstr_append(ds, datatoc_workbench_prepass_vert_glsl);
- str = BLI_dynstr_get_cstring(ds);
+ char *str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
}
static char *workbench_build_forward_transparent_accum_frag(void)
{
- char *str = NULL;
-
DynStr *ds = BLI_dynstr_new();
BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl);
@@ -108,15 +104,13 @@ static char *workbench_build_forward_transparent_accum_frag(void)
BLI_dynstr_append(ds, datatoc_workbench_world_light_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_forward_transparent_accum_frag_glsl);
- str = BLI_dynstr_get_cstring(ds);
+ char *str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
}
static char *workbench_build_forward_composite_frag(void)
{
- char *str = NULL;
-
DynStr *ds = BLI_dynstr_new();
BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl);
@@ -126,7 +120,7 @@ static char *workbench_build_forward_composite_frag(void)
BLI_dynstr_append(ds, datatoc_workbench_curvature_lib_glsl);
BLI_dynstr_append(ds, datatoc_workbench_forward_composite_frag_glsl);
- str = BLI_dynstr_get_cstring(ds);
+ char *str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;
}
@@ -138,8 +132,10 @@ static void workbench_init_object_data(DrawData *dd)
}
WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(
- WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type, int interp)
+ WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, ImageUser *iuser, int color_type, int interp)
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ WORKBENCH_FORWARD_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
WORKBENCH_StorageList *stl = vedata->stl;
WORKBENCH_PassList *psl = vedata->psl;
WORKBENCH_PrivateData *wpd = stl->g_data;
@@ -154,6 +150,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(
material_template.object_id = OBJECT_ID_PASS_ENABLED(wpd) ? engine_object_data->object_id : 1;
material_template.color_type = color_type;
material_template.ima = ima;
+ material_template.iuser = iuser;
material_template.interp = interp;
uint hash = workbench_material_get_hash(&material_template, false);
@@ -188,41 +185,44 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(
/* Depth */
if (workbench_material_determine_color_type(wpd, material->ima, ob) == V3D_SHADING_TEXTURE_COLOR) {
material->shgrp_object_outline = DRW_shgroup_create(
- e_data.object_outline_texture_sh, psl->object_outline_pass);
- GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false);
+ sh_data->object_outline_texture_sh, psl->object_outline_pass);
+ GPUTexture *tex = GPU_texture_from_blender(material->ima, material->iuser, GL_TEXTURE_2D, false);
DRW_shgroup_uniform_texture(material->shgrp_object_outline, "image", tex);
}
else {
material->shgrp_object_outline = DRW_shgroup_create(
- e_data.object_outline_sh, psl->object_outline_pass);
+ sh_data->object_outline_sh, psl->object_outline_pass);
}
material->object_id = engine_object_data->object_id;
DRW_shgroup_uniform_int(material->shgrp_object_outline, "object_id", &material->object_id, 1);
- if (wpd->world_clip_planes) {
- const DRWContextState *draw_ctx = DRW_context_state_get();
- RegionView3D *rv3d = draw_ctx->rv3d;
- DRW_shgroup_world_clip_planes_from_rv3d(material->shgrp_object_outline, rv3d);
+ if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
+ DRW_shgroup_world_clip_planes_from_rv3d(material->shgrp_object_outline, draw_ctx->rv3d);
}
BLI_ghash_insert(wpd->material_transp_hash, POINTER_FROM_UINT(hash), material);
}
return material;
}
-static GPUShader *ensure_forward_accum_shaders(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair)
+static GPUShader *ensure_forward_accum_shaders(
+ WORKBENCH_PrivateData *wpd, bool use_textures, 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);
- if (e_data.transparent_accum_sh_cache[index] == NULL) {
+ 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 *transparent_accum_vert = workbench_build_forward_vert(is_hair);
char *transparent_accum_frag = workbench_build_forward_transparent_accum_frag();
- e_data.transparent_accum_sh_cache[index] = DRW_shader_create(
- transparent_accum_vert, NULL,
- transparent_accum_frag, defines);
+ sh_data->transparent_accum_sh_cache[index] = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib, transparent_accum_vert, NULL},
+ .frag = (const char *[]){transparent_accum_frag, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, defines, NULL},
+ });
MEM_freeN(transparent_accum_vert);
MEM_freeN(transparent_accum_frag);
MEM_freeN(defines);
}
- return e_data.transparent_accum_sh_cache[index];
+ return sh_data->transparent_accum_sh_cache[index];
}
static GPUShader *ensure_forward_composite_shaders(WORKBENCH_PrivateData *wpd)
@@ -238,33 +238,42 @@ static GPUShader *ensure_forward_composite_shaders(WORKBENCH_PrivateData *wpd)
return e_data.composite_sh_cache[index];
}
-void workbench_forward_choose_shaders(WORKBENCH_PrivateData *wpd)
+void workbench_forward_choose_shaders(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg)
{
wpd->composite_sh = ensure_forward_composite_shaders(wpd);
- wpd->transparent_accum_sh = ensure_forward_accum_shaders(wpd, false, false);
- wpd->transparent_accum_hair_sh = ensure_forward_accum_shaders(wpd, false, true);
- wpd->transparent_accum_texture_sh = ensure_forward_accum_shaders(wpd, true, false);
- wpd->transparent_accum_texture_hair_sh = ensure_forward_accum_shaders(wpd, true, true);
+ 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);
}
-void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd)
+void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg)
{
- if (e_data.object_outline_sh == NULL) {
+ WORKBENCH_FORWARD_Shaders *sh_data = &e_data.sh_data[sh_cfg];
+
+ if (sh_data->object_outline_sh == NULL) {
+ const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
char *defines = workbench_material_build_defines(wpd, false, false);
char *defines_texture = workbench_material_build_defines(wpd, true, false);
char *defines_hair = workbench_material_build_defines(wpd, false, true);
char *forward_vert = workbench_build_forward_vert(false);
char *forward_hair_vert = workbench_build_forward_vert(true);
- e_data.object_outline_sh = DRW_shader_create(
- forward_vert, NULL,
- datatoc_workbench_forward_depth_frag_glsl, defines);
- e_data.object_outline_texture_sh = DRW_shader_create(
- forward_vert, NULL,
- datatoc_workbench_forward_depth_frag_glsl, defines_texture);
- e_data.object_outline_hair_sh = DRW_shader_create(
- forward_hair_vert, NULL,
- datatoc_workbench_forward_depth_frag_glsl, defines_hair);
+ sh_data->object_outline_sh = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib, forward_vert, NULL},
+ .frag = (const char *[]){datatoc_workbench_forward_depth_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, defines, NULL},
+ });
+ sh_data->object_outline_texture_sh = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib, forward_vert, NULL},
+ .frag = (const char *[]){datatoc_workbench_forward_depth_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, defines_texture, NULL},
+ });
+ sh_data->object_outline_hair_sh = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib, forward_hair_vert, NULL},
+ .frag = (const char *[]){datatoc_workbench_forward_depth_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, defines_hair, NULL},
+ });
MEM_freeN(forward_hair_vert);
MEM_freeN(forward_vert);
@@ -298,7 +307,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
workbench_private_data_get_light_direction(wpd, light_direction);
if (!e_data.checker_depth_sh) {
- workbench_forward_outline_shaders_ensure(wpd);
+ workbench_forward_outline_shaders_ensure(wpd, draw_ctx->sh_cfg);
e_data.checker_depth_sh = DRW_shader_create_fullscreen(
datatoc_workbench_checkerboard_depth_frag_glsl, NULL);
@@ -307,19 +316,20 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
workbench_fxaa_engine_init();
workbench_taa_engine_init(vedata);
- workbench_forward_choose_shaders(wpd);
+ workbench_forward_choose_shaders(wpd, draw_ctx->sh_cfg);
const float *viewport_size = DRW_viewport_size_get();
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
+ const eGPUTextureFormat comp_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_R11F_G11F_B10F;
- e_data.object_id_tx = DRW_texture_pool_query_2D(
+ e_data.object_id_tx = DRW_texture_pool_query_2d(
size[0], size[1], GPU_R32UI, &draw_engine_workbench_transparent);
- e_data.transparent_accum_tx = DRW_texture_pool_query_2D(
+ e_data.transparent_accum_tx = DRW_texture_pool_query_2d(
size[0], size[1], GPU_RGBA16F, &draw_engine_workbench_transparent);
- e_data.transparent_revealage_tx = DRW_texture_pool_query_2D(
+ e_data.transparent_revealage_tx = DRW_texture_pool_query_2d(
size[0], size[1], GPU_R16F, &draw_engine_workbench_transparent);
- e_data.composite_buffer_tx = DRW_texture_pool_query_2D(
- size[0], size[1], GPU_R11F_G11F_B10F, &draw_engine_workbench_transparent);
+ e_data.composite_buffer_tx = DRW_texture_pool_query_2d(
+ size[0], size[1], comp_tex_format, &draw_engine_workbench_transparent);
GPU_framebuffer_ensure_config(&fbl->object_outline_fb, {
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
@@ -369,8 +379,9 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
- /* TODO(campbell): displays but masks geometry, only use with wire for now. */
- if ((wpd->shading.type == OB_WIRE) &&
+ /* TODO(campbell): displays but masks geometry,
+ * only use with wire or solid-without-xray for now. */
+ if (((wpd->shading.type != OB_WIRE && XRAY_FLAG(wpd) == 0)) &&
(draw_ctx->rv3d && (draw_ctx->rv3d->rflag & RV3D_CLIPPING) && draw_ctx->rv3d->clipbb))
{
psl->background_pass = DRW_pass_create(
@@ -416,15 +427,19 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
void workbench_forward_engine_free()
{
+ for (int sh_data_index = 0; sh_data_index < ARRAY_SIZE(e_data.sh_data); sh_data_index++) {
+ WORKBENCH_FORWARD_Shaders *sh_data = &e_data.sh_data[sh_data_index];
+ for (int index = 0; index < MAX_ACCUM_SHADERS; index++) {
+ DRW_SHADER_FREE_SAFE(sh_data->transparent_accum_sh_cache[index]);
+ }
+ DRW_SHADER_FREE_SAFE(sh_data->object_outline_sh);
+ DRW_SHADER_FREE_SAFE(sh_data->object_outline_texture_sh);
+ DRW_SHADER_FREE_SAFE(sh_data->object_outline_hair_sh);
+ }
+
for (int index = 0; index < 2; index++) {
DRW_SHADER_FREE_SAFE(e_data.composite_sh_cache[index]);
}
- for (int index = 0; index < MAX_ACCUM_SHADERS; index++) {
- DRW_SHADER_FREE_SAFE(e_data.transparent_accum_sh_cache[index]);
- }
- DRW_SHADER_FREE_SAFE(e_data.object_outline_sh);
- DRW_SHADER_FREE_SAFE(e_data.object_outline_texture_sh);
- DRW_SHADER_FREE_SAFE(e_data.object_outline_hair_sh);
DRW_SHADER_FREE_SAFE(e_data.checker_depth_sh);
workbench_volume_engine_free();
@@ -448,9 +463,6 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O
continue;
}
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
- if (!psys_check_enabled(ob, psys, false)) {
- continue;
- }
if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
continue;
}
@@ -458,12 +470,14 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (draw_as == PART_DRAW_PATH) {
+ const DRWContextState *draw_ctx = DRW_context_state_get();
Material *mat;
Image *image;
+ ImageUser *iuser;
int interp;
- workbench_material_get_image_and_mat(ob, part->omat, &image, &interp, &mat);
+ workbench_material_get_image_and_mat(ob, part->omat, &image, &iuser, &interp, &mat);
int color_type = workbench_material_determine_color_type(wpd, image, ob);
- WORKBENCH_MaterialData *material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, color_type, interp);
+ WORKBENCH_MaterialData *material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, iuser, color_type, interp);
struct GPUShader *shader = (color_type != V3D_SHADING_TEXTURE_COLOR)
? wpd->transparent_accum_hair_sh
@@ -486,9 +500,12 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O
if (SPECULAR_HIGHLIGHT_ENABLED(wpd) || MATCAP_ENABLED(wpd)) {
DRW_shgroup_uniform_vec2(shgrp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
}
- shgrp = DRW_shgroup_hair_create(ob, psys, md,
- vedata->psl->object_outline_pass,
- e_data.object_outline_hair_sh);
+
+ WORKBENCH_FORWARD_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
+ shgrp = DRW_shgroup_hair_create(
+ ob, psys, md,
+ vedata->psl->object_outline_pass,
+ sh_data->object_outline_hair_sh);
DRW_shgroup_uniform_int(shgrp, "object_id", &material->object_id, 1);
}
}
@@ -541,10 +558,11 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
for (int i = 0; i < materials_len; i++) {
Material *mat;
Image *image;
+ ImageUser *iuser;
int interp;
- workbench_material_get_image_and_mat(ob, i + 1, &image, &interp, &mat);
+ workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat);
int color_type = workbench_material_determine_color_type(wpd, image, ob);
- material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, color_type, interp);
+ material = workbench_forward_get_or_create_material_data(vedata, ob, mat, image, iuser, color_type, interp);
DRW_shgroup_call_object_add(material->shgrp_object_outline, geom_array[i], ob);
DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob);
}
@@ -560,7 +578,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
/* No material split needed */
struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
- material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0);
+ material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, NULL, wpd->shading.color_type, 0);
if (is_sculpt_mode) {
DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat);
if (!is_wire) {
@@ -591,7 +609,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, V3D_SHADING_MATERIAL_COLOR, 0);
+ material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
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 e721a4ccdb8..2cec691a62f 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -92,46 +92,43 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_text
DynStr *ds = BLI_dynstr_new();
if (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE) {
- BLI_dynstr_appendf(ds, "#define V3D_SHADING_OBJECT_OUTLINE\n");
+ BLI_dynstr_append(ds, "#define V3D_SHADING_OBJECT_OUTLINE\n");
}
if (wpd->shading.flag & V3D_SHADING_SHADOW) {
- BLI_dynstr_appendf(ds, "#define V3D_SHADING_SHADOW\n");
+ BLI_dynstr_append(ds, "#define V3D_SHADING_SHADOW\n");
}
if (SSAO_ENABLED(wpd) || CURVATURE_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define WB_CAVITY\n");
+ BLI_dynstr_append(ds, "#define WB_CAVITY\n");
}
if (SPECULAR_HIGHLIGHT_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define V3D_SHADING_SPECULAR_HIGHLIGHT\n");
+ BLI_dynstr_append(ds, "#define V3D_SHADING_SPECULAR_HIGHLIGHT\n");
}
if (STUDIOLIGHT_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define V3D_LIGHTING_STUDIO\n");
+ BLI_dynstr_append(ds, "#define V3D_LIGHTING_STUDIO\n");
}
if (FLAT_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define V3D_LIGHTING_FLAT\n");
+ BLI_dynstr_append(ds, "#define V3D_LIGHTING_FLAT\n");
}
if (MATCAP_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define V3D_LIGHTING_MATCAP\n");
+ BLI_dynstr_append(ds, "#define V3D_LIGHTING_MATCAP\n");
}
if (OBJECT_ID_PASS_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define OBJECT_ID_PASS_ENABLED\n");
+ BLI_dynstr_append(ds, "#define OBJECT_ID_PASS_ENABLED\n");
}
if (MATDATA_PASS_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define MATDATA_PASS_ENABLED\n");
+ BLI_dynstr_append(ds, "#define MATDATA_PASS_ENABLED\n");
}
if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
- BLI_dynstr_appendf(ds, "#define NORMAL_VIEWPORT_PASS_ENABLED\n");
+ BLI_dynstr_append(ds, "#define NORMAL_VIEWPORT_PASS_ENABLED\n");
}
if (use_textures) {
- BLI_dynstr_appendf(ds, "#define V3D_SHADING_TEXTURE_COLOR\n");
+ BLI_dynstr_append(ds, "#define V3D_SHADING_TEXTURE_COLOR\n");
}
if (NORMAL_ENCODING_ENABLED()) {
- BLI_dynstr_appendf(ds, "#define WORKBENCH_ENCODE_NORMALS\n");
+ BLI_dynstr_append(ds, "#define WORKBENCH_ENCODE_NORMALS\n");
}
if (is_hair) {
- BLI_dynstr_appendf(ds, "#define HAIR_SHADER\n");
- }
- if (wpd->world_clip_planes != NULL) {
- BLI_dynstr_appendf(ds, "#define USE_WORLD_CLIP_PLANES\n");
+ BLI_dynstr_append(ds, "#define HAIR_SHADER\n");
}
str = BLI_dynstr_get_cstring(ds);
@@ -192,7 +189,6 @@ int workbench_material_get_prepass_shader_index(
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, wpd->world_clip_planes != NULL, 1 << 6);
BLI_assert(index < MAX_PREPASS_SHADERS);
return index;
}
@@ -220,11 +216,11 @@ int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *i
return color_type;
}
-void workbench_material_get_image_and_mat(Object *ob, int mat_nr, Image **r_image, int *r_interp, Material **r_mat)
+void workbench_material_get_image_and_mat(Object *ob, int mat_nr, Image **r_image, ImageUser **r_iuser, int *r_interp, Material **r_mat)
{
bNode *node;
*r_mat = give_current_material(ob, mat_nr);
- ED_object_get_active_image(ob, mat_nr, r_image, NULL, &node, NULL);
+ ED_object_get_active_image(ob, mat_nr, r_image, r_iuser, &node, NULL);
if (node && *r_image) {
switch (node->type) {
case SH_NODE_TEX_IMAGE:
@@ -258,11 +254,11 @@ void workbench_material_shgroup_uniform(
}
if (workbench_material_determine_color_type(wpd, material->ima, ob) == V3D_SHADING_TEXTURE_COLOR) {
- ImBuf *ibuf = BKE_image_acquire_ibuf(material->ima, NULL, NULL);
+ ImBuf *ibuf = BKE_image_acquire_ibuf(material->ima, material->iuser, NULL);
const bool do_color_correction = wpd->use_color_management &&
(ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0);
BKE_image_release_ibuf(material->ima, ibuf, NULL);
- GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false);
+ GPUTexture *tex = GPU_texture_from_blender(material->ima, material->iuser, GL_TEXTURE_2D, false);
DRW_shgroup_uniform_texture(grp, "image", tex);
DRW_shgroup_uniform_bool_copy(grp, "imageSrgb", do_color_correction);
DRW_shgroup_uniform_bool_copy(grp, "imageNearest", (interp == SHD_INTERP_CLOSEST));
@@ -281,7 +277,7 @@ void workbench_material_shgroup_uniform(
DRW_shgroup_uniform_float(grp, "materialRoughness", &material->roughness, 1);
}
- if (wpd->world_clip_planes != NULL) {
+ if (WORLD_CLIPPING_ENABLED(wpd)) {
DRW_shgroup_uniform_vec4(grp, "WorldClipPlanes", wpd->world_clip_planes[0], 6);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
@@ -296,4 +292,5 @@ void workbench_material_copy(WORKBENCH_MaterialData *dest_material, const WORKBE
dest_material->metallic = source_material->metallic;
dest_material->roughness = source_material->roughness;
dest_material->ima = source_material->ima;
+ dest_material->iuser = source_material->iuser;
}
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index da6df4c93bd..75d72933c8e 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -38,7 +38,7 @@
#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
#define M_GOLDEN_RATION_CONJUGATE 0.618033988749895
#define MAX_COMPOSITE_SHADERS (1 << 6)
-#define MAX_PREPASS_SHADERS (1 << 7)
+#define MAX_PREPASS_SHADERS (1 << 6)
#define MAX_ACCUM_SHADERS (1 << 5)
#define MAX_CAVITY_SHADERS (1 << 3)
@@ -56,13 +56,14 @@
#define SHADOW_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_SHADOW)
#define GHOST_ENABLED(psl) (!DRW_pass_is_empty(psl->ghost_prepass_pass) || !DRW_pass_is_empty(psl->ghost_prepass_hair_pass))
#define CULL_BACKFACE_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_BACKFACE_CULLING) != 0)
-#define OIT_ENABLED(wpd) (ELEM(wpd->shading.color_type, V3D_SHADING_MATERIAL_COLOR, V3D_SHADING_OBJECT_COLOR))
+#define OIT_ENABLED(wpd) (ELEM(wpd->shading.color_type, V3D_SHADING_MATERIAL_COLOR, V3D_SHADING_OBJECT_COLOR, V3D_SHADING_TEXTURE_COLOR))
#define IS_NAVIGATING(wpd) ((DRW_context_state_get()->rv3d) && (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING))
#define FXAA_ENABLED(wpd) ((!DRW_state_is_opengl_render()) && \
(IN_RANGE(wpd->preferences->gpu_viewport_quality, GPU_VIEWPORT_QUALITY_FXAA, GPU_VIEWPORT_QUALITY_TAA8) || \
((IS_NAVIGATING(wpd) || wpd->is_playback) && (wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8))))
-#define TAA_ENABLED(wpd) (DRW_state_is_image_render() || (wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 && !IS_NAVIGATING(wpd) && !wpd->is_playback))
+#define TAA_ENABLED(wpd) ((DRW_state_is_image_render() && DRW_context_state_get()->scene->r.mode & R_OSA) || \
+ (!DRW_state_is_image_render() && wpd->preferences->gpu_viewport_quality >= GPU_VIEWPORT_QUALITY_TAA8 && !IS_NAVIGATING(wpd) && !wpd->is_playback))
#define SPECULAR_HIGHLIGHT_ENABLED(wpd) (STUDIOLIGHT_ENABLED(wpd) && (wpd->shading.flag & V3D_SHADING_SPECULAR_HIGHLIGHT) && (!STUDIOLIGHT_TYPE_MATCAP_ENABLED(wpd)))
#define OBJECT_OUTLINE_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE)
#define OBJECT_ID_PASS_ENABLED(wpd) (OBJECT_OUTLINE_ENABLED(wpd) || CURVATURE_ENABLED(wpd))
@@ -70,6 +71,7 @@
#define NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) (MATCAP_ENABLED(wpd) || STUDIOLIGHT_ENABLED(wpd) || SHADOW_ENABLED(wpd))
#define NORMAL_VIEWPORT_PASS_ENABLED(wpd) (NORMAL_VIEWPORT_COMP_PASS_ENABLED(wpd) || SSAO_ENABLED(wpd) || CURVATURE_ENABLED(wpd))
#define NORMAL_ENCODING_ENABLED() (true)
+#define WORLD_CLIPPING_ENABLED(wpd) (wpd->world_clip_planes != NULL)
struct RenderEngine;
@@ -278,6 +280,7 @@ typedef struct WORKBENCH_MaterialData {
int color_type;
int interp;
Image *ima;
+ ImageUser *iuser;
/* Linked shgroup for drawing */
DRWShadingGroup *shgrp;
@@ -319,10 +322,10 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob);
void workbench_forward_cache_finish(WORKBENCH_Data *vedata);
/* For OIT in deferred */
-void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd);
-void workbench_forward_choose_shaders(WORKBENCH_PrivateData *wpd);
+void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg);
+void workbench_forward_choose_shaders(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg);
WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(
- WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, int color_type, int interp);
+ WORKBENCH_Data *vedata, Object *ob, Material *mat, Image *ima, ImageUser *iuser, int color_type, int interp);
/* workbench_effect_aa.c */
void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx);
@@ -350,7 +353,7 @@ void workbench_dof_draw_pass(WORKBENCH_Data *vedata);
/* workbench_materials.c */
int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima, Object *ob);
-void workbench_material_get_image_and_mat(Object *ob, int mat_nr, Image **r_image, int *r_interp, Material **r_mat);
+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_hair);
void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, WORKBENCH_MaterialData *data);
uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template, bool is_ghost);
diff --git a/source/blender/draw/engines/workbench/workbench_render.c b/source/blender/draw/engines/workbench/workbench_render.c
index 528b4b6b815..c551a369b58 100644
--- a/source/blender/draw/engines/workbench/workbench_render.c
+++ b/source/blender/draw/engines/workbench/workbench_render.c
@@ -86,8 +86,8 @@ static bool workbench_render_framebuffers_init(void)
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
- dtxl->color = GPU_texture_create_2D(size[0], size[1], GPU_RGBA8, NULL, NULL);
- dtxl->depth = GPU_texture_create_2D(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL);
+ dtxl->color = GPU_texture_create_2d(size[0], size[1], GPU_RGBA16F, NULL, NULL);
+ dtxl->depth = GPU_texture_create_2d(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL);
if (!(dtxl->depth && dtxl->color)) {
return false;
@@ -124,6 +124,7 @@ static void workbench_render_framebuffers_finish(void)
void workbench_render(WORKBENCH_Data *data, RenderEngine *engine, RenderLayer *render_layer, const rcti *rect)
{
+ DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
const DRWContextState *draw_ctx = DRW_context_state_get();
const Scene *scene = draw_ctx->scene;
Depsgraph *depsgraph = draw_ctx->depsgraph;
@@ -146,6 +147,10 @@ void workbench_render(WORKBENCH_Data *data, RenderEngine *engine, RenderLayer *r
workbench_deferred_cache_finish(data);
DRW_render_instance_buffer_finish();
+ /* Also we weed to have a correct fbo bound for DRW_hair_update */
+ GPU_framebuffer_bind(dfbl->color_only_fb);
+ DRW_hair_update();
+
/* Draw. */
int num_samples = workbench_taa_calculate_num_iterations(data);
for (int sample = 0; sample < num_samples; sample++) {
@@ -171,6 +176,10 @@ void workbench_render(WORKBENCH_Data *data, RenderEngine *engine, RenderLayer *r
workbench_forward_cache_finish(data);
DRW_render_instance_buffer_finish();
+ /* Also we weed to have a correct fbo bound for DRW_hair_update */
+ GPU_framebuffer_bind(dfbl->color_only_fb);
+ DRW_hair_update();
+
/* Draw. */
int num_samples = workbench_taa_calculate_num_iterations(data);
for (int sample = 0; sample < num_samples; sample++) {
@@ -189,7 +198,6 @@ void workbench_render(WORKBENCH_Data *data, RenderEngine *engine, RenderLayer *r
const char *viewname = RE_GetActiveRenderView(engine->re);
RenderPass *rp = RE_pass_find_by_name(render_layer, RE_PASSNAME_COMBINED, viewname);
- DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
GPU_framebuffer_bind(dfbl->color_only_fb);
GPU_framebuffer_read_color(dfbl->color_only_fb,
rect->xmin, rect->ymin,
diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c
index 0890f50c0df..f382ad31752 100644
--- a/source/blender/draw/engines/workbench/workbench_studiolight.c
+++ b/source/blender/draw/engines/workbench/workbench_studiolight.c
@@ -276,8 +276,8 @@ bool studiolight_camera_in_object_shadow(WORKBENCH_PrivateData *wpd, Object *ob,
for (int j = 0; j < 4; ++j) {
float dst = dot_v2v2(wpd->shadow_near_sides[i], pts[j]);
/* Do min max */
- if (min_dst > dst) min_dst = dst;
- if (max_dst < dst) max_dst = dst;
+ if (min_dst > dst) { min_dst = dst; }
+ if (max_dst < dst) { max_dst = dst; }
}
if ((wpd->shadow_near_sides[i][2] > max_dst) ||
diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c
index fa5ed3408d6..0f5debc46d8 100644
--- a/source/blender/draw/engines/workbench/workbench_volume.c
+++ b/source/blender/draw/engines/workbench/workbench_volume.c
@@ -92,8 +92,8 @@ void workbench_volume_engine_init(void)
{
if (!e_data.dummy_tex) {
float pixel[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- e_data.dummy_tex = GPU_texture_create_3D(1, 1, 1, GPU_RGBA8, pixel, NULL);
- e_data.dummy_coba_tex = GPU_texture_create_1D(1, GPU_RGBA8, pixel, NULL);
+ e_data.dummy_tex = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, pixel, NULL);
+ e_data.dummy_coba_tex = GPU_texture_create_1d(1, GPU_RGBA8, pixel, NULL);
}
}
@@ -168,7 +168,7 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Objec
}
else {
double noise_ofs;
- BLI_halton_1D(3, 0.0, effect_info->jitter_index, &noise_ofs);
+ BLI_halton_1d(3, 0.0, effect_info->jitter_index, &noise_ofs);
float dim[3], step_length, max_slice;
float slice_ct[3] = {sds->res[0], sds->res[1], sds->res[2]};
mul_v3_fl(slice_ct, max_ff(0.001f, sds->slice_per_voxel));
@@ -191,10 +191,14 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Objec
DRW_shgroup_uniform_texture(grp, "transferTexture", sds->tex_coba);
}
else {
+ static float white[3] = {1.0f, 1.0f, 1.0f};
+ bool use_constant_color = ((sds->active_fields & SM_ACTIVE_COLORS) == 0 &&
+ (sds->active_fields & SM_ACTIVE_COLOR_SET) != 0);
DRW_shgroup_uniform_texture(grp, "densityTexture", sds->tex);
DRW_shgroup_uniform_texture(grp, "shadowTexture", sds->tex_shadow);
DRW_shgroup_uniform_texture(grp, "flameTexture", (sds->tex_flame) ? sds->tex_flame : e_data.dummy_tex);
DRW_shgroup_uniform_texture(grp, "flameColorTexture", (sds->tex_flame) ? sds->tex_flame_coba : e_data.dummy_coba_tex);
+ DRW_shgroup_uniform_vec3(grp, "activeColor", (use_constant_color) ? sds->active_color : white, 1);
}
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
DRW_shgroup_uniform_float_copy(grp, "densityScale", 10.0f * sds->display_thickness);
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 153ec834e20..2e4df05e195 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -120,7 +120,7 @@ typedef char DRWViewportEmptyList;
DRW_multisamples_resolve(dtxl->multisample_depth, dtxl->multisample_color, true); \
DRW_stats_query_end(); \
} \
-}
+} ((void)0)
#define MULTISAMPLE_SYNC_DISABLE_NO_DEPTH(dfbl, dtxl) { \
if (dfbl->multisample_fb != NULL) { \
@@ -129,7 +129,7 @@ typedef char DRWViewportEmptyList;
DRW_multisamples_resolve(dtxl->multisample_depth, dtxl->multisample_color, false); \
DRW_stats_query_end(); \
} \
-}
+} ((void)0)
@@ -194,22 +194,22 @@ typedef enum {
/* Textures from DRW_texture_pool_query_* have the options
* DRW_TEX_FILTER for color float textures, and no options
* for depth textures and integer textures. */
-struct GPUTexture *DRW_texture_pool_query_2D(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type);
+struct GPUTexture *DRW_texture_pool_query_2d(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type);
-struct GPUTexture *DRW_texture_create_1D(
+struct GPUTexture *DRW_texture_create_1d(
int w, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
-struct GPUTexture *DRW_texture_create_2D(
+struct GPUTexture *DRW_texture_create_2d(
int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
-struct GPUTexture *DRW_texture_create_2D_array(
+struct GPUTexture *DRW_texture_create_2d_array(
int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
-struct GPUTexture *DRW_texture_create_3D(
+struct GPUTexture *DRW_texture_create_3d(
int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
struct GPUTexture *DRW_texture_create_cube(
int w, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
-void DRW_texture_ensure_fullscreen_2D(
+void DRW_texture_ensure_fullscreen_2d(
struct GPUTexture **tex, eGPUTextureFormat format, DRWTextureFlag flags);
-void DRW_texture_ensure_2D(
+void DRW_texture_ensure_2d(
struct GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags);
void DRW_texture_ensure_fullscreen_2D_multisample(
@@ -250,10 +250,10 @@ struct GPUShader *DRW_shader_create_with_lib(
struct GPUShader *DRW_shader_create_with_transform_feedback(
const char *vert, const char *geom, const char *defines,
const eGPUShaderTFBType prim_type, const char **varying_names, const int varying_count);
-struct GPUShader *DRW_shader_create_2D(const char *frag, const char *defines);
-struct GPUShader *DRW_shader_create_3D(const char *frag, const char *defines);
+struct GPUShader *DRW_shader_create_2d(const char *frag, const char *defines);
+struct GPUShader *DRW_shader_create_3d(const char *frag, const char *defines);
struct GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines);
-struct GPUShader *DRW_shader_create_3D_depth_only(eGPUShaderConfig slot);
+struct GPUShader *DRW_shader_create_3d_depth_only(eGPUShaderConfig slot);
struct GPUMaterial *DRW_shader_find_from_world(struct World *wo, const void *engine_type, int options, bool deferred);
struct GPUMaterial *DRW_shader_find_from_material(struct Material *ma, const void *engine_type, int options, bool deferred);
struct GPUMaterial *DRW_shader_create_from_world(
diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c
index 09625b9b47e..03566de01d2 100644
--- a/source/blender/draw/intern/draw_anim_viz.c
+++ b/source/blender/draw/intern/draw_anim_viz.c
@@ -309,7 +309,7 @@ static void MPATH_draw_scene(void *vedata)
DRW_draw_pass(psl->lines);
DRW_draw_pass(psl->points);
- MULTISAMPLE_SYNC_DISABLE_NO_DEPTH(dfbl, dtxl)
+ MULTISAMPLE_SYNC_DISABLE_NO_DEPTH(dfbl, dtxl);
}
/* *************************** Draw Engine Defines ****************************** */
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 2ee4ca1a4d8..76a48260fc2 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -207,11 +207,12 @@ static void drw_shgroup_bone_stick(
/* Envelope */
static void drw_shgroup_bone_envelope_distance(
const float (*bone_mat)[4],
- const float *radius_head, const float *radius_tail, const float *distance)
+ const float *radius_head, const float *radius_tail, const float *distance,
+ const eGPUShaderConfig sh_cfg)
{
if (g_data.passes.bone_envelope != NULL) {
if (g_data.bone_envelope_distance == NULL) {
- g_data.bone_envelope_distance = shgroup_instance_bone_envelope_distance(g_data.passes.bone_envelope);
+ g_data.bone_envelope_distance = shgroup_instance_bone_envelope_distance(g_data.passes.bone_envelope, sh_cfg);
/* passes.bone_envelope should have the DRW_STATE_CULL_FRONT state enabled. */
}
float head_sphere[4] = {0.0f, 0.0f, 0.0f, 1.0f}, tail_sphere[4] = {0.0f, 1.0f, 0.0f, 1.0f};
@@ -244,12 +245,12 @@ static void drw_shgroup_bone_envelope(
g_data.bone_point_solid = shgroup_instance_bone_sphere_solid(g_data.passes.bone_solid, g_data.transparent, sh_cfg);
}
if (g_data.bone_envelope_wire == NULL) {
- g_data.bone_envelope_wire = shgroup_instance_bone_envelope_outline(g_data.passes.bone_wire);
+ g_data.bone_envelope_wire = shgroup_instance_bone_envelope_outline(g_data.passes.bone_wire, sh_cfg);
}
if (g_data.bone_envelope_solid == NULL &&
g_data.passes.bone_solid != NULL)
{
- g_data.bone_envelope_solid = shgroup_instance_bone_envelope_solid(g_data.passes.bone_solid, g_data.transparent);
+ g_data.bone_envelope_solid = shgroup_instance_bone_envelope_solid(g_data.passes.bone_solid, g_data.transparent, sh_cfg);
/* We can have a lot of overdraw if we don't do this. Also envelope are not subject to
* inverted matrix. */
DRW_shgroup_state_enable(g_data.bone_envelope_solid, DRW_STATE_CULL_BACK);
@@ -416,10 +417,12 @@ static void drw_shgroup_bone_point(
}
/* Axes */
-static void drw_shgroup_bone_axes(const float (*bone_mat)[4], const float color[4])
+static void drw_shgroup_bone_axes(
+ const float (*bone_mat)[4], const float color[4],
+ const eGPUShaderConfig sh_cfg)
{
if (g_data.bone_axes == NULL) {
- g_data.bone_axes = shgroup_instance_bone_axes(g_data.passes.bone_axes);
+ g_data.bone_axes = shgroup_instance_bone_axes(g_data.passes.bone_axes, sh_cfg);
}
float final_bonemat[4][4];
mul_m4_m4m4(final_bonemat, g_data.ob->obmat, bone_mat);
@@ -427,11 +430,11 @@ static void drw_shgroup_bone_axes(const float (*bone_mat)[4], const float color[
}
/* Relationship lines */
-static void drw_shgroup_bone_relationship_lines(const float start[3], const float end[3])
+static void drw_shgroup_bone_relationship_lines(const float start[3], const float end[3], const eGPUShaderConfig sh_cfg)
{
if (g_data.lines_relationship == NULL) {
g_data.lines_relationship = shgroup_dynlines_dashed_uniform_color(
- g_data.passes.relationship_lines, g_theme.wire_color);
+ g_data.passes.relationship_lines, g_theme.wire_color, sh_cfg);
}
/* reverse order to have less stipple overlap */
float v[3];
@@ -441,11 +444,11 @@ static void drw_shgroup_bone_relationship_lines(const float start[3], const floa
DRW_shgroup_call_dynamic_add(g_data.lines_relationship, v);
}
-static void drw_shgroup_bone_ik_lines(const float start[3], const float end[3])
+static void drw_shgroup_bone_ik_lines(const float start[3], const float end[3], const eGPUShaderConfig sh_cfg)
{
if (g_data.lines_ik == NULL) {
static float fcolor[4] = {0.8f, 0.5f, 0.0f, 1.0f}; /* add theme! */
- g_data.lines_ik = shgroup_dynlines_dashed_uniform_color(g_data.passes.relationship_lines, fcolor);
+ g_data.lines_ik = shgroup_dynlines_dashed_uniform_color(g_data.passes.relationship_lines, fcolor, sh_cfg);
}
/* reverse order to have less stipple overlap */
float v[3];
@@ -455,11 +458,11 @@ static void drw_shgroup_bone_ik_lines(const float start[3], const float end[3])
DRW_shgroup_call_dynamic_add(g_data.lines_ik, v);
}
-static void drw_shgroup_bone_ik_no_target_lines(const float start[3], const float end[3])
+static void drw_shgroup_bone_ik_no_target_lines(const float start[3], const float end[3], const eGPUShaderConfig sh_cfg)
{
if (g_data.lines_ik_no_target == NULL) {
static float fcolor[4] = {0.8f, 0.8f, 0.2f, 1.0f}; /* add theme! */
- g_data.lines_ik_no_target = shgroup_dynlines_dashed_uniform_color(g_data.passes.relationship_lines, fcolor);
+ g_data.lines_ik_no_target = shgroup_dynlines_dashed_uniform_color(g_data.passes.relationship_lines, fcolor, sh_cfg);
}
/* reverse order to have less stipple overlap */
float v[3];
@@ -469,11 +472,11 @@ static void drw_shgroup_bone_ik_no_target_lines(const float start[3], const floa
DRW_shgroup_call_dynamic_add(g_data.lines_ik_no_target, v);
}
-static void drw_shgroup_bone_ik_spline_lines(const float start[3], const float end[3])
+static void drw_shgroup_bone_ik_spline_lines(const float start[3], const float end[3], const eGPUShaderConfig sh_cfg)
{
if (g_data.lines_ik_spline == NULL) {
static float fcolor[4] = {0.8f, 0.8f, 0.2f, 1.0f}; /* add theme! */
- g_data.lines_ik_spline = shgroup_dynlines_dashed_uniform_color(g_data.passes.relationship_lines, fcolor);
+ g_data.lines_ik_spline = shgroup_dynlines_dashed_uniform_color(g_data.passes.relationship_lines, fcolor, sh_cfg);
}
/* reverse order to have less stipple overlap */
float v[3];
@@ -640,10 +643,10 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
{
if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) {
uchar cp[4];
- if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 80);
- else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 80);
- else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 80);
- else if (constflag & PCHAN_HAS_CONST) rgba_char_args_set((char *)cp, 0, 255, 120, 80);
+ if (constflag & PCHAN_HAS_TARGET) { rgba_char_args_set((char *)cp, 255, 150, 0, 80); }
+ else if (constflag & PCHAN_HAS_IK) { rgba_char_args_set((char *)cp, 255, 255, 0, 80); }
+ else if (constflag & PCHAN_HAS_SPLINEIK) { rgba_char_args_set((char *)cp, 200, 255, 0, 80); }
+ else if (constflag & PCHAN_HAS_CONST) { rgba_char_args_set((char *)cp, 0, 255, 120, 80); }
else {
return false;
}
@@ -723,11 +726,11 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
/* inner part in background color or constraint */
if ((constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS))) {
uchar cp[4];
- if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 255);
- else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 255);
- else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 255);
- else if (constflag & PCHAN_HAS_CONST) rgba_char_args_set((char *)cp, 0, 255, 120, 255);
- else if (constflag) UI_GetThemeColor4ubv(TH_BONE_POSE, cp); /* PCHAN_HAS_ACTION */
+ if (constflag & PCHAN_HAS_TARGET) { rgba_char_args_set((char *)cp, 255, 150, 0, 255); }
+ else if (constflag & PCHAN_HAS_IK) { rgba_char_args_set((char *)cp, 255, 255, 0, 255); }
+ else if (constflag & PCHAN_HAS_SPLINEIK) { rgba_char_args_set((char *)cp, 200, 255, 0, 255); }
+ else if (constflag & PCHAN_HAS_CONST) { rgba_char_args_set((char *)cp, 0, 255, 120, 255); }
+ else if (constflag) { UI_GetThemeColor4ubv(TH_BONE_POSE, cp); } /* PCHAN_HAS_ACTION */
rgb_uchar_to_float(fcolor, cp);
}
@@ -1171,7 +1174,9 @@ static void draw_bone_update_disp_matrix_custom(bPoseChannel *pchan)
translate_m4(disp_tail_mat, 0.0f, 1.0f, 0.0f);
}
-static void draw_axes(EditBone *eBone, bPoseChannel *pchan)
+static void draw_axes(
+ EditBone *eBone, bPoseChannel *pchan,
+ const eGPUShaderConfig sh_cfg)
{
float final_col[4];
const float *col = (g_theme.const_color) ? g_theme.const_color :
@@ -1179,7 +1184,7 @@ static void draw_axes(EditBone *eBone, bPoseChannel *pchan)
copy_v4_v4(final_col, col);
/* Mix with axes color. */
final_col[3] = (g_theme.const_color) ? 1.0 : (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? 0.3 : 0.8;
- drw_shgroup_bone_axes(BONE_VAR(eBone, pchan, disp_mat), final_col);
+ drw_shgroup_bone_axes(BONE_VAR(eBone, pchan, disp_mat), final_col, sh_cfg);
}
static void draw_points(
@@ -1221,35 +1226,31 @@ static void draw_points(
bone_hint_color_shade(col_hint_root, (g_theme.const_color) ? col_solid_root : col_wire_root);
bone_hint_color_shade(col_hint_tail, (g_theme.const_color) ? col_solid_tail : col_wire_tail);
- /* Draw root point if we are not connected and parent are not hidden */
+ /* Draw root point if we are not connected to our parent */
if ((BONE_FLAG(eBone, pchan) & BONE_CONNECTED) == 0) {
if (select_id != -1) {
DRW_select_load_id(select_id | BONESEL_ROOT);
}
if (eBone) {
- if (!((eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent))) {
- if (is_envelope_draw) {
- drw_shgroup_bone_envelope(
- eBone->disp_mat, col_solid_root, col_hint_root, col_wire_root,
- &eBone->rad_head, &envelope_ignore, sh_cfg);
- }
- else {
- drw_shgroup_bone_point(eBone->disp_mat, col_solid_root, col_hint_root, col_wire_root, sh_cfg);
- }
+ if (is_envelope_draw) {
+ drw_shgroup_bone_envelope(
+ eBone->disp_mat, col_solid_root, col_hint_root, col_wire_root,
+ &eBone->rad_head, &envelope_ignore, sh_cfg);
+ }
+ else {
+ drw_shgroup_bone_point(eBone->disp_mat, col_solid_root, col_hint_root, col_wire_root, sh_cfg);
}
}
else {
Bone *bone = pchan->bone;
- if (!((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)))) {
- if (is_envelope_draw) {
- drw_shgroup_bone_envelope(
- pchan->disp_mat, col_solid_root, col_hint_root, col_wire_root,
- &bone->rad_head, &envelope_ignore, sh_cfg);
- }
- else {
- drw_shgroup_bone_point(pchan->disp_mat, col_solid_root, col_hint_root, col_wire_root, sh_cfg);
- }
+ if (is_envelope_draw) {
+ drw_shgroup_bone_envelope(
+ pchan->disp_mat, col_solid_root, col_hint_root, col_wire_root,
+ &bone->rad_head, &envelope_ignore, sh_cfg);
+ }
+ else {
+ drw_shgroup_bone_point(pchan->disp_mat, col_solid_root, col_hint_root, col_wire_root, sh_cfg);
}
}
}
@@ -1332,7 +1333,7 @@ static void draw_bone_envelope(
(boneflag & BONE_NO_DEFORM) == 0 &&
((boneflag & BONE_SELECTED) || (eBone && (boneflag & (BONE_ROOTSEL | BONE_TIPSEL)))))
{
- drw_shgroup_bone_envelope_distance(BONE_VAR(eBone, pchan, disp_mat), rad_head, rad_tail, distance);
+ drw_shgroup_bone_envelope_distance(BONE_VAR(eBone, pchan, disp_mat), rad_head, rad_tail, distance, sh_cfg);
}
if (select_id != -1) {
@@ -1371,16 +1372,13 @@ static void draw_bone_line(
col_wire = g_theme.wire_color;
}
- /* Draw root point if we are not connected and parent are not hidden */
+ /* Draw root point if we are not connected to our parent */
if ((BONE_FLAG(eBone, pchan) & BONE_CONNECTED) == 0) {
- if (eBone && !(eBone->parent && !EBONE_VISIBLE(arm, eBone->parent))) {
+ if (eBone) {
col_head = (eBone->flag & BONE_ROOTSEL) ? g_theme.vertex_select_color : col_bone;
}
else if (pchan) {
- Bone *bone = pchan->bone;
- if (!(bone->parent && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)))) {
- col_head = col_bone;
- }
+ col_head = col_bone;
}
}
@@ -1585,7 +1583,9 @@ static void draw_bone_dofs(bPoseChannel *pchan)
/** \name Draw Relationships
* \{ */
-static void pchan_draw_ik_lines(bPoseChannel *pchan, const bool only_temp, const int constflag)
+static void pchan_draw_ik_lines(
+ bPoseChannel *pchan, const bool only_temp, const int constflag,
+ const eGPUShaderConfig sh_cfg)
{
bConstraint *con;
bPoseChannel *parchan;
@@ -1624,10 +1624,10 @@ static void pchan_draw_ik_lines(bPoseChannel *pchan, const bool only_temp, const
line_end = parchan->pose_head;
if (constflag & PCHAN_HAS_TARGET) {
- drw_shgroup_bone_ik_lines(line_start, line_end);
+ drw_shgroup_bone_ik_lines(line_start, line_end, sh_cfg);
}
else {
- drw_shgroup_bone_ik_no_target_lines(line_start, line_end);
+ drw_shgroup_bone_ik_no_target_lines(line_start, line_end, sh_cfg);
}
}
break;
@@ -1649,13 +1649,15 @@ static void pchan_draw_ik_lines(bPoseChannel *pchan, const bool only_temp, const
while (parchan->parent) {
segcount++;
/* FIXME: revise the breaking conditions */
- if (segcount == data->chainlen || segcount > 255) break; /* 255 is weak */
+ if (segcount == data->chainlen || segcount > 255) {
+ break; /* 255 is weak */
+ }
parchan = parchan->parent;
}
/* Only draw line in case our chain is more than one bone long! */
if (parchan != pchan) { /* XXX revise the breaking conditions to only stop at the tail? */
line_end = parchan->pose_head;
- drw_shgroup_bone_ik_spline_lines(line_start, line_end);
+ drw_shgroup_bone_ik_spline_lines(line_start, line_end, sh_cfg);
}
break;
}
@@ -1665,7 +1667,8 @@ static void pchan_draw_ik_lines(bPoseChannel *pchan, const bool only_temp, const
static void draw_bone_relations(
EditBone *ebone, bPoseChannel *pchan, bArmature *arm,
- const int boneflag, const short constflag, const bool do_relations)
+ const int boneflag, const short constflag, const bool do_relations,
+ const eGPUShaderConfig sh_cfg)
{
if (g_data.passes.relationship_lines) {
if (ebone && ebone->parent) {
@@ -1674,7 +1677,7 @@ static void draw_bone_relations(
* since riggers will want to know about the links between bones
*/
if ((boneflag & BONE_CONNECTED) == 0) {
- drw_shgroup_bone_relationship_lines(ebone->head, ebone->parent->tail);
+ drw_shgroup_bone_relationship_lines(ebone->head, ebone->parent->tail, sh_cfg);
}
}
}
@@ -1685,7 +1688,7 @@ static void draw_bone_relations(
(pchan->parent->bone && (pchan->parent->bone->flag & BONE_SELECTED)))
{
if ((boneflag & BONE_CONNECTED) == 0) {
- drw_shgroup_bone_relationship_lines(pchan->pose_head, pchan->parent->pose_tail);
+ drw_shgroup_bone_relationship_lines(pchan->pose_head, pchan->parent->pose_tail, sh_cfg);
}
}
}
@@ -1694,7 +1697,7 @@ static void draw_bone_relations(
if (arm->flag & ARM_POSEMODE) {
if (constflag & (PCHAN_HAS_IK | PCHAN_HAS_SPLINEIK)) {
if (boneflag & BONE_SELECTED) {
- pchan_draw_ik_lines(pchan, !do_relations, constflag);
+ pchan_draw_ik_lines(pchan, !do_relations, constflag, sh_cfg);
}
}
}
@@ -1739,7 +1742,7 @@ static void draw_armature_edit(Object *ob)
boneflag |= BONE_DRAW_ACTIVE;
}
- draw_bone_relations(eBone, NULL, arm, boneflag, constflag, show_relations);
+ draw_bone_relations(eBone, NULL, arm, boneflag, constflag, show_relations, draw_ctx->sh_cfg);
if (arm->drawtype == ARM_ENVELOPE) {
draw_bone_update_disp_matrix_default(eBone, NULL);
@@ -1779,7 +1782,7 @@ static void draw_armature_edit(Object *ob)
/* Draw additional axes */
if (arm->flag & ARM_DRAWAXES) {
- draw_axes(eBone, NULL);
+ draw_axes(eBone, NULL, draw_ctx->sh_cfg);
}
}
}
@@ -1850,7 +1853,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
boneflag |= BONE_DRAW_ACTIVE;
}
- draw_bone_relations(NULL, pchan, arm, boneflag, constflag, show_relations);
+ draw_bone_relations(NULL, pchan, arm, boneflag, constflag, show_relations, draw_ctx->sh_cfg);
if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) {
draw_bone_update_disp_matrix_custom(pchan);
@@ -1903,7 +1906,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
/* Draw additional axes */
if (arm->flag & ARM_DRAWAXES) {
- draw_axes(NULL, pchan);
+ draw_axes(NULL, pchan, draw_ctx->sh_cfg);
}
}
}
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 28a897a4c35..0256564ffb5 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -705,8 +705,14 @@ GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
switch (ob->type) {
case OB_MESH:
return DRW_cache_mesh_edge_detection_get(ob, r_is_manifold);
-
- /* TODO, should match 'DRW_cache_object_surface_get' */
+ case OB_CURVE:
+ return DRW_cache_curve_edge_detection_get(ob, r_is_manifold);
+ case OB_SURF:
+ return DRW_cache_surf_edge_detection_get(ob, r_is_manifold);
+ case OB_FONT:
+ return DRW_cache_text_edge_detection_get(ob, r_is_manifold);
+ case OB_MBALL:
+ return DRW_cache_mball_edge_detection_get(ob, r_is_manifold);
default:
return NULL;
}
@@ -2009,7 +2015,7 @@ static const uint bone_octahedral_solid_tris[8][3] = {
* According to opengl specification it becomes (starting from
* the first vertex of the first face aka. vertex 2):
* {0, 12, 1, 10, 2, 3}
- **/
+ */
static const uint bone_octahedral_wire_lines_adjacency[12][4] = {
{ 0, 1, 2, 6}, { 0, 12, 1, 6}, { 0, 3, 12, 6}, { 0, 2, 3, 6},
{ 1, 6, 2, 3}, { 1, 12, 6, 3}, { 1, 0, 12, 3}, { 1, 2, 0, 3},
@@ -2161,7 +2167,7 @@ static const uint bone_box_solid_tris[12][3] = {
/**
* Store indices of generated verts from bone_box_solid_tris to define adjacency infos.
* See bone_octahedral_solid_tris for more infos.
- **/
+ */
static const uint bone_box_wire_lines_adjacency[12][4] = {
{ 4, 2, 0, 11}, { 0, 1, 2, 8}, { 2, 4, 1, 14}, { 1, 0, 4, 20}, /* bottom */
{ 0, 8, 11, 14}, { 2, 14, 8, 20}, { 1, 20, 14, 11}, { 4, 11, 20, 8}, /* top */
@@ -2745,9 +2751,10 @@ static const float staticSine[16] = {
0.994521895368f, 1.0f,
};
-#define set_vert(a, b, quarter) \
- copy_v2_fl2(pos, (quarter % 2 == 0) ? -(a) : (a), (quarter < 2) ? -(b) : (b)); \
- GPU_vertbuf_attr_set(vbo, attr_id.pos, v++, pos);
+#define set_vert(a, b, quarter) { \
+ copy_v2_fl2(pos, (quarter % 2 == 0) ? -(a) : (a), (quarter < 2) ? -(b) : (b)); \
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, v++, pos); \
+ } ((void)0)
GPUBatch *DRW_cache_bone_dof_sphere_get(void)
{
@@ -3179,6 +3186,19 @@ GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob)
}
}
+GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold)
+{
+ BLI_assert(ob->type == OB_CURVE);
+ struct Curve *cu = ob->data;
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ if (mesh_eval != NULL) {
+ return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
+ }
+ else {
+ return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
+ }
+}
+
/* Return list of batches */
GPUBatch **DRW_cache_curve_surface_shaded_get(
Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
@@ -3207,6 +3227,12 @@ GPUBatch *DRW_cache_mball_surface_get(Object *ob)
return DRW_metaball_batch_cache_get_triangles_with_normals(ob);
}
+GPUBatch *DRW_cache_mball_edge_detection_get(Object *ob, bool *r_is_manifold)
+{
+ BLI_assert(ob->type == OB_MBALL);
+ return DRW_metaball_batch_cache_get_edge_detection(ob, r_is_manifold);
+}
+
GPUBatch *DRW_cache_mball_face_wireframe_get(Object *ob)
{
BLI_assert(ob->type == OB_MBALL);
@@ -3251,6 +3277,22 @@ GPUBatch *DRW_cache_text_surface_get(Object *ob)
}
}
+GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold)
+{
+ BLI_assert(ob->type == OB_FONT);
+ struct Curve *cu = ob->data;
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ if (cu->editfont && (cu->flag & CU_FAST)) {
+ return NULL;
+ }
+ if (mesh_eval != NULL) {
+ return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
+ }
+ else {
+ return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
+ }
+}
+
GPUBatch *DRW_cache_text_loose_edges_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
@@ -3343,6 +3385,19 @@ GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)
}
}
+GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold)
+{
+ BLI_assert(ob->type == OB_SURF);
+ struct Curve *cu = ob->data;
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ if (mesh_eval != NULL) {
+ return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
+ }
+ else {
+ return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
+ }
+}
+
GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob)
{
BLI_assert(ob->type == OB_SURF);
@@ -3750,7 +3805,8 @@ void drw_batch_cache_generate_requested(Object *ob)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
const ToolSettings *ts = draw_ctx->scene->toolsettings;
- const int mode = CTX_data_mode_enum_ex(draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
+ const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
+ draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
const bool is_paint_mode = ELEM(mode, CTX_MODE_PAINT_TEXTURE, CTX_MODE_PAINT_VERTEX, CTX_MODE_PAINT_WEIGHT);
const bool use_hide = (
(ob->type == OB_MESH) &&
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index 287d970e298..2940a2c89f8 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -145,6 +145,7 @@ struct GPUBatch **DRW_cache_curve_surface_shaded_get(
struct GPUBatch *DRW_cache_curve_loose_edges_get(struct Object *ob);
struct GPUBatch *DRW_cache_curve_edge_wire_get(struct Object *ob);
struct GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob);
+struct GPUBatch *DRW_cache_curve_edge_detection_get(struct Object *ob, bool *r_is_manifold);
/* edit-mode */
struct GPUBatch *DRW_cache_curve_edge_normal_get(struct Object *ob);
struct GPUBatch *DRW_cache_curve_edge_overlay_get(struct Object *ob);
@@ -152,6 +153,7 @@ struct GPUBatch *DRW_cache_curve_vert_overlay_get(struct Object *ob, bool handle
/* Font */
struct GPUBatch *DRW_cache_text_surface_get(struct Object *ob);
+struct GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold);
struct GPUBatch *DRW_cache_text_loose_edges_get(struct Object *ob);
struct GPUBatch *DRW_cache_text_edge_wire_get(struct Object *ob);
struct GPUBatch **DRW_cache_text_surface_shaded_get(
@@ -165,6 +167,7 @@ struct GPUBatch *DRW_cache_surf_loose_edges_get(struct Object *ob);
struct GPUBatch **DRW_cache_surf_surface_shaded_get(
struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
struct GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob);
+struct GPUBatch *DRW_cache_surf_edge_detection_get(struct Object *ob, bool *r_is_manifold);
/* Lattice */
struct GPUBatch *DRW_cache_lattice_verts_get(struct Object *ob);
@@ -188,5 +191,6 @@ struct GPUBatch *DRW_cache_particles_get_prim(int type);
struct GPUBatch *DRW_cache_mball_surface_get(struct Object *ob);
struct GPUBatch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
struct GPUBatch *DRW_cache_mball_face_wireframe_get(Object *ob);
+struct GPUBatch *DRW_cache_mball_edge_detection_get(struct Object *ob, bool *r_is_manifold);
#endif /* __DRAW_CACHE_H__ */
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 7a8cea23655..4e014711245 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -66,6 +66,7 @@ void DRW_curve_batch_cache_create_requested(struct Object *ob);
struct GPUBatch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu);
struct GPUBatch *DRW_curve_batch_cache_get_normal_edge(struct Curve *cu);
+struct GPUBatch *DRW_curve_batch_cache_get_edge_detection(struct Curve *cu, bool *r_is_manifold);
struct GPUBatch *DRW_curve_batch_cache_get_edit_edges(struct Curve *cu);
struct GPUBatch *DRW_curve_batch_cache_get_edit_verts(struct Curve *cu, bool handles);
@@ -73,12 +74,12 @@ struct GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *
struct GPUBatch **DRW_curve_batch_cache_get_surface_shaded(
struct Curve *cu, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
struct GPUBatch *DRW_curve_batch_cache_get_wireframes_face(struct Curve *cu);
-
/* Metaball */
struct GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob);
struct GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(
struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len);
struct GPUBatch *DRW_metaball_batch_cache_get_wireframes_face(struct Object *ob);
+struct GPUBatch *DRW_metaball_batch_cache_get_edge_detection(struct Object *ob, bool *r_is_manifold);
/* DispList */
void DRW_displist_vertbuf_create_pos_and_nor(struct ListBase *lb, struct GPUVertBuf *vbo);
@@ -89,6 +90,7 @@ void DRW_displist_indexbuf_create_lines_in_order(struct ListBase *lb, struct GPU
void DRW_displist_indexbuf_create_triangles_in_order(struct ListBase *lb, struct GPUIndexBuf *ibo);
void DRW_displist_indexbuf_create_triangles_loop_split_by_material(
struct ListBase *lb, struct GPUIndexBuf **ibo_mat, uint mat_len);
+void DRW_displist_indexbuf_create_edges_adjacency_lines(struct ListBase *lb, struct GPUIndexBuf *ibo, bool *r_is_manifold);
/* Lattice */
struct GPUBatch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef);
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index ebffedf9454..eecb6c3dd6a 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -366,6 +366,7 @@ typedef struct CurveBatchCache {
GPUIndexBuf *surfaces_tris;
GPUIndexBuf *surfaces_lines;
GPUIndexBuf *curves_lines;
+ GPUIndexBuf *edges_adj_lines;
/* Edit mode */
GPUIndexBuf *edit_verts_points; /* Only control points. Not handles. */
GPUIndexBuf *edit_lines;
@@ -380,6 +381,7 @@ typedef struct CurveBatchCache {
GPUBatch *edit_verts;
GPUBatch *edit_handles_verts;
GPUBatch *edit_normals;
+ GPUBatch *edge_detection;
} batch;
GPUIndexBuf **surf_per_mat_tris;
@@ -390,6 +392,9 @@ typedef struct CurveBatchCache {
/* settings to determine if cache is invalid */
bool is_dirty;
bool is_editmode;
+
+ /* Valid only if edge_detection is up to date. */
+ bool is_manifold;
} CurveBatchCache;
/* GPUBatch cache management. */
@@ -880,6 +885,17 @@ GPUBatch *DRW_curve_batch_cache_get_wireframes_face(Curve *cu)
return DRW_batch_request(&cache->batch.surfaces_edges);
}
+GPUBatch *DRW_curve_batch_cache_get_edge_detection(Curve *cu, bool *r_is_manifold)
+{
+ CurveBatchCache *cache = curve_batch_cache_get(cu);
+ /* Even if is_manifold is not correct (not updated),
+ * the default (not manifold) is just the worst case. */
+ if (r_is_manifold) {
+ *r_is_manifold = cache->is_manifold;
+ }
+ return DRW_batch_request(&cache->batch.edge_detection);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -922,6 +938,10 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
DRW_ibo_request(cache->batch.curves, &cache->ibo.curves_lines);
DRW_vbo_request(cache->batch.curves, &cache->ordered.curves_pos);
}
+ if (DRW_batch_requested(cache->batch.edge_detection, GPU_PRIM_LINES_ADJ)) {
+ DRW_ibo_request(cache->batch.edge_detection, &cache->ibo.edges_adj_lines);
+ DRW_vbo_request(cache->batch.edge_detection, &cache->ordered.pos_nor);
+ }
/* Edit mode */
if (DRW_batch_requested(cache->batch.edit_edges, GPU_PRIM_LINES)) {
@@ -963,6 +983,7 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.surfaces_tris, CU_DATATYPE_SURFACE);
DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.surfaces_lines, CU_DATATYPE_SURFACE);
DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.curves_lines, CU_DATATYPE_WIRE);
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edges_adj_lines, CU_DATATYPE_SURFACE);
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.pos, CU_DATATYPE_OVERLAY);
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.data, CU_DATATYPE_OVERLAY);
@@ -1010,6 +1031,9 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
if (DRW_ibo_requested(cache->ibo.surfaces_lines)) {
DRW_displist_indexbuf_create_lines_in_order(lb, cache->ibo.surfaces_lines);
}
+ if (DRW_ibo_requested(cache->ibo.edges_adj_lines)) {
+ DRW_displist_indexbuf_create_edges_adjacency_lines(lb, cache->ibo.edges_adj_lines, &cache->is_manifold);
+ }
if (DRW_vbo_requested(cache->edit.pos) ||
DRW_vbo_requested(cache->edit.data) ||
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index 63514acf1c2..29fc5478072 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -28,6 +28,7 @@
#include "BLI_alloca.h"
#include "BLI_utildefines.h"
+#include "BLI_edgehash.h"
#include "BLI_math_vector.h"
#include "DNA_curve_types.h"
@@ -310,8 +311,8 @@ void DRW_displist_indexbuf_create_lines_in_order(ListBase *lb, GPUIndexBuf *ibo)
int ofs = 0;
for (const DispList *dl = lb->first; dl; dl = dl->next) {
displist_indexbufbuilder_set(
- (SetTriIndicesFn *)set_overlay_wires_tri_indices,
- (SetTriIndicesFn *)set_overlay_wires_quad_tri_indices,
+ set_overlay_wires_tri_indices,
+ set_overlay_wires_quad_tri_indices,
&elb, dl, ofs);
ofs += dl_vert_len(dl);
}
@@ -561,3 +562,97 @@ void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv(
}
}
}
+
+/* Edge detection/adjecency */
+#define NO_EDGE INT_MAX
+static void set_edge_adjacency_lines_indices(EdgeHash *eh, GPUIndexBufBuilder *elb, bool *r_is_manifold, uint v1, uint v2, uint v3)
+{
+ bool inv_indices = (v2 > v3);
+ void **pval;
+ bool value_is_init = BLI_edgehash_ensure_p(eh, v2, v3, &pval);
+ int v_data = POINTER_AS_INT(*pval);
+ if (!value_is_init || v_data == NO_EDGE) {
+ /* Save the winding order inside the sign bit. Because the
+ * edgehash sort the keys and we need to compare winding later. */
+ int value = (int)v1 + 1; /* Int 0 bm_looptricannot be signed */
+ *pval = POINTER_FROM_INT((inv_indices) ? -value : value);
+ }
+ else {
+ /* HACK Tag as not used. Prevent overhead of BLI_edgehash_remove. */
+ *pval = POINTER_FROM_INT(NO_EDGE);
+ bool inv_opposite = (v_data < 0);
+ uint v_opposite = (uint)abs(v_data) - 1;
+
+ if (inv_opposite == inv_indices) {
+ /* Don't share edge if triangles have non matching winding. */
+ GPU_indexbuf_add_line_adj_verts(elb, v1, v2, v3, v1);
+ GPU_indexbuf_add_line_adj_verts(elb, v_opposite, v2, v3, v_opposite);
+ *r_is_manifold = false;
+ }
+ else {
+ GPU_indexbuf_add_line_adj_verts(elb, v1, v2, v3, v_opposite);
+ }
+ }
+}
+
+static void set_edges_adjacency_lines_indices(void *thunk, uint v1, uint v2, uint v3)
+{
+ void **packed = (void **)thunk;
+ GPUIndexBufBuilder *elb = (GPUIndexBufBuilder*)packed[0];
+ EdgeHash *eh = (EdgeHash *)packed[1];
+ bool *r_is_manifold = (bool*)packed[2];
+
+ set_edge_adjacency_lines_indices(eh, elb, r_is_manifold, v1, v2, v3);
+ set_edge_adjacency_lines_indices(eh, elb, r_is_manifold, v2, v3, v1);
+ set_edge_adjacency_lines_indices(eh, elb, r_is_manifold, v3, v1, v2);
+}
+
+void DRW_displist_indexbuf_create_edges_adjacency_lines(struct ListBase *lb, struct GPUIndexBuf *ibo, bool *r_is_manifold)
+{
+ const int tri_len = curve_render_surface_tri_len_get(lb);
+ const int vert_len = curve_render_surface_vert_len_get(lb);
+
+ *r_is_manifold = true;
+
+ /* Allocate max but only used indices are sent to GPU. */
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, tri_len * 3, vert_len);
+
+ EdgeHash *eh = BLI_edgehash_new_ex(__func__, tri_len * 3);
+
+ /* pack values to pass to `set_edges_adjacency_lines_indices` function. */
+ void *thunk[3] = {&elb, eh, r_is_manifold};
+ int v_idx = 0;
+ for (const DispList *dl = lb->first; dl; dl = dl->next) {
+ displist_indexbufbuilder_set(
+ (SetTriIndicesFn *)set_edges_adjacency_lines_indices,
+ (SetTriIndicesFn *)set_edges_adjacency_lines_indices,
+ thunk, dl, v_idx);
+ v_idx += dl_vert_len(dl);
+ }
+
+ /* Create edges for remaning non manifold edges. */
+ EdgeHashIterator *ehi;
+ for (ehi = BLI_edgehashIterator_new(eh);
+ BLI_edgehashIterator_isDone(ehi) == false;
+ BLI_edgehashIterator_step(ehi))
+ {
+ uint v1, v2;
+ int v_data = POINTER_AS_INT(BLI_edgehashIterator_getValue(ehi));
+ if (v_data == NO_EDGE) {
+ continue;
+ }
+ BLI_edgehashIterator_getKey(ehi, &v1, &v2);
+ uint v0 = (uint)abs(v_data) - 1;
+ if (v_data < 0) { /* inv_opposite */
+ SWAP(uint, v1, v2);
+ }
+ GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0);
+ *r_is_manifold = false;
+ }
+ BLI_edgehashIterator_free(ehi);
+ BLI_edgehash_free(eh, NULL);
+
+ GPU_indexbuf_build_in_place(&elb, ibo);
+}
+#undef NO_EDGE
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 890181a532a..e47d46aca09 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -85,6 +85,40 @@ enum {
};
/* ---------------------------------------------------------------------- */
+/** \name BMesh Inline Wrappers
+ * \{ */
+
+/**
+ * Wrapper for #BM_vert_find_first_loop_visible
+ * since most of the time this can be accessed directly without a function call.
+ */
+BLI_INLINE BMLoop *bm_vert_find_first_loop_visible_inline(BMVert *v)
+{
+ if (v->e) {
+ BMLoop *l = v->e->l;
+ if (l && !BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) {
+ return l->v == v ? l : l->next;
+ }
+ return BM_vert_find_first_loop_visible(v);
+ }
+ return NULL;
+}
+
+BLI_INLINE BMLoop *bm_edge_find_first_loop_visible_inline(BMEdge *e)
+{
+ if (e->l) {
+ BMLoop *l = e->l;
+ if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) {
+ return l;
+ }
+ return BM_edge_find_first_loop_visible(e);
+ }
+ return NULL;
+}
+
+/** \} */
+
+/* ---------------------------------------------------------------------- */
/** \name Mesh/BMesh Interface (direct access to basic data).
* \{ */
@@ -203,6 +237,7 @@ typedef struct MeshRenderData {
MLoopUV **uv;
int uv_len;
int uv_active;
+ int uv_mask_active;
MLoopCol **vcol;
int vcol_len;
@@ -355,6 +390,17 @@ static void mesh_cd_calc_active_uv_layer(
}
}
+static void mesh_cd_calc_active_mask_uv_layer(
+ const Mesh *me, ushort cd_lused[CD_NUMTYPES])
+{
+ const CustomData *cd_ldata = (me->edit_mesh) ? &me->edit_mesh->bm->ldata : &me->ldata;
+
+ int layer = CustomData_get_stencil_layer(cd_ldata, CD_MLOOPUV);
+ if (layer != -1) {
+ cd_lused[CD_MLOOPUV] |= (1 << layer);
+ }
+}
+
static void mesh_cd_calc_active_vcol_layer(
const Mesh *me, ushort cd_lused[CD_NUMTYPES])
{
@@ -541,6 +587,10 @@ static void mesh_cd_extract_auto_layers_names_and_srgb(
auto_names = MEM_reallocN(auto_names, sizeof(char) * auto_ofs);
auto_is_srgb = MEM_reallocN(auto_is_srgb, sizeof(int) * auto_is_srgb_ofs);
+ /* WATCH: May have been referenced somewhere before freeing. */
+ MEM_SAFE_FREE(*r_auto_layers_names);
+ MEM_SAFE_FREE(*r_auto_layers_srgb);
+
*r_auto_layers_names = auto_names;
*r_auto_layers_srgb = auto_is_srgb;
*r_auto_layers_len = auto_is_srgb_ofs;
@@ -600,8 +650,8 @@ static MeshRenderData *mesh_render_data_create_ex(
rdata->mapped.l_origindex = CustomData_get_layer(&me_cage->ldata, CD_ORIGINDEX);
rdata->mapped.p_origindex = CustomData_get_layer(&me_cage->pdata, CD_ORIGINDEX);
rdata->mapped.supported = (
- rdata->mapped.v_origindex &&
- rdata->mapped.e_origindex &&
+ rdata->mapped.v_origindex ||
+ rdata->mapped.e_origindex ||
rdata->mapped.p_origindex);
}
@@ -805,6 +855,7 @@ static MeshRenderData *mesh_render_data_create_ex(
}
rdata->cd.layers.uv_active = CustomData_get_active_layer(cd_ldata, CD_MLOOPUV);
+ rdata->cd.layers.uv_mask_active = CustomData_get_stencil_layer(cd_ldata, CD_MLOOPUV);
rdata->cd.layers.vcol_active = CustomData_get_active_layer(cd_ldata, CD_MLOOPCOL);
rdata->cd.layers.tangent_active = rdata->cd.layers.uv_active;
@@ -814,6 +865,7 @@ static MeshRenderData *mesh_render_data_create_ex(
} ((void)0)
CD_VALIDATE_ACTIVE_LAYER(rdata->cd.layers.uv_active, cd_lused[CD_MLOOPUV]);
+ CD_VALIDATE_ACTIVE_LAYER(rdata->cd.layers.uv_mask_active, cd_lused[CD_MLOOPUV]);
CD_VALIDATE_ACTIVE_LAYER(rdata->cd.layers.tangent_active, cd_lused[CD_TANGENT]);
CD_VALIDATE_ACTIVE_LAYER(rdata->cd.layers.vcol_active, cd_lused[CD_MLOOPCOL]);
@@ -889,11 +941,13 @@ static MeshRenderData *mesh_render_data_create_ex(
* to a safe glsl var name, but without name clash.
* NOTE 2 : Replicate changes to code_generate_vertex_new() in gpu_codegen.c */
if (rdata->cd.layers.vcol_len != 0) {
+ int act_vcol = rdata->cd.layers.vcol_active;
for (int i_src = 0, i_dst = 0; i_src < cd_layers_src.vcol_len; i_src++, i_dst++) {
if ((cd_lused[CD_MLOOPCOL] & (1 << i_src)) == 0) {
+ /* This is a non-used VCol slot. Skip. */
i_dst--;
if (rdata->cd.layers.vcol_active >= i_src) {
- rdata->cd.layers.vcol_active--;
+ act_vcol--;
}
}
else {
@@ -916,6 +970,10 @@ static MeshRenderData *mesh_render_data_create_ex(
}
}
}
+ if (rdata->cd.layers.vcol_active != -1) {
+ /* Actual active Vcol slot inside vcol layers used for shading. */
+ rdata->cd.layers.vcol_active = act_vcol;
+ }
}
/* Start Fresh */
@@ -1768,6 +1826,7 @@ typedef struct MeshBatchCache {
GPUVertBuf *loop_uv_tan;
GPUVertBuf *loop_vcol;
GPUVertBuf *loop_edge_fac;
+ GPUVertBuf *loop_orco;
} ordered;
/* Edit Mesh Data:
@@ -1979,8 +2038,7 @@ static void mesh_batch_cache_discard_shaded_tri(MeshBatchCache *cache)
GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_pos_nor);
GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_uv_tan);
GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_vcol);
- /* TODO */
- // GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_orco);
+ GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_orco);
if (cache->surf_per_mat_tris) {
for (int i = 0; i < cache->mat_len; i++) {
@@ -2140,7 +2198,7 @@ static void mesh_create_edit_vertex_loops(
uchar fflag;
/* Static formats */
- static struct { GPUVertFormat sel_id, pos_nor, lnor, flag, uv; } format = { 0 };
+ static struct { GPUVertFormat sel_id, pos_nor, lnor, flag, uv; } format = {{ 0 }};
static struct { uint sel_id, pos, nor, lnor, data, uvs; } attr_id;
if (format.sel_id.attr_len == 0) {
attr_id.sel_id = GPU_vertformat_attr_add(&format.sel_id, "color", GPU_COMP_U32, 1, GPU_FETCH_INT);
@@ -2345,13 +2403,10 @@ static void mesh_create_edit_vertex_loops(
if (eidx != ORIGINDEX_NONE) {
BMEdge *eed = BM_edge_at_index(bm, eidx);
mesh_render_data_edge_flag(rdata, eed, &eattr);
- /* TODO find a more efficient way to do that. */
- BMLoop *loop;
- BMIter iter_loop;
- BM_ITER_ELEM (loop, &iter_loop, efa, BM_LOOPS_OF_FACE) {
- if (loop->e == eed) {
+ if (efa) {
+ BMLoop *loop = BM_face_edge_share_loop(efa, eed);
+ if (loop) {
mesh_render_data_loop_flag(rdata, loop, cd_loop_uv_offset, &eattr);
- break;
}
}
}
@@ -2915,6 +2970,46 @@ static void mesh_create_loop_pos_and_nor(MeshRenderData *rdata, GPUVertBuf *vbo)
}
}
+static void mesh_create_loop_orco(MeshRenderData *rdata, GPUVertBuf *vbo)
+{
+ const uint loops_len = mesh_render_data_loops_len_get(rdata);
+
+ /* initialize vertex format */
+ GPUVertFormat format = { 0 };
+ GPUVertBufRaw vbo_step;
+
+ /* FIXME(fclem): We use the last component as a way to differentiate from generic vertex attribs.
+ * This is a substential waste of Vram and should be done another way. Unfortunately,
+ * at the time of writting, I did not found any other "non disruptive" alternative. */
+ uint attr_id = GPU_vertformat_attr_add(&format, "orco", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+
+ GPU_vertbuf_init_with_format(vbo, &format);
+ GPU_vertbuf_data_alloc(vbo, loops_len);
+ GPU_vertbuf_attr_get_raw_data(vbo, attr_id, &vbo_step);
+
+ if (rdata->edit_bmesh) {
+ BMesh *bm = rdata->edit_bmesh->bm;
+ BMIter iter_efa, iter_loop;
+ BMFace *efa;
+ BMLoop *loop;
+
+ BM_ITER_MESH (efa, &iter_efa, bm, BM_FACES_OF_MESH) {
+ BM_ITER_ELEM (loop, &iter_loop, efa, BM_LOOPS_OF_FACE) {
+ float *data = (float *)GPU_vertbuf_raw_step(&vbo_step);
+ copy_v3_v3(data, rdata->orco[BM_elem_index_get(loop->v)]);
+ data[3] = 0.0; /* Tag as not a generic attrib */
+ }
+ }
+ }
+ else {
+ for (uint l = 0; l < loops_len; l++) {
+ float *data = (float *)GPU_vertbuf_raw_step(&vbo_step);
+ copy_v3_v3(data, rdata->orco[rdata->mloop[l].v]);
+ data[3] = 0.0; /* Tag as not a generic attrib */
+ }
+ }
+}
+
static void mesh_create_loop_uv_and_tan(MeshRenderData *rdata, GPUVertBuf *vbo)
{
const uint loops_len = mesh_render_data_loops_len_get(rdata);
@@ -2947,6 +3042,9 @@ static void mesh_create_loop_uv_and_tan(MeshRenderData *rdata, GPUVertBuf *vbo)
if (i == rdata->cd.layers.uv_active) {
GPU_vertformat_alias_add(&format, "u");
}
+ if (i == rdata->cd.layers.uv_mask_active) {
+ GPU_vertformat_alias_add(&format, "mu");
+ }
}
for (uint i = 0; i < tangent_len; i++) {
@@ -3420,8 +3518,8 @@ static void mesh_create_loops_lines(
if (!BM_elem_flag_test(bm_edge, BM_ELEM_HIDDEN) &&
bm_edge->l != NULL)
{
- BMLoop *bm_loop1 = BM_vert_find_first_loop_visible(bm_edge->v1);
- BMLoop *bm_loop2 = BM_vert_find_first_loop_visible(bm_edge->v2);
+ BMLoop *bm_loop1 = bm_vert_find_first_loop_visible_inline(bm_edge->v1);
+ BMLoop *bm_loop2 = bm_vert_find_first_loop_visible_inline(bm_edge->v2);
int v1 = BM_elem_index_get(bm_loop1);
int v2 = BM_elem_index_get(bm_loop2);
if (v1 > v2) {
@@ -3663,7 +3761,7 @@ static void mesh_create_edit_loops_points_lines(MeshRenderData *rdata, GPUIndexB
BMEdge *eed;
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- BMLoop *l = BM_edge_find_first_loop_visible(eed);
+ BMLoop *l = bm_edge_find_first_loop_visible_inline(eed);
if (l != NULL) {
int v1 = BM_elem_index_get(eed->l);
int v2 = BM_elem_index_get(eed->l->next);
@@ -3677,7 +3775,7 @@ static void mesh_create_edit_loops_points_lines(MeshRenderData *rdata, GPUIndexB
BMVert *eve;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- BMLoop *l = BM_vert_find_first_loop_visible(eve);
+ BMLoop *l = bm_vert_find_first_loop_visible_inline(eve);
if (l != NULL) {
int v = BM_elem_index_get(l);
GPU_indexbuf_add_generic_vert(&elb_vert, v);
@@ -3919,6 +4017,7 @@ static void texpaint_request_active_uv(MeshBatchCache *cache, Mesh *me)
/* This should not happen. */
BLI_assert(!"No uv layer available in texpaint, but batches requested anyway!");
}
+ mesh_cd_calc_active_mask_uv_layer(me, cd_lneeded);
bool cd_overlap = mesh_cd_layers_type_overlap(cache->cd_vused, cache->cd_lused,
cd_vneeded, cd_lneeded);
if (cd_overlap == false) {
@@ -4530,6 +4629,13 @@ void DRW_mesh_batch_cache_create_requested(
for (int type = 0; type < CD_NUMTYPES; ++type) {
if ((cache->cd_vused[type] & cache->cd_vneeded[type]) != cache->cd_vneeded[type]) {
switch (type) {
+ case CD_ORCO:
+ GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_orco);
+ break;
+ }
+ }
+ if ((cache->cd_lused[type] & cache->cd_lneeded[type]) != cache->cd_lneeded[type]) {
+ switch (type) {
case CD_MLOOPUV:
case CD_TANGENT:
GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_uv_tan);
@@ -4537,10 +4643,6 @@ void DRW_mesh_batch_cache_create_requested(
case CD_MLOOPCOL:
GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_vcol);
break;
- case CD_ORCO:
- /* TODO */
- // GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_orco);
- break;
}
}
}
@@ -4729,10 +4831,19 @@ void DRW_mesh_batch_cache_create_requested(
if (cache->cd_lused[CD_MLOOPCOL] != 0) {
DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_vcol);
}
- /* TODO */
- // if (cache->cd_vused[CD_ORCO] != 0) {
- // DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_orco);
- // }
+ if (cache->cd_vused[CD_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_lused[CD_TANGENT] & DM_TANGENT_MASK_ORCO) == 0) {
+ /* Skip orco calculation if not needed by tangent generation. */
+ cache->cd_vused[CD_ORCO] = 0;
+ }
+ }
}
}
@@ -4741,7 +4852,8 @@ void DRW_mesh_batch_cache_create_requested(
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.pos_nor, MR_DATATYPE_VERT);
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.weights, MR_DATATYPE_VERT | MR_DATATYPE_DVERT);
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_pos_nor, MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_uv_tan, MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP | MR_DATATYPE_SHADING);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_uv_tan, MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP | MR_DATATYPE_SHADING | MR_DATATYPE_LOOPTRI);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_orco, MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP | MR_DATATYPE_SHADING);
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_vcol, MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP | MR_DATATYPE_SHADING);
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_edge_fac, MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP);
DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.surf_tris, MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI);
@@ -4808,6 +4920,9 @@ void DRW_mesh_batch_cache_create_requested(
if (DRW_vbo_requested(cache->ordered.loop_uv_tan)) {
mesh_create_loop_uv_and_tan(rdata, cache->ordered.loop_uv_tan);
}
+ if (DRW_vbo_requested(cache->ordered.loop_orco)) {
+ mesh_create_loop_orco(rdata, cache->ordered.loop_orco);
+ }
if (DRW_vbo_requested(cache->ordered.loop_vcol)) {
mesh_create_loop_vcol(rdata, cache->ordered.loop_vcol);
}
@@ -4885,7 +5000,7 @@ void DRW_mesh_batch_cache_create_requested(
* TODO: The code and data structure is ready to support modified UV display
* but the selection code for UVs needs to support it first. So for now, only
* display the cage in all cases.
- **/
+ */
if (rdata && rdata->mapped.supported) {
rdata->mapped.use = false;
}
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index 811f01aa83a..46c247d67ea 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -47,6 +47,7 @@ static void metaball_batch_cache_clear(MetaBall *mb);
typedef struct MetaBallBatchCache {
GPUBatch *batch;
GPUBatch **shaded_triangles;
+
int mat_len;
/* Shared */
@@ -57,8 +58,15 @@ typedef struct MetaBallBatchCache {
GPUBatch *batch;
} face_wire;
+ /* Edge detection */
+ GPUBatch *edge_detection;
+ GPUIndexBuf *edges_adj_lines;
+
/* settings to determine if cache is invalid */
bool is_dirty;
+
+ /* Valid only if edge_detection is up to date. */
+ bool is_manifold;
} MetaBallBatchCache;
/* GPUBatch cache management. */
@@ -87,6 +95,9 @@ static void metaball_batch_cache_init(MetaBall *mb)
cache->is_dirty = false;
cache->pos_nor_in_order = NULL;
cache->face_wire.batch = NULL;
+ cache->edge_detection = NULL;
+ cache->edges_adj_lines = NULL;
+ cache->is_manifold = false;
}
static MetaBallBatchCache *metaball_batch_cache_get(MetaBall *mb)
@@ -122,10 +133,13 @@ static void metaball_batch_cache_clear(MetaBall *mb)
GPU_BATCH_DISCARD_SAFE(cache->face_wire.batch);
GPU_BATCH_DISCARD_SAFE(cache->batch);
+ GPU_BATCH_DISCARD_SAFE(cache->edge_detection);
GPU_VERTBUF_DISCARD_SAFE(cache->pos_nor_in_order);
+ GPU_INDEXBUF_DISCARD_SAFE(cache->edges_adj_lines);
/* Note: shaded_triangles[0] is already freed by cache->batch */
MEM_SAFE_FREE(cache->shaded_triangles);
cache->mat_len = 0;
+ cache->is_manifold = false;
}
void DRW_mball_batch_cache_free(MetaBall *mb)
@@ -144,6 +158,16 @@ static GPUVertBuf *mball_batch_cache_get_pos_and_normals(Object *ob, MetaBallBat
return cache->pos_nor_in_order;
}
+static GPUIndexBuf *mball_batch_cache_get_edges_adj_lines(Object *ob, MetaBallBatchCache *cache)
+{
+ if (cache->edges_adj_lines == NULL) {
+ ListBase *lb = &ob->runtime.curve_cache->disp;
+ cache->edges_adj_lines = MEM_callocN(sizeof(GPUVertBuf), __func__);
+ DRW_displist_indexbuf_create_edges_adjacency_lines(lb, cache->edges_adj_lines, &cache->is_manifold);
+ }
+ return cache->edges_adj_lines;
+}
+
/* -------------------------------------------------------------------- */
/** \name Public Object/MetaBall API
* \{ */
@@ -219,3 +243,26 @@ GPUBatch *DRW_metaball_batch_cache_get_wireframes_face(Object *ob)
return cache->face_wire.batch;
}
+
+struct GPUBatch *DRW_metaball_batch_cache_get_edge_detection(struct Object *ob, bool *r_is_manifold)
+{
+ if (!BKE_mball_is_basis(ob)) {
+ return NULL;
+ }
+
+ MetaBall *mb = ob->data;
+ MetaBallBatchCache *cache = metaball_batch_cache_get(mb);
+
+ if (cache->edge_detection == NULL) {
+ cache->edge_detection = GPU_batch_create(
+ GPU_PRIM_LINES_ADJ,
+ mball_batch_cache_get_pos_and_normals(ob, cache),
+ mball_batch_cache_get_edges_adj_lines(ob, cache));
+ }
+
+ if (r_is_manifold) {
+ *r_is_manifold = cache->is_manifold;
+ }
+
+ return cache->edge_detection;
+} \ No newline at end of file
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 6790a8aa0cc..def425e3c7c 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -793,8 +793,12 @@ static int particle_batch_cache_fill_strands_data(
continue;
}
+ /* XXX: We might need something more robust.
+ * Adjust shader code accordingly. (see unpack_strand_data() ) */
+ BLI_assert((path->segments - 1) <= 0x3FF);
+
uint *seg_data = (uint *)GPU_vertbuf_raw_step(data_step);
- *seg_data = (curr_point & 0xFFFFFF) | (path->segments << 24);
+ *seg_data = (curr_point & 0x3FFFFF) | ((path->segments - 1) << 22);
curr_point += path->segments + 1;
if (psmd != NULL) {
@@ -918,7 +922,7 @@ static void particle_batch_cache_ensure_procedural_strand_data(
BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%u", hash);
if (i == active_uv) {
- BLI_snprintf(cache->uv_layer_names[i][n], MAX_LAYER_NAME_LEN, "u");
+ BLI_strncpy(cache->uv_layer_names[i][n], "u", MAX_LAYER_NAME_LEN);
}
}
/* Vertex colors */
@@ -938,7 +942,7 @@ static void particle_batch_cache_ensure_procedural_strand_data(
}
if (i == active_col) {
- BLI_snprintf(cache->col_layer_names[i][n], MAX_LAYER_NAME_LEN, "c");
+ BLI_strncpy(cache->col_layer_names[i][n], "c", MAX_LAYER_NAME_LEN);
}
}
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 8c600cd85e8..573b906413f 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -41,7 +41,7 @@
ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, (float)a / 255.0f)
/* Colors & Constant */
-struct DRW_Global G_draw = {0};
+struct DRW_Global G_draw = {{{0}}};
static bool weight_ramp_custom = false;
static ColorBand weight_ramp_copy;
@@ -182,7 +182,7 @@ void DRW_globals_update(void)
BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size);
- G_draw.ramp = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL);
+ G_draw.ramp = GPU_texture_create_1d(col_size, GPU_RGBA8, colors, NULL);
MEM_freeN(colors);
}
@@ -321,9 +321,9 @@ DRWShadingGroup *shgroup_dynlines_flat_color(DRWPass *pass, eGPUShaderConfig sh_
return grp;
}
-DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(DRWPass *pass, const float color[4])
+DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(DRWPass *pass, const float color[4], eGPUShaderConfig sh_cfg)
{
- GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
+ GPUShader *sh = GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR, sh_cfg);
static float dash_width = 6.0f;
static float dash_factor = 0.5f;
@@ -333,7 +333,9 @@ DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(DRWPass *pass, const floa
DRW_shgroup_uniform_float(grp, "dash_width", &dash_width, 1);
DRW_shgroup_uniform_float(grp, "dash_factor", &dash_factor, 1);
DRW_shgroup_uniform_int_copy(grp, "colors_len", 0); /* "simple" mode */
-
+ if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
+ DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+ }
return grp;
}
@@ -600,13 +602,16 @@ DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct GPUBatch *geom, eGP
return grp;
}
-DRWShadingGroup *shgroup_instance_bone_axes(DRWPass *pass)
+DRWShadingGroup *shgroup_instance_bone_axes(DRWPass *pass, eGPUShaderConfig sh_cfg)
{
- COMMON_Shaders *sh_data = &g_shaders[GPU_SHADER_CFG_DEFAULT];
+ COMMON_Shaders *sh_data = &g_shaders[sh_cfg];
if (sh_data->bone_axes == NULL) {
- sh_data->bone_axes = DRW_shader_create(
- datatoc_armature_axes_vert_glsl, NULL,
- datatoc_gpu_shader_flat_color_frag_glsl, NULL);
+ const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
+ sh_data->bone_axes = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib, datatoc_armature_axes_vert_glsl, NULL},
+ .frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, NULL},
+ });
}
DRW_shgroup_instance_format(g_formats.instance_color, {
@@ -619,17 +624,22 @@ DRWShadingGroup *shgroup_instance_bone_axes(DRWPass *pass)
pass, DRW_cache_bone_arrows_get(),
g_formats.instance_color);
DRW_shgroup_uniform_vec3(grp, "screenVecs[0]", DRW_viewport_screenvecs_get(), 2);
-
+ if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
+ DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+ }
return grp;
}
-DRWShadingGroup *shgroup_instance_bone_envelope_outline(DRWPass *pass)
+DRWShadingGroup *shgroup_instance_bone_envelope_outline(DRWPass *pass, eGPUShaderConfig sh_cfg)
{
- COMMON_Shaders *sh_data = &g_shaders[GPU_SHADER_CFG_DEFAULT];
+ COMMON_Shaders *sh_data = &g_shaders[sh_cfg];
if (sh_data->bone_envelope_outline == NULL) {
- sh_data->bone_envelope_outline = DRW_shader_create(
- datatoc_armature_envelope_outline_vert_glsl, NULL,
- datatoc_gpu_shader_flat_color_frag_glsl, NULL);
+ const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
+ sh_data->bone_envelope_outline = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib, datatoc_armature_envelope_outline_vert_glsl, NULL},
+ .frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, NULL},
+ });
}
DRW_shgroup_instance_format(g_formats.instance_bone_envelope_outline, {
@@ -644,17 +654,22 @@ DRWShadingGroup *shgroup_instance_bone_envelope_outline(DRWPass *pass)
pass, DRW_cache_bone_envelope_outline_get(),
g_formats.instance_bone_envelope_outline);
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
-
+ if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
+ DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+ }
return grp;
}
-DRWShadingGroup *shgroup_instance_bone_envelope_distance(DRWPass *pass)
+DRWShadingGroup *shgroup_instance_bone_envelope_distance(DRWPass *pass, eGPUShaderConfig sh_cfg)
{
- COMMON_Shaders *sh_data = &g_shaders[GPU_SHADER_CFG_DEFAULT];
+ COMMON_Shaders *sh_data = &g_shaders[sh_cfg];
if (sh_data->bone_envelope_distance == NULL) {
- sh_data->bone_envelope_distance = DRW_shader_create(
- datatoc_armature_envelope_solid_vert_glsl, NULL,
- datatoc_armature_envelope_distance_frag_glsl, NULL);
+ const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
+ sh_data->bone_envelope_distance = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib, datatoc_armature_envelope_solid_vert_glsl, NULL},
+ .frag = (const char *[]){datatoc_armature_envelope_distance_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, NULL},
+ });
}
DRW_shgroup_instance_format(g_formats.instance_bone_envelope_distance, {
@@ -667,17 +682,22 @@ DRWShadingGroup *shgroup_instance_bone_envelope_distance(DRWPass *pass)
sh_data->bone_envelope_distance,
pass, DRW_cache_bone_envelope_solid_get(),
g_formats.instance_bone_envelope_distance);
-
+ if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
+ DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+ }
return grp;
}
-DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, bool transp)
+DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, bool transp, eGPUShaderConfig sh_cfg)
{
- COMMON_Shaders *sh_data = &g_shaders[GPU_SHADER_CFG_DEFAULT];
+ COMMON_Shaders *sh_data = &g_shaders[sh_cfg];
if (sh_data->bone_envelope == NULL) {
- sh_data->bone_envelope = DRW_shader_create(
- datatoc_armature_envelope_solid_vert_glsl, NULL,
- datatoc_armature_envelope_solid_frag_glsl, "#define SMOOTH_ENVELOPE\n");
+ const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
+ sh_data->bone_envelope = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib, datatoc_armature_envelope_solid_vert_glsl, NULL},
+ .frag = (const char *[]){datatoc_armature_envelope_solid_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, NULL},
+ });
}
DRW_shgroup_instance_format(g_formats.instance_bone_envelope, {
@@ -693,7 +713,9 @@ DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, bool transp
pass, DRW_cache_bone_envelope_solid_get(),
g_formats.instance_bone_envelope);
DRW_shgroup_uniform_float_copy(grp, "alpha", transp ? 0.6f : 1.0f);
-
+ if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
+ DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+ }
return grp;
}
@@ -787,7 +809,7 @@ DRWShadingGroup *shgroup_instance_bone_shape_solid(
DRWShadingGroup *shgroup_instance_bone_sphere_solid(DRWPass *pass, bool transp, eGPUShaderConfig sh_cfg)
{
- COMMON_Shaders *sh_data = &g_shaders[GPU_SHADER_CFG_DEFAULT];
+ COMMON_Shaders *sh_data = &g_shaders[sh_cfg];
if (sh_data->bone_sphere == NULL) {
const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
sh_data->bone_sphere = GPU_shader_create_from_arrays({
@@ -816,7 +838,7 @@ DRWShadingGroup *shgroup_instance_bone_sphere_solid(DRWPass *pass, bool transp,
DRWShadingGroup *shgroup_instance_bone_sphere_outline(DRWPass *pass, eGPUShaderConfig sh_cfg)
{
- COMMON_Shaders *sh_data = &g_shaders[GPU_SHADER_CFG_DEFAULT];
+ COMMON_Shaders *sh_data = &g_shaders[sh_cfg];
if (sh_data->bone_sphere_outline == NULL) {
const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
sh_data->bone_sphere_outline = GPU_shader_create_from_arrays({
@@ -981,11 +1003,11 @@ int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color
theme_id = (active) ? TH_ACTIVE : TH_SELECT;
}
else {
- if (ob->type == OB_LAMP) theme_id = TH_LIGHT;
- else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER;
- else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA;
- else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY;
- else if (ob->type == OB_LIGHTPROBE) theme_id = TH_EMPTY; /* TODO add lightprobe color */
+ if (ob->type == OB_LAMP) { theme_id = TH_LIGHT; }
+ else if (ob->type == OB_SPEAKER) { theme_id = TH_SPEAKER; }
+ else if (ob->type == OB_CAMERA) { theme_id = TH_CAMERA; }
+ else if (ob->type == OB_EMPTY) { theme_id = TH_EMPTY; }
+ else if (ob->type == OB_LIGHTPROBE) { theme_id = TH_EMPTY; } /* TODO add lightprobe color */
/* fallback to TH_WIRE */
}
}
@@ -1111,5 +1133,5 @@ static GPUTexture *DRW_create_weight_colorramp_texture(void)
pixels[i][3] = 1.0f;
}
- return GPU_texture_create_1D(256, GPU_RGBA8, pixels[0], error);
+ return GPU_texture_create_1d(256, GPU_RGBA8, pixels[0], error);
}
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index 72416ed0889..f6ebfcab788 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -125,7 +125,7 @@ void DRW_globals_free(void);
void DRW_shgroup_world_clip_planes_from_rv3d(struct DRWShadingGroup *shgrp, const RegionView3D *rv3d);
struct DRWShadingGroup *shgroup_dynlines_flat_color(struct DRWPass *pass, eGPUShaderConfig sh_cfg);
-struct DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(struct DRWPass *pass, const float color[4]);
+struct DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(struct DRWPass *pass, const float color[4], eGPUShaderConfig sh_cfg);
struct DRWShadingGroup *shgroup_dynpoints_uniform_color(struct DRWPass *pass, const float color[4], const float *size, eGPUShaderConfig sh_cfg);
struct DRWShadingGroup *shgroup_groundlines_uniform_color(struct DRWPass *pass, const float color[4], eGPUShaderConfig sh_cfg);
struct DRWShadingGroup *shgroup_groundpoints_uniform_color(struct DRWPass *pass, const float color[4], eGPUShaderConfig sh_cfg);
@@ -142,10 +142,10 @@ struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct GPU
struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct GPUBatch *geom, eGPUShaderConfig sh_cfg);
struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct GPUBatch *geom, eGPUShaderConfig sh_cfg);
struct DRWShadingGroup *shgroup_instance_mball_handles(struct DRWPass *pass, eGPUShaderConfig sh_cfg);
-struct DRWShadingGroup *shgroup_instance_bone_axes(struct DRWPass *pass);
-struct DRWShadingGroup *shgroup_instance_bone_envelope_distance(struct DRWPass *pass);
-struct DRWShadingGroup *shgroup_instance_bone_envelope_outline(struct DRWPass *pass);
-struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass, bool transp);
+struct DRWShadingGroup *shgroup_instance_bone_axes(struct DRWPass *pass, eGPUShaderConfig sh_cfg);
+struct DRWShadingGroup *shgroup_instance_bone_envelope_distance(struct DRWPass *pass, eGPUShaderConfig sh_cfg);
+struct DRWShadingGroup *shgroup_instance_bone_envelope_outline(struct DRWPass *pass, eGPUShaderConfig sh_cfg);
+struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass, bool transp, eGPUShaderConfig sh_cfg);
struct DRWShadingGroup *shgroup_instance_bone_shape_outline(struct DRWPass *pass, struct GPUBatch *geom, eGPUShaderConfig sh_cfg);
struct DRWShadingGroup *shgroup_instance_bone_shape_solid(struct DRWPass *pass, struct GPUBatch *geom, bool transp, eGPUShaderConfig sh_cfg);
struct DRWShadingGroup *shgroup_instance_bone_sphere_outline(struct DRWPass *pass, eGPUShaderConfig sh_cfg);
diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c
index 09d0fa06f22..1d0fb5cb2a8 100644
--- a/source/blender/draw/intern/draw_hair.c
+++ b/source/blender/draw/intern/draw_hair.c
@@ -246,7 +246,7 @@ void DRW_hair_update(void)
* readback the result to system memory and reupload as VBO data.
* It is really not ideal performance wise, but it is the simplest
* and the most local workaround that still uses the power of the GPU.
- **/
+ */
if (g_tf_calls == NULL) {
return;
@@ -263,7 +263,7 @@ void DRW_hair_update(void)
* Do chunks of maximum 2048 * 2048 hair points. */
int width = 2048;
int height = min_ii(width, 1 + max_size / width);
- GPUTexture *tex = DRW_texture_pool_query_2D(width, height, GPU_RGBA32F, (void *)DRW_hair_update);
+ GPUTexture *tex = DRW_texture_pool_query_2d(width, height, GPU_RGBA32F, (void *)DRW_hair_update);
g_tf_target_height = height;
g_tf_target_width = width;
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 119ac7c2609..718518643e0 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -24,10 +24,10 @@
* DRW Instance Data Manager
* This is a special memory manager that keeps memory blocks ready to send as vbo data in one continuous allocation.
* This way we avoid feeding gawain each instance data one by one and unnecessary memcpy.
- * Since we loose which memory block was used each DRWShadingGroup we need to redistribute them in the same order/size
+ * Since we loose which memory block was used each #DRWShadingGroup we need to redistribute them in the same order/size
* to avoid to realloc each frame.
- * This is why DRWInstanceDatas are sorted in a list for each different data size.
- **/
+ * This is why #DRWInstanceDatas are sorted in a list for each different data size.
+ */
#include "draw_instance_data.h"
#include "DRW_engine.h"
@@ -94,15 +94,14 @@ static ListBase g_idatalists = {NULL, NULL};
* be static so that it's pointer never changes (because we are using
* this pointer as identifier [we don't want to check the full format
* that would be too slow]).
- **/
-
+ */
static void instance_batch_free(GPUBatch *batch, void *UNUSED(user_data))
{
if (batch->verts[0] == NULL) {
/** XXX This is a false positive case.
* The batch has been requested but not init yet
* and there is a chance that it might become init.
- **/
+ */
return;
}
/* Free all batches that have the same key before they are reused. */
@@ -313,7 +312,7 @@ static void DRW_instance_data_free(DRWInstanceData *idata)
/**
* Return a pointer to the next instance data space.
- **/
+ */
void *DRW_instance_data_next(DRWInstanceData *idata)
{
return BLI_mempool_alloc(idata->mempool);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index e5307fa952f..72117f60ed8 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -59,6 +59,7 @@
#include "GPU_uniformbuffer.h"
#include "GPU_viewport.h"
#include "GPU_matrix.h"
+#include "GPU_select.h"
#include "IMB_colormanagement.h"
@@ -218,6 +219,13 @@ bool DRW_object_is_visible_psys_in_active_context(
const Object *object,
const ParticleSystem *psys)
{
+ const bool for_render = DRW_state_is_image_render();
+ /* NOTE: psys_check_enabled is using object and particle system for only
+ * reading, but is using some other functions which are more generic and
+ * which are hard to make const-pointer. */
+ if (!psys_check_enabled((Object *)object, (ParticleSystem *)psys, for_render)) {
+ return false;
+ }
const DRWContextState *draw_ctx = DRW_context_state_get();
const Scene *scene = draw_ctx->scene;
if (object == draw_ctx->object_edit) {
@@ -340,6 +348,8 @@ void DRW_transform_to_display(GPUTexture *tex, bool use_view_transform, bool use
/* Draw texture to framebuffer without any color transforms */
void DRW_transform_none(GPUTexture *tex)
{
+ drw_state_set(DRW_STATE_WRITE_COLOR);
+
/* Draw as texture for final render (without immediate mode). */
GPUBatch *geom = DRW_cache_fullscreen_quad_get();
GPU_batch_program_set_builtin(geom, GPU_SHADER_2D_IMAGE_COLOR);
@@ -367,9 +377,11 @@ void DRW_transform_none(GPUTexture *tex)
/** \name Multisample Resolve
* \{ */
-/* Use manual multisample resolve pass.
+/**
+ * Use manual multisample resolve pass.
* Much quicker than blitting back and forth.
- * Assume destination fb is bound*/
+ * Assume destination fb is bound.
+ */
void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color, bool use_depth)
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_PREMUL;
@@ -1299,7 +1311,8 @@ static void drw_engines_enable_basic(void)
static void drw_engines_enable(ViewLayer *view_layer, RenderEngineType *engine_type)
{
Object *obact = OBACT(view_layer);
- const int mode = CTX_data_mode_enum_ex(DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode);
+ const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
+ DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode);
View3D *v3d = DST.draw_ctx.v3d;
const int drawtype = v3d->shading.type;
const bool use_xray = XRAY_ENABLED(v3d);
@@ -1320,8 +1333,6 @@ static void drw_engines_enable(ViewLayer *view_layer, RenderEngineType *engine_t
if (v3d->shading.type == OB_WIRE) {
drw_engines_enable_from_overlays(v3d->overlay.flag);
}
-
- drw_engines_enable_from_mode(mode);
}
}
@@ -1559,7 +1570,7 @@ void DRW_draw_render_loop_ex(
if (do_annotations) {
GPU_depth_test(false);
/* XXX: as scene->gpd is not copied for COW yet */
- ED_gpencil_draw_view3d_annotations(DEG_get_input_scene(depsgraph), depsgraph, v3d, ar, true);
+ ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, v3d, ar, true);
GPU_depth_test(true);
}
@@ -1598,7 +1609,7 @@ void DRW_draw_render_loop_ex(
{
GPU_depth_test(false);
/* XXX: as scene->gpd is not copied for COW yet */
- ED_gpencil_draw_view3d_annotations(DEG_get_input_scene(depsgraph), depsgraph, v3d, ar, false);
+ ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, v3d, ar, false);
GPU_depth_test(true);
}
@@ -1663,7 +1674,9 @@ void DRW_draw_render_loop(
void DRW_draw_render_loop_offscreen(
struct Depsgraph *depsgraph, RenderEngineType *engine_type,
ARegion *ar, View3D *v3d,
- const bool draw_background, GPUOffScreen *ofs,
+ const bool draw_background,
+ const bool do_color_management,
+ GPUOffScreen *ofs,
GPUViewport *viewport)
{
/* Create temporary viewport if needed. */
@@ -1676,7 +1689,9 @@ void DRW_draw_render_loop_offscreen(
/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
- DST.options.is_image_render = true;
+ /* WATCH: Force color management to output CManaged byte buffer by
+ * forcing is_image_render to false. */
+ DST.options.is_image_render = !do_color_management;
DST.options.draw_background = draw_background;
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, render_viewport, NULL);
@@ -1702,7 +1717,7 @@ bool DRW_render_check_grease_pencil(Depsgraph *depsgraph)
}
}
}
- DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END
+ DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
return false;
}
@@ -1775,11 +1790,6 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph
drw_viewport_var_init();
- /* set default viewport */
- gpuPushAttr(GPU_ENABLE_BIT | GPU_VIEWPORT_BIT);
- glDisable(GL_SCISSOR_TEST);
- glViewport(0, 0, size[0], size[1]);
-
/* Main rendering. */
rctf view_rect;
rcti render_rect;
@@ -1801,8 +1811,6 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph
glDisable(GL_DEPTH_TEST);
/* Restore Drawing area. */
- gpuPopAttr();
- glEnable(GL_SCISSOR_TEST);
GPU_framebuffer_restore();
/* Changing Context */
@@ -1818,7 +1826,6 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
RenderEngineType *engine_type = engine->type;
DrawEngineType *draw_engine_type = engine_type->draw_engine;
- RenderData *r = &scene->r;
Render *render = engine->re;
if (G.background && DST.gl_context == NULL) {
@@ -1857,7 +1864,7 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
drw_context_state_init();
DST.viewport = GPU_viewport_create();
- const int size[2] = {(r->size * r->xsch) / 100, (r->size * r->ysch) / 100};
+ const int size[2] = {engine->resolution_x, engine->resolution_y};
GPU_viewport_size_set(DST.viewport, size);
drw_viewport_var_init();
@@ -1875,6 +1882,9 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
BLI_rcti_init(&render_rect, 0, size[0], 0, size[1]);
}
+ /* Reset state before drawing */
+ DRW_state_reset();
+
/* Init render result. */
RenderResult *render_result = RE_engine_begin_result(
engine,
@@ -1894,6 +1904,7 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
engine_type->draw_engine->render_to_image(data, engine, render_layer, &render_rect);
/* grease pencil: render result is merged in the previous render result. */
if (DRW_render_check_grease_pencil(depsgraph)) {
+ DRW_state_reset();
DRW_render_gpencil_to_image(engine, render_layer, &render_rect);
}
DST.buffer_finish_called = false;
@@ -1912,6 +1923,9 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
drw_state_ensure_not_reused(&DST);
#endif
+ /* Reset state after drawing */
+ DRW_state_reset();
+
/* Changing Context */
if (re_gl_context != NULL) {
DRW_gawain_render_context_disable(re_gpu_context);
@@ -1946,7 +1960,7 @@ void DRW_render_object_iter(
drw_batch_cache_generate_requested(ob);
}
}
- DEG_OBJECT_ITER_END
+ DEG_OBJECT_ITER_END;
}
/* Assume a valid gl context is bound (and that the gl_context_mutex has been acquired).
@@ -1993,6 +2007,12 @@ void DRW_custom_pipeline(
GPU_viewport_free(DST.viewport);
GPU_framebuffer_restore();
+ /* The use of custom pipeline in other thread using the same
+ * resources as the main thread (viewport) may lead to data
+ * races and undefined behavior on certain drivers. Using
+ * GPU_finish to sync seems to fix the issue. (see T62997) */
+ GPU_finish();
+
#ifdef DEBUG
/* Avoid accidental reuse. */
drw_state_ensure_not_reused(&DST);
@@ -2000,34 +2020,68 @@ void DRW_custom_pipeline(
}
static struct DRWSelectBuffer {
- struct GPUFrameBuffer *framebuffer;
+ struct GPUFrameBuffer *framebuffer_depth_only;
+ struct GPUFrameBuffer *framebuffer_select_id;
struct GPUTexture *texture_depth;
+ struct GPUTexture *texture_u32;
} g_select_buffer = {NULL};
-static void draw_select_framebuffer_setup(const rcti *rect)
+static void draw_select_framebuffer_depth_only_setup(const int size[2])
{
- if (g_select_buffer.framebuffer == NULL) {
- g_select_buffer.framebuffer = GPU_framebuffer_create();
+ if (g_select_buffer.framebuffer_depth_only == NULL) {
+ g_select_buffer.framebuffer_depth_only = GPU_framebuffer_create();
+ g_select_buffer.framebuffer_select_id = GPU_framebuffer_create();
}
- /* If size mismatch recreate the texture. */
if ((g_select_buffer.texture_depth != NULL) &&
- ((GPU_texture_width(g_select_buffer.texture_depth) != BLI_rcti_size_x(rect)) ||
- (GPU_texture_height(g_select_buffer.texture_depth) != BLI_rcti_size_y(rect))))
+ ((GPU_texture_width(g_select_buffer.texture_depth) != size[0]) ||
+ (GPU_texture_height(g_select_buffer.texture_depth) != size[1])))
{
GPU_texture_free(g_select_buffer.texture_depth);
g_select_buffer.texture_depth = NULL;
}
if (g_select_buffer.texture_depth == NULL) {
- g_select_buffer.texture_depth = GPU_texture_create_2D(
- BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), GPU_DEPTH_COMPONENT24, NULL, NULL);
+ g_select_buffer.texture_depth = GPU_texture_create_2d(
+ size[0], size[1], GPU_DEPTH_COMPONENT24, NULL, NULL);
- GPU_framebuffer_texture_attach(g_select_buffer.framebuffer, g_select_buffer.texture_depth, 0, 0);
+ GPU_framebuffer_texture_attach(
+ g_select_buffer.framebuffer_depth_only,
+ g_select_buffer.texture_depth, 0, 0);
- if (!GPU_framebuffer_check_valid(g_select_buffer.framebuffer, NULL)) {
- printf("Error invalid selection framebuffer\n");
- }
+ GPU_framebuffer_texture_attach(
+ g_select_buffer.framebuffer_select_id,
+ g_select_buffer.texture_depth, 0, 0);
+
+ GPU_framebuffer_check_valid(
+ g_select_buffer.framebuffer_depth_only, NULL);
+ GPU_framebuffer_check_valid(
+ g_select_buffer.framebuffer_select_id, NULL);
+ }
+}
+
+static void draw_select_framebuffer_select_id_setup(const int size[2])
+{
+ draw_select_framebuffer_depth_only_setup(size);
+
+ if ((g_select_buffer.texture_u32 != NULL) &&
+ ((GPU_texture_width(g_select_buffer.texture_u32) != size[0]) ||
+ (GPU_texture_height(g_select_buffer.texture_u32) != size[1])))
+ {
+ GPU_texture_free(g_select_buffer.texture_u32);
+ g_select_buffer.texture_u32 = NULL;
+ }
+
+ if (g_select_buffer.texture_u32 == NULL) {
+ g_select_buffer.texture_u32 = GPU_texture_create_2d(
+ size[0], size[1], GPU_R32UI, NULL, NULL);
+
+ GPU_framebuffer_texture_attach(
+ g_select_buffer.framebuffer_select_id,
+ g_select_buffer.texture_u32, 0, 0);
+
+ GPU_framebuffer_check_valid(
+ g_select_buffer.framebuffer_select_id, NULL);
}
}
@@ -2085,8 +2139,9 @@ void DRW_draw_select_loop(
}
}
+ int viewport_size[2] = {BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)};
struct GPUViewport *viewport = GPU_viewport_create();
- GPU_viewport_size_set(viewport, (const int[2]){BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)});
+ GPU_viewport_size_set(viewport, viewport_size);
DST.viewport = viewport;
DST.options.is_select = true;
@@ -2194,9 +2249,9 @@ void DRW_draw_select_loop(
}
/* Setup framebuffer */
- draw_select_framebuffer_setup(rect);
- GPU_framebuffer_bind(g_select_buffer.framebuffer);
- GPU_framebuffer_clear_depth(g_select_buffer.framebuffer, 1.0f);
+ draw_select_framebuffer_depth_only_setup(viewport_size);
+ GPU_framebuffer_bind(g_select_buffer.framebuffer_depth_only);
+ GPU_framebuffer_clear_depth(g_select_buffer.framebuffer_depth_only, 1.0f);
/* Start Drawing */
DRW_state_reset();
@@ -2279,51 +2334,20 @@ static void draw_depth_texture_to_screen(GPUTexture *texture)
immUnbindProgram();
}
+
/**
* object mode select-loop, see: ED_view3d_draw_depth_loop (legacy drawing).
*/
-void DRW_draw_depth_loop(
- Depsgraph *depsgraph,
- ARegion *ar, View3D *v3d)
+static void drw_draw_depth_loop_imp(void)
{
- Scene *scene = DEG_get_evaluated_scene(depsgraph);
- RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
- ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
- RegionView3D *rv3d = ar->regiondata;
-
DRW_opengl_context_enable();
- /* Reset before using it. */
- drw_state_prepare_clean_for_draw(&DST);
-
- struct GPUViewport *viewport = GPU_viewport_create();
- GPU_viewport_size_set(viewport, (const int[2]){ar->winx, ar->winy});
-
/* Setup framebuffer */
- draw_select_framebuffer_setup(&ar->winrct);
- GPU_framebuffer_bind(g_select_buffer.framebuffer);
- GPU_framebuffer_clear_depth(g_select_buffer.framebuffer, 1.0f);
-
- DST.viewport = viewport;
- DST.options.is_depth = true;
-
- /* Get list of enabled engines */
- {
- drw_engines_enable_basic();
- if (DRW_state_draw_support()) {
- drw_engines_enable_from_object_mode();
- }
- }
+ DefaultFramebufferList *fbl = (DefaultFramebufferList *)GPU_viewport_framebuffer_list_get(DST.viewport);
+ GPU_framebuffer_bind(fbl->depth_only_fb);
+ GPU_framebuffer_clear_depth(fbl->depth_only_fb, 1.0f);
/* Setup viewport */
-
- /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
- DST.draw_ctx = (DRWContextState){
- .ar = ar, .rv3d = rv3d, .v3d = v3d,
- .scene = scene, .view_layer = view_layer, .obact = OBACT(view_layer),
- .engine_type = engine_type,
- .depsgraph = depsgraph,
- };
drw_context_state_init();
drw_viewport_var_init();
@@ -2336,10 +2360,11 @@ void DRW_draw_depth_loop(
{
drw_engines_cache_init();
- drw_engines_world_update(scene);
+ drw_engines_world_update(DST.draw_ctx.scene);
+ View3D *v3d = DST.draw_ctx.v3d;
const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
- DEG_OBJECT_ITER_BEGIN(depsgraph, ob,
+ DEG_OBJECT_ITER_BEGIN(DST.draw_ctx.depsgraph, ob,
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
DEG_ITER_OBJECT_FLAG_VISIBLE |
@@ -2374,36 +2399,185 @@ void DRW_draw_depth_loop(
DRW_draw_callbacks_post_scene();
DRW_state_reset();
- drw_engines_disable();
-
-#ifdef DEBUG
- /* Avoid accidental reuse. */
- drw_state_ensure_not_reused(&DST);
-#endif
/* TODO: Reading depth for operators should be done here. */
GPU_framebuffer_restore();
- /* Cleanup for selection state */
- GPU_viewport_free(viewport);
-
/* Changin context */
DRW_opengl_context_disable();
+}
+
+/**
+ * object mode select-loop, see: ED_view3d_draw_depth_loop (legacy drawing).
+ */
+void DRW_draw_depth_loop(
+ struct Depsgraph *depsgraph,
+ ARegion *ar, View3D *v3d,
+ GPUViewport *viewport)
+{
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
+ RegionView3D *rv3d = ar->regiondata;
+
+ /* Reset before using it. */
+ drw_state_prepare_clean_for_draw(&DST);
+
+ DST.viewport = viewport;
+ DST.options.is_depth = true;
+
+ /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
+ DST.draw_ctx = (DRWContextState){
+ .ar = ar, .rv3d = rv3d, .v3d = v3d,
+ .scene = scene, .view_layer = view_layer, .obact = OBACT(view_layer),
+ .engine_type = engine_type,
+ .depsgraph = depsgraph,
+ };
+
+ /* Get list of enabled engines */
+ {
+ drw_engines_enable_basic();
+ if (DRW_state_draw_support()) {
+ drw_engines_enable_from_object_mode();
+ }
+ }
+
+ drw_draw_depth_loop_imp();
+
+ drw_engines_disable();
/* XXX Drawing the resulting buffer to the BACK_BUFFER */
GPU_matrix_push();
GPU_matrix_push_projection();
- wmOrtho2_region_pixelspace(ar);
+ 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);
- draw_depth_texture_to_screen(g_select_buffer.texture_depth);
+ 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);
+#endif
+}
+
+/**
+ * Converted from ED_view3d_draw_depth_gpencil (legacy drawing).
+ */
+void DRW_draw_depth_loop_gpencil(
+ struct Depsgraph *depsgraph,
+ ARegion *ar, View3D *v3d,
+ GPUViewport *viewport)
+{
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
+ RegionView3D *rv3d = ar->regiondata;
+
+ /* Reset before using it. */
+ drw_state_prepare_clean_for_draw(&DST);
+
+ DST.viewport = viewport;
+ DST.options.is_depth = true;
+
+ /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
+ DST.draw_ctx = (DRWContextState){
+ .ar = ar, .rv3d = rv3d, .v3d = v3d,
+ .scene = scene, .view_layer = view_layer, .obact = OBACT(view_layer),
+ .depsgraph = depsgraph,
+ };
+
+ use_drw_engine(&draw_engine_gpencil_type);
+ drw_draw_depth_loop_imp();
+ drw_engines_disable();
+
+#ifdef DEBUG
+ /* Avoid accidental reuse. */
+ drw_state_ensure_not_reused(&DST);
+#endif
+}
+
+
+/* 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)
+{
+ RegionView3D *rv3d = ar->regiondata;
+
+ DRW_opengl_context_enable();
+
+ /* Setup framebuffer */
+ int viewport_size[2] = {ar->winx, ar->winy};
+ draw_select_framebuffer_select_id_setup(viewport_size);
+ GPU_framebuffer_bind(g_select_buffer.framebuffer_select_id);
+
+ /* dithering and AA break color coding, so disable */
+ glDisable(GL_DITHER);
+
+ GPU_depth_test(true);
+ glDisable(GL_SCISSOR_TEST);
+
+ if (clear) {
+ GPU_framebuffer_clear_color_depth(
+ g_select_buffer.framebuffer_select_id, (const float[4]){0.0f}, 1.0f);
+ }
+
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ ED_view3d_clipping_set(rv3d);
+ }
+}
+
+
+/* Ends the context for selection and restoring the previous one. */
+void DRW_framebuffer_select_id_release(ARegion *ar)
+{
+ RegionView3D *rv3d = ar->regiondata;
+
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ ED_view3d_clipping_disable();
+ }
+
+ GPU_depth_test(false);
+
+ GPU_framebuffer_restore();
+
+ DRW_opengl_context_disable();
+}
+
+
+/* Read a block of pixels from the select frame buffer. */
+void DRW_framebuffer_select_id_read(const rcti *rect, uint *r_buf)
+{
+ /* clamp rect by texture */
+ rcti r = {
+ .xmin = 0,
+ .xmax = GPU_texture_width(g_select_buffer.texture_u32),
+ .ymin = 0,
+ .ymax = GPU_texture_height(g_select_buffer.texture_u32),
+ };
+
+ rcti rect_clamp = *rect;
+ if (BLI_rcti_isect(&r, &rect_clamp, &rect_clamp)) {
+ GPU_texture_read_rect(
+ g_select_buffer.texture_u32,
+ GPU_DATA_UNSIGNED_INT, &rect_clamp, r_buf);
+
+ if (!BLI_rcti_compare(rect, &rect_clamp)) {
+ GPU_select_buffer_stride_realign(rect, &rect_clamp, r_buf);
+ }
+ }
+ else {
+ size_t buf_size = BLI_rcti_size_x(rect) *
+ BLI_rcti_size_y(rect) *
+ sizeof(*r_buf);
+
+ memset(r_buf, 0, buf_size);
+ }
}
/** \} */
@@ -2589,10 +2763,19 @@ void DRW_engines_register(void)
void DRW_engines_free(void)
{
+ if (DST.gl_context == NULL) {
+ /* Nothing has been setup. Nothing to clear.
+ * Otherwise, DRW_opengl_context_enable can
+ * create a context in background mode. (see T62355) */
+ return;
+ }
+
DRW_opengl_context_enable();
+ DRW_TEXTURE_FREE_SAFE(g_select_buffer.texture_u32);
DRW_TEXTURE_FREE_SAFE(g_select_buffer.texture_depth);
- GPU_FRAMEBUFFER_FREE_SAFE(g_select_buffer.framebuffer);
+ GPU_FRAMEBUFFER_FREE_SAFE(g_select_buffer.framebuffer_select_id);
+ GPU_FRAMEBUFFER_FREE_SAFE(g_select_buffer.framebuffer_depth_only);
DRW_hair_free();
DRW_shape_cache_free();
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 22dfc28e305..45721951abf 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -83,7 +83,7 @@
* Data structure containing all drawcalls organized by passes and materials.
* DRWPass > DRWShadingGroup > DRWCall > DRWCallState
* > DRWUniform
- **/
+ */
/* Used by DRWCallState.flag */
enum {
@@ -99,10 +99,11 @@ enum {
DRW_CALL_MODELVIEWINVERSE = (1 << 2),
DRW_CALL_MODELVIEWPROJECTION = (1 << 3),
DRW_CALL_NORMALVIEW = (1 << 4),
- DRW_CALL_NORMALWORLD = (1 << 5),
- DRW_CALL_ORCOTEXFAC = (1 << 6),
- DRW_CALL_EYEVEC = (1 << 7),
- DRW_CALL_OBJECTINFO = (1 << 8),
+ DRW_CALL_NORMALVIEWINVERSE = (1 << 5),
+ DRW_CALL_NORMALWORLD = (1 << 6),
+ DRW_CALL_ORCOTEXFAC = (1 << 7),
+ DRW_CALL_EYEVEC = (1 << 8),
+ DRW_CALL_OBJECTINFO = (1 << 9),
};
typedef struct DRWCallState {
@@ -122,6 +123,7 @@ typedef struct DRWCallState {
float modelviewinverse[4][4];
float modelviewprojection[4][4];
float normalview[3][3];
+ float normalviewinverse[3][3];
float normalworld[3][3]; /* Not view dependent */
float orcotexfac[2][3]; /* Not view dependent */
float objectinfo[2];
@@ -258,6 +260,7 @@ struct DRWShadingGroup {
int modelviewinverse;
int modelviewprojection;
int normalview;
+ int normalviewinverse;
int normalworld;
int orcotexfac;
int eye;
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 6f9e2cff36c..7f553c0926d 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -695,6 +695,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
shgroup->modelviewinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW_INV);
shgroup->modelviewprojection = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MVP);
shgroup->normalview = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_NORMAL);
+ shgroup->normalviewinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_NORMAL_INV);
shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_WORLDNORMAL);
shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_ORCO);
shgroup->objectinfo = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_OBJECT_INFO);
@@ -717,6 +718,9 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
if (shgroup->normalview > -1) {
shgroup->matflag |= DRW_CALL_NORMALVIEW;
}
+ if (shgroup->normalviewinverse > -1) {
+ shgroup->matflag |= DRW_CALL_NORMALVIEWINVERSE;
+ }
if (shgroup->normalworld > -1) {
shgroup->matflag |= DRW_CALL_NORMALWORLD;
}
@@ -1179,8 +1183,8 @@ static int pass_shgroup_dist_sort(void *thunk, const void *a, const void *b)
const DRWCall *call_a = (DRWCall *)shgrp_a->calls.first;
const DRWCall *call_b = (DRWCall *)shgrp_b->calls.first;
- if (call_a == NULL) return -1;
- if (call_b == NULL) return -1;
+ if (call_a == NULL) { return -1; }
+ if (call_b == NULL) { return -1; }
float tmp[3];
sub_v3_v3v3(tmp, zsortdata->origin, call_a->state->model[3]);
@@ -1188,8 +1192,8 @@ static int pass_shgroup_dist_sort(void *thunk, const void *a, const void *b)
sub_v3_v3v3(tmp, zsortdata->origin, call_b->state->model[3]);
const float b_sq = dot_v3v3(zsortdata->axis, tmp);
- if (a_sq < b_sq) return 1;
- else if (a_sq > b_sq) return -1;
+ if (a_sq < b_sq) { return 1; }
+ else if (a_sq > b_sq) { return -1; }
else {
/* If there is a depth prepass put it before */
if ((shgrp_a->state_extra & DRW_STATE_WRITE_DEPTH) != 0) {
@@ -1198,7 +1202,9 @@ static int pass_shgroup_dist_sort(void *thunk, const void *a, const void *b)
else if ((shgrp_b->state_extra & DRW_STATE_WRITE_DEPTH) != 0) {
return 1;
}
- else return 0;
+ else {
+ return 0;
+ }
}
}
@@ -1217,7 +1223,7 @@ static int pass_shgroup_dist_sort(void *thunk, const void *a, const void *b)
/**
* Sort Shading groups by decreasing Z of their first draw call.
* This is useful for order dependent effect such as transparency.
- **/
+ */
void DRW_pass_sort_shgroup_z(DRWPass *pass)
{
float (*viewinv)[4];
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 2e8ba259a31..7dc42c4d459 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -426,7 +426,7 @@ void DRW_state_invert_facing(void)
* This only works if DRWPasses have been tagged with DRW_STATE_CLIP_PLANES,
* and if the shaders have support for it (see usage of gl_ClipDistance).
* Be sure to call DRW_state_clip_planes_reset() after you finish drawing.
- **/
+ */
void DRW_state_clip_planes_len_set(uint plane_len)
{
BLI_assert(plane_len <= MAX_CLIP_PLANES);
@@ -464,24 +464,17 @@ void DRW_state_clip_planes_set_from_rv3d(RegionView3D *rv3d)
*/
static void draw_frustum_boundbox_calc(const float(*projmat)[4], BoundBox *r_bbox)
{
- float near, far, left, right, bottom, top;
+ float left, right, bottom, top, near, far;
bool is_persp = projmat[3][3] == 0.0f;
+ projmat_dimensions(
+ projmat, &left, &right, &bottom, &top, &near, &far);
+
if (is_persp) {
- near = projmat[3][2] / (projmat[2][2] - 1.0f);
- far = projmat[3][2] / (projmat[2][2] + 1.0f);
- left = near * (projmat[2][0] - 1.0f) / projmat[0][0];
- right = near * (projmat[2][0] + 1.0f) / projmat[0][0];
- bottom = near * (projmat[2][1] - 1.0f) / projmat[1][1];
- top = near * (projmat[2][1] + 1.0f) / projmat[1][1];
- }
- else {
- near = ( projmat[3][2] + 1.0f) / projmat[2][2];
- far = ( projmat[3][2] - 1.0f) / projmat[2][2];
- left = (-projmat[3][0] - 1.0f) / projmat[0][0];
- right = (-projmat[3][0] + 1.0f) / projmat[0][0];
- bottom = (-projmat[3][1] - 1.0f) / projmat[1][1];
- top = (-projmat[3][1] + 1.0f) / projmat[1][1];
+ left *= near;
+ right *= near;
+ bottom *= near;
+ top *= near;
}
r_bbox->vec[0][2] = r_bbox->vec[3][2] = r_bbox->vec[7][2] = r_bbox->vec[4][2] = -near;
@@ -494,8 +487,8 @@ static void draw_frustum_boundbox_calc(const float(*projmat)[4], BoundBox *r_bbo
if (is_persp) {
float sca_far = far / near;
left *= sca_far;
- bottom *= sca_far;
right *= sca_far;
+ bottom *= sca_far;
top *= sca_far;
}
@@ -799,18 +792,20 @@ static void draw_matrices_model_prepare(DRWCallState *st)
if (st->matflag & DRW_CALL_MODELVIEWPROJECTION) {
mul_m4_m4m4(st->modelviewprojection, DST.view_data.matstate.mat[DRW_MAT_PERS], st->model);
}
- if (st->matflag & (DRW_CALL_NORMALVIEW | DRW_CALL_EYEVEC)) {
+ if (st->matflag & (DRW_CALL_NORMALVIEW | DRW_CALL_NORMALVIEWINVERSE | DRW_CALL_EYEVEC)) {
copy_m3_m4(st->normalview, st->modelview);
invert_m3(st->normalview);
transpose_m3(st->normalview);
}
+ if (st->matflag & (DRW_CALL_NORMALVIEWINVERSE | DRW_CALL_EYEVEC)) {
+ invert_m3_m3(st->normalviewinverse, st->normalview);
+ }
+ /* TODO remove eye vec (unused) */
if (st->matflag & DRW_CALL_EYEVEC) {
/* Used by orthographic wires */
- float tmp[3][3];
copy_v3_fl3(st->eyevec, 0.0f, 0.0f, 1.0f);
- invert_m3_m3(tmp, st->normalview);
/* set eye vector, transformed to object coords */
- mul_m3_v3(tmp, st->eyevec);
+ mul_m3_v3(st->normalviewinverse, st->eyevec);
}
/* Non view dependent */
if (st->matflag & DRW_CALL_MODELINVERSE) {
@@ -830,10 +825,11 @@ static void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWCall *call)
/* step 1 : bind object dependent matrices */
if (call != NULL) {
DRWCallState *state = call->state;
- float objectinfo[3];
+ float objectinfo[4];
objectinfo[0] = state->objectinfo[0];
objectinfo[1] = call->single.ma_index; /* WATCH this is only valid for single drawcalls. */
objectinfo[2] = state->objectinfo[1];
+ objectinfo[3] = (state->flag & DRW_CALL_NEGSCALE) ? -1.0f : 1.0f;
GPU_shader_uniform_vector(shgroup->shader, shgroup->model, 16, 1, (float *)state->model);
GPU_shader_uniform_vector(shgroup->shader, shgroup->modelinverse, 16, 1, (float *)state->modelinverse);
@@ -841,8 +837,9 @@ static void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWCall *call)
GPU_shader_uniform_vector(shgroup->shader, shgroup->modelviewinverse, 16, 1, (float *)state->modelviewinverse);
GPU_shader_uniform_vector(shgroup->shader, shgroup->modelviewprojection, 16, 1, (float *)state->modelviewprojection);
GPU_shader_uniform_vector(shgroup->shader, shgroup->normalview, 9, 1, (float *)state->normalview);
+ GPU_shader_uniform_vector(shgroup->shader, shgroup->normalviewinverse, 9, 1, (float *)state->normalviewinverse);
GPU_shader_uniform_vector(shgroup->shader, shgroup->normalworld, 9, 1, (float *)state->normalworld);
- GPU_shader_uniform_vector(shgroup->shader, shgroup->objectinfo, 3, 1, (float *)objectinfo);
+ GPU_shader_uniform_vector(shgroup->shader, shgroup->objectinfo, 4, 1, (float *)objectinfo);
GPU_shader_uniform_vector(shgroup->shader, shgroup->orcotexfac, 3, 2, (float *)state->orcotexfac);
GPU_shader_uniform_vector(shgroup->shader, shgroup->eye, 3, 1, (float *)state->eyevec);
}
@@ -856,7 +853,7 @@ static void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWCall *call)
GPU_shader_uniform_vector(shgroup->shader, shgroup->modelview, 16, 1, (float *)DST.view_data.matstate.mat[DRW_MAT_VIEW]);
GPU_shader_uniform_vector(shgroup->shader, shgroup->modelviewinverse, 16, 1, (float *)DST.view_data.matstate.mat[DRW_MAT_VIEWINV]);
GPU_shader_uniform_vector(shgroup->shader, shgroup->modelviewprojection, 16, 1, (float *)DST.view_data.matstate.mat[DRW_MAT_PERS]);
- GPU_shader_uniform_vector(shgroup->shader, shgroup->objectinfo, 3, 1, (float *)unitmat);
+ GPU_shader_uniform_vector(shgroup->shader, shgroup->objectinfo, 4, 1, (float *)unitmat);
GPU_shader_uniform_vector(shgroup->shader, shgroup->orcotexfac, 3, 2, (float *)shgroup->instance_orcofac);
}
}
@@ -1042,7 +1039,9 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
bool use_tfeedback = false;
if (shader_changed) {
- if (DST.shader) GPU_shader_unbind();
+ if (DST.shader) {
+ GPU_shader_unbind();
+ }
GPU_shader_bind(shgroup->shader);
DST.shader = shgroup->shader;
}
diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c
index 1ce0a92c978..51c0f4c4640 100644
--- a/source/blender/draw/intern/draw_manager_profiling.c
+++ b/source/blender/draw/intern/draw_manager_profiling.c
@@ -317,7 +317,7 @@ void DRW_stats_draw(rcti *rect)
v += 1;
/* GPU Timings */
- BLI_snprintf(stat_string, sizeof(stat_string), "GPU Render Timings");
+ BLI_strncpy(stat_string, "GPU Render Timings", sizeof(stat_string));
draw_stat(rect, 0, v++, stat_string, sizeof(stat_string));
for (int i = 0; i < DTP.timer_increment; ++i) {
@@ -326,7 +326,9 @@ void DRW_stats_draw(rcti *rect)
DRWTimer *timer_parent = (timer->lvl > 0) ? &DTP.timers[lvl_index[timer->lvl - 1]] : NULL;
/* Only display a number of lvl at a time */
- if ((G.debug_value - 21) < timer->lvl) continue;
+ if ((G.debug_value - 21) < timer->lvl) {
+ continue;
+ }
BLI_assert(timer->lvl < MAX_NESTED_TIMER);
lvl_index[timer->lvl] = i;
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 54ad98d3189..1fc6b61b87a 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -297,12 +297,12 @@ GPUShader *DRW_shader_create_with_transform_feedback(
prim_type, varying_names, varying_count, __func__);
}
-GPUShader *DRW_shader_create_2D(const char *frag, const char *defines)
+GPUShader *DRW_shader_create_2d(const char *frag, const char *defines)
{
return GPU_shader_create(datatoc_gpu_shader_2D_vert_glsl, frag, NULL, NULL, defines, __func__);
}
-GPUShader *DRW_shader_create_3D(const char *frag, const char *defines)
+GPUShader *DRW_shader_create_3d(const char *frag, const char *defines)
{
return GPU_shader_create(datatoc_gpu_shader_3D_vert_glsl, frag, NULL, NULL, defines, __func__);
}
@@ -312,7 +312,7 @@ GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines)
return GPU_shader_create(datatoc_common_fullscreen_vert_glsl, frag, NULL, NULL, defines, __func__);
}
-GPUShader *DRW_shader_create_3D_depth_only(eGPUShaderConfig sh_cfg)
+GPUShader *DRW_shader_create_3d_depth_only(eGPUShaderConfig sh_cfg)
{
return GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_DEPTH_ONLY, sh_cfg);
}
diff --git a/source/blender/draw/intern/draw_manager_texture.c b/source/blender/draw/intern/draw_manager_texture.c
index 09b473f8b5f..e138ac99533 100644
--- a/source/blender/draw/intern/draw_manager_texture.c
+++ b/source/blender/draw/intern/draw_manager_texture.c
@@ -73,43 +73,35 @@ void drw_texture_set_parameters(GPUTexture *tex, DRWTextureFlag flags)
GPU_texture_unbind(tex);
}
-GPUTexture *DRW_texture_create_1D(int w, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
+GPUTexture *DRW_texture_create_1d(int w, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
{
- GPUTexture *tex = GPU_texture_create_1D(w, format, fpixels, NULL);
+ GPUTexture *tex = GPU_texture_create_1d(w, format, fpixels, NULL);
drw_texture_set_parameters(tex, flags);
return tex;
}
-GPUTexture *DRW_texture_create_2D(int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
+GPUTexture *DRW_texture_create_2d(int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
{
- GPUTexture *tex = GPU_texture_create_2D(w, h, format, fpixels, NULL);
+ GPUTexture *tex = GPU_texture_create_2d(w, h, format, fpixels, NULL);
drw_texture_set_parameters(tex, flags);
return tex;
}
-GPUTexture *DRW_texture_create_2D_multisample(int w, int h, eGPUTextureFormat format, int samples, DRWTextureFlag flags, const float *fpixels)
-{
- GPUTexture *tex = GPU_texture_create_2D_multisample(w, h, format, fpixels, samples, NULL);
- drw_texture_set_parameters(tex, flags);
-
- return tex;
-}
-
-GPUTexture *DRW_texture_create_2D_array(
+GPUTexture *DRW_texture_create_2d_array(
int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
{
- GPUTexture *tex = GPU_texture_create_2D_array(w, h, d, format, fpixels, NULL);
+ GPUTexture *tex = GPU_texture_create_2d_array(w, h, d, format, fpixels, NULL);
drw_texture_set_parameters(tex, flags);
return tex;
}
-GPUTexture *DRW_texture_create_3D(
+GPUTexture *DRW_texture_create_3d(
int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
{
- GPUTexture *tex = GPU_texture_create_3D(w, h, d, format, fpixels, NULL);
+ GPUTexture *tex = GPU_texture_create_3d(w, h, d, format, fpixels, NULL);
drw_texture_set_parameters(tex, flags);
return tex;
@@ -123,7 +115,7 @@ GPUTexture *DRW_texture_create_cube(int w, eGPUTextureFormat format, DRWTextureF
return tex;
}
-GPUTexture *DRW_texture_pool_query_2D(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type)
+GPUTexture *DRW_texture_pool_query_2d(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type)
{
BLI_assert(drw_texture_format_supports_framebuffer(format));
GPUTexture *tex = GPU_viewport_texture_pool_query(DST.viewport, engine_type, w, h, format);
@@ -131,18 +123,18 @@ GPUTexture *DRW_texture_pool_query_2D(int w, int h, eGPUTextureFormat format, Dr
return tex;
}
-void DRW_texture_ensure_fullscreen_2D(GPUTexture **tex, eGPUTextureFormat format, DRWTextureFlag flags)
+void DRW_texture_ensure_fullscreen_2d(GPUTexture **tex, eGPUTextureFormat format, DRWTextureFlag flags)
{
if (*(tex) == NULL) {
const float *size = DRW_viewport_size_get();
- *(tex) = DRW_texture_create_2D((int)size[0], (int)size[1], format, flags, NULL);
+ *(tex) = DRW_texture_create_2d((int)size[0], (int)size[1], format, flags, NULL);
}
}
-void DRW_texture_ensure_2D(GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags)
+void DRW_texture_ensure_2d(GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags)
{
if (*(tex) == NULL) {
- *(tex) = DRW_texture_create_2D(w, h, format, flags, NULL);
+ *(tex) = DRW_texture_create_2d(w, h, format, flags, NULL);
}
}
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index cde63e7408b..b907452dad2 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -215,8 +215,8 @@ void DRW_draw_cursor(void)
/* Draw nice Anti Aliased cursor. */
GPU_line_width(1.0f);
- glEnable(GL_BLEND);
- glEnable(GL_LINE_SMOOTH);
+ GPU_blend(true);
+ GPU_line_smooth(true);
float eps = 1e-5f;
rv3d->viewquat[0] = -rv3d->viewquat[0];
@@ -247,7 +247,7 @@ void DRW_draw_cursor(void)
#define CURSOR_EDGE(axis_vec, axis, sign) { \
CURSOR_VERT(axis_vec, axis, sign 1.0f); \
CURSOR_VERT(axis_vec, axis, sign 0.25f); \
- }
+ } ((void)0)
for (int axis = 0; axis < 3; axis++) {
float axis_vec[3] = {0};
@@ -277,8 +277,8 @@ void DRW_draw_cursor(void)
GPU_batch_draw(cursor_batch);
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
+ GPU_blend(false);
+ GPU_line_smooth(false);
GPU_matrix_pop();
GPU_matrix_projection_set(original_proj);
}
diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c
index 2c47667a4e9..68f091da797 100644
--- a/source/blender/draw/modes/edit_armature_mode.c
+++ b/source/blender/draw/modes/edit_armature_mode.c
@@ -109,9 +109,11 @@ static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
if (arm->edbo) {
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
EDIT_ARMATURE_StorageList *stl = ((EDIT_ARMATURE_Data *)vedata)->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
int ghost = (ob->dtx & OB_DRAWXRAY) ? 1 : 0;
- bool transp = (stl->g_data->transparent_bones || (ob->dt <= OB_WIRE));
+ bool transp = (stl->g_data->transparent_bones || (ob->dt <= OB_WIRE)) ||
+ (draw_ctx->v3d->shading.flag & XRAY_FLAG(draw_ctx->v3d)) != 0;
DRWArmaturePasses passes = {
.bone_solid = (transp) ? psl->bone_transp[ghost] : psl->bone_solid[ghost],
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c
index c2841549270..a1741c7e967 100644
--- a/source/blender/draw/modes/edit_curve_mode.c
+++ b/source/blender/draw/modes/edit_curve_mode.c
@@ -57,6 +57,7 @@ extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
typedef struct EDIT_CURVE_PassList {
struct DRWPass *wire_pass;
+ struct DRWPass *wire_pass_xray;
struct DRWPass *overlay_edge_pass;
struct DRWPass *overlay_vert_pass;
} EDIT_CURVE_PassList;
@@ -86,12 +87,14 @@ typedef struct EDIT_CURVE_Shaders {
static struct {
EDIT_CURVE_Shaders sh_data[GPU_SHADER_CFG_LEN];
-} e_data = {NULL}; /* Engine data */
+} e_data = {{{NULL}}}; /* Engine data */
typedef struct EDIT_CURVE_PrivateData {
/* resulting curve as 'wire' for curves (and optionally normals) */
DRWShadingGroup *wire_shgrp;
+ DRWShadingGroup *wire_shgrp_xray;
DRWShadingGroup *wire_normals_shgrp;
+ DRWShadingGroup *wire_normals_shgrp_xray;
DRWShadingGroup *overlay_edge_shgrp;
DRWShadingGroup *overlay_vert_shgrp;
@@ -147,6 +150,30 @@ static void EDIT_CURVE_engine_init(void *UNUSED(vedata))
}
}
+static void EDIT_CURVE_wire_shgrp_create(
+ EDIT_CURVE_Shaders *sh_data,
+ const View3D *v3d,
+ const RegionView3D *rv3d,
+ DRWPass *pass,
+ DRWShadingGroup **wire_shgrp,
+ DRWShadingGroup **wire_normals_shgrp)
+{
+ DRWShadingGroup *grp = DRW_shgroup_create(sh_data->wire_sh, pass);
+ DRW_shgroup_uniform_vec4(grp, "color", G_draw.block.colorWireEdit, 1);
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
+ }
+ *wire_shgrp = grp;
+
+ grp = DRW_shgroup_create(sh_data->wire_normals_sh, pass);
+ DRW_shgroup_uniform_vec4(grp, "color", G_draw.block.colorWireEdit, 1);
+ DRW_shgroup_uniform_float_copy(grp, "normalSize", v3d->overlay.normals_length);
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
+ }
+ *wire_normals_shgrp = grp;
+}
+
/* Here init all passes and shading groups
* Assume that all Passes are NULL */
static void EDIT_CURVE_cache_init(void *vedata)
@@ -172,22 +199,16 @@ static void EDIT_CURVE_cache_init(void *vedata)
psl->wire_pass = DRW_pass_create(
"Curve Wire",
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WIRE);
+ EDIT_CURVE_wire_shgrp_create(sh_data, v3d, rv3d, psl->wire_pass,
+ &stl->g_data->wire_shgrp,
+ &stl->g_data->wire_normals_shgrp);
- grp = DRW_shgroup_create(sh_data->wire_sh, psl->wire_pass);
- DRW_shgroup_uniform_vec4(grp, "color", G_draw.block.colorWireEdit, 1);
- if (rv3d->rflag & RV3D_CLIPPING) {
- DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
- }
- stl->g_data->wire_shgrp = grp;
-
-
- grp = DRW_shgroup_create(sh_data->wire_normals_sh, psl->wire_pass);
- DRW_shgroup_uniform_vec4(grp, "color", G_draw.block.colorWireEdit, 1);
- DRW_shgroup_uniform_float_copy(grp, "normalSize", v3d->overlay.normals_length);
- if (rv3d->rflag & RV3D_CLIPPING) {
- DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
- }
- stl->g_data->wire_normals_shgrp = grp;
+ psl->wire_pass_xray = DRW_pass_create(
+ "Curve Wire Xray",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_WIRE);
+ EDIT_CURVE_wire_shgrp_create(sh_data, v3d, rv3d, psl->wire_pass_xray,
+ &stl->g_data->wire_shgrp_xray,
+ &stl->g_data->wire_normals_shgrp_xray);
psl->overlay_edge_pass = DRW_pass_create(
"Curve Handle Overlay",
@@ -229,13 +250,24 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob)
/* Get geometry cache */
struct GPUBatch *geom;
+ DRWShadingGroup *wire_shgrp, *wire_normals_shgrp;
+
+ if (ob->dtx & OB_DRAWXRAY) {
+ wire_shgrp = stl->g_data->wire_shgrp_xray;
+ wire_normals_shgrp = stl->g_data->wire_normals_shgrp_xray;
+ }
+ else {
+ wire_shgrp = stl->g_data->wire_shgrp;
+ wire_normals_shgrp = stl->g_data->wire_normals_shgrp;
+ }
+
geom = DRW_cache_curve_edge_wire_get(ob);
- DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat);
+ DRW_shgroup_call_add(wire_shgrp, geom, ob->obmat);
if ((cu->flag & CU_3D) && (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_NORMALS) != 0) {
static uint instance_len = 2;
geom = DRW_cache_curve_edge_normal_get(ob);
- DRW_shgroup_call_instances_add(stl->g_data->wire_normals_shgrp, geom, ob->obmat, &instance_len);
+ DRW_shgroup_call_instances_add(wire_normals_shgrp, geom, ob->obmat, &instance_len);
}
geom = DRW_cache_curve_edge_overlay_get(ob);
@@ -273,7 +305,20 @@ static void EDIT_CURVE_draw_scene(void *vedata)
DRW_draw_pass(psl->wire_pass);
- MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
+ MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl);
+ }
+
+ /* Unfortunately this pass cannot be AA'd without
+ * MULTISAMPLE_SYNC_DISABLE_NO_DEPTH. While it's
+ * quite unlikely to happen to multi-edit curves
+ * with a mix of xray enabled/disabled we still
+ * support this case. */
+ if (!DRW_pass_is_empty(psl->wire_pass_xray)) {
+ MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl);
+
+ DRW_draw_pass(psl->wire_pass_xray);
+
+ MULTISAMPLE_SYNC_DISABLE_NO_DEPTH(dfbl, dtxl);
}
/* Thoses passes don't write to depth and are AA'ed using other tricks. */
diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c
index 70870292556..3db167fc1fd 100644
--- a/source/blender/draw/modes/edit_lattice_mode.c
+++ b/source/blender/draw/modes/edit_lattice_mode.c
@@ -99,7 +99,7 @@ static struct {
EDIT_LATTICE_Shaders sh_data[GPU_SHADER_CFG_LEN];
-} e_data = {NULL}; /* Engine data */
+} e_data = {{{NULL}}}; /* Engine data */
typedef struct EDIT_LATTICE_PrivateData {
/* This keeps the references of the shading groups for
@@ -262,7 +262,7 @@ static void EDIT_LATTICE_draw_scene(void *vedata)
DRW_draw_pass(psl->wire_pass);
DRW_draw_pass(psl->vert_pass);
- MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
+ MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl);
/* If you changed framebuffer, double check you rebind
* the default one with its textures attached before finishing */
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index 9afb9ce40a0..71c759d47a5 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -61,14 +61,15 @@ extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[];
extern char datatoc_gpu_shader_flat_color_frag_glsl[];
extern char datatoc_gpu_shader_point_varying_color_frag_glsl[];
-extern char datatoc_gpu_shader_depth_only_frag_glsl[];
/* *********** LISTS *********** */
typedef struct EDIT_MESH_PassList {
struct DRWPass *weight_faces;
struct DRWPass *depth_hidden_wire;
- struct DRWPass *ghost_clear_depth;
+ struct DRWPass *depth_hidden_wire_in_front;
struct DRWPass *edit_face_overlay;
+ struct DRWPass *edit_face_overlay_in_front;
+ struct DRWPass *edit_face_in_front;
struct DRWPass *edit_face_occluded;
struct DRWPass *mix_occlude;
struct DRWPass *facefill_occlude;
@@ -112,7 +113,6 @@ typedef struct EDIT_MESH_Shaders {
GPUShader *normals_loop;
GPUShader *normals;
GPUShader *depth;
- GPUShader *ghost_clear_depth;
} EDIT_MESH_Shaders;
/* *********** STATIC *********** */
@@ -122,12 +122,13 @@ static struct {
/* temp buffer texture */
struct GPUTexture *occlude_wire_depth_tx;
struct GPUTexture *occlude_wire_color_tx;
-} e_data = {NULL}; /* Engine data */
+} e_data = {{{NULL}}}; /* Engine data */
typedef struct EDIT_MESH_PrivateData {
/* weight */
DRWShadingGroup *fweights_shgrp;
DRWShadingGroup *depth_shgrp_hidden_wire;
+ DRWShadingGroup *depth_shgrp_hidden_wire_in_front;
DRWShadingGroup *fnormals_shgrp;
DRWShadingGroup *vnormals_shgrp;
@@ -139,6 +140,12 @@ typedef struct EDIT_MESH_PrivateData {
DRWShadingGroup *face_cage_shgrp;
DRWShadingGroup *facedot_shgrp;
+ DRWShadingGroup *vert_shgrp_in_front;
+ DRWShadingGroup *edge_shgrp_in_front;
+ DRWShadingGroup *face_shgrp_in_front;
+ DRWShadingGroup *face_cage_shgrp_in_front;
+ DRWShadingGroup *facedot_shgrp_in_front;
+
DRWShadingGroup *facefill_occluded_shgrp;
int data_mask[4];
@@ -162,9 +169,9 @@ static void EDIT_MESH_engine_init(void *vedata)
const float *viewport_size = DRW_viewport_size_get();
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
- e_data.occlude_wire_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_DEPTH_COMPONENT24,
+ e_data.occlude_wire_depth_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_DEPTH_COMPONENT24,
&draw_engine_edit_mesh_type);
- e_data.occlude_wire_color_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8,
+ e_data.occlude_wire_color_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_RGBA8,
&draw_engine_edit_mesh_type);
GPU_framebuffer_ensure_config(&fbl->occlude_wire_fb, {
@@ -197,7 +204,7 @@ static void EDIT_MESH_engine_init(void *vedata)
geom_sh_code[0] = NULL;
}
const char *use_geom_def = use_geom_shader ? "#define USE_GEOM_SHADER\n" : "";
- const char *use_smooth_def = (U.uiflag2 & USER_EDIT_MODE_SMOOTH_WIRE) ? "#define USE_SMOOTH_WIRE\n" : "";
+ const char *use_smooth_def = (U.gpu_flag & USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE) ? "" : "#define USE_SMOOTH_WIRE\n";
sh_data->overlay_face = GPU_shader_create_from_arrays({
.vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL},
.frag = (const char *[]){datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL},
@@ -255,14 +262,12 @@ static void EDIT_MESH_engine_init(void *vedata)
.defs = (const char *[]){sh_cfg_data->def, NULL},
});
- sh_data->depth = DRW_shader_create_3D_depth_only(draw_ctx->sh_cfg);
-
- sh_data->ghost_clear_depth = DRW_shader_create_fullscreen(datatoc_gpu_shader_depth_only_frag_glsl, NULL);
+ sh_data->depth = DRW_shader_create_3d_depth_only(draw_ctx->sh_cfg);
}
}
static DRWPass *edit_mesh_create_overlay_pass(
- float *face_alpha, int *data_mask, bool do_edges, bool UNUSED(xray),
+ float *face_alpha, int *data_mask, bool do_edges,
DRWState statemod,
DRWShadingGroup **r_face_shgrp, DRWShadingGroup **r_face_cage_shgrp, DRWShadingGroup **r_facedot_shgrp,
DRWShadingGroup **r_edge_shgrp, DRWShadingGroup **r_vert_shgrp)
@@ -395,6 +400,7 @@ static void EDIT_MESH_cache_init(void *vedata)
if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACES) == 0) {
stl->g_data->data_mask[0] &= ~(VFLAG_FACE_SELECTED & VFLAG_FACE_FREESTYLE);
stl->g_data->do_faces = false;
+ stl->g_data->do_zbufclip = false;
}
if ((tsettings->selectmode & SCE_SELECT_FACE) == 0) {
stl->g_data->data_mask[0] &= ~VFLAG_FACE_ACTIVE;
@@ -446,19 +452,16 @@ static void EDIT_MESH_cache_init(void *vedata)
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK);
stl->g_data->depth_shgrp_hidden_wire = DRW_shgroup_create(sh_data->depth, psl->depth_hidden_wire);
if (rv3d->rflag & RV3D_CLIPPING) {
- DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->fweights_shgrp, rv3d);
+ DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->depth_shgrp_hidden_wire, rv3d);
}
- }
- {
- /* Depth clearing for ghosting. */
- psl->ghost_clear_depth = DRW_pass_create(
- "Ghost Depth Clear",
- DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_STENCIL_NEQUAL);
-
- DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->ghost_clear_depth, psl->ghost_clear_depth);
- DRW_shgroup_stencil_mask(shgrp, 0x00);
- DRW_shgroup_call_add(shgrp, DRW_cache_fullscreen_quad_get(), NULL);
+ psl->depth_hidden_wire_in_front = DRW_pass_create(
+ "Depth Pass Hidden Wire In Front",
+ DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK);
+ stl->g_data->depth_shgrp_hidden_wire_in_front = DRW_shgroup_create(sh_data->depth, psl->depth_hidden_wire_in_front);
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->depth_shgrp_hidden_wire_in_front, rv3d);
+ }
}
{
@@ -489,9 +492,19 @@ static void EDIT_MESH_cache_init(void *vedata)
}
}
+ /* For in front option */
+ psl->edit_face_overlay_in_front = edit_mesh_create_overlay_pass(
+ &face_mod, stl->g_data->data_mask, stl->g_data->do_edges,
+ DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND,
+ &stl->g_data->face_shgrp_in_front,
+ &stl->g_data->face_cage_shgrp_in_front,
+ &stl->g_data->facedot_shgrp_in_front,
+ &stl->g_data->edge_shgrp_in_front,
+ &stl->g_data->vert_shgrp_in_front);
+
if (!stl->g_data->do_zbufclip) {
psl->edit_face_overlay = edit_mesh_create_overlay_pass(
- &face_mod, stl->g_data->data_mask, stl->g_data->do_edges, false,
+ &face_mod, stl->g_data->data_mask, stl->g_data->do_edges,
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND,
&stl->g_data->face_shgrp,
&stl->g_data->face_cage_shgrp,
@@ -502,7 +515,7 @@ static void EDIT_MESH_cache_init(void *vedata)
else {
/* We render all wires with depth and opaque to a new fbo and blend the result based on depth values */
psl->edit_face_occluded = edit_mesh_create_overlay_pass(
- &zero, stl->g_data->data_mask, stl->g_data->do_edges, true,
+ &zero, stl->g_data->data_mask, stl->g_data->do_edges,
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH,
&stl->g_data->face_shgrp,
&stl->g_data->face_cage_shgrp,
@@ -539,7 +552,10 @@ static void EDIT_MESH_cache_init(void *vedata)
static void edit_mesh_add_ob_to_pass(
Scene *scene, Object *ob,
- EDIT_MESH_PrivateData *g_data,
+ DRWShadingGroup *vert_shgrp,
+ DRWShadingGroup *edge_shgrp,
+ DRWShadingGroup *face_shgrp,
+ DRWShadingGroup *face_cage_shgrp,
DRWShadingGroup *facedot_shgrp,
DRWShadingGroup *facefill_shgrp)
{
@@ -554,10 +570,7 @@ static void edit_mesh_add_ob_to_pass(
has_edit_mesh_cage = embm->mesh_eval_cage && (embm->mesh_eval_cage != embm->mesh_eval_final);
}
- DRWShadingGroup *face_shgrp = (has_edit_mesh_cage) ? g_data->face_cage_shgrp : g_data->face_shgrp;
- DRWShadingGroup *vert_shgrp = g_data->vert_shgrp;
- DRWShadingGroup *edge_shgrp = g_data->edge_shgrp;
-
+ face_shgrp = (has_edit_mesh_cage) ? face_cage_shgrp : face_shgrp;
face_shgrp = (facefill_shgrp != NULL) ? facefill_shgrp : face_shgrp;
geom_tris = DRW_mesh_batch_cache_get_edit_triangles(ob->data);
@@ -579,6 +592,7 @@ static void edit_mesh_add_ob_to_pass(
static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
{
EDIT_MESH_StorageList *stl = ((EDIT_MESH_Data *)vedata)->stl;
+ EDIT_MESH_PrivateData *g_data = stl->g_data;
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
Scene *scene = draw_ctx->scene;
@@ -587,6 +601,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
if (ob->type == OB_MESH) {
if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) {
+ bool do_in_front = (ob->dtx & OB_DRAWXRAY) != 0;
bool do_occlude_wire = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) != 0;
bool do_show_weight = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_WEIGHT) != 0;
bool fnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_NORMALS) != 0;
@@ -595,8 +610,8 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
bool show_face_dots = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_DOT) != 0;
- if (stl->g_data->do_faces == false &&
- stl->g_data->do_edges == false &&
+ if (g_data->do_faces == false &&
+ g_data->do_edges == false &&
(tsettings->selectmode & SCE_SELECT_FACE))
{
/* Force display of face centers in this case because that's
@@ -610,48 +625,68 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
face_mod = (do_occlude_wire) ? 0.0f : 1.0f;
- if (!stl->g_data->do_faces) {
+ if (!g_data->do_faces) {
face_mod = 0.0f;
}
if (do_show_weight) {
geom = DRW_cache_mesh_surface_weights_get(ob);
- DRW_shgroup_call_add(stl->g_data->fweights_shgrp, geom, ob->obmat);
+ DRW_shgroup_call_add(g_data->fweights_shgrp, geom, ob->obmat);
}
- if (do_occlude_wire) {
+ if (do_occlude_wire || do_in_front) {
geom = DRW_cache_mesh_surface_get(ob);
- DRW_shgroup_call_add(stl->g_data->depth_shgrp_hidden_wire, geom, ob->obmat);
+ DRW_shgroup_call_add(do_in_front ? g_data->depth_shgrp_hidden_wire_in_front
+ : g_data->depth_shgrp_hidden_wire,
+ geom, ob->obmat);
}
if (vnormals_do) {
geom = DRW_mesh_batch_cache_get_edit_vertices(ob->data);
- DRW_shgroup_call_add(stl->g_data->vnormals_shgrp, geom, ob->obmat);
+ DRW_shgroup_call_add(g_data->vnormals_shgrp, geom, ob->obmat);
}
if (lnormals_do) {
geom = DRW_mesh_batch_cache_get_edit_lnors(ob->data);
- DRW_shgroup_call_add(stl->g_data->lnormals_shgrp, geom, ob->obmat);
+ DRW_shgroup_call_add(g_data->lnormals_shgrp, geom, ob->obmat);
}
if (fnormals_do) {
geom = DRW_mesh_batch_cache_get_edit_facedots(ob->data);
- DRW_shgroup_call_add(stl->g_data->fnormals_shgrp, geom, ob->obmat);
+ DRW_shgroup_call_add(g_data->fnormals_shgrp, geom, ob->obmat);
}
- if (stl->g_data->do_zbufclip) {
+ if (g_data->do_zbufclip) {
+ edit_mesh_add_ob_to_pass(
+ scene, ob,
+ g_data->vert_shgrp,
+ g_data->edge_shgrp,
+ g_data->face_shgrp,
+ g_data->face_cage_shgrp,
+ g_data->facedot_shgrp,
+ (g_data->do_faces) ? g_data->facefill_occluded_shgrp : NULL);
+ }
+ else if (do_in_front) {
edit_mesh_add_ob_to_pass(
- scene, ob, stl->g_data,
- stl->g_data->facedot_shgrp,
- (stl->g_data->do_faces) ? stl->g_data->facefill_occluded_shgrp : NULL);
+ scene, ob,
+ g_data->vert_shgrp_in_front,
+ g_data->edge_shgrp_in_front,
+ g_data->face_shgrp_in_front,
+ g_data->face_cage_shgrp_in_front,
+ (show_face_dots) ? g_data->facedot_shgrp_in_front : NULL,
+ NULL);
}
else {
edit_mesh_add_ob_to_pass(
- scene, ob, stl->g_data,
- (show_face_dots) ? stl->g_data->facedot_shgrp : NULL,
+ scene, ob,
+ g_data->vert_shgrp,
+ g_data->edge_shgrp,
+ g_data->face_shgrp,
+ g_data->face_cage_shgrp,
+ (show_face_dots) ? g_data->facedot_shgrp : NULL,
NULL);
}
- stl->g_data->ghost_ob += (ob->dtx & OB_DRAWXRAY) ? 1 : 0;
- stl->g_data->edit_ob += 1;
+ g_data->ghost_ob += (ob->dtx & OB_DRAWXRAY) ? 1 : 0;
+ g_data->edit_ob += 1;
/* 3D text overlay */
if (v3d->overlay.edit_flag & (V3D_OVERLAY_EDIT_EDGE_LEN |
@@ -675,7 +710,6 @@ static void EDIT_MESH_draw_scene(void *vedata)
EDIT_MESH_StorageList *stl = ((EDIT_MESH_Data *)vedata)->stl;
EDIT_MESH_FramebufferList *fbl = ((EDIT_MESH_Data *)vedata)->fbl;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
- DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
DRW_draw_pass(psl->weight_faces);
@@ -683,6 +717,9 @@ static void EDIT_MESH_draw_scene(void *vedata)
if (stl->g_data->do_zbufclip) {
float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+
+ DRW_draw_pass(psl->depth_hidden_wire_in_front);
+
/* render facefill */
DRW_draw_pass(psl->facefill_occlude);
@@ -697,35 +734,23 @@ static void EDIT_MESH_draw_scene(void *vedata)
DRW_draw_pass(psl->mix_occlude);
}
else {
- DRW_draw_pass(psl->normals);
-
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
+ DRW_draw_pass(psl->normals);
+ DRW_draw_pass(psl->edit_face_overlay);
+
if (v3d->shading.type == OB_SOLID && (v3d->shading.flag & XRAY_FLAG(v3d)) == 0 &&
stl->g_data->ghost_ob == 1 && stl->g_data->edit_ob == 1)
{
/* In the case of single ghost object edit (common case for retopology):
- * we duplicate the depht+stencil buffer and clear all depth to 1.0f where
- * the stencil buffer is no 0x00. */
- const float *viewport_size = DRW_viewport_size_get();
- const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
- struct GPUTexture *ghost_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_DEPTH24_STENCIL8, &draw_engine_edit_mesh_type);
- GPU_framebuffer_ensure_config(&fbl->ghost_wire_fb, {
- GPU_ATTACHMENT_TEXTURE(ghost_depth_tx),
- GPU_ATTACHMENT_TEXTURE(dtxl->color),
- });
-
- GPU_framebuffer_blit(dfbl->depth_only_fb, 0, fbl->ghost_wire_fb, 0, GPU_DEPTH_BIT | GPU_STENCIL_BIT);
- GPU_framebuffer_bind(fbl->ghost_wire_fb);
-
- DRW_draw_pass(psl->ghost_clear_depth);
-
- DRW_draw_pass(psl->edit_face_overlay);
- }
- else {
- DRW_draw_pass(psl->edit_face_overlay);
+ * we clear the depth buffer so that only the depth of the retopo mesh
+ * is occluding the edit cage. */
+ GPU_framebuffer_clear_depth(dfbl->default_fb, 1.0f);
}
+
+ DRW_draw_pass(psl->depth_hidden_wire_in_front);
+ DRW_draw_pass(psl->edit_face_overlay_in_front);
}
DRW_state_clip_planes_reset();
diff --git a/source/blender/draw/modes/edit_mesh_mode_text.c b/source/blender/draw/modes/edit_mesh_mode_text.c
index bd2f65a40cd..629cb042562 100644
--- a/source/blender/draw/modes/edit_mesh_mode_text.c
+++ b/source/blender/draw/modes/edit_mesh_mode_text.c
@@ -71,11 +71,11 @@ void DRW_edit_mesh_mode_text_measure_stats(
/* make the precision of the display value proportionate to the gridsize */
- if (grid <= 0.01f) conv_float = "%.6g";
- else if (grid <= 0.1f) conv_float = "%.5g";
- else if (grid <= 1.0f) conv_float = "%.4g";
- else if (grid <= 10.0f) conv_float = "%.3g";
- else conv_float = "%.2g";
+ if (grid <= 0.01f) { conv_float = "%.6g"; }
+ else if (grid <= 0.1f) { conv_float = "%.5g"; }
+ else if (grid <= 1.0f) { conv_float = "%.4g"; }
+ else if (grid <= 10.0f) { conv_float = "%.3g"; }
+ else { conv_float = "%.2g"; }
if (v3d->overlay.edit_flag & (V3D_OVERLAY_EDIT_EDGE_LEN | V3D_OVERLAY_EDIT_EDGE_ANG | V3D_OVERLAY_EDIT_INDICES)) {
BoundBox bb;
diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c
index 04b03cb3ac1..600b77f46bf 100644
--- a/source/blender/draw/modes/edit_metaball_mode.c
+++ b/source/blender/draw/modes/edit_metaball_mode.c
@@ -172,8 +172,12 @@ static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
float draw_stiffness_radius = ml->rad * atanf(ml->s) / (float)M_PI_2;
- if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) color = col_radius_select;
- else color = col_radius;
+ if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) {
+ color = col_radius_select;
+ }
+ else {
+ color = col_radius;
+ }
if (is_select) {
DRW_select_load_id(select_id | MBALLSEL_RADIUS);
@@ -181,8 +185,12 @@ static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
DRW_shgroup_call_dynamic_add(group, draw_scale_xform, &ml->rad, color);
- if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) color = col_stiffness_select;
- else color = col_stiffness;
+ if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) {
+ color = col_stiffness_select;
+ }
+ else {
+ color = col_stiffness;
+ }
if (is_select) {
DRW_select_load_id(select_id | MBALLSEL_STIFF);
diff --git a/source/blender/draw/modes/edit_text_mode.c b/source/blender/draw/modes/edit_text_mode.c
index f52bfaccd5b..caebc94f3ce 100644
--- a/source/blender/draw/modes/edit_text_mode.c
+++ b/source/blender/draw/modes/edit_text_mode.c
@@ -151,9 +151,11 @@ static void EDIT_TEXT_engine_init(void *vedata)
* Assume that all Passes are NULL */
static void EDIT_TEXT_cache_init(void *vedata)
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
EDIT_TEXT_PassList *psl = ((EDIT_TEXT_Data *)vedata)->psl;
EDIT_TEXT_StorageList *stl = ((EDIT_TEXT_Data *)vedata)->stl;
+
if (!stl->g_data) {
/* Alloc transient pointers */
stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
@@ -179,8 +181,8 @@ static void EDIT_TEXT_cache_init(void *vedata)
psl->text_box_pass = DRW_pass_create(
"Font Text Boxes",
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH);
- stl->g_data->box_shgrp = shgroup_dynlines_dashed_uniform_color(psl->text_box_pass, G_draw.block.colorWire);
- stl->g_data->box_active_shgrp = shgroup_dynlines_dashed_uniform_color(psl->text_box_pass, G_draw.block.colorActive);
+ stl->g_data->box_shgrp = shgroup_dynlines_dashed_uniform_color(psl->text_box_pass, G_draw.block.colorWire, draw_ctx->sh_cfg);
+ stl->g_data->box_active_shgrp = shgroup_dynlines_dashed_uniform_color(psl->text_box_pass, G_draw.block.colorActive, draw_ctx->sh_cfg);
}
}
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 3ed6034731b..ceba8361fef 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -28,6 +28,7 @@
#include "DNA_constraint_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
+#include "DNA_gpencil_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_modifier_types.h"
@@ -353,7 +354,8 @@ enum {
};
/* Prototypes. */
-static void DRW_shgroup_empty_ex(OBJECT_ShadingGroupList *sgl, float mat[4][4], float *draw_size, char draw_type, float *color);
+static void DRW_shgroup_empty_ex(
+ OBJECT_ShadingGroupList *sgl, const float mat[4][4], const float *draw_size, char draw_type, const float color[4]);
/* *********** FUNCTIONS *********** */
@@ -365,12 +367,12 @@ static void OBJECT_engine_init(void *vedata)
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
if (DRW_state_is_fbo()) {
- e_data.outlines_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_DEPTH_COMPONENT24,
+ e_data.outlines_depth_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_DEPTH_COMPONENT24,
&draw_engine_object_type);
/* XXX TODO GPU_R16UI can overflow, it would cause no harm
* (only bad colored or missing outlines) but we should
* use 32bits only if the scene have that many objects */
- e_data.outlines_id_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R16UI,
+ e_data.outlines_id_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_R16UI,
&draw_engine_object_type);
GPU_framebuffer_ensure_config(&fbl->outlines_fb, {
@@ -378,7 +380,7 @@ static void OBJECT_engine_init(void *vedata)
GPU_ATTACHMENT_TEXTURE(e_data.outlines_id_tx)
});
- e_data.outlines_color_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8,
+ e_data.outlines_color_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_RGBA8,
&draw_engine_object_type);
GPU_framebuffer_ensure_config(&fbl->expand_fb, {
@@ -386,7 +388,7 @@ static void OBJECT_engine_init(void *vedata)
GPU_ATTACHMENT_TEXTURE(e_data.outlines_color_tx)
});
- e_data.outlines_blur_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8,
+ e_data.outlines_blur_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_RGBA8,
&draw_engine_object_type);
GPU_framebuffer_ensure_config(&fbl->blur_fb, {
@@ -926,6 +928,7 @@ static void DRW_shgroup_empty_image(
/* Calling 'BKE_image_get_size' may free the texture. Get the size from 'tex' instead, see: T59347 */
int size[2] = {0};
+ const bool use_alpha_blend = (ob->empty_image_flag & OB_EMPTY_IMAGE_USE_ALPHA_BLEND) != 0;
GPUTexture *tex = NULL;
if (ob->data != NULL) {
@@ -942,38 +945,49 @@ static void DRW_shgroup_empty_image(
float image_aspect[2];
image_calc_aspect(ob->data, size, image_aspect);
- /* OPTI(fclem) We need sorting only for transparent images. If an image as no alpha channel and
- * ob->col[3] == 1.0f, we could remove it from the sorting pass. */
+ char depth_mode;
+ if (DRW_state_is_depth()) {
+ /* Use the actual depth if we are doing depth tests to determine the distance to the object */
+ depth_mode = OB_EMPTY_IMAGE_DEPTH_DEFAULT;
+ }
+ else {
+ depth_mode = ob->empty_image_depth;
+ }
- if (tex && (ob->color[3] > 0.0f) && BKE_object_empty_image_data_is_visible_in_view3d(ob, rv3d)) {
- DRWShadingGroup *grp = DRW_shgroup_create(sh_data->object_empty_image, sgl->image_empties);
- DRW_shgroup_uniform_texture(grp, "image", tex);
+ {
+ DRWShadingGroup *grp = DRW_shgroup_create(sh_data->object_empty_image_wire, sgl->non_meshes);
/* TODO(fclem) implement DRW_shgroup_uniform_vec2_copy */
DRW_shgroup_uniform_float_copy(grp, "aspectX", image_aspect[0]);
DRW_shgroup_uniform_float_copy(grp, "aspectY", image_aspect[1]);
- DRW_shgroup_uniform_int_copy(grp, "depthMode", ob->empty_image_depth);
+ DRW_shgroup_uniform_int_copy(grp, "depthMode", depth_mode);
DRW_shgroup_uniform_float(grp, "size", &ob->empty_drawsize, 1);
DRW_shgroup_uniform_vec2(grp, "offset", ob->ima_ofs, 1);
- DRW_shgroup_uniform_vec4(grp, "objectColor", ob->color, 1);
+ DRW_shgroup_uniform_vec3(grp, "color", color, 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
}
- DRW_shgroup_call_add(grp, DRW_cache_image_plane_get(), ob->obmat);
+ DRW_shgroup_call_add(grp, DRW_cache_image_plane_wire_get(), ob->obmat);
}
- {
- DRWShadingGroup *grp = DRW_shgroup_create(sh_data->object_empty_image_wire, sgl->non_meshes);
- /* TODO(fclem) implement DRW_shgroup_uniform_vec2_copy */
+ if (!BKE_object_empty_image_data_is_visible_in_view3d(ob, rv3d)) {
+ return;
+ }
+
+ if (tex && ((ob->color[3] > 0.0f) || !use_alpha_blend)) {
+ DRWShadingGroup *grp = DRW_shgroup_create(sh_data->object_empty_image,
+ (use_alpha_blend) ? sgl->image_empties : sgl->non_meshes);
DRW_shgroup_uniform_float_copy(grp, "aspectX", image_aspect[0]);
DRW_shgroup_uniform_float_copy(grp, "aspectY", image_aspect[1]);
- DRW_shgroup_uniform_int_copy(grp, "depthMode", ob->empty_image_depth);
+ DRW_shgroup_uniform_int_copy(grp, "depthMode", depth_mode);
DRW_shgroup_uniform_float(grp, "size", &ob->empty_drawsize, 1);
DRW_shgroup_uniform_vec2(grp, "offset", ob->ima_ofs, 1);
- DRW_shgroup_uniform_vec3(grp, "color", color, 1);
+ DRW_shgroup_uniform_texture(grp, "image", tex);
+ DRW_shgroup_uniform_vec4(grp, "objectColor", ob->color, 1);
+ DRW_shgroup_uniform_bool_copy(grp, "useAlphaTest", !use_alpha_blend);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
}
- DRW_shgroup_call_add(grp, DRW_cache_image_plane_wire_get(), ob->obmat);
+ DRW_shgroup_call_add(grp, DRW_cache_image_plane_get(), ob->obmat);
}
}
@@ -1358,8 +1372,8 @@ static void OBJECT_cache_init(void *vedata)
/* -------- STIPPLES ------- */
/* Relationship Lines */
- sgl->relationship_lines = shgroup_dynlines_dashed_uniform_color(sgl->non_meshes, gb->colorWire);
- sgl->constraint_lines = shgroup_dynlines_dashed_uniform_color(sgl->non_meshes, gb->colorGridAxisZ);
+ sgl->relationship_lines = shgroup_dynlines_dashed_uniform_color(sgl->non_meshes, gb->colorWire, draw_ctx->sh_cfg);
+ sgl->constraint_lines = shgroup_dynlines_dashed_uniform_color(sgl->non_meshes, gb->colorGridAxisZ, draw_ctx->sh_cfg);
/* Force Field Curve Guide End (here because of stipple) */
/* TODO port to shader stipple */
@@ -1672,13 +1686,11 @@ static void batch_camera_path_free(ListBase *camera_paths)
}
}
-static bool camera_view3d_is_stereo3d(Scene *scene, View3D *v3d)
-{
- return (scene->r.scemode & R_MULTIVIEW) != 0 &&
- (v3d->stereo3d_flag);
-}
-
-static void camera_stereo3d(
+/**
+ * Draw the stereo 3d support elements (cameras, plane, volume).
+ * They are only visible when not looking through the camera:
+ */
+static void camera_view3d_stereoscopy_display_extra(
OBJECT_ShadingGroupList *sgl,
Scene *scene, ViewLayer *view_layer, View3D *v3d,
Object *ob, Camera *cam,
@@ -1806,6 +1818,163 @@ static void camera_stereo3d(
}
}
+static void camera_view3d_reconstruction(
+ OBJECT_ShadingGroupList *sgl,
+ Scene *scene,
+ View3D *v3d,
+ const Object *camera_object,
+ Object *ob,
+ const float color[4],
+ const bool is_select)
+{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Camera *cam = ob->data;
+
+ if ((v3d->flag2 & V3D_SHOW_RECONSTRUCTION) == 0) {
+ return;
+ }
+
+ MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);
+ if (clip == NULL) {
+ return;
+ }
+
+ BLI_assert(BLI_listbase_is_empty(&sgl->camera_path));
+ const bool is_solid_bundle = (v3d->bundle_drawtype == OB_EMPTY_SPHERE) &&
+ ((v3d->shading.type != OB_SOLID) ||
+ ((v3d->shading.flag & XRAY_FLAG(v3d)) == 0));
+
+ MovieTracking *tracking = &clip->tracking;
+ /* Index must start in 1, to mimic BKE_tracking_track_get_indexed. */
+ int track_index = 1;
+
+ uchar text_color_selected[4], text_color_unselected[4];
+ float bundle_color_unselected[4], bundle_color_solid[4];
+
+ UI_GetThemeColor4ubv(TH_SELECT, text_color_selected);
+ UI_GetThemeColor4ubv(TH_TEXT, text_color_unselected);
+ UI_GetThemeColor4fv(TH_WIRE, bundle_color_unselected);
+ UI_GetThemeColor4fv(TH_BUNDLE_SOLID, bundle_color_solid);
+
+ float camera_mat[4][4];
+ BKE_tracking_get_camera_object_matrix(scene, ob, camera_mat);
+
+ float bundle_scale_mat[4][4];
+ if (is_solid_bundle) {
+ scale_m4_fl(bundle_scale_mat, v3d->bundle_size);
+ }
+
+ for (MovieTrackingObject *tracking_object = tracking->objects.first;
+ tracking_object != NULL;
+ tracking_object = tracking_object->next)
+ {
+ float tracking_object_mat[4][4];
+
+ if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
+ copy_m4_m4(tracking_object_mat, camera_mat);
+ }
+ else {
+ const int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, DEG_get_ctime(draw_ctx->depsgraph));
+ float object_mat[4][4];
+ BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, object_mat);
+
+ invert_m4(object_mat);
+ mul_m4_m4m4(tracking_object_mat, cam->runtime.drw_normalmat, object_mat);
+ }
+
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
+ for (MovieTrackingTrack *track = tracksbase->first; track; track = track->next) {
+
+ if ((track->flag & TRACK_HAS_BUNDLE) == 0) {
+ continue;
+ }
+
+ bool is_selected = TRACK_SELECTED(track);
+
+ float bundle_mat[4][4];
+ copy_m4_m4(bundle_mat, tracking_object_mat);
+ translate_m4(bundle_mat, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
+
+ const float *bundle_color;
+ if (track->flag & TRACK_CUSTOMCOLOR) {
+ bundle_color = track->color;
+ }
+ else if (is_solid_bundle) {
+ bundle_color = bundle_color_solid;
+ }
+ else if (is_selected) {
+ bundle_color = color;
+ }
+ else {
+ bundle_color = bundle_color_unselected;
+ }
+
+ if (is_select) {
+ DRW_select_load_id(camera_object->select_id | (track_index << 16));
+ track_index++;
+ }
+
+ if (is_solid_bundle) {
+
+ if (is_selected) {
+ DRW_shgroup_empty_ex(sgl,
+ bundle_mat,
+ &v3d->bundle_size,
+ v3d->bundle_drawtype,
+ color);
+ }
+
+ float bundle_color_v4[4] = {
+ bundle_color[0],
+ bundle_color[1],
+ bundle_color[2],
+ 1.0f,
+ };
+
+ mul_m4_m4m4(bundle_mat, bundle_mat, bundle_scale_mat);
+ DRW_shgroup_call_dynamic_add(sgl->sphere_solid,
+ bundle_mat,
+ bundle_color_v4);
+ }
+ else {
+ DRW_shgroup_empty_ex(sgl,
+ bundle_mat,
+ &v3d->bundle_size,
+ v3d->bundle_drawtype,
+ bundle_color);
+ }
+
+ if ((v3d->flag2 & V3D_SHOW_BUNDLENAME) && !is_select) {
+ struct DRWTextStore *dt = DRW_text_cache_ensure();
+
+ DRW_text_cache_add(dt,
+ bundle_mat[3],
+ track->name,
+ strlen(track->name),
+ 10, 0,
+ DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR,
+ is_selected ? text_color_selected : text_color_unselected);
+ }
+ }
+
+ if ((v3d->flag2 & V3D_SHOW_CAMERAPATH) && (tracking_object->flag & TRACKING_OBJECT_CAMERA) && !is_select) {
+ MovieTrackingReconstruction *reconstruction;
+ reconstruction = BKE_tracking_object_get_reconstruction(tracking, tracking_object);
+
+ if (reconstruction->camnr) {
+ static float camera_path_color[4];
+ UI_GetThemeColor4fv(TH_CAMERA_PATH, camera_path_color);
+
+ GPUBatch *geom = batch_camera_path_get(&sgl->camera_path, reconstruction);
+ GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
+ DRWShadingGroup *shading_group = DRW_shgroup_create(shader, sgl->non_meshes);
+ DRW_shgroup_uniform_vec4(shading_group, "color", camera_path_color, 1);
+ DRW_shgroup_call_add(shading_group, geom, camera_mat);
+ }
+ }
+ }
+}
+
static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLayer *view_layer)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -1818,9 +1987,10 @@ static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLay
const bool is_select = DRW_state_is_select();
const bool is_active = (ob == camera_object);
const bool look_through = (is_active && (rv3d->persp == RV3D_CAMOB));
+
const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
- const bool is_stereo3d = is_active && camera_view3d_is_stereo3d(scene, v3d);
const bool is_stereo3d_view = (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D);
+ const bool is_stereo3d_display_extra = is_active && is_multiview && (!look_through) && ((v3d->stereo3d_flag) != 0);
const bool is_stereo3d_cameras = (ob == scene->camera) &&
is_multiview &&
is_stereo3d_view &&
@@ -1846,7 +2016,7 @@ static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLay
scale[2] = 1.0f / len_v3(ob->obmat[2]);
}
- BKE_camera_view_frame_ex(scene, cam, cam->drawsize, false, scale,
+ BKE_camera_view_frame_ex(scene, cam, cam->drawsize, look_through, scale,
asp, shift, &drawsize, vec);
/* Frame coords */
@@ -1867,15 +2037,16 @@ static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLay
if (look_through) {
/* Only draw the frame. */
float mat[4][4];
- if (is_stereo3d_view) {
+ if (is_multiview) {
const bool is_left = v3d->multiview_eye == STEREO_LEFT_ID;
const char *view_name = is_left ? STEREO_LEFT_NAME : STEREO_RIGHT_NAME;
BKE_camera_multiview_model_matrix(&scene->r, ob, view_name, mat);
const float shiftx = BKE_camera_multiview_shift_x(&scene->r, ob, view_name);
- cam->runtime.drw_corners[0][0][0] += shiftx;
- cam->runtime.drw_corners[0][1][0] += shiftx;
- cam->runtime.drw_corners[0][2][0] += shiftx;
- cam->runtime.drw_corners[0][3][0] += shiftx;
+ const float delta_shiftx = shiftx - cam->shiftx;
+ const float width = cam->runtime.drw_corners[0][2][0] - cam->runtime.drw_corners[0][0][0];
+ for (int i = 0; i < 4; i++) {
+ cam->runtime.drw_corners[0][i][0] -= delta_shiftx * width;
+ }
}
else {
copy_m4_m4(mat, ob->obmat);
@@ -1940,153 +2111,17 @@ static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLay
}
}
- /* Stereo cameras drawing. */
- if (is_stereo3d && !look_through) {
- camera_stereo3d(sgl, scene, view_layer, v3d, ob, cam, vec, drawsize, scale);
+ /* Stereo cameras, volumes, plane drawing. */
+ if (is_stereo3d_display_extra) {
+ camera_view3d_stereoscopy_display_extra(sgl, scene, view_layer, v3d, ob, cam, vec, drawsize, scale);
}
/* Motion Tracking. */
- MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);
- if ((v3d->flag2 & V3D_SHOW_RECONSTRUCTION) && (clip != NULL)) {
- BLI_assert(BLI_listbase_is_empty(&sgl->camera_path));
- const bool is_solid_bundle = (v3d->bundle_drawtype == OB_EMPTY_SPHERE) &&
- ((v3d->shading.type != OB_SOLID) ||
- ((v3d->shading.flag & XRAY_FLAG(v3d)) == 0));
-
- MovieTracking *tracking = &clip->tracking;
- /* Index must start in 1, to mimic BKE_tracking_track_get_indexed. */
- int track_index = 1;
-
- uchar text_color_selected[4], text_color_unselected[4];
- float bundle_color_unselected[4], bundle_color_solid[4];
-
- UI_GetThemeColor4ubv(TH_SELECT, text_color_selected);
- UI_GetThemeColor4ubv(TH_TEXT, text_color_unselected);
- UI_GetThemeColor4fv(TH_WIRE, bundle_color_unselected);
- UI_GetThemeColor4fv(TH_BUNDLE_SOLID, bundle_color_solid);
-
- float camera_mat[4][4];
- BKE_tracking_get_camera_object_matrix(scene, ob, camera_mat);
-
- float bundle_scale_mat[4][4];
- if (is_solid_bundle) {
- scale_m4_fl(bundle_scale_mat, v3d->bundle_size);
- }
-
- for (MovieTrackingObject *tracking_object = tracking->objects.first;
- tracking_object != NULL;
- tracking_object = tracking_object->next)
- {
- float tracking_object_mat[4][4];
-
- if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
- copy_m4_m4(tracking_object_mat, camera_mat);
- }
- else {
- const int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, DEG_get_ctime(draw_ctx->depsgraph));
- float object_mat[4][4];
- BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, object_mat);
-
- invert_m4(object_mat);
- mul_m4_m4m4(tracking_object_mat, cam->runtime.drw_normalmat, object_mat);
- }
-
- ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
- for (MovieTrackingTrack *track = tracksbase->first; track; track = track->next) {
-
- if ((track->flag & TRACK_HAS_BUNDLE) == 0) {
- continue;
- }
-
- bool is_selected = TRACK_SELECTED(track);
-
- float bundle_mat[4][4];
- copy_m4_m4(bundle_mat, tracking_object_mat);
- translate_m4(bundle_mat, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
-
- float *bundle_color;
- if (track->flag & TRACK_CUSTOMCOLOR) {
- bundle_color = track->color;
- }
- else if (is_solid_bundle) {
- bundle_color = bundle_color_solid;
- }
- else if (is_selected) {
- bundle_color = color;
- }
- else {
- bundle_color = bundle_color_unselected;
- }
-
- if (is_select) {
- DRW_select_load_id(camera_object->select_id | (track_index << 16));
- track_index++;
- }
-
- if (is_solid_bundle) {
-
- if (is_selected) {
- DRW_shgroup_empty_ex(sgl,
- bundle_mat,
- &v3d->bundle_size,
- v3d->bundle_drawtype,
- color);
- }
-
- float bundle_color_v4[4] = {
- bundle_color[0],
- bundle_color[1],
- bundle_color[2],
- 1.0f,
- };
-
- mul_m4_m4m4(bundle_mat, bundle_mat, bundle_scale_mat);
- DRW_shgroup_call_dynamic_add(sgl->sphere_solid,
- bundle_mat,
- bundle_color_v4);
- }
- else {
- DRW_shgroup_empty_ex(sgl,
- bundle_mat,
- &v3d->bundle_size,
- v3d->bundle_drawtype,
- bundle_color);
- }
-
- if ((v3d->flag2 & V3D_SHOW_BUNDLENAME) && !is_select) {
- struct DRWTextStore *dt = DRW_text_cache_ensure();
-
- DRW_text_cache_add(dt,
- bundle_mat[3],
- track->name,
- strlen(track->name),
- 10, 0,
- DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR,
- is_selected ? text_color_selected : text_color_unselected);
- }
- }
-
- if ((v3d->flag2 & V3D_SHOW_CAMERAPATH) && (tracking_object->flag & TRACKING_OBJECT_CAMERA) && !is_select) {
- MovieTrackingReconstruction *reconstruction;
- reconstruction = BKE_tracking_object_get_reconstruction(tracking, tracking_object);
-
- if (reconstruction->camnr) {
- static float camera_path_color[4];
- UI_GetThemeColor4fv(TH_CAMERA_PATH, camera_path_color);
-
- GPUBatch *geom = batch_camera_path_get(&sgl->camera_path, reconstruction);
- GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
- DRWShadingGroup *shading_group = DRW_shgroup_create(shader, sgl->non_meshes);
- DRW_shgroup_uniform_vec4(shading_group, "color", camera_path_color, 1);
- DRW_shgroup_call_add(shading_group, geom, camera_mat);
- }
- }
- }
- }
+ camera_view3d_reconstruction(sgl, scene, v3d, camera_object, ob, color, is_select);
}
static void DRW_shgroup_empty_ex(
- OBJECT_ShadingGroupList *sgl, float mat[4][4], float *draw_size, char draw_type, float *color)
+ OBJECT_ShadingGroupList *sgl, const float mat[4][4], const float *draw_size, char draw_type, const float color[4])
{
switch (draw_type) {
case OB_PLAINAXES:
@@ -2732,7 +2767,7 @@ static void DRW_shgroup_bounds(OBJECT_ShadingGroupList *sgl, Object *ob, int the
BoundBox *bb = BKE_object_boundbox_get(ob);
if (!ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT,
- OB_MBALL, OB_ARMATURE, OB_LATTICE))
+ OB_MBALL, OB_ARMATURE, OB_LATTICE, OB_GPENCIL))
{
const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f};
bb = &bb_local;
@@ -2802,9 +2837,6 @@ static void OBJECT_cache_populate_particles(
OBJECT_PassList *psl)
{
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
- if (!psys_check_enabled(ob, psys, false)) {
- continue;
- }
if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
continue;
}
@@ -2873,6 +2905,60 @@ static void OBJECT_cache_populate_particles(
}
}
+static void OBJECT_gpencil_color_names(Object *ob, struct DRWTextStore *dt, uchar color[4])
+{
+ if (ob->mode != OB_MODE_EDIT_GPENCIL) {
+ return;
+ }
+
+ bGPdata *gpd = (bGPdata *)ob->data;
+ if (gpd == NULL) {
+ return;
+ }
+
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ if (gpl->flag & GP_LAYER_HIDE) {
+ continue;
+ }
+ bGPDframe *gpf = gpl->actframe;
+ if (gpf == NULL) {
+ continue;
+ }
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ Material *ma = give_current_material(ob, gps->mat_nr + 1);
+ if (ma == NULL) {
+ continue;
+ }
+
+ MaterialGPencilStyle *gp_style = ma->gp_style;
+ /* skip stroke if it doesn't have any valid data */
+ if ((gps->points == NULL) || (gps->totpoints < 1) || (gp_style == NULL)) {
+ continue;
+ }
+ /* check if the color is visible */
+ if (gp_style->flag & GP_STYLE_COLOR_HIDE) {
+ continue;
+ }
+
+ /* only if selected */
+ if (gps->flag & GP_STROKE_SELECT) {
+ float fpt[3];
+ for (int i = 0; i < gps->totpoints; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ if (pt->flag & GP_SPOINT_SELECT) {
+ mul_v3_m4v3(fpt, ob->obmat, &pt->x);
+ DRW_text_cache_add(
+ dt, fpt,
+ ma->id.name + 2, strlen(ma->id.name + 2),
+ 10, 0, DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR, color);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
static void OBJECT_cache_populate(void *vedata, Object *ob)
{
OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
@@ -2941,16 +3027,14 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
break;
}
Mesh *me = ob->data;
- if (me->totedge == 0) {
- if (!is_edit_mode) {
- struct GPUBatch *geom = DRW_cache_mesh_all_verts_get(ob);
- if (geom) {
- if (theme_id == TH_UNDEFINED) {
- theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
- }
- DRWShadingGroup *shgroup = shgroup_theme_id_to_point(sgl, theme_id, ob->base_flag);
- DRW_shgroup_call_object_add(shgroup, geom, ob);
+ if (!is_edit_mode && me->totedge == 0) {
+ struct GPUBatch *geom = DRW_cache_mesh_all_verts_get(ob);
+ if (geom) {
+ if (theme_id == TH_UNDEFINED) {
+ theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
+ DRWShadingGroup *shgroup = shgroup_theme_id_to_point(sgl, theme_id, ob->base_flag);
+ DRW_shgroup_call_object_add(shgroup, geom, ob);
}
}
else {
@@ -2960,7 +3044,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
BMEditMesh *embm = me->edit_mesh;
has_edit_mesh_cage = embm->mesh_eval_cage && (embm->mesh_eval_cage != embm->mesh_eval_final);
}
- if (!is_edit_mode || has_edit_mesh_cage) {
+ if ((!is_edit_mode && me->totedge > 0) || has_edit_mesh_cage) {
struct GPUBatch *geom = DRW_cache_mesh_loose_edges_get(ob);
if (geom) {
if (theme_id == TH_UNDEFINED) {
@@ -3068,7 +3152,8 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
bArmature *arm = ob->data;
if (arm->edbo == NULL) {
if (DRW_state_is_select() || !DRW_pose_mode_armature(ob, draw_ctx->obact)) {
- bool is_wire = (v3d->shading.type == OB_WIRE) || (ob->dt <= OB_WIRE);
+ bool is_wire = (v3d->shading.type == OB_WIRE) || (ob->dt <= OB_WIRE) ||
+ (v3d->shading.flag & XRAY_FLAG(v3d)) != 0;
DRWArmaturePasses passes = {
.bone_solid = (is_wire) ? NULL : sgl->bone_solid,
.bone_outline = sgl->bone_outline,
@@ -3109,7 +3194,9 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
DRW_shgroup_forcefield(sgl, ob, view_layer);
}
- if (ob->dt == OB_BOUNDBOX) {
+ if ((ob->dt == OB_BOUNDBOX) &&
+ !ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_EMPTY, OB_SPEAKER, OB_LIGHTPROBE))
+ {
if (theme_id == TH_UNDEFINED) {
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
@@ -3141,6 +3228,11 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
dt, ob->obmat[3],
ob->id.name + 2, strlen(ob->id.name + 2),
10, 0, DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR, color);
+
+ /* draw grease pencil stroke names */
+ if (ob->type == OB_GPENCIL) {
+ OBJECT_gpencil_color_names(ob, dt, color);
+ }
}
if ((ob->dtx & OB_TEXSPACE) && ELEM(ob->type, OB_MESH, OB_CURVE, OB_MBALL)) {
@@ -3148,7 +3240,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
}
/* Don't draw bounding box again if draw type is bound box. */
- if (ob->dtx & OB_DRAWBOUNDOX && ob->dt != OB_BOUNDBOX) {
+ if ((ob->dtx & OB_DRAWBOUNDOX) &&
+ (ob->dt != OB_BOUNDBOX) &&
+ !ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_EMPTY, OB_SPEAKER, OB_LIGHTPROBE))
+ {
DRW_shgroup_bounds(sgl, ob, theme_id);
}
@@ -3213,7 +3308,7 @@ static void OBJECT_draw_scene(void *vedata)
DRW_draw_pass(psl->particle);
DRW_draw_pass(stl->g_data->sgl.bone_axes);
- MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl)
+ MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl);
DRW_draw_pass(stl->g_data->sgl.image_empties);
@@ -3284,7 +3379,7 @@ static void OBJECT_draw_scene(void *vedata)
const float *viewport_size = DRW_viewport_size_get();
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
- GPUTexture *ghost_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_object_type);
+ GPUTexture *ghost_depth_tx = DRW_texture_pool_query_2d(size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_object_type);
GPU_framebuffer_ensure_config(&fbl->ghost_fb, {
GPU_ATTACHMENT_TEXTURE(ghost_depth_tx),
GPU_ATTACHMENT_TEXTURE(dtxl->color),
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
index a2dca50a600..52e8f73f971 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -82,7 +82,7 @@ typedef struct OVERLAY_Shaders {
/* *********** STATIC *********** */
static struct {
OVERLAY_Shaders sh_data[GPU_SHADER_CFG_LEN];
-} e_data = {NULL};
+} e_data = {{{NULL}}};
/* Shaders */
extern char datatoc_overlay_face_orientation_frag_glsl[];
@@ -177,7 +177,6 @@ static void overlay_cache_init(void *vedata)
if (v3d->shading.type == OB_WIRE) {
g_data->overlay.flag |= V3D_OVERLAY_WIREFRAMES;
- g_data->show_overlays = true;
if (ELEM(v3d->shading.wire_color_type,
V3D_SHADING_OBJECT_COLOR,
@@ -328,8 +327,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
- if ((!pd->show_overlays) ||
- (ob->dt < OB_WIRE) ||
+ if ((ob->dt < OB_WIRE) ||
(!DRW_object_is_renderable(ob) && (ob->dt != OB_WIRE)))
{
return;
@@ -359,14 +357,14 @@ static void overlay_cache_populate(void *vedata, Object *ob)
}
/* Don't do that in edit Mesh mode, unless there is a modifier preview. */
- if ((((ob != draw_ctx->object_edit) && !is_edit_mode) || has_edit_mesh_cage) ||
+ if ((!pd->show_overlays) || (((ob != draw_ctx->object_edit) && !is_edit_mode) || has_edit_mesh_cage) ||
ob->type != OB_MESH)
{
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
const bool all_wires = (ob->dtx & OB_DRAW_ALL_EDGES);
const bool is_wire = (ob->dt < OB_SOLID);
- const bool use_coloring = (!is_edit_mode && !is_sculpt_mode && !has_edit_mesh_cage);
+ const bool use_coloring = (pd->show_overlays && !is_edit_mode && !is_sculpt_mode && !has_edit_mesh_cage);
const int stencil_mask = (ob->dtx & OB_DRAWXRAY) ? 0x00 : 0xFF;
float *rim_col, *wire_col;
DRWShadingGroup *shgrp = NULL;
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index 0a9746b3de5..83dfdd3284f 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -106,6 +106,7 @@ static struct {
* free in PAINT_TEXTURE_engine_free(); */
struct GPUShader *fallback_sh;
struct GPUShader *image_sh;
+ struct GPUShader *image_masking_sh;
struct GPUShader *wire_overlay_shader;
struct GPUShader *face_overlay_shader;
@@ -136,6 +137,12 @@ static void PAINT_TEXTURE_engine_init(void *UNUSED(vedata))
datatoc_paint_texture_frag_glsl,
datatoc_common_globals_lib_glsl, NULL);
+ e_data.image_masking_sh = DRW_shader_create_with_lib(
+ datatoc_paint_texture_vert_glsl, NULL,
+ datatoc_paint_texture_frag_glsl,
+ datatoc_common_globals_lib_glsl,
+ "#define TEXTURE_PAINT_MASK\n");
+
e_data.wire_overlay_shader = DRW_shader_create_with_lib(
datatoc_paint_wire_vert_glsl, NULL,
datatoc_paint_wire_frag_glsl,
@@ -148,6 +155,30 @@ static void PAINT_TEXTURE_engine_init(void *UNUSED(vedata))
}
}
+static DRWShadingGroup *create_texture_paint_shading_group(
+ PAINT_TEXTURE_PassList *psl, const struct GPUTexture *texture, const DRWContextState *draw_ctx, const bool nearest_interp)
+{
+ Scene *scene = draw_ctx->scene;
+ const ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
+ const bool masking_enabled = imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL && imapaint->stencil != NULL;
+
+ DRWShadingGroup *grp = DRW_shgroup_create(
+ masking_enabled ? e_data.image_masking_sh : e_data.image_sh, psl->image_faces);
+ DRW_shgroup_uniform_texture(grp, "image", texture);
+ DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1);
+ DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+ DRW_shgroup_uniform_bool_copy(grp, "nearestInterp", nearest_interp);
+
+ if (masking_enabled) {
+ const bool masking_inverted = (imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL_INV) > 0;
+ GPUTexture *stencil = GPU_texture_from_blender(imapaint->stencil, NULL, GL_TEXTURE_2D, false);
+ DRW_shgroup_uniform_texture(grp, "maskingImage", stencil);
+ DRW_shgroup_uniform_vec3(grp, "maskingColor", imapaint->stencil_col, 1);
+ DRW_shgroup_uniform_bool_copy(grp, "maskingInvertStencil", masking_inverted);
+ }
+ return grp;
+}
+
/* Here init all passes and shading groups
* Assume that all Passes are NULL */
static void PAINT_TEXTURE_cache_init(void *vedata)
@@ -192,15 +223,10 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
Material *ma = give_current_material(ob, i + 1);
Image *ima = (ma && ma->texpaintslot) ? ma->texpaintslot[ma->paint_active_slot].ima : NULL;
int interp = (ma && ma->texpaintslot) ? ma->texpaintslot[ma->paint_active_slot].interp : 0;
- GPUTexture *tex = ima ?
- GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false) : NULL;
+ GPUTexture *tex = GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false);
if (tex) {
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces);
- DRW_shgroup_uniform_texture(grp, "image", tex);
- DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1);
- DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
- DRW_shgroup_uniform_bool_copy(grp, "nearestInterp", interp == SHD_INTERP_CLOSEST);
+ DRWShadingGroup *grp = create_texture_paint_shading_group(psl, tex, draw_ctx, interp == SHD_INTERP_CLOSEST);
stl->g_data->shgroup_image_array[i] = grp;
}
else {
@@ -210,15 +236,10 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
}
else {
Image *ima = imapaint->canvas;
- GPUTexture *tex = ima ?
- GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false) : NULL;
+ GPUTexture *tex = GPU_texture_from_blender(ima, NULL, GL_TEXTURE_2D, false);
if (tex) {
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces);
- DRW_shgroup_uniform_texture(grp, "image", tex);
- DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1);
- DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
- DRW_shgroup_uniform_bool_copy(grp, "nearestInterp", imapaint->interp == IMAGEPAINT_INTERP_CLOSEST);
+ DRWShadingGroup *grp = create_texture_paint_shading_group(psl, tex, draw_ctx, imapaint->interp == IMAGEPAINT_INTERP_CLOSEST);
stl->g_data->shgroup_image_array[0] = grp;
}
else {
@@ -345,6 +366,7 @@ static void PAINT_TEXTURE_draw_scene(void *vedata)
static void PAINT_TEXTURE_engine_free(void)
{
DRW_SHADER_FREE_SAFE(e_data.image_sh);
+ DRW_SHADER_FREE_SAFE(e_data.image_masking_sh);
DRW_SHADER_FREE_SAFE(e_data.wire_overlay_shader);
DRW_SHADER_FREE_SAFE(e_data.face_overlay_shader);
}
diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c
index ac678a996dc..95ee3729c77 100644
--- a/source/blender/draw/modes/paint_vertex_mode.c
+++ b/source/blender/draw/modes/paint_vertex_mode.c
@@ -108,7 +108,7 @@ static void PAINT_VERTEX_engine_init(void *UNUSED(vedata))
const DRWContextState *draw_ctx = DRW_context_state_get();
PAINT_VERTEX_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
- if (draw_ctx->sh_cfg) {
+ if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_state_clip_planes_set_from_rv3d(draw_ctx->rv3d);
}
const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[draw_ctx->sh_cfg];
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 01affecade4..c4050bf3f1a 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -198,7 +198,8 @@ static void POSE_cache_populate(void *vedata, Object *ob)
}
if (DRW_pose_mode_armature(ob, draw_ctx->obact)) {
int ghost = (ob->dtx & OB_DRAWXRAY) ? 1 : 0;
- bool transp = (ppd->transparent_bones || (ob->dt <= OB_WIRE));
+ bool transp = (ppd->transparent_bones || (ob->dt <= OB_WIRE)) ||
+ (draw_ctx->v3d->shading.flag & XRAY_FLAG(draw_ctx->v3d)) != 0;
DRWArmaturePasses passes = {
.bone_solid = (transp) ? psl->bone_transp[ghost] : psl->bone_solid[ghost],
diff --git a/source/blender/draw/modes/shaders/armature_axes_vert.glsl b/source/blender/draw/modes/shaders/armature_axes_vert.glsl
index 137bcff1ed1..ac640f0c303 100644
--- a/source/blender/draw/modes/shaders/armature_axes_vert.glsl
+++ b/source/blender/draw/modes/shaders/armature_axes_vert.glsl
@@ -1,7 +1,9 @@
uniform mat4 ViewProjectionMatrix;
uniform vec3 screenVecs[3];
-
+#ifdef USE_WORLD_CLIP_PLANES
+uniform mat4 ModelMatrix;
+#endif
/* ---- Instantiated Attrs ---- */
in float axis; /* position on the axis. [0.0-1.0] is X axis, [1.0-2.0] is Y, etc... */
in vec2 screenPos;
@@ -23,8 +25,13 @@ void main()
/* Scale uniformly by axis length */
spos *= length(chosen_axis);
- gl_Position = ViewProjectionMatrix * vec4(wpos + spos, 1.0);
+ vec4 pos_4d = vec4(wpos + spos, 1.0);
+ gl_Position = ViewProjectionMatrix * pos_4d;
finalColor.rgb = mix(colorAxis, color.rgb, color.a);
finalColor.a = 1.0;
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance((ModelMatrix * pos_4d).xyz);
+#endif
}
diff --git a/source/blender/draw/modes/shaders/armature_envelope_outline_vert.glsl b/source/blender/draw/modes/shaders/armature_envelope_outline_vert.glsl
index b170b4f41e2..7e78f600518 100644
--- a/source/blender/draw/modes/shaders/armature_envelope_outline_vert.glsl
+++ b/source/blender/draw/modes/shaders/armature_envelope_outline_vert.glsl
@@ -3,6 +3,9 @@ uniform mat4 ViewMatrix;
uniform mat4 ViewMatrixInverse;
uniform mat4 ViewProjectionMatrix;
uniform mat4 ProjectionMatrix;
+#ifdef USE_WORLD_CLIP_PLANES
+uniform mat4 ModelMatrix;
+#endif
uniform vec2 viewportSize;
uniform float lineThickness = 2.0;
@@ -130,7 +133,13 @@ void main()
vec3 wpos1 = get_outline_point(pos1, sph_near, sph_far, mat_near, mat_far, z_ofs_near, z_ofs_far, b);
vec3 wpos2 = get_outline_point(pos2, sph_near, sph_far, mat_near, mat_far, z_ofs_near, z_ofs_far, b);
- vec4 V = ViewMatrix * vec4(wpos1, 1.0);
+
+ vec4 pos_4d = vec4(wpos1, 1.0);
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance((ModelMatrix * pos_4d).xyz);
+#endif
+
+ vec4 V = ViewMatrix * pos_4d;
float pres_fac = (ProjectionMatrix[3][3] == 0.0) ? abs(V.z) : 1.0;
vec4 p0 = ViewProjectionMatrix * vec4(wpos0, 1.0);
diff --git a/source/blender/draw/modes/shaders/armature_envelope_solid_vert.glsl b/source/blender/draw/modes/shaders/armature_envelope_solid_vert.glsl
index 01e77837201..880c8c6262c 100644
--- a/source/blender/draw/modes/shaders/armature_envelope_solid_vert.glsl
+++ b/source/blender/draw/modes/shaders/armature_envelope_solid_vert.glsl
@@ -2,6 +2,10 @@
uniform mat4 ViewMatrix;
uniform mat4 ViewMatrixInverse;
uniform mat4 ViewProjectionMatrix;
+#ifdef USE_WORLD_CLIP_PLANES
+uniform mat4 ModelMatrix;
+#endif
+
/* ---- Instantiated Attrs ---- */
in vec3 pos;
@@ -48,8 +52,12 @@ void main()
normalView = mat3(ViewMatrix) * nor;
- gl_Position = ViewProjectionMatrix * vec4(sp, 1.0);
-
finalStateColor = stateColor;
finalBoneColor = boneColor;
+
+ vec4 pos_4d = vec4(sp, 1.0);
+ gl_Position = ViewProjectionMatrix * pos_4d;
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance((ModelMatrix * pos_4d).xyz);
+#endif
}
diff --git a/source/blender/draw/modes/shaders/common_hair_lib.glsl b/source/blender/draw/modes/shaders/common_hair_lib.glsl
index 359e4d87b7a..9cda44c8f42 100644
--- a/source/blender/draw/modes/shaders/common_hair_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_hair_lib.glsl
@@ -3,13 +3,13 @@
* This is less bandwidth intensive than fetching the vertex attributes
* but does more ALU work per vertex. This also reduce the number
* of data the CPU has to precompute and transfert for each update.
- **/
+ */
/**
* hairStrandsRes: Number of points per hair strand.
* 2 - no subdivision
* 3+ - 1 or more interpolated points per hair.
- **/
+ */
uniform int hairStrandsRes = 8;
/**
@@ -17,7 +17,7 @@ uniform int hairStrandsRes = 8;
* 1 - Wire Hair: Only one pixel thick, independent of view distance.
* 2 - Polystrip Hair: Correct width, flat if camera is parallel.
* 3+ - Cylinder Hair: Massive calculation but potentially perfect. Still need proper support.
- **/
+ */
uniform int hairThicknessRes = 1;
/* Hair thickness shape. */
@@ -46,8 +46,8 @@ void unpack_strand_data(uint data, out int strand_offset, out int strand_segment
// strand_offset = (data & 0x1FFFFFFFu);
// strand_segments = 1u << (data >> 29u); /* We only need 3 bits to store subdivision level. */
#else
- strand_offset = int(data & 0x00FFFFFFu);
- strand_segments = int(data >> 24u);
+ strand_offset = int(data & 0x003FFFFFu);
+ strand_segments = int(data >> 22u) + 1;
#endif
}
@@ -58,7 +58,7 @@ void unpack_strand_data(uint data, out int strand_offset, out int strand_segment
* children particle modifiers being evaluated at this stage.
*
* If no more subdivision is needed, we can skip this step.
- **/
+ */
#ifdef HAIR_PHASE_SUBDIV
int hair_get_base_id(float local_time, int strand_segments, out float interp_time)
@@ -104,7 +104,7 @@ void hair_get_interp_attrs(out vec4 data0, out vec4 data1, out vec4 data2, out v
/* -- Drawing stage -- */
/**
* For final drawing, the vertex index and the number of vertex per segment
- **/
+ */
#ifndef HAIR_PHASE_SUBDIV
int hair_get_strand_id(void)
@@ -136,6 +136,10 @@ float hair_shaperadius(float shape, float root, float tip, float time)
return (radius * (root - tip)) + tip;
}
+#ifdef OS_MAC
+in float dummy;
+#endif
+
void hair_get_pos_tan_binor_time(
bool is_persp, mat4 invmodel_mat, vec3 camera_pos, vec3 camera_z,
out vec3 wpos, out vec3 wtan, out vec3 wbinor, out float time, out float thickness, out float thick_time)
@@ -144,6 +148,13 @@ void hair_get_pos_tan_binor_time(
vec4 data = texelFetch(hairPointBuffer, id);
wpos = data.point_position;
time = data.point_time;
+
+#ifdef OS_MAC
+ /* Generate a dummy read to avoid the driver bug with shaders having no
+ * vertex reads on macOS (T60171) */
+ wpos.y += dummy * 0.0;
+#endif
+
if (time == 0.0) {
/* Hair root */
wtan = texelFetch(hairPointBuffer, id + 1).point_position - wpos;
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 dbad525c281..59fb8e7fc90 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
@@ -7,7 +7,7 @@
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
* The formula for the area uses inverse trig function and is quite complexe.
* Instead, we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
- **/
+ */
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
#define GRID_LINE_SMOOTH_END (0.5 + DISC_RADIUS)
@@ -16,7 +16,7 @@ uniform float edgeScale;
flat in vec4 finalColorOuter_f;
in vec4 finalColor_f;
-in float edgeCoord_f;
+noperspective in float edgeCoord_f;
out vec4 FragColor;
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 9a0bda3b81d..d5d9f213b94 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
@@ -12,15 +12,15 @@ in int selectOveride[2];
flat out vec4 finalColorOuter_f;
out vec4 finalColor_f;
-out float edgeCoord_f;
+noperspective out float edgeCoord_f;
-void do_vertex(const int i, float coord, vec2 offset)
+void do_vertex(const int i, vec4 pos, float coord, vec2 offset)
{
finalColor_f = (selectOveride[0] == 0) ? finalColor[i] : finalColor[0];
edgeCoord_f = coord;
- gl_Position = gl_in[i].gl_Position;
+ gl_Position = pos;
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
- gl_Position.xy += offset * 2.0 * gl_Position.w;
+ gl_Position.xy += offset * 2.0 * pos.w;
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_set_clip_distance(gl_in[i].gl_ClipDistance);
#endif
@@ -30,8 +30,28 @@ void do_vertex(const int i, float coord, vec2 offset)
void main()
{
vec2 ss_pos[2];
- ss_pos[0] = gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w;
- ss_pos[1] = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w;
+
+ /* Clip line against near plane to avoid deformed lines. */
+ vec4 pos0 = gl_in[0].gl_Position;
+ vec4 pos1 = gl_in[1].gl_Position;
+ vec2 pz_ndc = vec2(pos0.z / pos0.w, pos1.z / pos1.w);
+ bvec2 clipped = lessThan(pz_ndc, vec2(-1.0));
+ if (all(clipped)) {
+ /* Totally clipped. */
+ return;
+ }
+
+ vec4 pos01 = pos0 - pos1;
+ float ofs = abs((pz_ndc.y + 1.0) / (pz_ndc.x - pz_ndc.y));
+ if (clipped.y) {
+ pos1 += pos01 * ofs;
+ }
+ else if (clipped.x) {
+ pos0 -= pos01 * (1.0 - ofs);
+ }
+
+ ss_pos[0] = pos0.xy / pos0.w;
+ ss_pos[1] = pos1.xy / pos1.w;
vec2 line = ss_pos[0] - ss_pos[1];
line = abs(line) * viewportSize;
@@ -51,10 +71,10 @@ void main()
bool horizontal = line.x > line.y;
edge_ofs = (horizontal) ? edge_ofs.zyz : edge_ofs.xzz;
- do_vertex(0, half_size, edge_ofs.xy);
- do_vertex(0, -half_size, -edge_ofs.xy);
- do_vertex(1, half_size, edge_ofs.xy);
- do_vertex(1, -half_size, -edge_ofs.xy);
+ 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);
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 982ef2ca801..c43ae6073c6 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
@@ -78,9 +78,9 @@ void main()
/* Facing based color blend */
vec4 vpos = ModelViewMatrix * vec4(pos, 1.0);
vec3 view_normal = normalize(NormalMatrix * vnor + 1e-4);
- vec3 view_vec = (ProjectionMatrix[3][3] == 0.0)
- ? normalize(vpos.xyz)
- : vec3(0.0, 0.0, 1.0);
+ vec3 view_vec = (ProjectionMatrix[3][3] == 0.0) ?
+ normalize(vpos.xyz) :
+ vec3(0.0, 0.0, 1.0);
float facing = dot(view_vec, view_normal);
facing = 1.0 - abs(facing) * 0.3;
diff --git a/source/blender/draw/modes/shaders/object_empty_axes_vert.glsl b/source/blender/draw/modes/shaders/object_empty_axes_vert.glsl
index 4aafceeb437..8de25de35ad 100644
--- a/source/blender/draw/modes/shaders/object_empty_axes_vert.glsl
+++ b/source/blender/draw/modes/shaders/object_empty_axes_vert.glsl
@@ -1,6 +1,8 @@
uniform mat4 ViewProjectionMatrix;
+#ifdef USE_WORLD_CLIP_PLANES
uniform mat4 ModelMatrix;
+#endif
uniform vec3 screenVecs[3];
@@ -25,12 +27,12 @@ void main()
/* Scale uniformly by axis length */
spos *= length(chosen_axis) * draw_size;
- vec4 pos = vec4(wpos + spos, 1.0);
- gl_Position = ViewProjectionMatrix * pos;
+ vec4 pos_4d = vec4(wpos + spos, 1.0);
+ gl_Position = ViewProjectionMatrix * pos_4d;
finalColor = vec4(color, 1.0);
#ifdef USE_WORLD_CLIP_PLANES
- world_clip_planes_calc_clip_distance((ModelMatrix * pos).xyz);
+ world_clip_planes_calc_clip_distance((ModelMatrix * pos_4d).xyz);
#endif
}
diff --git a/source/blender/draw/modes/shaders/object_empty_image_frag.glsl b/source/blender/draw/modes/shaders/object_empty_image_frag.glsl
index e47b28d80c6..c20d70e3b06 100644
--- a/source/blender/draw/modes/shaders/object_empty_image_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_empty_image_frag.glsl
@@ -12,13 +12,26 @@ uniform sampler2D image;
#endif
uniform int depthMode;
+uniform bool useAlphaTest;
void main()
{
#ifdef USE_WIRE
fragColor = finalColor;
#else
- fragColor = finalColor * texture(image, texCoord_interp);
+ vec4 tex_col = texture(image, texCoord_interp);
+ fragColor = finalColor * tex_col;
+
+ if (useAlphaTest) {
+ /* Arbitrary discard anything below 5% opacity.
+ * Note that this could be exposed to the User. */
+ if (tex_col.a < 0.05) {
+ discard;
+ }
+ else {
+ fragColor.a = 1.0;
+ }
+ }
#endif
if (depthMode == DEPTH_BACK) {
diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl
index 5a2913fc2e2..7d89676fd47 100644
--- a/source/blender/draw/modes/shaders/object_grid_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl
@@ -42,7 +42,7 @@ uniform int gridFlag;
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
* The formula for the area uses inverse trig function and is quite complexe.
* Instead, we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
- **/
+ */
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
#define GRID_LINE_SMOOTH_END (0.5 + DISC_RADIUS)
diff --git a/source/blender/draw/modes/shaders/paint_texture_frag.glsl b/source/blender/draw/modes/shaders/paint_texture_frag.glsl
index 68fd1be0886..aadbf8c58c0 100644
--- a/source/blender/draw/modes/shaders/paint_texture_frag.glsl
+++ b/source/blender/draw/modes/shaders/paint_texture_frag.glsl
@@ -1,11 +1,21 @@
in vec2 uv_interp;
+#ifdef TEXTURE_PAINT_MASK
+in vec2 masking_uv_interp;
+#endif
+
out vec4 fragColor;
uniform sampler2D image;
uniform float alpha = 1.0;
uniform bool nearestInterp;
+#ifdef TEXTURE_PAINT_MASK
+uniform sampler2D maskingImage;
+uniform vec3 maskingColor;
+uniform bool maskingInvertStencil;
+#endif
+
void main()
{
vec2 uv = uv_interp;
@@ -13,5 +23,19 @@ void main()
vec2 tex_size = vec2(textureSize(image, 0).xy);
uv = (floor(uv_interp * tex_size) + 0.5) / tex_size;
}
- fragColor = vec4(texture(image, uv).rgb, alpha);
+
+ vec4 color = texture(image, uv);
+ color.a *= alpha;
+
+#ifdef TEXTURE_PAINT_MASK
+ vec4 mask = vec4(texture(maskingImage, masking_uv_interp).rgb, 1.0);
+ if (maskingInvertStencil) {
+ mask.rgb = 1.0 - mask.rgb;
+ }
+ float mask_step = smoothstep(0, 3.0, mask.r+mask.g+mask.b);
+ mask.rgb *= maskingColor;
+ color = mix(color, mask, mask_step);
+#endif
+
+ fragColor = color;
}
diff --git a/source/blender/draw/modes/shaders/paint_texture_vert.glsl b/source/blender/draw/modes/shaders/paint_texture_vert.glsl
index c53439f46a0..43a353f0278 100644
--- a/source/blender/draw/modes/shaders/paint_texture_vert.glsl
+++ b/source/blender/draw/modes/shaders/paint_texture_vert.glsl
@@ -5,15 +5,27 @@ uniform mat4 ModelMatrix;
in vec2 u; /* active uv map */
in vec3 pos;
+#ifdef TEXTURE_PAINT_MASK
+in vec2 mu; /* masking uv map */
+#endif
+
out vec2 uv_interp;
+#ifdef TEXTURE_PAINT_MASK
+out vec2 masking_uv_interp;
+#endif
+
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
uv_interp = u;
+#ifdef TEXTURE_PAINT_MASK
+ masking_uv_interp = mu;
+#endif
+
#ifdef USE_WORLD_CLIP_PLANES
- world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index d1cef1cfa17..618ac8f6f13 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -220,6 +220,23 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
}
}
+/* get backdrop color for grease pencil channels */
+static void acf_gpencil_channel_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3])
+{
+ const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
+ short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
+ bool showGroupColors = acf_show_channel_colors(ac);
+
+ if ((showGroupColors) && (ale->type == ANIMTYPE_GPLAYER)) {
+ bGPDlayer *gpl = (bGPDlayer *)ale->data;
+ copy_v3_v3(r_color, gpl->color);
+ }
+ else {
+ int colOfs = 10 - 10 * indent;
+ UI_GetThemeColorShade3fv(TH_SHADE2, colOfs, r_color);
+ }
+}
+
/* backdrop for generic channels */
static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
{
@@ -3058,7 +3075,7 @@ static bAnimChannelType ACF_GPL =
"GPencil Layer", /* type name */
ACHANNEL_ROLE_CHANNEL, /* role */
- acf_generic_channel_color, /* backdrop color */
+ acf_gpencil_channel_color, /* backdrop color */
acf_generic_channel_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset, /* offset */
@@ -4059,13 +4076,13 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL);
}
- /* tag copy-on-write flushing (so that the settings will have an effect) */
+ /* Tag for full animation update, so that the settings will have an effect. */
if (ale_setting->id) {
- DEG_id_tag_update(ale_setting->id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(ale_setting->id, ID_RECALC_ANIMATION);
}
if (ale_setting->adt && ale_setting->adt->action) {
- /* action is it's own datablock, so has to be tagged specifically... */
- DEG_id_tag_update(&ale_setting->adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ /* Action is it's own datablock, so has to be tagged specifically. */
+ DEG_id_tag_update(&ale_setting->adt->action->id, ID_RECALC_ANIMATION);
}
/* verify animation context */
@@ -4109,7 +4126,7 @@ static void achannel_nlatrack_solo_widget_cb(bContext *C, void *ale_poin, void *
BKE_nlatrack_solo_toggle(adt, nlt);
/* send notifiers */
- DEG_id_tag_update(ale->id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(ale->id, ID_RECALC_ANIMATION);
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
}
@@ -4152,8 +4169,13 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
/* 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) {
+ if (adt->action != NULL) {
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH);
+ }
+ DEG_id_tag_update(id, ID_RECALC_ANIMATION_NO_FLUSH);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ }
}
BKE_animsys_free_nla_keyframing_context_cache(&nla_cache);
@@ -4427,12 +4449,18 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni
}
/* Draw UI widgets the given channel */
-void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListElem *ale, uiBlock *block, float yminc, float ymaxc, size_t channel_index)
+void ANIM_channel_draw_widgets(
+ const bContext *C,
+ bAnimContext *ac,
+ bAnimListElem *ale,
+ uiBlock *block,
+ rctf *rect,
+ size_t channel_index)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
View2D *v2d = &ac->ar->v2d;
- float y, ymid /*, ytext*/;
- short offset;
+ float ymid;
+ const short channel_height = round_fl_to_int(BLI_rctf_size_y(rect));
const bool is_being_renamed = achannel_is_being_renamed(ac, acf, channel_index);
/* sanity checks - don't draw anything */
@@ -4440,15 +4468,13 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
return;
/* get initial offset */
- if (acf->get_offset)
- offset = acf->get_offset(ac, ale);
- else
- offset = 0;
+ short offset = rect->xmin;
+ if (acf->get_offset) {
+ offset += acf->get_offset(ac, ale);
+ }
- /* calculate appropriate y-coordinates for icon buttons
- */
- y = (ymaxc - yminc) / 2 + yminc;
- ymid = y - 0.5f * ICON_WIDTH;
+ /* calculate appropriate y-coordinates for icon buttons */
+ ymid = BLI_rctf_cent_y(rect) - 0.5f * ICON_WIDTH;
/* no button backdrop behind icons */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
@@ -4530,13 +4556,12 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
*/
if (acf->name_prop(ale, &ptr, &prop)) {
const short margin_x = 3 * round_fl_to_int(UI_DPI_FAC);
- const short channel_height = round_fl_to_int(ymaxc - yminc);
const short width = ac->ar->winx - offset - (margin_x * 2);
uiBut *but;
UI_block_emboss_set(block, UI_EMBOSS);
- but = uiDefButR(block, UI_BTYPE_TEXT, 1, "", offset + margin_x, yminc,
+ but = uiDefButR(block, UI_BTYPE_TEXT, 1, "", offset + margin_x, rect->ymin,
MAX2(width, RENAME_TEXT_MIN_WIDTH), channel_height,
&ptr, RNA_property_identifier(prop), -1, 0, 0, -1, -1, NULL);
@@ -4561,7 +4586,7 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
/* step 5) draw mute+protection toggles + (sliders) ....................... */
/* reset offset - now goes from RHS of panel */
- offset = 0;
+ offset = (int)rect->xmax;
// TODO: when drawing sliders, make those draw instead of these toggles if not enough space
if (v2d && !is_being_renamed) {
@@ -4589,33 +4614,33 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
/* protect... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
- offset += ICON_WIDTH;
- draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_PROTECT);
+ offset -= ICON_WIDTH;
+ draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_PROTECT);
}
/* mute... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) {
- offset += ICON_WIDTH;
- draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_MUTE);
+ offset -= ICON_WIDTH;
+ 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) */
- offset += ICON_WIDTH;
- draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_VISIBLE);
+ offset -= ICON_WIDTH;
+ draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_VISIBLE);
}
/* modifiers disable */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MOD_OFF)) {
/* hack: extra spacing, to avoid touching the mute toggle */
- offset += ICON_WIDTH * 1.2f;
- draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_MOD_OFF);
+ offset -= ICON_WIDTH * 1.2f;
+ draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_MOD_OFF);
}
/* ----------- */
/* pinned... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED)) {
- offset += ICON_WIDTH;
- draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_PINNED);
+ offset -= ICON_WIDTH;
+ draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_PINNED);
}
/* NLA Action "pushdown" */
@@ -4625,9 +4650,9 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
UI_block_emboss_set(block, UI_EMBOSS);
- offset += UI_UNIT_X;
+ offset -= UI_UNIT_X;
but = uiDefIconButO(block, UI_BTYPE_BUT, "NLA_OT_action_pushdown", WM_OP_INVOKE_DEFAULT, ICON_NLA_PUSHDOWN,
- (int)v2d->cur.xmax - offset, ymid, UI_UNIT_X, UI_UNIT_X, NULL);
+ offset, ymid, UI_UNIT_X, UI_UNIT_X, NULL);
opptr_b = UI_but_operator_ptr_get(but);
RNA_int_set(opptr_b, "channel_index", channel_index);
@@ -4647,7 +4672,7 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
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
- offset += SLIDER_WIDTH;
+ offset -= SLIDER_WIDTH;
/* need backdrop behind sliders... */
UI_block_emboss_set(block, UI_EMBOSS);
@@ -4668,7 +4693,7 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
uiBut *but;
/* create the slider button, and assign relevant callback to ensure keyframes are inserted... */
- but = uiDefAutoButR(block, &ptr, prop, fcu->array_index, "", ICON_NONE, (int)v2d->cur.xmax - offset, ymid, SLIDER_WIDTH, (int)ymaxc - yminc);
+ but = uiDefAutoButR(block, &ptr, prop, fcu->array_index, "", ICON_NONE, offset, ymid, SLIDER_WIDTH, channel_height);
UI_but_func_set(but, achannel_setting_slider_nla_curve_cb, ale->id, ale->data);
}
}
@@ -4705,7 +4730,7 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle
uiBut *but;
/* create the slider button, and assign relevant callback to ensure keyframes are inserted... */
- but = uiDefAutoButR(block, &ptr, prop, array_index, "", ICON_NONE, (int)v2d->cur.xmax - offset, ymid, SLIDER_WIDTH, (int)ymaxc - yminc);
+ but = uiDefAutoButR(block, &ptr, prop, array_index, "", ICON_NONE, offset, ymid, SLIDER_WIDTH, channel_height);
/* assign keyframing function according to slider type */
if (ale->type == ANIMTYPE_SHAPEKEY)
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 3bcbe2d99e3..558c5d5bfc1 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1258,8 +1258,9 @@ static void rearrange_nla_control_channels(bAnimContext *ac, AnimData *adt, eRea
/* we cannot rearrange between strips, but within each strip, we can rearrange those curves */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
- rearrange_animchannel_islands(&strip->fcurves, rearrange_func, mode, ANIMTYPE_NLACURVE,
- &anim_data_visible);
+ rearrange_animchannel_islands(
+ &strip->fcurves, rearrange_func, mode, ANIMTYPE_NLACURVE,
+ &anim_data_visible);
}
}
@@ -1350,7 +1351,7 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
switch (ac.datatype) {
case ANIMCONT_NLA: /* NLA-tracks only */
rearrange_nla_channels(&ac, adt, mode);
- DEG_id_tag_update(ale->id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(ale->id, ID_RECALC_ANIMATION);
break;
case ANIMCONT_DRIVERS: /* Drivers list only */
@@ -1637,7 +1638,7 @@ static void update_dependencies_on_delete(bAnimListElem *ale)
if (adt != NULL) {
DEG_id_tag_update(id, ID_RECALC_ANIMATION);
if (adt->action != NULL) {
- DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION);
}
}
/* Deals with NLA and drivers.
@@ -1693,7 +1694,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* free the group itself */
if (adt->action) {
BLI_freelinkN(&adt->action->groups, agrp);
- DEG_id_tag_update_ex(CTX_data_main(C), &adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(CTX_data_main(C), &adt->action->id, ID_RECALC_ANIMATION);
}
else
MEM_freeN(agrp);
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 7bef42d8682..dfb1a456364 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -72,13 +72,13 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
if (adt) {
DEG_id_tag_update(id, ID_RECALC_ANIMATION);
if (adt->action != NULL) {
- DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION);
}
}
/* Tag copy on the main object if updating anything directly inside AnimData */
if (ELEM(ale->type, ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, ANIMTYPE_NLATRACK, ANIMTYPE_NLACURVE)) {
- DEG_id_tag_update(id, ID_RECALC_ANIMATION | ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(id, ID_RECALC_ANIMATION);
return;
}
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index af2037ef376..17d74e8324f 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1418,10 +1418,11 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop
* - 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;
- });
+ ANIMCHANNEL_NEW_CHANNEL_FULL(
+ (void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id, NULL,
+ {
+ ale->data = adt->action ? adt->action : NULL;
+ });
}
}
@@ -1551,26 +1552,27 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope
* 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(iat,
- { /* AnimData */
- /* specifically filter animdata block */
- if (ANIMCHANNEL_SELOK(SEL_ANIMDATA(adt)) ) {
- ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_ANIMDATA, id, NULL);
- }
- },
- { /* NLA */
- items += animfilter_nla(ac, anim_data, ads, adt, filter_mode, id);
- },
- { /* Drivers */
- items += animfilter_fcurves(anim_data, ads, adt->drivers.first, ANIMTYPE_FCURVE,
- filter_mode, NULL, id, id);
- },
- { /* NLA Control Keyframes */
- items += animfilter_nla_controls(anim_data, ads, adt, filter_mode, id);
- },
- { /* Keyframes */
- items += animfilter_action(ac, anim_data, ads, adt->action, filter_mode, id);
- }
+ ANIMDATA_FILTER_CASES(
+ iat,
+ { /* AnimData */
+ /* specifically filter animdata block */
+ if (ANIMCHANNEL_SELOK(SEL_ANIMDATA(adt)) ) {
+ ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_ANIMDATA, id, NULL);
+ }
+ },
+ { /* NLA */
+ items += animfilter_nla(ac, anim_data, ads, adt, filter_mode, id);
+ },
+ { /* Drivers */
+ items += animfilter_fcurves(anim_data, ads, adt->drivers.first, ANIMTYPE_FCURVE,
+ filter_mode, NULL, id, id);
+ },
+ { /* NLA Control Keyframes */
+ items += animfilter_nla_controls(anim_data, ads, adt, filter_mode, id);
+ },
+ { /* Keyframes */
+ items += animfilter_action(ac, anim_data, ads, adt->action, filter_mode, id);
+ }
);
}
@@ -2531,20 +2533,21 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b
/* determine the type of expander channels to use */
/* this is the best way to do this for now... */
- ANIMDATA_FILTER_CASES(ob,
- { /* AnimData - no channel, but consider data */ },
- { /* NLA - no channel, but consider data */ },
- { /* Drivers */
- type = ANIMTYPE_FILLDRIVERS;
- cdata = adt;
- expanded = EXPANDED_DRVD(adt);
- },
- { /* NLA Strip Controls - no dedicated channel for now (XXX) */ },
- { /* Keyframes */
- type = ANIMTYPE_FILLACTD;
- cdata = adt->action;
- expanded = EXPANDED_ACTC(adt->action);
- });
+ ANIMDATA_FILTER_CASES(
+ ob,
+ { /* AnimData - no channel, but consider data */ },
+ { /* NLA - no channel, but consider data */ },
+ { /* Drivers */
+ type = ANIMTYPE_FILLDRIVERS;
+ cdata = adt;
+ expanded = EXPANDED_DRVD(adt);
+ },
+ { /* NLA Strip Controls - no dedicated channel for now (XXX) */ },
+ { /* Keyframes */
+ type = ANIMTYPE_FILLACTD;
+ cdata = adt->action;
+ expanded = EXPANDED_ACTC(adt->action);
+ });
/* add object-level animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
@@ -2701,20 +2704,21 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD
/* determine the type of expander channels to use */
// this is the best way to do this for now...
- ANIMDATA_FILTER_CASES(sce,
- { /* AnimData - no channel, but consider data */},
- { /* NLA - no channel, but consider data */},
- { /* Drivers */
- type = ANIMTYPE_FILLDRIVERS;
- cdata = adt;
- expanded = EXPANDED_DRVD(adt);
- },
- { /* NLA Strip Controls - no dedicated channel for now (XXX) */ },
- { /* Keyframes */
- type = ANIMTYPE_FILLACTD;
- cdata = adt->action;
- expanded = EXPANDED_ACTC(adt->action);
- });
+ ANIMDATA_FILTER_CASES(
+ sce,
+ { /* AnimData - no channel, but consider data */},
+ { /* NLA - no channel, but consider data */},
+ { /* Drivers */
+ type = ANIMTYPE_FILLDRIVERS;
+ cdata = adt;
+ expanded = EXPANDED_DRVD(adt);
+ },
+ { /* NLA Strip Controls - no dedicated channel for now (XXX) */ },
+ { /* Keyframes */
+ type = ANIMTYPE_FILLACTD;
+ cdata = adt->action;
+ expanded = EXPANDED_ACTC(adt->action);
+ });
/* add scene-level animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 40454bcad0c..8edad506a33 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -100,7 +100,7 @@ static void delete_fmodifier_cb(bContext *C, void *ctx_v, void *fcm_v)
/* 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
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
- DEG_id_tag_update(ctx->fcurve_owner_id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(ctx->fcurve_owner_id, ID_RECALC_ANIMATION);
}
/* --------------- */
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 1922b876d1e..4cea8ddbf74 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -157,7 +157,7 @@ bAction *verify_adt_action(Main *bmain, ID *id, short add)
DEG_relations_tag_update(bmain);
}
- DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH);
/* return the action */
return adt->action;
@@ -1317,10 +1317,10 @@ short insert_keyframe(
if (ret) {
if (act != NULL) {
- DEG_id_tag_update(&act->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&act->id, ID_RECALC_ANIMATION_NO_FLUSH);
}
if (adt != NULL && adt->action != NULL && adt->action != act) {
- DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH);
}
}
@@ -1371,11 +1371,11 @@ static void deg_tag_after_keyframe_delete(Main *bmain, ID *id, AnimData *adt)
/* In the case last f-curve wes removed need to inform dependency graph
* about relations update, since it needs to get rid of animation operation
* for this datablock. */
- DEG_id_tag_update_ex(bmain, id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, id, ID_RECALC_ANIMATION_NO_FLUSH);
DEG_relations_tag_update(bmain);
}
else {
- DEG_id_tag_update_ex(bmain, &adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update_ex(bmain, &adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH);
}
}
@@ -1975,6 +1975,7 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
*/
success += delete_keyframe_fcurve(adt, fcu, cfra_unmap);
}
+ DEG_id_tag_update(&ob->adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH);
}
/* report success (or failure) */
@@ -2125,6 +2126,13 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
}
if (success) {
+ ID *id = ptr.id.data;
+ AnimData *adt = BKE_animdata_from_id(id);
+ if (adt->action != NULL) {
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH);
+ }
+ DEG_id_tag_update(id, ID_RECALC_ANIMATION_NO_FLUSH);
+
/* send updates */
UI_context_update_anim_flag(C);
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 444e4634644..d532e22e7f7 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -1049,7 +1049,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
break;
}
default:
- DEG_id_tag_update(ksp->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(ksp->id, ID_RECALC_ANIMATION_NO_FLUSH);
break;
}
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index f3a4fef2789..e3db0ca8f2c 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -1649,7 +1649,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_hide(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Hide Selected Bones";
+ ot->name = "Hide Selected";
ot->idname = "ARMATURE_OT_hide";
ot->description = "Tag selected bones to not be visible in Edit Mode";
@@ -1701,7 +1701,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_reveal(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Reveal Bones";
+ ot->name = "Reveal Hidden";
ot->idname = "ARMATURE_OT_reveal";
ot->description = "Reveal all bones hidden in Edit Mode";
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 8d58ee28f5c..6e93ecc484d 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -421,7 +421,7 @@ static EditBone *get_nearest_editbonepoint(
if (vc->v3d->shading.type > OB_WIRE) {
do_nearest = true;
- if (len_manhattan_v2v2_int(vc->mval, last_mval) < 3) {
+ if (len_manhattan_v2v2_int(vc->mval, last_mval) <= WM_EVENT_CURSOR_MOTION_THRESHOLD) {
do_nearest = false;
}
}
@@ -561,46 +561,69 @@ cache_end:
return NULL;
}
-void ED_armature_edit_deselect_all(Object *obedit)
+bool ED_armature_edit_deselect_all(Object *obedit)
{
bArmature *arm = obedit->data;
- EditBone *ebone;
-
- for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ bool changed = false;
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) {
+ ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ changed = true;
+ }
}
+ return changed;
}
-void ED_armature_edit_deselect_all_visible(Object *obedit)
+bool ED_armature_edit_deselect_all_visible(Object *obedit)
{
bArmature *arm = obedit->data;
- EditBone *ebone;
-
- for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ bool changed = false;
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
/* first and foremost, bone must be visible and selected */
if (EBONE_VISIBLE(arm, ebone)) {
- ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) {
+ ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ changed = true;
+ }
}
}
- ED_armature_edit_sync_selection(arm->edbo);
+ if (changed) {
+ ED_armature_edit_sync_selection(arm->edbo);
+ }
+ return changed;
}
-void ED_armature_edit_deselect_all_multi(struct Object **objects, uint objects_len)
+bool ED_armature_edit_deselect_all_multi_ex(struct Base **bases, uint bases_len)
{
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
- ED_armature_edit_deselect_all(obedit);
+ bool changed_multi = false;
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
+ changed_multi |= ED_armature_edit_deselect_all(obedit);
}
+ return changed_multi;
}
-void ED_armature_edit_deselect_all_visible_multi(struct Object **objects, uint objects_len)
+bool ED_armature_edit_deselect_all_visible_multi_ex(struct Base **bases, uint bases_len)
{
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
- ED_armature_edit_deselect_all_visible(obedit);
+ bool changed_multi = false;
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
+ changed_multi |= ED_armature_edit_deselect_all_visible(obedit);
}
+ return changed_multi;
+}
+
+bool ED_armature_edit_deselect_all_visible_multi(bContext *C)
+{
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &bases_len);
+ bool changed_multi = ED_armature_edit_deselect_all_multi_ex(bases, bases_len);
+ MEM_freeN(bases);
+ return changed_multi;
}
/* accounts for connected parents */
@@ -631,11 +654,15 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b
ED_view3d_viewcontext_init_object(&vc, basact->object);
bArmature *arm = vc.obedit->data;
+ if (!EBONE_SELECTABLE(arm, nearBone)) {
+ return false;
+ }
+
if (!extend && !deselect && !toggle) {
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &objects_len);
- ED_armature_edit_deselect_all_multi(objects, objects_len);
- MEM_freeN(objects);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &bases_len);
+ ED_armature_edit_deselect_all_multi_ex(bases, bases_len);
+ MEM_freeN(bases);
}
/* by definition the non-root connected bones have no root point drawn,
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 285901f8dd0..5ef61f0f6c6 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -172,10 +172,10 @@ bool ED_armature_pose_select_pick_with_buffer(
if (!extend && !deselect && !toggle) {
{
- uint objects_len = 0;
- Object **objects = BKE_object_pose_array_get_unique(view_layer, v3d, &objects_len);
- ED_pose_deselect_all_multi(objects, objects_len, SEL_DESELECT, true);
- MEM_freeN(objects);
+ uint bases_len = 0;
+ Base **bases = BKE_object_pose_base_array_get_unique(view_layer, v3d, &bases_len);
+ ED_pose_deselect_all_multi_ex(bases, bases_len, SEL_DESELECT, true);
+ MEM_freeN(bases);
}
nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
arm->act_bone = nearBone;
@@ -283,10 +283,10 @@ static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility)
return false;
}
-static bool ed_pose_is_any_selected_multi(Object **objects, uint objects_len, bool ignore_visibility)
+static bool ed_pose_is_any_selected_multi(Base **bases, uint bases_len, bool ignore_visibility)
{
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *ob_iter = objects[ob_index];
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *ob_iter = bases[base_index]->object;
if (ed_pose_is_any_selected(ob_iter, ignore_visibility)) {
return true;
}
@@ -294,19 +294,34 @@ static bool ed_pose_is_any_selected_multi(Object **objects, uint objects_len, bo
return false;
}
-void ED_pose_deselect_all_multi(Object **objects, uint objects_len, int select_mode, const bool ignore_visibility)
+bool ED_pose_deselect_all_multi_ex(Base **bases, uint bases_len, int select_mode, const bool ignore_visibility)
{
if (select_mode == SEL_TOGGLE) {
select_mode = ed_pose_is_any_selected_multi(
- objects, objects_len, ignore_visibility) ? SEL_DESELECT : SEL_SELECT;
+ bases, bases_len, ignore_visibility) ? SEL_DESELECT : SEL_SELECT;
}
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *ob_iter = objects[ob_index];
+ bool changed_multi = false;
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *ob_iter = bases[base_index]->object;
if (ED_pose_deselect_all(ob_iter, select_mode, ignore_visibility)) {
ED_pose_bone_select_tag_update(ob_iter);
+ changed_multi = true;
}
}
+ return changed_multi;
+}
+
+
+bool ED_pose_deselect_all_multi(bContext *C, int select_mode, const bool ignore_visibility)
+{
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_mode(vc.view_layer, vc.v3d, &bases_len, {.object_mode = OB_MODE_POSE,});
+ bool changed_multi = ED_pose_deselect_all_multi_ex(bases, bases_len, select_mode, ignore_visibility);
+ MEM_freeN(bases);
+ return changed_multi;
}
/* ***************** Selections ********************** */
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 769398e9e0c..8b0bfadcbe7 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -293,8 +293,10 @@ static void pose_slide_refresh(bContext *C, tPoseSlideOp *pso)
}
}
-/** Although this lookup is not ideal, we won't be dealing with a lot of objects at a given time.
- * But if it comes to that we can instead store prev/next frme in the tPChanFCurveLink. */
+/**
+ * Although this lookup is not ideal, we won't be dealing with a lot of objects at a given time.
+ * But if it comes to that we can instead store prev/next frme in the #tPChanFCurveLink.
+ */
static bool pose_frame_range_from_object_get(tPoseSlideOp *pso, Object *ob, float *prevFrameF, float *nextFrameF)
{
for (uint ob_index = 0; ob_index < pso->objects_len; ob_index++) {
@@ -556,54 +558,67 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
/* only if all channels exist, proceed */
if (fcu_w && fcu_x && fcu_y && fcu_z) {
- float quat_prev[4], quat_next[4];
+ float quat_prev[4], quat_prev_orig[4];
+ float quat_next[4], quat_next_orig[4];
+ float quat_curr[4], quat_curr_orig[4];
+ float quat_final[4];
+
+ copy_qt_qt(quat_curr_orig, pchan->quat);
/* get 2 quats */
- quat_prev[0] = evaluate_fcurve(fcu_w, prevFrameF);
- quat_prev[1] = evaluate_fcurve(fcu_x, prevFrameF);
- quat_prev[2] = evaluate_fcurve(fcu_y, prevFrameF);
- quat_prev[3] = evaluate_fcurve(fcu_z, prevFrameF);
+ quat_prev_orig[0] = evaluate_fcurve(fcu_w, prevFrameF);
+ quat_prev_orig[1] = evaluate_fcurve(fcu_x, prevFrameF);
+ quat_prev_orig[2] = evaluate_fcurve(fcu_y, prevFrameF);
+ quat_prev_orig[3] = evaluate_fcurve(fcu_z, prevFrameF);
- quat_next[0] = evaluate_fcurve(fcu_w, nextFrameF);
- quat_next[1] = evaluate_fcurve(fcu_x, nextFrameF);
- quat_next[2] = evaluate_fcurve(fcu_y, nextFrameF);
- quat_next[3] = evaluate_fcurve(fcu_z, nextFrameF);
+ quat_next_orig[0] = evaluate_fcurve(fcu_w, nextFrameF);
+ quat_next_orig[1] = evaluate_fcurve(fcu_x, nextFrameF);
+ quat_next_orig[2] = evaluate_fcurve(fcu_y, nextFrameF);
+ quat_next_orig[3] = evaluate_fcurve(fcu_z, nextFrameF);
+
+ normalize_qt_qt(quat_prev, quat_prev_orig);
+ normalize_qt_qt(quat_next, quat_next_orig);
+ normalize_qt_qt(quat_curr, quat_curr_orig);
/* perform blending */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* just perform the interpol between quat_prev and quat_next using pso->percentage as a guide */
- interp_qt_qtqt(pchan->quat, quat_prev, quat_next, pso->percentage);
+ interp_qt_qtqt(quat_final, quat_prev, quat_next, pso->percentage);
}
else if (pso->mode == POSESLIDE_PUSH) {
- float quat_diff[4], quat_orig[4];
+ float quat_diff[4];
/* calculate the delta transform from the previous to the current */
/* TODO: investigate ways to favour one transform more? */
- sub_qt_qtqt(quat_diff, pchan->quat, quat_prev);
-
- /* make a copy of the original rotation */
- copy_qt_qt(quat_orig, pchan->quat);
+ sub_qt_qtqt(quat_diff, quat_curr, quat_prev);
/* increase the original by the delta transform, by an amount determined by percentage */
- add_qt_qtqt(pchan->quat, quat_orig, quat_diff, pso->percentage);
+ add_qt_qtqt(quat_final, quat_curr, quat_diff, pso->percentage);
+
+ normalize_qt(quat_final);
}
else {
- float quat_interp[4], quat_orig[4];
+ BLI_assert(pso->mode == POSESLIDE_RELAX);
+ float quat_interp[4], quat_final_prev[4];
/* TODO: maybe a sensitivity ctrl on top of this is needed */
int iters = (int)ceil(10.0f * pso->percentage);
+ copy_qt_qt(quat_final, quat_curr);
+
/* perform this blending several times until a satisfactory result is reached */
while (iters-- > 0) {
/* calculate the interpolation between the endpoints */
interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe - pso->prevFrame) / (pso->nextFrame - pso->prevFrame));
- /* make a copy of the original rotation */
- copy_qt_qt(quat_orig, pchan->quat);
+ normalize_qt_qt(quat_final_prev, quat_final);
/* tricky interpolations - blending between original and new */
- interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f / 6.0f);
+ interp_qt_qtqt(quat_final, quat_final_prev, quat_interp, 1.0f / 6.0f);
}
}
+
+ /* Apply final to the pose bone, keeping compatible for similar keyframe positions. */
+ quat_to_compatible_quat(pchan->quat, quat_final, quat_curr_orig);
}
/* free the path now */
@@ -1645,19 +1660,19 @@ void POSE_OT_propagate(wmOperatorType *ot)
{
static const EnumPropertyItem terminate_items[] = {
{POSE_PROPAGATE_SMART_HOLDS, "WHILE_HELD", 0, "While Held",
- "Propagate pose to all keyframes after current frame that don't change (Default behavior)"},
+ "Propagate pose to all keyframes after current frame that don't change (Default behavior)"},
{POSE_PROPAGATE_NEXT_KEY, "NEXT_KEY", 0, "To Next Keyframe",
- "Propagate pose to first keyframe following the current frame only"},
+ "Propagate pose to first keyframe following the current frame only"},
{POSE_PROPAGATE_LAST_KEY, "LAST_KEY", 0, "To Last Keyframe",
- "Propagate pose to the last keyframe only (i.e. making action cyclic)"},
+ "Propagate pose to the last keyframe only (i.e. making action cyclic)"},
{POSE_PROPAGATE_BEFORE_FRAME, "BEFORE_FRAME", 0, "Before Frame",
- "Propagate pose to all keyframes between current frame and 'Frame' property"},
+ "Propagate pose to all keyframes between current frame and 'Frame' property"},
{POSE_PROPAGATE_BEFORE_END, "BEFORE_END", 0, "Before Last Keyframe",
- "Propagate pose to all keyframes from current frame until no more are found"},
+ "Propagate pose to all keyframes from current frame until no more are found"},
{POSE_PROPAGATE_SELECTED_KEYS, "SELECTED_KEYS", 0, "On Selected Keyframes",
- "Propagate pose to all selected keyframes"},
+ "Propagate pose to all selected keyframes"},
{POSE_PROPAGATE_SELECTED_MARKERS, "SELECTED_MARKERS", 0, "On Selected Markers",
- "Propagate pose to all keyframes occurring on frames with Scene Markers after the current frame"},
+ "Propagate pose to all keyframes occurring on frames with Scene Markers after the current frame"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 3c21919a7ac..cbb6d63aefe 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -530,7 +530,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
char str[FILE_MAX];
Main *tmp_bmain = BKE_main_new();
BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer_pose.blend");
- if (!BKE_copybuffer_read(tmp_bmain, str, op->reports)) {
+ if (!BKE_copybuffer_read(tmp_bmain, str, op->reports, FILTER_ID_OB)) {
BKE_report(op->reports, RPT_ERROR, "Copy buffer is empty");
BKE_main_free(tmp_bmain);
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index ad8cff70e27..75a3f13ee84 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -125,7 +125,7 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
/**
* Returns a valid pose armature for this object, else returns NULL.
- **/
+ */
Object *poseAnim_object_get(Object *ob_)
{
Object *ob = BKE_object_pose_armature_get(ob_);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index fe3ac8fc947..10729ecaa5e 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -140,7 +140,9 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
CVKeyIndex *keyIndex;
int a, key_index = 0, nu_index = 0, pt_index = 0, vertex_index = 0;
- if (editnurb->keyindex) return;
+ if (editnurb->keyindex) {
+ return;
+ }
gh = BLI_ghash_ptr_new("editNurb keyIndex");
@@ -346,8 +348,12 @@ static void keyIndex_swap(EditNurb *editnurb, void *a, void *b)
CVKeyIndex *index1 = popCVKeyIndex(editnurb, a);
CVKeyIndex *index2 = popCVKeyIndex(editnurb, b);
- if (index2) BLI_ghash_insert(editnurb->keyindex, a, index2);
- if (index1) BLI_ghash_insert(editnurb->keyindex, b, index1);
+ if (index2) {
+ BLI_ghash_insert(editnurb->keyindex, a, index2);
+ }
+ if (index1) {
+ BLI_ghash_insert(editnurb->keyindex, b, index1);
+ }
}
static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
@@ -363,7 +369,9 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
bezt1 = nu->bezt;
bezt2 = bezt1 + (a - 1);
- if (a & 1) ++a;
+ if (a & 1) {
+ a++;
+ }
a /= 2;
@@ -371,12 +379,16 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
index1 = getCVKeyIndex(editnurb, bezt1);
index2 = getCVKeyIndex(editnurb, bezt2);
- if (index1) index1->switched = !index1->switched;
+ if (index1) {
+ index1->switched = !index1->switched;
+ }
if (bezt1 != bezt2) {
keyIndex_swap(editnurb, bezt1, bezt2);
- if (index2) index2->switched = !index2->switched;
+ if (index2) {
+ index2->switched = !index2->switched;
+ }
}
bezt1++;
@@ -395,10 +407,14 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
index1 = getCVKeyIndex(editnurb, bp1);
index2 = getCVKeyIndex(editnurb, bp2);
- if (index1) index1->switched = !index1->switched;
+ if (index1) {
+ index1->switched = !index1->switched;
+ }
if (bp1 != bp2) {
- if (index2) index2->switched = !index2->switched;
+ if (index2) {
+ index2->switched = !index2->switched;
+ }
keyIndex_swap(editnurb, bp1, bp2);
}
@@ -422,10 +438,14 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
index1 = getCVKeyIndex(editnurb, bp1);
index2 = getCVKeyIndex(editnurb, bp2);
- if (index1) index1->switched = !index1->switched;
+ if (index1) {
+ index1->switched = !index1->switched;
+ }
if (bp1 != bp2) {
- if (index2) index2->switched = !index2->switched;
+ if (index2) {
+ index2->switched = !index2->switched;
+ }
keyIndex_swap(editnurb, bp1, bp2);
}
@@ -506,8 +526,9 @@ static void keyData_switchDirectionNurb(Curve *cu, Nurb *nu)
}
keyIndex_switchDirection(editnurb, nu);
- if (cu->key)
+ if (cu->key) {
switch_keys_direction(cu, nu);
+ }
}
GHash *ED_curve_keyindex_hash_duplicate(GHash *keyindex)
@@ -579,8 +600,12 @@ static void calc_keyHandles(ListBase *nurb, float *key)
while (a--) {
key_to_bezt(fp, bezt, &cur);
- if (nextp) key_to_bezt(nextfp, nextp, &next);
- if (prevp) key_to_bezt(prevfp, prevp, &prev);
+ if (nextp) {
+ key_to_bezt(nextfp, nextp, &next);
+ }
+ if (prevp) {
+ key_to_bezt(prevfp, prevp, &prev);
+ }
BKE_nurb_handle_calc(&cur, prevp ? &prev : NULL, nextp ? &next : NULL, 0, 0);
bezt_to_key(&cur, fp);
@@ -856,13 +881,17 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs)
}
currkey->totelem = totvert;
- if (currkey->data) MEM_freeN(currkey->data);
+ if (currkey->data) {
+ MEM_freeN(currkey->data);
+ }
currkey->data = newkey;
currkey = currkey->next;
}
- if (ofs) MEM_freeN(ofs);
+ if (ofs) {
+ MEM_freeN(ofs);
+ }
}
}
@@ -894,10 +923,12 @@ static void fcurve_path_rename(AnimData *adt, const char *orig_rna_path, char *r
action_groups_remove_channel(adt->action, fcu);
action_groups_add_channel(adt->action, fcu->grp, nfcu);
}
- else if ((adt->action) && (&adt->action->curves == orig_curves))
+ else if ((adt->action) && (&adt->action->curves == orig_curves)) {
BLI_remlink(&adt->action->curves, fcu);
- else
+ }
+ else {
BLI_remlink(&adt->drivers, fcu);
+ }
free_fcurve(fcu);
@@ -908,8 +939,12 @@ static void fcurve_path_rename(AnimData *adt, const char *orig_rna_path, char *r
static void fcurve_remove(AnimData *adt, ListBase *orig_curves, FCurve *fcu)
{
- if (orig_curves == &adt->drivers) BLI_remlink(&adt->drivers, fcu);
- else action_groups_remove_channel(adt->action, fcu);
+ if (orig_curves == &adt->drivers) {
+ BLI_remlink(&adt->drivers, fcu);
+ }
+ else {
+ action_groups_remove_channel(adt->action, fcu);
+ }
free_fcurve(fcu);
}
@@ -989,16 +1024,21 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
if (STREQLEN(fcu->rna_path, "splines", 7)) {
const char *ch = strchr(fcu->rna_path, '.');
- if (ch && (STREQLEN(ch, ".bezier_points", 14) || STREQLEN(ch, ".points", 7)))
+ if (ch && (STREQLEN(ch, ".bezier_points", 14) || STREQLEN(ch, ".points", 7))) {
fcurve_remove(adt, orig_curves, fcu);
+ }
}
}
for (nu = editnurb->nurbs.first, nu_index = 0; nu != NULL; nu = nu->next, nu_index++) {
keyIndex = NULL;
if (nu->pntsu) {
- if (nu->bezt) keyIndex = getCVKeyIndex(editnurb, &nu->bezt[0]);
- else keyIndex = getCVKeyIndex(editnurb, &nu->bp[0]);
+ if (nu->bezt) {
+ keyIndex = getCVKeyIndex(editnurb, &nu->bezt[0]);
+ }
+ else {
+ keyIndex = getCVKeyIndex(editnurb, &nu->bp[0]);
+ }
}
if (keyIndex) {
@@ -1013,8 +1053,12 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
for (fcu = orig_curves->first; fcu; fcu = next) {
next = fcu->next;
- if (STREQLEN(fcu->rna_path, "splines", 7)) fcurve_remove(adt, orig_curves, fcu);
- else BLI_addtail(&curves, fcu);
+ if (STREQLEN(fcu->rna_path, "splines", 7)) {
+ fcurve_remove(adt, orig_curves, fcu);
+ }
+ else {
+ BLI_addtail(&curves, fcu);
+ }
}
*orig_curves = curves;
@@ -1026,10 +1070,13 @@ int ED_curve_updateAnimPaths(Main *bmain, Curve *cu)
AnimData *adt = BKE_animdata_from_id(&cu->id);
EditNurb *editnurb = cu->editnurb;
- if (!editnurb->keyindex)
+ if (!editnurb->keyindex) {
return 0;
+ }
- if (!curve_is_animated(cu)) return 0;
+ if (!curve_is_animated(cu)) {
+ return 0;
+ }
if (adt->action != NULL) {
curve_rename_fcurves(cu, &adt->action->curves);
@@ -1199,7 +1246,9 @@ void ED_curve_editnurb_load(Main *bmain, Object *obedit)
{
ListBase *editnurb = object_editcurve_get(obedit);
- if (obedit == NULL) return;
+ if (obedit == NULL) {
+ return;
+ }
if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
Curve *cu = obedit->data;
@@ -1509,11 +1558,17 @@ static bool isNurbselUV(
for (b = 0; b < nu->pntsv; b++) {
sel = 0;
for (a = 0; a < nu->pntsu; a++, bp++) {
- if (bp->f1 & flag) sel++;
+ if (bp->f1 & flag) {
+ sel++;
+ }
}
if (sel == nu->pntsu) {
- if (*r_u == -1) *r_u = b;
- else return 0;
+ if (*r_u == -1) {
+ *r_u = b;
+ }
+ else {
+ return 0;
+ }
}
else if (sel > 1) {
return 0; /* because sel == 1 is still ok */
@@ -1524,19 +1579,29 @@ static bool isNurbselUV(
sel = 0;
bp = &nu->bp[a];
for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) {
- if (bp->f1 & flag) sel++;
+ if (bp->f1 & flag) {
+ sel++;
+ }
}
if (sel == nu->pntsv) {
- if (*r_v == -1) *r_v = a;
- else return 0;
+ if (*r_v == -1) {
+ *r_v = a;
+ }
+ else {
+ return 0;
+ }
}
else if (sel > 1) {
return 0;
}
}
- if (*r_u == -1 && *r_v > -1) return 1;
- if (*r_v == -1 && *r_u > -1) return 1;
+ if (*r_u == -1 && *r_v > -1) {
+ return 1;
+ }
+ if (*r_v == -1 && *r_u > -1) {
+ return 1;
+ }
return 0;
}
@@ -1551,7 +1616,9 @@ static bool isNurbselU(Nurb *nu, int *v, int flag)
for (b = 0, bp = nu->bp; b < nu->pntsv; b++) {
sel = 0;
for (a = 0; a < nu->pntsu; a++, bp++) {
- if (bp->f1 & flag) sel++;
+ if (bp->f1 & flag) {
+ sel++;
+ }
}
if (sel == nu->pntsu) {
(*v)++;
@@ -1577,7 +1644,9 @@ static bool isNurbselV(Nurb *nu, int *u, int flag)
bp = &nu->bp[a];
sel = 0;
for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) {
- if (bp->f1 & flag) sel++;
+ if (bp->f1 & flag) {
+ sel++;
+ }
}
if (sel == nu->pntsv) {
(*u)++;
@@ -1628,9 +1697,9 @@ void ed_editnurb_translate_flag(ListBase *editnurb, short flag, const float vec[
a = nu->pntsu;
bezt = nu->bezt;
while (a--) {
- if (bezt->f1 & flag) add_v3_v3(bezt->vec[0], vec);
- if (bezt->f2 & flag) add_v3_v3(bezt->vec[1], vec);
- if (bezt->f3 & flag) add_v3_v3(bezt->vec[2], vec);
+ if (bezt->f1 & flag) { add_v3_v3(bezt->vec[0], vec); }
+ if (bezt->f2 & flag) { add_v3_v3(bezt->vec[1], vec); }
+ if (bezt->f3 & flag) { add_v3_v3(bezt->vec[2], vec); }
bezt++;
}
}
@@ -1638,7 +1707,9 @@ void ed_editnurb_translate_flag(ListBase *editnurb, short flag, const float vec[
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
while (a--) {
- if (bp->f1 & flag) add_v3_v3(bp->vec, vec);
+ if (bp->f1 & flag) {
+ add_v3_v3(bp->vec, vec);
+ }
bp++;
}
}
@@ -1753,7 +1824,9 @@ static void ed_surf_delete_selected(Object *obedit)
nu->pntsv = 1;
SWAP(short, nu->orderu, nu->orderv);
BKE_nurb_order_clamp_u(nu);
- if (nu->knotsv) MEM_freeN(nu->knotsv);
+ if (nu->knotsv) {
+ MEM_freeN(nu->knotsv);
+ }
nu->knotsv = NULL;
}
else {
@@ -1797,8 +1870,9 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
bezt++;
}
if (a == 0) {
- if (cu->actnu == nuindex)
+ if (cu->actnu == nuindex) {
cu->actnu = CU_ACT_NONE;
+ }
BLI_remlink(nubase, nu);
keyIndex_delNurb(editnurb, nu);
@@ -1821,8 +1895,9 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
bp++;
}
if (a == 0) {
- if (cu->actnu == nuindex)
+ if (cu->actnu == nuindex) {
cu->actnu = CU_ACT_NONE;
+ }
BLI_remlink(nubase, nu);
keyIndex_delNurb(editnurb, nu);
@@ -2058,9 +2133,13 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
enda = -1;
starta = a;
while ((bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag)) {
- if (!split) select_beztriple(bezt, DESELECT, flag, HIDDEN);
+ if (!split) {
+ select_beztriple(bezt, DESELECT, flag, HIDDEN);
+ }
enda = a;
- if (a >= nu->pntsu - 1) break;
+ if (a >= nu->pntsu - 1) {
+ break;
+ }
a++;
bezt++;
}
@@ -2071,7 +2150,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
cyclicu = newu;
}
else {
- if (enda == nu->pntsu - 1) newu += cyclicu;
+ if (enda == nu->pntsu - 1) {
+ newu += cyclicu;
+ }
if (i == cu->actnu) {
calc_duplicate_actvert(
editnurb, newnurb, cu,
@@ -2090,7 +2171,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
cyclicu = 0;
}
- if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
+ if (newu != nu->pntsu) {
+ newnu->flagu &= ~CU_NURB_CYCLIC;
+ }
for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) {
select_beztriple(bezt1, SELECT, flag, HIDDEN);
@@ -2124,9 +2207,13 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
enda = -1;
starta = a;
while (bp->f1 & flag) {
- if (!split) select_bpoint(bp, DESELECT, flag, HIDDEN);
+ if (!split) {
+ select_bpoint(bp, DESELECT, flag, HIDDEN);
+ }
enda = a;
- if (a >= nu->pntsu - 1) break;
+ if (a >= nu->pntsu - 1) {
+ break;
+ }
a++;
bp++;
}
@@ -2137,7 +2224,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
cyclicu = newu;
}
else {
- if (enda == nu->pntsu - 1) newu += cyclicu;
+ if (enda == nu->pntsu - 1) {
+ newu += cyclicu;
+ }
if (i == cu->actnu) {
calc_duplicate_actvert(
editnurb, newnurb, cu,
@@ -2156,7 +2245,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
cyclicu = 0;
}
- if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
+ if (newu != nu->pntsu) {
+ newnu->flagu &= ~CU_NURB_CYCLIC;
+ }
for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) {
select_bpoint(bp1, SELECT, flag, HIDDEN);
@@ -2192,7 +2283,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
bp = nu->bp;
for (a = 0; a < nu->pntsv; a++) {
for (b = 0; b < nu->pntsu; b++, bp++) {
- if (bp->f1 & flag) usel[b]++;
+ if (bp->f1 & flag) {
+ usel[b]++;
+ }
}
}
newu = 0;
@@ -2214,8 +2307,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
if ((newu == 0 || newv == 0) ||
(split && !isNurbselU(nu, &newv, SELECT) && !isNurbselV(nu, &newu, SELECT)))
{
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Can't duplicate Nurb\n");
+ }
}
else {
for (a = 0, bp1 = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp1++) {
@@ -2230,7 +2324,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
if (bp3->f1 & flag) {
/* flag as seen so skipped on future iterations */
bp3->f1 |= SURF_SEEN;
- if (newu == 1) newv++;
+ if (newu == 1) {
+ newv++;
+ }
}
else {
break;
@@ -2247,9 +2343,15 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
/* ignore single points */
if (a == 0) {
/* check if need to save cyclic selection and continue if so */
- if (newu == nu->pntsu && (nu->flagv & CU_NURB_CYCLIC)) cyclicv = newv;
- if (newv == nu->pntsv && (nu->flagu & CU_NURB_CYCLIC)) cyclicu = newu;
- if (cyclicu != 0 || cyclicv != 0) continue;
+ if (newu == nu->pntsu && (nu->flagv & CU_NURB_CYCLIC)) {
+ cyclicv = newv;
+ }
+ if (newv == nu->pntsv && (nu->flagu & CU_NURB_CYCLIC)) {
+ cyclicu = newu;
+ }
+ if (cyclicu != 0 || cyclicv != 0) {
+ continue;
+ }
}
if (a + newu == nu->pntsu && cyclicu != 0) {
@@ -2320,8 +2422,12 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
}
BLI_addtail(newnurb, newnu);
- if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
- if (newv != nu->pntsv) newnu->flagv &= ~CU_NURB_CYCLIC;
+ if (newu != nu->pntsu) {
+ newnu->flagu &= ~CU_NURB_CYCLIC;
+ }
+ if (newv != nu->pntsv) {
+ newnu->flagv &= ~CU_NURB_CYCLIC;
+ }
}
}
@@ -2350,13 +2456,19 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
}
BLI_addtail(newnurb, newnu);
- if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
- if (newv != nu->pntsv) newnu->flagv &= ~CU_NURB_CYCLIC;
+ if (newu != nu->pntsu) {
+ newnu->flagu &= ~CU_NURB_CYCLIC;
+ }
+ if (newv != nu->pntsv) {
+ newnu->flagv &= ~CU_NURB_CYCLIC;
+ }
}
for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) {
bp1->f1 &= ~SURF_SEEN;
- if (!split) select_bpoint(bp1, DESELECT, flag, HIDDEN);
+ if (!split) {
+ select_bpoint(bp1, DESELECT, flag, HIDDEN);
+ }
}
}
}
@@ -2463,14 +2575,16 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op)
for (nu = editnurb->first; nu; nu = nu->next) {
if (nu->bezt) {
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->weight = weight;
+ }
}
}
else if (nu->bp) {
for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
- if (bp->f1 & SELECT)
+ if (bp->f1 & SELECT) {
bp->weight = weight;
+ }
}
}
}
@@ -2515,14 +2629,16 @@ static int set_radius_exec(bContext *C, wmOperator *op)
for (nu = editnurb->first; nu; nu = nu->next) {
if (nu->bezt) {
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->radius = radius;
+ }
}
}
else if (nu->bp) {
for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
- if (bp->f1 & SELECT)
+ if (bp->f1 & SELECT) {
bp->radius = radius;
+ }
}
}
}
@@ -2756,12 +2872,12 @@ static void curve_smooth_value(ListBase *editnurb,
if (start_sel == end_sel) {
/* simple, only 1 point selected */
- if (start_sel > 0) start_rad = BEZT_VALUE(&nu->bezt[start_sel - 1]);
- if (end_sel != -1 && end_sel < nu->pntsu) end_rad = BEZT_VALUE(&nu->bezt[start_sel + 1]);
+ if (start_sel > 0) { start_rad = BEZT_VALUE(&nu->bezt[start_sel - 1]); }
+ if (end_sel != -1 && end_sel < nu->pntsu) { end_rad = BEZT_VALUE(&nu->bezt[start_sel + 1]); }
- if (start_rad != FLT_MAX && end_rad >= FLT_MAX) BEZT_VALUE(&nu->bezt[start_sel]) = (start_rad + end_rad) / 2.0f;
- else if (start_rad != FLT_MAX) BEZT_VALUE(&nu->bezt[start_sel]) = start_rad;
- else if (end_rad != FLT_MAX) BEZT_VALUE(&nu->bezt[start_sel]) = end_rad;
+ if (start_rad != FLT_MAX && end_rad >= FLT_MAX) { BEZT_VALUE(&nu->bezt[start_sel]) = (start_rad + end_rad) / 2.0f; }
+ else if (start_rad != FLT_MAX) { BEZT_VALUE(&nu->bezt[start_sel]) = start_rad; }
+ else if (end_rad != FLT_MAX) { BEZT_VALUE(&nu->bezt[start_sel]) = end_rad; }
}
else {
/* if endpoints selected, then use them */
@@ -2827,12 +2943,12 @@ static void curve_smooth_value(ListBase *editnurb,
if (start_sel == end_sel) {
/* simple, only 1 point selected */
- if (start_sel > 0) start_rad = BP_VALUE(&nu->bp[start_sel - 1]);
- if (end_sel != -1 && end_sel < nu->pntsu) end_rad = BP_VALUE(&nu->bp[start_sel + 1]);
+ if (start_sel > 0) { start_rad = BP_VALUE(&nu->bp[start_sel - 1]); }
+ if (end_sel != -1 && end_sel < nu->pntsu) { end_rad = BP_VALUE(&nu->bp[start_sel + 1]); }
- if (start_rad != FLT_MAX && end_rad != FLT_MAX) BP_VALUE(&nu->bp[start_sel]) = (start_rad + end_rad) / 2;
- else if (start_rad != FLT_MAX) BP_VALUE(&nu->bp[start_sel]) = start_rad;
- else if (end_rad != FLT_MAX) BP_VALUE(&nu->bp[start_sel]) = end_rad;
+ if (start_rad != FLT_MAX && end_rad != FLT_MAX) { BP_VALUE(&nu->bp[start_sel]) = (start_rad + end_rad) / 2; }
+ else if (start_rad != FLT_MAX) { BP_VALUE(&nu->bp[start_sel]) = start_rad; }
+ else if (end_rad != FLT_MAX) { BP_VALUE(&nu->bp[start_sel]) = end_rad; }
}
else {
/* if endpoints selected, then use them */
@@ -2988,10 +3104,14 @@ static int hide_exec(bContext *C, wmOperator *op)
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
bezt->hide = 1;
}
- if (bezt->hide) sel++;
+ if (bezt->hide) {
+ sel++;
+ }
bezt++;
}
- if (sel == nu->pntsu) nu->hide = 1;
+ if (sel == nu->pntsu) {
+ nu->hide = 1;
+ }
}
else {
bp = nu->bp;
@@ -3006,14 +3126,18 @@ static int hide_exec(bContext *C, wmOperator *op)
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
bp->hide = 1;
}
- if (bp->hide) sel++;
+ if (bp->hide) {
+ sel++;
+ }
bp++;
}
- if (sel == nu->pntsu * nu->pntsv) nu->hide = 1;
+ if (sel == nu->pntsu * nu->pntsv) {
+ nu->hide = 1;
+ }
}
}
- DEG_id_tag_update(obedit->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
+ DEG_id_tag_update(obedit->data, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
}
@@ -3409,7 +3533,9 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
/* subdivide in v direction? */
sel = 0;
for (a = 0; a < nu->pntsv - 1; a++) {
- if (vsel[a] == nu->pntsu && vsel[a + 1] == nu->pntsu) sel += number_cuts;
+ if (vsel[a] == nu->pntsu && vsel[a + 1] == nu->pntsu) {
+ sel += number_cuts;
+ }
}
if (sel) { /* V ! */
@@ -3454,7 +3580,9 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
/* or in u direction? */
sel = 0;
for (a = 0; a < nu->pntsu - 1; a++) {
- if (usel[a] == nu->pntsv && usel[a + 1] == nu->pntsv) sel += number_cuts;
+ if (usel[a] == nu->pntsv && usel[a + 1] == nu->pntsv) {
+ sel += number_cuts;
+ }
}
if (sel) { /* U ! */
@@ -3578,8 +3706,12 @@ static void ED_curve_pick_vert__doClosest(void *userData, Nurb *nu, BPoint *bp,
}
dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
- if ((flag & SELECT) == data->select) dist_test += 5.0f;
- if (bezt && beztindex == 1) dist_test += 3.0f; /* middle points get a small disadvantage */
+ if ((flag & SELECT) == data->select) {
+ dist_test += 5.0f;
+ }
+ if (bezt && beztindex == 1) {
+ dist_test += 3.0f; /* middle points get a small disadvantage */
+ }
if (dist_test < data->dist) {
data->dist = dist_test;
@@ -3897,7 +4029,9 @@ static void switchdirection_knots(float *base, int tot)
float *fp1, *fp2, *tempf;
int a;
- if (base == NULL || tot == 0) return;
+ if (base == NULL || tot == 0) {
+ return;
+ }
/* reverse knots */
a = tot;
@@ -4076,7 +4210,9 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
else {
/* For 2D curves blender uses (orderv = 0). It doesn't make any sense mathematically. */
/* but after rotating (orderu = 0) will be confusing. */
- if (nu1->orderv == 0) nu1->orderv = 1;
+ if (nu1->orderv == 0) {
+ nu1->orderv = 1;
+ }
rotate_direction_nurb(nu1);
if (is_u_selected(nu1, nu1->pntsu - 1)) {
@@ -4094,7 +4230,9 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
}
else {
/* rotate again, now its OK! */
- if (nu1->pntsv != 1) rotate_direction_nurb(nu1);
+ if (nu1->pntsv != 1) {
+ rotate_direction_nurb(nu1);
+ }
return true;
}
}
@@ -4106,7 +4244,9 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
/* pass */
}
else {
- if (nu2->orderv == 0) nu2->orderv = 1;
+ if (nu2->orderv == 0) {
+ nu2->orderv = 1;
+ }
rotate_direction_nurb(nu2);
if (is_u_selected(nu2, 0)) {
/* pass */
@@ -4123,8 +4263,12 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
}
else {
/* rotate again, now its OK! */
- if (nu1->pntsu == 1) rotate_direction_nurb(nu1);
- if (nu2->pntsv != 1) rotate_direction_nurb(nu2);
+ if (nu1->pntsu == 1) {
+ rotate_direction_nurb(nu1);
+ }
+ if (nu2->pntsv != 1) {
+ rotate_direction_nurb(nu2);
+ }
return true;
}
}
@@ -4157,8 +4301,12 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
/* merge */
origu = nu1->pntsu;
nu1->pntsu += nu2->pntsu;
- if (nu1->orderu < 3 && nu1->orderu < nu1->pntsu) nu1->orderu++;
- if (nu1->orderv < 3 && nu1->orderv < nu1->pntsv) nu1->orderv++;
+ if (nu1->orderu < 3 && nu1->orderu < nu1->pntsu) {
+ nu1->orderu++;
+ }
+ if (nu1->orderv < 3 && nu1->orderv < nu1->pntsv) {
+ nu1->orderv++;
+ }
temp = nu1->bp;
nu1->bp = MEM_mallocN(nu1->pntsu * nu1->pntsv * sizeof(BPoint), "mergeBP");
@@ -4168,8 +4316,12 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
for (v = 0; v < nu1->pntsv; v++) {
/* switch direction? */
- if (len1 < len2) bp2 = &nu2->bp[v * nu2->pntsu];
- else bp2 = &nu2->bp[(nu1->pntsv - v - 1) * nu2->pntsu];
+ if (len1 < len2) {
+ bp2 = &nu2->bp[v * nu2->pntsu];
+ }
+ else {
+ bp2 = &nu2->bp[(nu1->pntsv - v - 1) * nu2->pntsu];
+ }
for (u = 0; u < nu1->pntsu; u++, bp++) {
if (u < origu) {
@@ -4291,8 +4443,12 @@ static int make_segment_exec(bContext *C, wmOperator *op)
bool ok = false;
/* first decide if this is a surface merge! */
- if (obedit->type == OB_SURF) nu = nubase->first;
- else nu = NULL;
+ if (obedit->type == OB_SURF) {
+ nu = nubase->first;
+ }
+ else {
+ nu = NULL;
+ }
while (nu) {
const int nu_select_num = ED_curve_nurb_select_count(v3d, nu);
@@ -4341,8 +4497,9 @@ static int make_segment_exec(bContext *C, wmOperator *op)
/* find both nurbs and points, nu1 will be put behind nu2 */
for (nu = nubase->first; nu; nu = nu->next) {
- if (nu->pntsu == 1)
+ if (nu->pntsu == 1) {
nu->flagu &= ~CU_NURB_CYCLIC;
+ }
if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic */
if (nu->type == CU_BEZIER) {
@@ -4603,8 +4760,12 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
}
else {
- if (hand == 0) bezt->f1 |= SELECT;
- else bezt->f3 |= SELECT;
+ if (hand == 0) {
+ bezt->f1 |= SELECT;
+ }
+ else {
+ bezt->f3 |= SELECT;
+ }
}
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
}
@@ -4617,7 +4778,9 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
if (bezt) {
if (hand == 1) {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
- if (bezt == vert) cu->actvert = CU_ACT_NONE;
+ if (bezt == vert) {
+ cu->actvert = CU_ACT_NONE;
+ }
}
else if (hand == 0) {
bezt->f1 &= ~SELECT;
@@ -4628,7 +4791,9 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
}
else {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
- if (bp == vert) cu->actvert = CU_ACT_NONE;
+ if (bp == vert) {
+ cu->actvert = CU_ACT_NONE;
+ }
}
}
else if (toggle) {
@@ -4636,7 +4801,9 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
if (hand == 1) {
if (bezt->f2 & SELECT) {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
- if (bezt == vert) cu->actvert = CU_ACT_NONE;
+ if (bezt == vert) {
+ cu->actvert = CU_ACT_NONE;
+ }
}
else {
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
@@ -4653,7 +4820,9 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
else {
if (bp->f1 & SELECT) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
- if (bp == vert) cu->actvert = CU_ACT_NONE;
+ if (bp == vert) {
+ cu->actvert = CU_ACT_NONE;
+ }
}
else {
select_bpoint(bp, SELECT, SELECT, HIDDEN);
@@ -4670,8 +4839,12 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
}
else {
- if (hand == 0) bezt->f1 |= SELECT;
- else bezt->f3 |= SELECT;
+ if (hand == 0) {
+ bezt->f1 |= SELECT;
+ }
+ else {
+ bezt->f3 |= SELECT;
+ }
}
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
}
@@ -4748,8 +4921,9 @@ bool ed_editnurb_spin(float viewmat[4][4], View3D *v3d, Object *obedit, const fl
for (a = 0; a < 7; a++) {
ok = ed_editnurb_extrude_flag(cu->editnurb, SELECT);
- if (ok == false)
+ if (ok == false) {
return changed;
+ }
changed = true;
@@ -4790,10 +4964,12 @@ static int spin_exec(bContext *C, wmOperator *op)
RNA_float_get_array(op->ptr, "center", cent);
RNA_float_get_array(op->ptr, "axis", axis);
- if (rv3d)
+ if (rv3d) {
copy_m4_m4(viewmat, rv3d->viewmat);
- else
+ }
+ else {
unit_m4(viewmat);
+ }
uint objects_len;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
@@ -4835,8 +5011,9 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
float axis[3] = {0.0f, 0.0f, 1.0f};
- if (rv3d)
+ if (rv3d) {
copy_v3_v3(axis, rv3d->viewinv[2]);
+ }
RNA_float_set_array(op->ptr, "center", scene->cursor.location);
RNA_float_set_array(op->ptr, "axis", axis);
@@ -5718,8 +5895,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
if (!BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
enda = a;
- if (starta == -1) starta = a;
- if (a < nu->pntsu - 1) continue;
+ if (starta == -1) {
+ starta = a;
+ }
+ if (a < nu->pntsu - 1) {
+ continue;
+ }
}
else if (a < nu->pntsu - 1 && !BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt + 1)) {
/* if just single selected point then continue */
@@ -5730,7 +5911,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
/* got selected segment, now check where and copy */
if (starta <= 1 && a == nu->pntsu - 1) {
/* copying all points in spline */
- if (starta == 1 && enda != a) nu->flagu &= ~CU_NURB_CYCLIC;
+ if (starta == 1 && enda != a) {
+ nu->flagu &= ~CU_NURB_CYCLIC;
+ }
starta = 0;
enda = a;
@@ -5755,8 +5938,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
cut = 1;
}
else {
- if (nu->flagu & CU_NURB_CYCLIC) cyclicut = cut;
- else nu1 = BKE_nurb_copy(nu, cut, 1);
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ cyclicut = cut;
+ }
+ else {
+ nu1 = BKE_nurb_copy(nu, cut, 1);
+ }
}
}
else if (enda == nu->pntsu - 1) {
@@ -5796,7 +5983,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
ED_curve_beztcpy(editnurb, nu1->bezt, &nu->bezt[starta], cut);
BLI_addtail(&newnurb, nu1);
- if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC;
+ if (starta != 0 || enda != nu->pntsu - 1) {
+ nu1->flagu &= ~CU_NURB_CYCLIC;
+ }
nu1 = NULL;
}
starta = enda = -1;
@@ -5835,8 +6024,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
for (a = 0, bp = nu->bp; a < nu->pntsu; a++, bp++) {
if (!(bp->f1 & SELECT)) {
enda = a;
- if (starta == -1) starta = a;
- if (a < nu->pntsu - 1) continue;
+ if (starta == -1) {
+ starta = a;
+ }
+ if (a < nu->pntsu - 1) {
+ continue;
+ }
}
else if (a < nu->pntsu - 1 && !((bp + 1)->f1 & SELECT)) {
/* if just single selected point then continue */
@@ -5847,7 +6040,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
/* got selected segment, now check where and copy */
if (starta <= 1 && a == nu->pntsu - 1) {
/* copying all points in spline */
- if (starta == 1 && enda != a) nu->flagu &= ~CU_NURB_CYCLIC;
+ if (starta == 1 && enda != a) {
+ nu->flagu &= ~CU_NURB_CYCLIC;
+ }
starta = 0;
enda = a;
@@ -5871,8 +6066,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
cut = 1;
}
else {
- if (nu->flagu & CU_NURB_CYCLIC) cyclicut = cut;
- else nu1 = BKE_nurb_copy(nu, cut, nu->pntsv);
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ cyclicut = cut;
+ }
+ else {
+ nu1 = BKE_nurb_copy(nu, cut, nu->pntsv);
+ }
}
}
else if (enda == nu->pntsu - 1) {
@@ -5914,7 +6113,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
}
BLI_addtail(&newnurb, nu1);
- if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC;
+ if (starta != 0 || enda != nu->pntsu - 1) {
+ nu1->flagu &= ~CU_NURB_CYCLIC;
+ }
nu1 = NULL;
}
starta = enda = -1;
@@ -5950,8 +6151,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
for (a = 0, bp = nu->bp; a < nu->pntsv; a++, bp += nu->pntsu) {
if (!(bp->f1 & SELECT)) {
enda = a;
- if (starta == -1) starta = a;
- if (a < nu->pntsv - 1) continue;
+ if (starta == -1) {
+ starta = a;
+ }
+ if (a < nu->pntsv - 1) {
+ continue;
+ }
}
else if (a < nu->pntsv - 1 && !((bp + nu->pntsu)->f1 & SELECT)) {
/* if just single selected point then continue */
@@ -5962,7 +6167,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
/* got selected segment, now check where and copy */
if (starta <= 1 && a == nu->pntsv - 1) {
/* copying all points in spline */
- if (starta == 1 && enda != a) nu->flagv &= ~CU_NURB_CYCLIC;
+ if (starta == 1 && enda != a) {
+ nu->flagv &= ~CU_NURB_CYCLIC;
+ }
starta = 0;
enda = a;
@@ -5984,8 +6191,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
cut = 1;
}
else {
- if (nu->flagv & CU_NURB_CYCLIC) cyclicut = cut;
- else nu1 = BKE_nurb_copy(nu, nu->pntsu, cut);
+ if (nu->flagv & CU_NURB_CYCLIC) {
+ cyclicut = cut;
+ }
+ else {
+ nu1 = BKE_nurb_copy(nu, nu->pntsu, cut);
+ }
}
}
else if (enda == nu->pntsv - 1) {
@@ -6022,7 +6233,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
ED_curve_bpcpy(editnurb, nu1->bp, &nu->bp[starta * nu->pntsu], cut * nu->pntsu);
BLI_addtail(&newnurb, nu1);
- if (starta != 0 || enda != nu->pntsv - 1) nu1->flagv &= ~CU_NURB_CYCLIC;
+ if (starta != 0 || enda != nu->pntsv - 1) {
+ nu1->flagv &= ~CU_NURB_CYCLIC;
+ }
nu1 = NULL;
}
starta = enda = -1;
@@ -6159,8 +6372,9 @@ static const EnumPropertyItem *rna_curve_delete_type_itemf(
EnumPropertyItem *item = NULL;
int totitem = 0;
- if (!C) /* needed for docs and i18n tools */
+ if (!C) { /* needed for docs and i18n tools */
return curve_delete_type_items;
+ }
RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_VERTEX);
RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_SEGMENT);
@@ -6417,13 +6631,18 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
Nurb *nu;
int clear = (STREQ(op->idname, "CURVE_OT_shade_flat"));
- if (obedit->type != OB_CURVE)
+ if (obedit->type != OB_CURVE) {
return OPERATOR_CANCELLED;
+ }
for (nu = editnurb->first; nu; nu = nu->next) {
if (ED_curve_nurb_select_check(v3d, nu)) {
- if (!clear) nu->flag |= CU_SMOOTH;
- else nu->flag &= ~CU_SMOOTH;
+ if (!clear) {
+ nu->flag |= CU_SMOOTH;
+ }
+ else {
+ nu->flag &= ~CU_SMOOTH;
+ }
}
}
@@ -6595,7 +6814,9 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
- if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) bezt->tilt = 0.0;
+ if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
+ bezt->tilt = 0.0;
+ }
bezt++;
}
}
@@ -6603,7 +6824,9 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
bp = nu->bp;
a = nu->pntsu * nu->pntsv;
while (a--) {
- if (bp->f1 & SELECT) bp->tilt = 0.0f;
+ if (bp->f1 & SELECT) {
+ bp->tilt = 0.0f;
+ }
bp++;
}
}
@@ -6648,8 +6871,9 @@ bool ED_curve_active_center(Curve *cu, float center[3])
Nurb *nu = NULL;
void *vert = NULL;
- if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert))
+ if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) {
return false;
+ }
if (nu->type == CU_BEZIER) {
BezTriple *bezt = (BezTriple *)vert;
@@ -6695,9 +6919,15 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
size[2] = (max[2] - min[2]) / 2.0f;
for (a = 0; a < 3; a++) {
- if (size[a] == 0.0f) size[a] = 1.0f;
- else if (size[a] > 0.0f && size[a] < 0.00001f) size[a] = 0.00001f;
- else if (size[a] < 0.0f && size[a] > -0.00001f) size[a] = -0.00001f;
+ if (size[a] == 0.0f) {
+ size[a] = 1.0f;
+ }
+ else if (size[a] > 0.0f && size[a] < 0.00001f) {
+ size[a] = 0.00001f;
+ }
+ else if (size[a] < 0.0f && size[a] > -0.00001f) {
+ size[a] = -0.00001f;
+ }
}
copy_v3_v3(curve->loc, loc);
diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c
index 0e110edf35f..0b6d4f6585a 100644
--- a/source/blender/editors/curve/editcurve_add.c
+++ b/source/blender/editors/curve/editcurve_add.c
@@ -148,7 +148,9 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
bezt->vec[0][1] += -0.5f * grid;
bezt->vec[2][0] += -0.5f * grid;
bezt->vec[2][1] += 0.5f * grid;
- for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
+ for (a = 0; a < 3; a++) {
+ mul_m4_v3(mat, bezt->vec[a]);
+ }
bezt++;
bezt->h1 = bezt->h2 = HD_ALIGN;
@@ -161,7 +163,9 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
bezt->vec[1][1] = 0;
bezt->vec[2][0] = grid * 2;
bezt->vec[2][1] = 0;
- for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
+ for (a = 0; a < 3; a++) {
+ mul_m4_v3(mat, bezt->vec[a]);
+ }
BKE_nurb_handles_calc(nu);
}
@@ -191,7 +195,9 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
bp->vec[0] += 1.5f * grid;
bp = nu->bp;
- for (a = 0; a < 4; a++, bp++) mul_m4_v3(mat, bp->vec);
+ for (a = 0; a < 4; a++, bp++) {
+ mul_m4_v3(mat, bp->vec);
+ }
if (cutype == CU_NURBS) {
nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */
@@ -225,7 +231,9 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
bp->vec[0] += 2.0f * grid;
bp = nu->bp;
- for (a = 0; a < 5; a++, bp++) mul_m4_v3(mat, bp->vec);
+ for (a = 0; a < 5; a++, bp++) {
+ mul_m4_v3(mat, bp->vec);
+ }
if (cutype == CU_NURBS) {
nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */
@@ -245,28 +253,36 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
bezt->h1 = bezt->h2 = HD_AUTO;
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
bezt->vec[1][0] += -grid;
- for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
+ for (a = 0; a < 3; a++) {
+ mul_m4_v3(mat, bezt->vec[a]);
+ }
bezt->radius = bezt->weight = 1.0;
bezt++;
bezt->h1 = bezt->h2 = HD_AUTO;
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
bezt->vec[1][1] += grid;
- for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
+ for (a = 0; a < 3; a++) {
+ mul_m4_v3(mat, bezt->vec[a]);
+ }
bezt->radius = bezt->weight = 1.0;
bezt++;
bezt->h1 = bezt->h2 = HD_AUTO;
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
bezt->vec[1][0] += grid;
- for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
+ for (a = 0; a < 3; a++) {
+ mul_m4_v3(mat, bezt->vec[a]);
+ }
bezt->radius = bezt->weight = 1.0;
bezt++;
bezt->h1 = bezt->h2 = HD_AUTO;
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
bezt->vec[1][1] += -grid;
- for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
+ for (a = 0; a < 3; a++) {
+ mul_m4_v3(mat, bezt->vec[a]);
+ }
bezt->radius = bezt->weight = 1.0;
BKE_nurb_handles_calc(nu);
@@ -289,8 +305,12 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
bp->vec[0] += 0.25f * nurbcircle[a][0] * grid - 0.75f * grid;
bp->vec[2] += 0.25f * nurbcircle[a][1] * grid;
}
- if (a & 1) bp->vec[3] = 0.25 * M_SQRT2;
- else bp->vec[3] = 1.0;
+ if (a & 1) {
+ bp->vec[3] = 0.25 * M_SQRT2;
+ }
+ else {
+ bp->vec[3] = 1.0;
+ }
mul_m4_v3(mat, bp->vec);
bp->radius = bp->weight = 1.0;
@@ -378,8 +398,12 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
bp->f1 = SELECT;
bp->vec[0] += nurbcircle[a][0] * grid;
bp->vec[2] += nurbcircle[a][1] * grid;
- if (a & 1) bp->vec[3] = 0.5 * M_SQRT2;
- else bp->vec[3] = 1.0;
+ if (a & 1) {
+ bp->vec[3] = 0.5 * M_SQRT2;
+ }
+ else {
+ bp->vec[3] = 1.0;
+ }
mul_m4_v3(mat, bp->vec);
bp++;
}
@@ -388,12 +412,15 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
BLI_addtail(editnurb, nu); /* temporal for spin */
- if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0)
+ if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) {
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, tmp_cent);
- else if ((U.flag & USER_ADD_VIEWALIGNED))
+ }
+ else if ((U.flag & USER_ADD_VIEWALIGNED)) {
ed_editnurb_spin(viewmat, NULL, obedit, zvec, mat[3]);
- else
+ }
+ else {
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, mat[3]);
+ }
BKE_nurb_knot_calc_v(nu);
@@ -420,12 +447,15 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
BLI_addtail(editnurb, nu); /* temporal for spin */
/* same as above */
- if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0)
+ if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) {
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, tmp_cent);
- else if ((U.flag & USER_ADD_VIEWALIGNED))
+ }
+ else if ((U.flag & USER_ADD_VIEWALIGNED)) {
ed_editnurb_spin(viewmat, NULL, obedit, zvec, mat[3]);
- else
+ }
+ else {
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, mat[3]);
+ }
BLI_remlink(editnurb, nu);
@@ -476,8 +506,9 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
WM_operator_view3d_unit_defaults(C, op);
- if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL))
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
+ }
if (!isSurf) { /* adding curve */
if (obedit == NULL || obedit->type != OB_CURVE) {
@@ -490,8 +521,9 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
cu = (Curve *)obedit->data;
cu->flag |= CU_DEFORM_FILL;
- if (type & CU_PRIM_PATH)
+ if (type & CU_PRIM_PATH) {
cu->flag |= CU_PATH | CU_3D;
+ }
}
else {
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 0edee8a84ea..d930174c25b 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -784,13 +784,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
}
/* Deselect all existing curves. */
- {
- ViewLayer *view_layer = CTX_data_view_layer(C);
- uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
- ED_curve_deselect_all_multi(objects, objects_len);
- MEM_freeN(objects);
- }
+ ED_curve_deselect_all_multi(C);
const float radius_min = cps->radius_min;
const float radius_max = cps->radius_max;
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c
index 25470f7344a..d9392090166 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -96,18 +96,22 @@ bool select_bpoint(BPoint *bp, bool selstatus, short flag, bool hidden)
static bool swap_selection_beztriple(BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
return select_beztriple(bezt, DESELECT, SELECT, VISIBLE);
- else
+ }
+ else {
return select_beztriple(bezt, SELECT, SELECT, VISIBLE);
+ }
}
static bool swap_selection_bpoint(BPoint *bp)
{
- if (bp->f1 & SELECT)
+ if (bp->f1 & SELECT) {
return select_bpoint(bp, DESELECT, SELECT, VISIBLE);
- else
+ }
+ else {
return select_bpoint(bp, SELECT, SELECT, VISIBLE);
+ }
}
bool ED_curve_nurb_select_check(View3D *v3d, Nurb *nu)
@@ -163,15 +167,18 @@ int ED_curve_nurb_select_count(View3D *v3d, Nurb *nu)
return sel;
}
-void ED_curve_nurb_select_all(Nurb *nu)
+bool ED_curve_nurb_select_all(const Nurb *nu)
{
+ bool changed = false;
int i;
-
if (nu->bezt) {
BezTriple *bezt;
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
if (bezt->hide == 0) {
- BEZT_SEL_ALL(bezt);
+ if (BEZT_ISSEL_ALL(bezt) == false) {
+ BEZT_SEL_ALL(bezt);
+ changed = true;
+ }
}
}
}
@@ -179,36 +186,48 @@ void ED_curve_nurb_select_all(Nurb *nu)
BPoint *bp;
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
if (bp->hide == 0) {
- bp->f1 |= SELECT;
+ if ((bp->f1 & SELECT) == 0) {
+ bp->f1 |= SELECT;
+ changed = true;
+ }
}
}
}
+ return changed;
}
-void ED_curve_select_all(EditNurb *editnurb)
+bool ED_curve_select_all(EditNurb *editnurb)
{
- Nurb *nu;
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
- ED_curve_nurb_select_all(nu);
+ bool changed = false;
+ for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ changed |= ED_curve_nurb_select_all(nu);
}
+ return changed;
}
-void ED_curve_nurb_deselect_all(Nurb *nu)
+bool ED_curve_nurb_deselect_all(const Nurb *nu)
{
+ bool changed = false;
int i;
-
if (nu->bezt) {
BezTriple *bezt;
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
- BEZT_DESEL_ALL(bezt);
+ if (BEZT_ISSEL_ANY(bezt)) {
+ BEZT_DESEL_ALL(bezt);
+ changed = true;
+ }
}
}
else if (nu->bp) {
BPoint *bp;
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
- bp->f1 &= ~SELECT;
+ if (bp->f1 & SELECT) {
+ bp->f1 &= ~SELECT;
+ changed = true;
+ }
}
}
+ return changed;
}
int ED_curve_select_count(View3D *v3d, struct EditNurb *editnurb)
@@ -236,30 +255,45 @@ bool ED_curve_select_check(View3D *v3d, struct EditNurb *editnurb)
return false;
}
-void ED_curve_deselect_all(EditNurb *editnurb)
+bool ED_curve_deselect_all(EditNurb *editnurb)
{
- Nurb *nu;
-
- for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
- ED_curve_nurb_deselect_all(nu);
+ bool changed = false;
+ for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ changed |= ED_curve_nurb_deselect_all(nu);
}
+ return changed;
}
-void ED_curve_deselect_all_multi(Object **objects, int objects_len)
+bool ED_curve_deselect_all_multi_ex(Base **bases, int bases_len)
{
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ bool changed_multi = false;
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
Curve *cu = obedit->data;
- ED_curve_deselect_all(cu->editnurb);
+ changed_multi |= ED_curve_deselect_all(cu->editnurb);
+ DEG_id_tag_update(&cu->id, ID_RECALC_SELECT);
}
+ return changed_multi;
+}
+
+bool ED_curve_deselect_all_multi(struct bContext *C)
+{
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &bases_len);
+ bool changed_multi = ED_curve_deselect_all_multi_ex(bases, bases_len);
+ MEM_freeN(bases);
+ return changed_multi;
}
-void ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
+bool ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
{
Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int a;
+ bool changed = false;
for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
@@ -272,6 +306,7 @@ void ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
bezt->f1 ^= SELECT;
bezt->f3 ^= SELECT;
}
+ changed = true;
}
bezt++;
}
@@ -280,11 +315,15 @@ void ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
bp = nu->bp;
a = nu->pntsu * nu->pntsv;
while (a--) {
- swap_selection_bpoint(bp);
+ if (bp->hide == 0) {
+ swap_selection_bpoint(bp);
+ changed = true;
+ }
bp++;
}
}
}
+ return changed;
}
/**
@@ -302,21 +341,29 @@ static void select_adjacent_cp(
int a;
bool lastsel = false;
- if (next == 0) return;
+ if (next == 0) {
+ return;
+ }
for (nu = editnurb->first; nu; nu = nu->next) {
lastsel = false;
if (nu->type == CU_BEZIER) {
a = nu->pntsu;
bezt = nu->bezt;
- if (next < 0) bezt = &nu->bezt[a - 1];
+ if (next < 0) {
+ bezt = &nu->bezt[a - 1];
+ }
while (a--) {
- if (a - abs(next) < 0) break;
+ if (a - abs(next) < 0) {
+ break;
+ }
if ((lastsel == false) && (bezt->hide == 0) && ((bezt->f2 & SELECT) || (selstatus == DESELECT))) {
bezt += next;
if (!(bezt->f2 & SELECT) || (selstatus == DESELECT)) {
bool sel = select_beztriple(bezt, selstatus, SELECT, VISIBLE);
- if (sel && !cont) lastsel = true;
+ if (sel && !cont) {
+ lastsel = true;
+ }
}
}
else {
@@ -330,14 +377,20 @@ static void select_adjacent_cp(
else {
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
- if (next < 0) bp = &nu->bp[a - 1];
+ if (next < 0) {
+ bp = &nu->bp[a - 1];
+ }
while (a--) {
- if (a - abs(next) < 0) break;
+ if (a - abs(next) < 0) {
+ break;
+ }
if ((lastsel == false) && (bp->hide == 0) && ((bp->f1 & SELECT) || (selstatus == DESELECT))) {
bp += next;
if (!(bp->f1 & SELECT) || (selstatus == DESELECT)) {
bool sel = select_bpoint(bp, selstatus, SELECT, VISIBLE);
- if (sel && !cont) lastsel = true;
+ if (sel && !cont) {
+ lastsel = true;
+ }
}
}
else {
@@ -367,7 +420,9 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap
Curve *cu;
int a;
- if (obedit == NULL) return;
+ if (obedit == NULL) {
+ return;
+ }
cu = (Curve *)obedit->data;
cu->actvert = CU_ACT_NONE;
@@ -386,10 +441,16 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap
while (a--) {
bool sel;
- if (doswap) sel = swap_selection_beztriple(bezt);
- else sel = select_beztriple(bezt, selstatus, SELECT, VISIBLE);
+ if (doswap) {
+ sel = swap_selection_beztriple(bezt);
+ }
+ else {
+ sel = select_beztriple(bezt, selstatus, SELECT, VISIBLE);
+ }
- if (sel == true) break;
+ if (sel == true) {
+ break;
+ }
}
}
else {
@@ -406,10 +467,16 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap
while (a--) {
if (bp->hide == 0) {
bool sel;
- if (doswap) sel = swap_selection_bpoint(bp);
- else sel = select_bpoint(bp, selstatus, SELECT, VISIBLE);
+ if (doswap) {
+ sel = swap_selection_bpoint(bp);
+ }
+ else {
+ sel = select_bpoint(bp, selstatus, SELECT, VISIBLE);
+ }
- if (sel == true) break;
+ if (sel == true) {
+ break;
+ }
}
}
}
@@ -489,7 +556,6 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
-
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -506,22 +572,25 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Curve *cu = obedit->data;
+ bool changed = false;
switch (action) {
case SEL_SELECT:
- ED_curve_select_all(cu->editnurb);
+ changed = ED_curve_select_all(cu->editnurb);
break;
case SEL_DESELECT:
- ED_curve_deselect_all(cu->editnurb);
+ changed = ED_curve_deselect_all(cu->editnurb);
break;
case SEL_INVERT:
- ED_curve_select_swap(cu->editnurb, (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0);
+ changed = ED_curve_select_swap(cu->editnurb, (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0);
break;
}
- DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- BKE_curve_nurb_vert_active_validate(cu);
+ if (changed) {
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ BKE_curve_nurb_vert_active_validate(cu);
+ }
}
MEM_freeN(objects);
@@ -567,8 +636,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
for (nu = nurbs->first; nu; nu = nu->next) {
if (ED_curve_nurb_select_check(v3d, nu)) {
- ED_curve_nurb_select_all(nu);
- changed = true;
+ changed |= ED_curve_nurb_select_all(nu);
}
}
@@ -686,8 +754,9 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
BPoint *bp = NULL;
int u = 0, v = 0, a, b;
- if (!BKE_curve_nurb_vert_active_get(cu, &nu, (void *)&bp))
+ if (!BKE_curve_nurb_vert_active_get(cu, &nu, (void *)&bp)) {
return OPERATOR_CANCELLED;
+ }
if (last == bp) {
direction = 1 - direction;
@@ -701,10 +770,14 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
for (a = 0; a < nu->pntsv; a++) {
for (b = 0; b < nu->pntsu; b++, bp++) {
if (direction) {
- if (a == v) select_bpoint(bp, SELECT, SELECT, VISIBLE);
+ if (a == v) {
+ select_bpoint(bp, SELECT, SELECT, VISIBLE);
+ }
}
else {
- if (b == u) select_bpoint(bp, SELECT, SELECT, VISIBLE);
+ if (b == u) {
+ select_bpoint(bp, SELECT, SELECT, VISIBLE);
+ }
}
}
}
@@ -823,29 +896,39 @@ static void curve_select_more(Object *obedit)
/* upper control point */
if (a % nu->pntsu != 0) {
tempbp = bp - 1;
- if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
+ if (!(tempbp->f1 & SELECT)) {
+ select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
+ }
}
/* left control point. select only if it is not selected already */
if (a - nu->pntsu > 0) {
sel = 0;
tempbp = bp + nu->pntsu;
- if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
+ if (!(tempbp->f1 & SELECT)) {
+ sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
+ }
/* make sure selected bpoint is discarded */
- if (sel == 1) BLI_BITMAP_ENABLE(selbpoints, a - nu->pntsu);
+ if (sel == 1) {
+ BLI_BITMAP_ENABLE(selbpoints, a - nu->pntsu);
+ }
}
/* right control point */
if (a + nu->pntsu < nu->pntsu * nu->pntsv) {
tempbp = bp - nu->pntsu;
- if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
+ if (!(tempbp->f1 & SELECT)) {
+ select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
+ }
}
/* lower control point. skip next bp in case selection was made */
if (a % nu->pntsu != 1) {
sel = 0;
tempbp = bp + 1;
- if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
+ if (!(tempbp->f1 & SELECT)) {
+ sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
+ }
if (sel) {
bp++;
a--;
@@ -926,7 +1009,9 @@ static void curve_select_less(Object *obedit)
}
else {
bp--;
- if (BLI_BITMAP_TEST(selbpoints, a + 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
+ if (BLI_BITMAP_TEST(selbpoints, a + 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) {
+ sel++;
+ }
bp++;
}
@@ -935,7 +1020,9 @@ static void curve_select_less(Object *obedit)
}
else {
bp++;
- if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++;
+ if ((bp->hide == 0) && (bp->f1 & SELECT)) {
+ sel++;
+ }
bp--;
}
@@ -944,7 +1031,9 @@ static void curve_select_less(Object *obedit)
}
else {
bp -= nu->pntsu;
- if (BLI_BITMAP_TEST(selbpoints, a + nu->pntsu) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
+ if (BLI_BITMAP_TEST(selbpoints, a + nu->pntsu) || ((bp->hide == 0) && (bp->f1 & SELECT))) {
+ sel++;
+ }
bp += nu->pntsu;
}
@@ -953,7 +1042,9 @@ static void curve_select_less(Object *obedit)
}
else {
bp += nu->pntsu;
- if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++;
+ if ((bp->hide == 0) && (bp->f1 & SELECT)) {
+ sel++;
+ }
bp -= nu->pntsu;
}
@@ -990,7 +1081,9 @@ static void curve_select_less(Object *obedit)
}
else {
bezt--;
- if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++;
+ if ((bezt->hide == 0) && (bezt->f2 & SELECT)) {
+ sel++;
+ }
bezt++;
}
@@ -999,7 +1092,9 @@ static void curve_select_less(Object *obedit)
}
else {
bezt++;
- if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++;
+ if ((bezt->hide == 0) && (bezt->f2 & SELECT)) {
+ sel++;
+ }
bezt--;
}
@@ -1031,7 +1126,9 @@ static void curve_select_less(Object *obedit)
}
else {
bp--;
- if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++;
+ if ((bp->hide == 0) && (bp->f1 & SELECT)) {
+ sel++;
+ }
bp++;
}
@@ -1040,7 +1137,9 @@ static void curve_select_less(Object *obedit)
}
else {
bp++;
- if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++;
+ if ((bp->hide == 0) && (bp->f1 & SELECT)) {
+ sel++;
+ }
bp--;
}
@@ -1238,8 +1337,9 @@ static bool ed_curve_select_nth(Curve *cu, const struct CheckerIntervalParams *p
Nurb *nu = NULL;
void *vert = NULL;
- if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert))
+ if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) {
return false;
+ }
if (nu->bezt) {
select_nth_bezt(nu, vert, params);
@@ -1362,7 +1462,8 @@ static void nurb_bpoint_direction_worldspace_get(Object *ob, Nurb *nu, BPoint *b
normalize_v3(r_dir);
}
-static void curve_nurb_selected_type_get(Object *ob, Nurb *nu, const int type, KDTree *r_tree)
+static void curve_nurb_selected_type_get(
+ Object *ob, Nurb *nu, const int type, KDTree_1d *tree_1d, KDTree_3d *tree_3d)
{
float tree_entry[3] = {0.0f, 0.0f, 0.0f};
@@ -1393,7 +1494,12 @@ static void curve_nurb_selected_type_get(Object *ob, Nurb *nu, const int type, K
break;
}
}
- BLI_kdtree_insert(r_tree, tree_index++, tree_entry);
+ if (tree_1d) {
+ BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
+ }
+ else {
+ BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
+ }
}
}
}
@@ -1423,7 +1529,12 @@ static void curve_nurb_selected_type_get(Object *ob, Nurb *nu, const int type, K
break;
}
}
- BLI_kdtree_insert(r_tree, tree_index++, tree_entry);
+ if (tree_1d) {
+ BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
+ }
+ else {
+ BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
+ }
}
}
}
@@ -1431,7 +1542,8 @@ static void curve_nurb_selected_type_get(Object *ob, Nurb *nu, const int type, K
static bool curve_nurb_select_similar_type(
Object *ob, Nurb *nu, const int type,
- const KDTree *tree, const float thresh, const int compare)
+ const KDTree_1d *tree_1d, const KDTree_3d *tree_3d,
+ const float thresh, const int compare)
{
const float thresh_cos = cosf(thresh * (float)M_PI_2);
bool changed = false;
@@ -1448,7 +1560,7 @@ static bool curve_nurb_select_similar_type(
case SIMCURHAND_RADIUS:
{
float radius_ref = bezt->radius;
- if (ED_select_similar_compare_float_tree(tree, radius_ref, thresh, compare)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, radius_ref, thresh, compare)) {
select = true;
}
break;
@@ -1456,7 +1568,7 @@ static bool curve_nurb_select_similar_type(
case SIMCURHAND_WEIGHT:
{
float weight_ref = bezt->weight;
- if (ED_select_similar_compare_float_tree(tree, weight_ref, thresh, compare)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, weight_ref, thresh, compare)) {
select = true;
}
break;
@@ -1465,8 +1577,8 @@ static bool curve_nurb_select_similar_type(
{
float dir[3];
nurb_bezt_direction_worldspace_get(ob, nu, bezt, dir);
- KDTreeNearest nearest;
- if (BLI_kdtree_find_nearest(tree, dir, &nearest) != -1) {
+ KDTreeNearest_3d nearest;
+ if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
float orient = angle_normalized_v3v3(dir, nearest.co);
float delta = thresh_cos - fabsf(cosf(orient));
if (ED_select_similar_compare_float(delta, thresh, compare)) {
@@ -1496,7 +1608,7 @@ static bool curve_nurb_select_similar_type(
case SIMCURHAND_RADIUS:
{
float radius_ref = bp->radius;
- if (ED_select_similar_compare_float_tree(tree, radius_ref, thresh, compare)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, radius_ref, thresh, compare)) {
select = true;
}
break;
@@ -1504,7 +1616,7 @@ static bool curve_nurb_select_similar_type(
case SIMCURHAND_WEIGHT:
{
float weight_ref = bp->weight;
- if (ED_select_similar_compare_float_tree(tree, weight_ref, thresh, compare)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, weight_ref, thresh, compare)) {
select = true;
}
break;
@@ -1513,8 +1625,8 @@ static bool curve_nurb_select_similar_type(
{
float dir[3];
nurb_bpoint_direction_worldspace_get(ob, nu, bp, dir);
- KDTreeNearest nearest;
- if (BLI_kdtree_find_nearest(tree, dir, &nearest) != -1) {
+ KDTreeNearest_3d nearest;
+ if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
float orient = angle_normalized_v3v3(dir, nearest.co);
float delta = fabsf(cosf(orient)) - thresh_cos;
if (ED_select_similar_compare_float(delta, thresh, compare)) {
@@ -1560,14 +1672,17 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- KDTree *tree = NULL;
+ KDTree_1d *tree_1d = NULL;
+ KDTree_3d *tree_3d = NULL;
short type_ref = 0;
switch (optype) {
case SIMCURHAND_RADIUS:
case SIMCURHAND_WEIGHT:
+ tree_1d = BLI_kdtree_1d_new(tot_nurbs_selected_all);
+ break;
case SIMCURHAND_DIRECTION:
- tree = BLI_kdtree_new(tot_nurbs_selected_all);
+ tree_3d = BLI_kdtree_3d_new(tot_nurbs_selected_all);
break;
}
@@ -1591,14 +1706,19 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
case SIMCURHAND_RADIUS:
case SIMCURHAND_WEIGHT:
case SIMCURHAND_DIRECTION:
- curve_nurb_selected_type_get(obedit, nu, optype, tree);
+ curve_nurb_selected_type_get(obedit, nu, optype, tree_1d, tree_3d);
break;
}
}
}
- if (tree != NULL) {
- BLI_kdtree_balance(tree);
+ if (tree_1d != NULL) {
+ BLI_kdtree_1d_deduplicate(tree_1d);
+ BLI_kdtree_1d_balance(tree_1d);
+ }
+ if (tree_3d != NULL) {
+ BLI_kdtree_3d_deduplicate(tree_3d);
+ BLI_kdtree_3d_balance(tree_3d);
}
/* Select control points with desired type. */
@@ -1614,15 +1734,15 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
case SIMCURHAND_TYPE:
{
if (nu->type & type_ref) {
- ED_curve_nurb_select_all(nu);
- changed = true;
+ changed |= ED_curve_nurb_select_all(nu);
}
break;
}
case SIMCURHAND_RADIUS:
case SIMCURHAND_WEIGHT:
case SIMCURHAND_DIRECTION:
- changed = curve_nurb_select_similar_type(obedit, nu, optype, tree, thresh, compare);
+ changed = curve_nurb_select_similar_type(
+ obedit, nu, optype, tree_1d, tree_3d, thresh, compare);
break;
}
}
@@ -1634,8 +1754,12 @@ static int curve_select_similar_exec(bContext *C, wmOperator *op)
}
MEM_freeN(objects);
- if (tree != NULL) {
- BLI_kdtree_free(tree);
+
+ if (tree_1d != NULL) {
+ BLI_kdtree_1d_free(tree_1d);
+ }
+ if (tree_3d != NULL) {
+ BLI_kdtree_3d_free(tree_3d);
}
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/curve/editcurve_undo.c b/source/blender/editors/curve/editcurve_undo.c
index 30dd7346191..6cde9abb33f 100644
--- a/source/blender/editors/curve/editcurve_undo.c
+++ b/source/blender/editors/curve/editcurve_undo.c
@@ -133,8 +133,9 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
}
if (ad) {
- if (ad->action)
+ if (ad->action) {
copy_fcurves(&ucu->fcurves, &ad->action->curves);
+ }
copy_fcurves(&ucu->drivers, &ad->drivers);
}
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 03161df2a29..480819dd47a 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -79,139 +79,143 @@ static char findaccent(char char1, unsigned int code)
char new = 0;
if (char1 == 'a') {
- if (code == '`') new = 224;
- else if (code == 39) new = 225;
- else if (code == '^') new = 226;
- else if (code == '~') new = 227;
- else if (code == '"') new = 228;
- else if (code == 'o') new = 229;
- else if (code == 'e') new = 230;
- else if (code == '-') new = 170;
+ if (code == '`') { new = 224; }
+ else if (code == 39) { new = 225; }
+ else if (code == '^') { new = 226; }
+ else if (code == '~') { new = 227; }
+ else if (code == '"') { new = 228; }
+ else if (code == 'o') { new = 229; }
+ else if (code == 'e') { new = 230; }
+ else if (code == '-') { new = 170; }
}
else if (char1 == 'c') {
- if (code == ',') new = 231;
- else if (code == '|') new = 162;
- else if (code == 'o') new = 169;
+ if (code == ',') { new = 231; }
+ else if (code == '|') { new = 162; }
+ else if (code == 'o') { new = 169; }
}
else if (char1 == 'e') {
- if (code == '`') new = 232;
- else if (code == 39) new = 233;
- else if (code == '^') new = 234;
- else if (code == '"') new = 235;
+ if (code == '`') { new = 232; }
+ else if (code == 39) { new = 233; }
+ else if (code == '^') { new = 234; }
+ else if (code == '"') { new = 235; }
}
else if (char1 == 'i') {
- if (code == '`') new = 236;
- else if (code == 39) new = 237;
- else if (code == '^') new = 238;
- else if (code == '"') new = 239;
+ if (code == '`') { new = 236; }
+ else if (code == 39) { new = 237; }
+ else if (code == '^') { new = 238; }
+ else if (code == '"') { new = 239; }
}
else if (char1 == 'n') {
- if (code == '~') new = 241;
+ if (code == '~') { new = 241; }
}
else if (char1 == 'o') {
- if (code == '`') new = 242;
- else if (code == 39) new = 243;
- else if (code == '^') new = 244;
- else if (code == '~') new = 245;
- else if (code == '"') new = 246;
- else if (code == '/') new = 248;
- else if (code == '-') new = 186;
- else if (code == 'e') new = 143;
- else if (code == 'c') new = 169;
- else if (code == 'r') new = 174;
+ if (code == '`') { new = 242; }
+ else if (code == 39) { new = 243; }
+ else if (code == '^') { new = 244; }
+ else if (code == '~') { new = 245; }
+ else if (code == '"') { new = 246; }
+ else if (code == '/') { new = 248; }
+ else if (code == '-') { new = 186; }
+ else if (code == 'e') { new = 143; }
+ else if (code == 'c') { new = 169; }
+ else if (code == 'r') { new = 174; }
}
else if (char1 == 'r') {
- if (code == 'o') new = 174;
+ if (code == 'o') { new = 174; }
}
else if (char1 == 's') {
- if (code == 's') new = 167;
+ if (code == 's') { new = 167; }
}
else if (char1 == 't') {
- if (code == 'm') new = 153;
+ if (code == 'm') { new = 153; }
}
else if (char1 == 'u') {
- if (code == '`') new = 249;
- else if (code == 39) new = 250;
- else if (code == '^') new = 251;
- else if (code == '"') new = 252;
+ if (code == '`') { new = 249; }
+ else if (code == 39) { new = 250; }
+ else if (code == '^') { new = 251; }
+ else if (code == '"') { new = 252; }
}
else if (char1 == 'y') {
- if (code == 39) new = 253;
- else if (code == '"') new = 255;
+ if (code == 39) { new = 253; }
+ else if (code == '"') { new = 255; }
}
else if (char1 == 'A') {
- if (code == '`') new = 192;
- else if (code == 39) new = 193;
- else if (code == '^') new = 194;
- else if (code == '~') new = 195;
- else if (code == '"') new = 196;
- else if (code == 'o') new = 197;
- else if (code == 'e') new = 198;
+ if (code == '`') { new = 192; }
+ else if (code == 39) { new = 193; }
+ else if (code == '^') { new = 194; }
+ else if (code == '~') { new = 195; }
+ else if (code == '"') { new = 196; }
+ else if (code == 'o') { new = 197; }
+ else if (code == 'e') { new = 198; }
}
else if (char1 == 'C') {
- if (code == ',') new = 199;
+ if (code == ',') { new = 199; }
}
else if (char1 == 'E') {
- if (code == '`') new = 200;
- else if (code == 39) new = 201;
- else if (code == '^') new = 202;
- else if (code == '"') new = 203;
+ if (code == '`') { new = 200; }
+ else if (code == 39) { new = 201; }
+ else if (code == '^') { new = 202; }
+ else if (code == '"') { new = 203; }
}
else if (char1 == 'I') {
- if (code == '`') new = 204;
- else if (code == 39) new = 205;
- else if (code == '^') new = 206;
- else if (code == '"') new = 207;
+ if (code == '`') { new = 204; }
+ else if (code == 39) { new = 205; }
+ else if (code == '^') { new = 206; }
+ else if (code == '"') { new = 207; }
}
else if (char1 == 'N') {
- if (code == '~') new = 209;
+ if (code == '~') { new = 209; }
}
else if (char1 == 'O') {
- if (code == '`') new = 210;
- else if (code == 39) new = 211;
- else if (code == '^') new = 212;
- else if (code == '~') new = 213;
- else if (code == '"') new = 214;
- else if (code == '/') new = 216;
- else if (code == 'e') new = 141;
+ if (code == '`') { new = 210; }
+ else if (code == 39) { new = 211; }
+ else if (code == '^') { new = 212; }
+ else if (code == '~') { new = 213; }
+ else if (code == '"') { new = 214; }
+ else if (code == '/') { new = 216; }
+ else if (code == 'e') { new = 141; }
}
else if (char1 == 'U') {
- if (code == '`') new = 217;
- else if (code == 39) new = 218;
- else if (code == '^') new = 219;
- else if (code == '"') new = 220;
+ if (code == '`') { new = 217; }
+ else if (code == 39) { new = 218; }
+ else if (code == '^') { new = 219; }
+ else if (code == '"') { new = 220; }
}
else if (char1 == 'Y') {
- if (code == 39) new = 221;
+ if (code == 39) { new = 221; }
}
else if (char1 == '1') {
- if (code == '4') new = 188;
- if (code == '2') new = 189;
+ if (code == '4') { new = 188; }
+ if (code == '2') { new = 189; }
}
else if (char1 == '3') {
- if (code == '4') new = 190;
+ if (code == '4') { new = 190; }
}
else if (char1 == ':') {
- if (code == '-') new = 247;
+ if (code == '-') { new = 247; }
}
else if (char1 == '-') {
- if (code == ':') new = 247;
- if (code == '|') new = 135;
- if (code == '+') new = 177;
+ if (code == ':') { new = 247; }
+ if (code == '|') { new = 135; }
+ if (code == '+') { new = 177; }
}
else if (char1 == '|') {
- if (code == '-') new = 135;
- if (code == '=') new = 136;
+ if (code == '-') { new = 135; }
+ if (code == '=') { new = 136; }
}
else if (char1 == '=') {
- if (code == '|') new = 136;
+ if (code == '|') { new = 136; }
}
else if (char1 == '+') {
- if (code == '-') new = 177;
+ if (code == '-') { new = 177; }
}
- if (new) return new;
- else return char1;
+ if (new) {
+ return new;
+ }
+ else {
+ return char1;
+ }
}
static int insert_into_textbuf(Object *obedit, uintptr_t c)
@@ -222,8 +226,12 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
if (ef->len < MAXTEXT - 1) {
int x;
- for (x = ef->len; x > ef->pos; x--) ef->textbuf[x] = ef->textbuf[x - 1];
- for (x = ef->len; x > ef->pos; x--) ef->textbufinfo[x] = ef->textbufinfo[x - 1];
+ for (x = ef->len; x > ef->pos; x--) {
+ ef->textbuf[x] = ef->textbuf[x - 1];
+ }
+ for (x = ef->len; x > ef->pos; x--) {
+ ef->textbufinfo[x] = ef->textbufinfo[x - 1];
+ }
ef->textbuf[ef->pos] = c;
ef->textbufinfo[ef->pos] = cu->curinfo;
ef->textbufinfo[ef->pos].kern = 0;
@@ -235,8 +243,9 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
return 1;
}
- else
+ else {
return 0;
+ }
}
static void text_update_edited(bContext *C, Object *obedit, int mode)
@@ -383,8 +392,9 @@ static int paste_from_file_exec(bContext *C, wmOperator *op)
static int paste_from_file_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return paste_from_file_exec(C, op);
+ }
WM_event_add_fileselect(C, op);
@@ -450,8 +460,12 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
nbytes += nbytes_line + 1;
}
- if (cu->str) MEM_freeN(cu->str);
- if (cu->strinfo) MEM_freeN(cu->strinfo);
+ if (cu->str) {
+ MEM_freeN(cu->str);
+ }
+ if (cu->strinfo) {
+ MEM_freeN(cu->strinfo);
+ }
cu->str = MEM_mallocN(nbytes + 4, "str");
cu->strinfo = MEM_callocN((nchars + 4) * sizeof(CharInfo), "strinfo");
@@ -492,7 +506,9 @@ void ED_text_to_object(bContext *C, Text *text, const bool split_lines)
float offset[3];
int linenum = 0;
- if (!text || !text->lines.first) return;
+ if (!text || !text->lines.first) {
+ return;
+ }
if (split_lines) {
for (line = text->lines.first; line; line = line->next) {
@@ -507,8 +523,9 @@ void ED_text_to_object(bContext *C, Text *text, const bool split_lines)
offset[1] = -linenum;
offset[2] = 0;
- if (rv3d)
+ if (rv3d) {
mul_mat3_m4_v3(rv3d->viewinv, offset);
+ }
txt_add_object(C, line, 1, offset);
@@ -537,14 +554,20 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */
direction = BKE_vfont_select_get(obedit, &selstart, &selend);
if (direction) {
int size;
- if (ins) offset = 1;
- if (ef->pos >= selstart) ef->pos = selstart + offset;
+ if (ins) {
+ offset = 1;
+ }
+ if (ef->pos >= selstart) {
+ ef->pos = selstart + offset;
+ }
if ((direction == -1) && ins) {
selstart++;
selend++;
}
getfrom = selend + offset;
- if (ins == 0) getfrom++;
+ if (ins == 0) {
+ getfrom++;
+ }
size = (ef->len * sizeof(wchar_t)) - (selstart * sizeof(wchar_t)) + (offset * sizeof(wchar_t));
memmove(ef->textbuf + selstart, ef->textbuf + getfrom, size);
memmove(ef->textbufinfo + selstart, ef->textbufinfo + getfrom, ((ef->len - selstart) + offset) * sizeof(CharInfo));
@@ -572,14 +595,17 @@ static int set_style(bContext *C, const int style, const bool clear)
EditFont *ef = cu->editfont;
int i, selstart, selend;
- if (!BKE_vfont_select_get(obedit, &selstart, &selend))
+ if (!BKE_vfont_select_get(obedit, &selstart, &selend)) {
return OPERATOR_CANCELLED;
+ }
for (i = selstart; i <= selend; i++) {
- if (clear)
+ if (clear) {
ef->textbufinfo[i].flag &= ~style;
- else
+ }
+ else {
ef->textbufinfo[i].flag |= style;
+ }
}
DEG_id_tag_update(obedit->data, 0);
@@ -623,8 +649,9 @@ static int toggle_style_exec(bContext *C, wmOperator *op)
Curve *cu = obedit->data;
int style, clear, selstart, selend;
- if (!BKE_vfont_select_get(obedit, &selstart, &selend))
+ if (!BKE_vfont_select_get(obedit, &selstart, &selend)) {
return OPERATOR_CANCELLED;
+ }
style = RNA_enum_get(op->ptr, "style");
@@ -748,8 +775,9 @@ static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
Object *obedit = CTX_data_edit_object(C);
int selstart, selend;
- if (!BKE_vfont_select_get(obedit, &selstart, &selend))
+ if (!BKE_vfont_select_get(obedit, &selstart, &selend)) {
return OPERATOR_CANCELLED;
+ }
copy_selection(obedit);
kill_selection(obedit, 0);
@@ -906,8 +934,12 @@ static int move_cursor(bContext *C, int type, const bool select)
switch (type) {
case LINE_BEGIN:
while (ef->pos > 0) {
- if (ef->textbuf[ef->pos - 1] == '\n') break;
- if (ef->textbufinfo[ef->pos - 1].flag & CU_CHINFO_WRAP) break;
+ if (ef->textbuf[ef->pos - 1] == '\n') {
+ break;
+ }
+ if (ef->textbufinfo[ef->pos - 1].flag & CU_CHINFO_WRAP) {
+ break;
+ }
ef->pos--;
}
cursmove = FO_CURS;
@@ -915,9 +947,15 @@ static int move_cursor(bContext *C, int type, const bool select)
case LINE_END:
while (ef->pos < ef->len) {
- if (ef->textbuf[ef->pos] == 0) break;
- if (ef->textbuf[ef->pos] == '\n') break;
- if (ef->textbufinfo[ef->pos].flag & CU_CHINFO_WRAP) break;
+ if (ef->textbuf[ef->pos] == 0) {
+ break;
+ }
+ if (ef->textbuf[ef->pos] == '\n') {
+ break;
+ }
+ if (ef->textbufinfo[ef->pos].flag & CU_CHINFO_WRAP) {
+ break;
+ }
ef->pos++;
}
cursmove = FO_CURS;
@@ -969,12 +1007,13 @@ static int move_cursor(bContext *C, int type, const bool select)
break;
}
- if (cursmove == -1)
+ if (cursmove == -1) {
return OPERATOR_CANCELLED;
+ }
- if (ef->pos > ef->len) ef->pos = ef->len;
- else if (ef->pos >= MAXTEXT) ef->pos = MAXTEXT;
- else if (ef->pos < 0) ef->pos = 0;
+ if (ef->pos > ef->len) { ef->pos = ef->len; }
+ else if (ef->pos >= MAXTEXT) { ef->pos = MAXTEXT; }
+ else if (ef->pos < 0) { ef->pos = 0; }
/* apply vertical cursor motion to position immediately
* otherwise the selection will lag behind */
@@ -990,8 +1029,9 @@ static int move_cursor(bContext *C, int type, const bool select)
}
}
- if (select)
+ if (select) {
ef->selend = ef->pos;
+ }
text_update_edited(C, obedit, cursmove);
@@ -1063,8 +1103,9 @@ static int change_spacing_exec(bContext *C, wmOperator *op)
kern += delta;
CLAMP(kern, -20, 20);
- if (ef->textbufinfo[ef->pos - 1].kern == kern)
+ if (ef->textbufinfo[ef->pos - 1].kern == kern) {
return OPERATOR_CANCELLED;
+ }
ef->textbufinfo[ef->pos - 1].kern = kern;
@@ -1100,15 +1141,17 @@ static int change_character_exec(bContext *C, wmOperator *op)
EditFont *ef = cu->editfont;
int character, delta = RNA_int_get(op->ptr, "delta");
- if (ef->pos <= 0)
+ if (ef->pos <= 0) {
return OPERATOR_CANCELLED;
+ }
character = ef->textbuf[ef->pos - 1];
character += delta;
CLAMP(character, 0, 255);
- if (character == ef->textbuf[ef->pos - 1])
+ if (character == ef->textbuf[ef->pos - 1]) {
return OPERATOR_CANCELLED;
+ }
ef->textbuf[ef->pos - 1] = character;
@@ -1189,27 +1232,38 @@ static int delete_exec(bContext *C, wmOperator *op)
int range[2] = {0, 0};
bool has_select = false;
- if (ef->len == 0)
+ if (ef->len == 0) {
return OPERATOR_CANCELLED;
+ }
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
- if (type == DEL_NEXT_SEL) type = DEL_SELECTION;
- else if (type == DEL_PREV_SEL) type = DEL_SELECTION;
+ if (type == DEL_NEXT_SEL) {
+ type = DEL_SELECTION;
+ }
+ else if (type == DEL_PREV_SEL) {
+ type = DEL_SELECTION;
+ }
has_select = true;
}
else {
- if (type == DEL_NEXT_SEL) type = DEL_NEXT_CHAR;
- else if (type == DEL_PREV_SEL) type = DEL_PREV_CHAR;
+ if (type == DEL_NEXT_SEL) {
+ type = DEL_NEXT_CHAR;
+ }
+ else if (type == DEL_PREV_SEL) {
+ type = DEL_PREV_CHAR;
+ }
}
switch (type) {
case DEL_SELECTION:
- if (!kill_selection(obedit, 0))
+ if (!kill_selection(obedit, 0)) {
return OPERATOR_CANCELLED;
+ }
break;
case DEL_PREV_CHAR:
- if (ef->pos <= 0)
+ if (ef->pos <= 0) {
return OPERATOR_CANCELLED;
+ }
range[0] = ef->pos - 1;
range[1] = ef->pos;
@@ -1217,8 +1271,9 @@ static int delete_exec(bContext *C, wmOperator *op)
ef->pos--;
break;
case DEL_NEXT_CHAR:
- if (ef->pos >= ef->len)
+ if (ef->pos >= ef->len) {
return OPERATOR_CANCELLED;
+ }
range[0] = ef->pos;
range[1] = ef->pos + 1;
@@ -1306,8 +1361,9 @@ static int insert_text_exec(bContext *C, wmOperator *op)
wchar_t *inserted_text;
int a, len;
- if (!RNA_struct_property_is_set(op->ptr, "text"))
+ if (!RNA_struct_property_is_set(op->ptr, "text")) {
return OPERATOR_CANCELLED;
+ }
inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0);
len = BLI_strlen_utf8(inserted_utf8);
@@ -1315,8 +1371,9 @@ static int insert_text_exec(bContext *C, wmOperator *op)
inserted_text = MEM_callocN(sizeof(wchar_t) * (len + 1), "FONT_insert_text");
BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len + 1);
- for (a = 0; a < len; a++)
+ for (a = 0; a < len; a++) {
insert_into_textbuf(obedit, inserted_text[a]);
+ }
MEM_freeN(inserted_text);
MEM_freeN(inserted_utf8);
@@ -1338,26 +1395,31 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int event_type = event->type, event_val = event->val;
wchar_t inserted_text[2] = {0};
- if (RNA_struct_property_is_set(op->ptr, "text"))
+ if (RNA_struct_property_is_set(op->ptr, "text")) {
return insert_text_exec(C, op);
+ }
if (RNA_struct_property_is_set(op->ptr, "accent")) {
- if (ef->len != 0 && ef->pos > 0)
+ if (ef->len != 0 && ef->pos > 0) {
accentcode = 1;
+ }
return OPERATOR_FINISHED;
}
/* tab should exit editmode, but we allow it to be typed using modifier keys */
if (event_type == TABKEY) {
- if ((alt || ctrl || shift) == 0)
+ if ((alt || ctrl || shift) == 0) {
return OPERATOR_PASS_THROUGH;
- else
+ }
+ else {
ascii = 9;
+ }
}
if (event_type == BACKSPACEKEY) {
- if (alt && ef->len != 0 && ef->pos > 0)
+ if (alt && ef->len != 0 && ef->pos > 0) {
accentcode = 1;
+ }
return OPERATOR_PASS_THROUGH;
}
@@ -1400,8 +1462,9 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
text_update_edited(C, obedit, FO_EDIT);
}
}
- else
+ else {
return OPERATOR_PASS_THROUGH;
+ }
if (inserted_text[0]) {
/* store as utf8 in RNA string */
@@ -1412,8 +1475,9 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
/* reset property? */
- if (event_val == 0)
+ if (event_val == 0) {
accentcode = 0;
+ }
return OPERATOR_FINISHED;
}
@@ -1447,7 +1511,9 @@ static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
int i;
if (cu->totbox < 256) {
- for (i = cu->totbox; i > cu->actbox; i--) cu->tb[i] = cu->tb[i - 1];
+ for (i = cu->totbox; i > cu->actbox; i--) {
+ cu->tb[i] = cu->tb[i - 1];
+ }
cu->tb[cu->actbox] = cu->tb[cu->actbox - 1];
cu->actbox++;
cu->totbox++;
@@ -1490,10 +1556,13 @@ static int textbox_remove_exec(bContext *C, wmOperator *op)
if (cu->totbox > 1) {
- for (i = index; i < cu->totbox; i++) cu->tb[i] = cu->tb[i + 1];
+ for (i = index; i < cu->totbox; i++) {
+ cu->tb[i] = cu->tb[i + 1];
+ }
cu->totbox--;
- if (cu->actbox >= index)
+ if (cu->actbox >= index) {
cu->actbox--;
+ }
}
DEG_id_tag_update(obedit->data, 0);
@@ -1544,7 +1613,9 @@ void ED_curve_editfont_make(Object *obedit)
memcpy(ef->textbufinfo, cu->strinfo, ef->len * sizeof(CharInfo));
- if (ef->pos > ef->len) ef->pos = ef->len;
+ if (ef->pos > ef->len) {
+ ef->pos = ef->len;
+ }
cu->curinfo = ef->textbufinfo[ef->pos ? ef->pos - 1 : 0];
@@ -1575,8 +1646,9 @@ void ED_curve_editfont_load(Object *obedit)
/* Copy the wchar to UTF-8 */
BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, cu->len + 1);
- if (cu->strinfo)
+ if (cu->strinfo) {
MEM_freeN(cu->strinfo);
+ }
cu->strinfo = MEM_callocN((cu->len_wchar + 4) * sizeof(CharInfo), "texteditinfo");
memcpy(cu->strinfo, ef->textbufinfo, cu->len_wchar * sizeof(CharInfo));
@@ -1612,8 +1684,9 @@ static int set_case(bContext *C, int ccase)
len = (selend - selstart) + 1;
str = &ef->textbuf[selstart];
while (len) {
- if (*str >= 'a' && *str <= 'z')
+ if (*str >= 'a' && *str <= 'z') {
*str -= 32;
+ }
len--;
str++;
}
@@ -1727,12 +1800,15 @@ static int font_open_exec(bContext *C, wmOperator *op)
font = BKE_vfont_load(bmain, filepath);
if (!font) {
- if (op->customdata) MEM_freeN(op->customdata);
+ if (op->customdata) {
+ MEM_freeN(op->customdata);
+ }
return OPERATOR_CANCELLED;
}
- if (!op->customdata)
+ if (!op->customdata) {
font_ui_template_init(C, op);
+ }
/* hook into UI */
pprop = op->customdata;
@@ -1772,8 +1848,9 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
path = (vfont && !BKE_vfont_is_builtin(vfont)) ? vfont->name : U.fontdir;
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return font_open_exec(C, op);
+ }
RNA_string_set(op->ptr, "filepath", path);
WM_event_add_fileselect(C, op);
diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt
index c116254ebc9..876af10f884 100644
--- a/source/blender/editors/datafiles/CMakeLists.txt
+++ b/source/blender/editors/datafiles/CMakeLists.txt
@@ -683,11 +683,13 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.gpencil.edit_mirror
ops.gpencil.edit_shear
ops.gpencil.edit_to_sphere
+ ops.gpencil.extrude_move
ops.gpencil.primitive_arc
ops.gpencil.primitive_box
ops.gpencil.primitive_circle
ops.gpencil.primitive_curve
ops.gpencil.primitive_line
+ ops.gpencil.radius
ops.gpencil.sculpt_clone
ops.gpencil.sculpt_grab
ops.gpencil.sculpt_pinch
@@ -721,6 +723,7 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.mesh.spin
ops.mesh.spin.duplicate
ops.mesh.vertices_smooth
+ ops.node.links_cut
ops.paint.vertex_color_fill
ops.paint.weight_fill
ops.paint.weight_gradient
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 d25f982fc23..45b7b37eb8d 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
@@ -60,7 +60,7 @@
#define GIZMO_RESIZER_SIZE 10.0f
#define GIZMO_MARGIN_OFFSET_SCALE 1.5f
-static void gizmo_calc_rect_view_scale(
+static bool gizmo_calc_rect_view_scale(
const wmGizmo *gz, const float dims[2], float scale[2])
{
float matrix_final_no_offset[4][4];
@@ -79,11 +79,19 @@ static void gizmo_calc_rect_view_scale(
mul_v2_v2(x_axis, asp);
mul_v2_v2(y_axis, asp);
- scale[0] = 1.0f / len_v3(x_axis);
- scale[1] = 1.0f / len_v3(y_axis);
+ float len_x_axis = len_v3(x_axis);
+ float len_y_axis = len_v3(y_axis);
+
+ if (len_x_axis == 0.0f || len_y_axis == 0.0f) {
+ return false;
+ }
+
+ scale[0] = 1.0f / len_x_axis;
+ scale[1] = 1.0f / len_y_axis;
+ return true;
}
-static void gizmo_calc_rect_view_margin(
+static bool gizmo_calc_rect_view_margin(
const wmGizmo *gz, const float dims[2], float margin[2])
{
float handle_size;
@@ -95,9 +103,12 @@ static void gizmo_calc_rect_view_margin(
}
handle_size *= gz->scale_final;
float scale_xy[2];
- gizmo_calc_rect_view_scale(gz, dims, scale_xy);
+ if (!gizmo_calc_rect_view_scale(gz, dims, scale_xy)) {
+ return false;
+ }
margin[0] = ((handle_size * scale_xy[0]));
margin[1] = ((handle_size * scale_xy[1]));
+ return true;
}
/* -------------------------------------------------------------------- */
@@ -725,7 +736,10 @@ static int gizmo_cage2d_test_select(
}
float margin[2];
- gizmo_calc_rect_view_margin(gz, dims, margin);
+ if (!gizmo_calc_rect_view_margin(gz, dims, margin)) {
+ return -1;
+ }
+
/* expand for hotspot */
const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
@@ -745,7 +759,7 @@ static int gizmo_cage2d_test_select(
r.ymin = -size[1] + margin[1];
r.xmax = size[0] - margin[0];
r.ymax = size[1] - margin[1];
- };
+ }
bool isect = BLI_rctf_isect_pt_v(&r, point_local);
if (isect) {
return ED_GIZMO_CAGE2D_PART_TRANSLATE;
diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
index b5be45bb63f..9072ced0bd1 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
@@ -106,7 +106,11 @@ static void dial_geom_draw(
UNUSED_VARS(gz, axis_modal_mat, clip_plane);
wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_dial, select, color);
#else
- const bool filled = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_FILL) != 0;
+ const bool filled = (
+ (draw_options &
+ (select ?
+ (ED_GIZMO_DIAL_DRAW_FLAG_FILL | ED_GIZMO_DIAL_DRAW_FLAG_FILL_SELECT) :
+ ED_GIZMO_DIAL_DRAW_FLAG_FILL)));
GPU_line_width(line_width);
@@ -368,7 +372,7 @@ static void dial_draw_intern(
}
ED_gizmotypes_dial_3d_draw_util(
- gz->matrix_basis, matrix_final, gz->line_width, color,
+ gz->matrix_basis, matrix_final, gz->line_width, color, select,
&(struct Dial3dParams){
.draw_options = draw_options,
.angle_ofs = angle_ofs,
@@ -536,6 +540,7 @@ void ED_gizmotypes_dial_3d_draw_util(
const float matrix_final[4][4],
const float line_width,
const float color[4],
+ const bool select,
struct Dial3dParams *params)
{
GPU_matrix_push();
@@ -562,7 +567,7 @@ void ED_gizmotypes_dial_3d_draw_util(
/* Draw actual dial gizmo. */
dial_geom_draw(
- color, line_width, false, matrix_basis, params->clip_plane,
+ color, line_width, select, matrix_basis, params->clip_plane,
params->arc_partial_angle, params->arc_inner_factor, params->draw_options);
GPU_matrix_pop();
@@ -587,6 +592,7 @@ static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
static EnumPropertyItem rna_enum_draw_options[] = {
{ED_GIZMO_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""},
{ED_GIZMO_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
+ {ED_GIZMO_DIAL_DRAW_FLAG_FILL_SELECT, "FILL_SELECT", 0, "Use fill for selection test", ""},
{ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""},
{ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""},
{ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE, "ANGLE_VALUE", 0, "Show Angle Value", ""},
diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
index 0fe5a4e7d80..3870ce984b5 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
@@ -104,7 +104,11 @@ static void move_geom_draw(
wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_move3d, select);
#else
const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
- const bool filled = (draw_options & ED_GIZMO_MOVE_DRAW_FLAG_FILL) != 0;
+ const bool filled = (
+ (draw_options &
+ (select ?
+ (ED_GIZMO_MOVE_DRAW_FLAG_FILL | ED_GIZMO_MOVE_DRAW_FLAG_FILL_SELECT) :
+ ED_GIZMO_MOVE_DRAW_FLAG_FILL)));
GPU_line_width(gz->line_width);
@@ -440,6 +444,7 @@ static void GIZMO_GT_move_3d(wmGizmoType *gzt)
};
static EnumPropertyItem rna_enum_draw_options[] = {
{ED_GIZMO_MOVE_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
+ {ED_GIZMO_MOVE_DRAW_FLAG_FILL_SELECT, "FILL_SELECT", 0, "Use fill for selection test", ""},
{ED_GIZMO_MOVE_DRAW_FLAG_ALIGN_VIEW, "ALIGN_VIEW", 0, "Align View", ""},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index f30b3a45971..43e2b5bd3bf 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -717,8 +717,8 @@ static void gp_draw_strokes_edit(
/* ----- General Drawing ------ */
/* draw onion-skinning for a layer */
static void gp_draw_onionskins(
- bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, int offsx, int offsy, int winx, int winy,
- int UNUSED(cfra), int dflag)
+ bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, int offsx, int offsy, int winx, int winy,
+ int UNUSED(cfra), int dflag)
{
const float alpha = 1.0f;
float color[4];
@@ -738,8 +738,8 @@ static void gp_draw_onionskins(
fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
color[3] = alpha * fac * 0.66f;
gp_draw_strokes(
- gpd, gpl, gf, offsx, offsy, winx, winy, dflag,
- gpl->thickness, color);
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
}
else
break;
@@ -750,8 +750,8 @@ static void gp_draw_onionskins(
if (gpf->prev) {
color[3] = (alpha / 7);
gp_draw_strokes(
- gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag,
- gpl->thickness, color);
+ gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
}
}
else {
@@ -774,8 +774,8 @@ static void gp_draw_onionskins(
fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
color[3] = alpha * fac * 0.66f;
gp_draw_strokes(
- gpd, gpl, gf, offsx, offsy, winx, winy, dflag,
- gpl->thickness, color);
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
}
else
break;
@@ -786,8 +786,8 @@ static void gp_draw_onionskins(
if (gpf->next) {
color[3] = (alpha / 4);
gp_draw_strokes(
- gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag,
- gpl->thickness, color);
+ gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
}
}
else {
@@ -981,7 +981,7 @@ static void gp_draw_data_all(
* ............................ */
/* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */
-void ED_gpencil_draw_2dimage(const bContext *C)
+void ED_annotation_draw_2dimage(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *sa = CTX_wm_area(C);
@@ -1049,7 +1049,7 @@ void ED_gpencil_draw_2dimage(const bContext *C)
/* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly
* Note: this gets called twice - first time with onlyv2d=true to draw 'canvas' strokes,
* second time with onlyv2d=false for screen-aligned strokes */
-void ED_gpencil_draw_view2d(const bContext *C, bool onlyv2d)
+void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
{
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *sa = CTX_wm_area(C);
@@ -1083,7 +1083,7 @@ void ED_gpencil_draw_view2d(const bContext *C, bool onlyv2d)
/* draw annotations sketches to specified 3d-view assuming that matrices are already set correctly
* Note: this gets called twice - first time with only3d=true to draw 3d-strokes,
* second time with only3d=false for screen-aligned strokes */
-void ED_gpencil_draw_view3d_annotations(
+void ED_annotation_draw_view3d(
Scene *scene, struct Depsgraph *depsgraph,
View3D *v3d, ARegion *ar,
bool only3d)
@@ -1133,4 +1133,13 @@ void ED_gpencil_draw_view3d_annotations(
gp_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
}
+void ED_annotation_draw_ex(
+ Scene *scene, bGPdata *gpd,
+ int winx, int winy, const int cfra, const char spacetype)
+{
+ int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D;
+
+ gp_draw_data_all(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype);
+}
+
/* ************************************************** */
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 1c2ad3d2a95..b9b0c8fe788 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -84,7 +84,8 @@ typedef enum eGPencil_PaintStatus {
GP_STATUS_IDLING = 0, /* stroke isn't in progress yet */
GP_STATUS_PAINTING, /* a stroke is in progress */
GP_STATUS_ERROR, /* something wasn't correctly set up */
- GP_STATUS_DONE /* painting done */
+ GP_STATUS_DONE, /* painting done */
+ GP_STATUS_CAPTURE /* capture event, but cancel */
} eGPencil_PaintStatus;
/* Return flags for adding points to stroke buffer */
@@ -223,10 +224,10 @@ static bool gpencil_draw_poll(bContext *C)
Object *obact = CTX_data_active_object(C);
ScrArea *sa = CTX_wm_area(C);
if ((sa) && (sa->spacetype == SPACE_VIEW3D)) {
- if ((obact) && (obact->type == OB_GPENCIL)
- && (obact->mode == OB_MODE_PAINT_GPENCIL)) {
- CTX_wm_operator_poll_msg_set(C,
- "Annotation cannot be used in grease pencil draw mode");
+ if ((obact) && (obact->type == OB_GPENCIL) &&
+ (obact->mode == OB_MODE_PAINT_GPENCIL))
+ {
+ CTX_wm_operator_poll_msg_set(C, "Annotation cannot be used in grease pencil draw mode");
return false;
}
}
@@ -1328,7 +1329,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
}
if (has_layer_to_erase == false) {
- p->status = GP_STATUS_ERROR;
+ p->status = GP_STATUS_CAPTURE;
//if (G.debug & G_DEBUG)
printf("Error: Eraser will not be affecting anything (gpencil_paint_init)\n");
return;
@@ -1713,6 +1714,7 @@ static void gpencil_draw_status_indicators(bContext *C, tGPsdata *p)
case GP_STATUS_ERROR:
case GP_STATUS_DONE:
+ case GP_STATUS_CAPTURE:
/* clear status string */
ED_workspace_status_text(C, NULL);
break;
@@ -1784,9 +1786,9 @@ static void annotation_draw_apply_event(wmOperator *op, const wmEvent *event, De
float mousef[2];
int tablet = 0;
- /* convert from window-space to area-space mouse coordinates
- * add any x,y override position for fake events
- */
+ /* convert from window-space to area-space mouse coordinates
+ * add any x,y override position for fake events
+ */
p->mval[0] = (float)event->mval[0] - x;
p->mval[1] = (float)event->mval[1] - y;
@@ -2013,6 +2015,14 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
else
p = op->customdata;
+ /* if empty erase capture and finish */
+ if (p->status == GP_STATUS_CAPTURE) {
+ gpencil_draw_exit(C, op);
+
+ BKE_report(op->reports, RPT_ERROR, "Nothing to erase");
+ return OPERATOR_FINISHED;
+ }
+
/* TODO: set any additional settings that we can take from the events?
* TODO? if tablet is erasing, force eraser to be on? */
@@ -2122,8 +2132,7 @@ static void annotation_add_missing_events(bContext *C, wmOperator *op, const wmE
interp_v2_v2v2(pt, a, b, 0.5f);
sub_v2_v2v2(pt, b, pt);
/* create fake event */
- annotation_draw_apply_event(op, event, CTX_data_depsgraph(C),
- pt[0], pt[1]);
+ annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), pt[0], pt[1]);
}
else if (dist >= factor) {
int slices = 2 + (int)((dist - 1.0) / factor);
@@ -2132,8 +2141,9 @@ static void annotation_add_missing_events(bContext *C, wmOperator *op, const wmE
interp_v2_v2v2(pt, a, b, n * i);
sub_v2_v2v2(pt, b, pt);
/* create fake event */
- annotation_draw_apply_event(op, event, CTX_data_depsgraph(C),
- pt[0], pt[1]);
+ annotation_draw_apply_event(
+ op, event, CTX_data_depsgraph(C),
+ pt[0], pt[1]);
}
}
}
@@ -2270,8 +2280,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (G.debug & G_DEBUG) {
printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n",
- current_region, p->ar, event->x, event->y,
- p->sa->totrct.xmin, p->sa->totrct.ymin, p->sa->totrct.xmax, p->sa->totrct.ymax);
+ current_region, p->ar, event->x, event->y,
+ p->sa->totrct.xmin, p->sa->totrct.ymin, p->sa->totrct.xmax, p->sa->totrct.ymax);
}
if (current_region) {
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index dafc9507bd1..711962400ff 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -117,13 +117,6 @@ typedef enum eDrawStrokeFlags {
/* ----- Tool Buffer Drawing ------ */
/* helper functions to set color of buffer point */
-static void gp_set_tpoint_varying_color(const tGPspoint *pt, const float ink[4], uint attr_id)
-{
- float alpha = ink[3] * pt->strength;
- CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
- immAttr4ub(attr_id, F2UB(ink[0]), F2UB(ink[1]), F2UB(ink[2]), F2UB(alpha));
-}
-
static void gp_set_point_uniform_color(const bGPDspoint *pt, const float ink[4])
{
float alpha = ink[3] * pt->strength;
@@ -138,161 +131,6 @@ static void gp_set_point_varying_color(const bGPDspoint *pt, const float ink[4],
immAttr4ub(attr_id, F2UB(ink[0]), F2UB(ink[1]), F2UB(ink[2]), F2UB(alpha));
}
-/* draw fills for buffer stroke */
-static void gp_draw_stroke_buffer_fill(const tGPspoint *points, int totpoints, float ink[4])
-{
- if (totpoints < 3) {
- return;
- }
- int tot_triangles = totpoints - 2;
- /* allocate memory for temporary areas */
- uint(*tmp_triangles)[3] = MEM_mallocN(sizeof(*tmp_triangles) * tot_triangles, "GP Stroke buffer temp triangulation");
- float(*points2d)[2] = MEM_mallocN(sizeof(*points2d) * totpoints, "GP Stroke buffer temp 2d points");
-
- /* Convert points to array and triangulate
- * Here a cache is not used because while drawing the information changes all the time, so the cache
- * would be recalculated constantly, so it is better to do direct calculation for each function call
- */
- for (int i = 0; i < totpoints; i++) {
- const tGPspoint *pt = &points[i];
- points2d[i][0] = pt->x;
- points2d[i][1] = pt->y;
- }
- BLI_polyfill_calc((const float(*)[2])points2d, (uint)totpoints, 0, (uint(*)[3])tmp_triangles);
-
- /* draw triangulation data */
- if (tot_triangles > 0) {
- GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
- uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
-
- /* Draw all triangles for filling the polygon */
- immBegin(GPU_PRIM_TRIS, tot_triangles * 3);
- /* TODO: use batch instead of immediate mode, to share vertices */
-
- const tGPspoint *pt;
- for (int i = 0; i < tot_triangles; i++) {
- /* vertex 1 */
- pt = &points[tmp_triangles[i][0]];
- gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2fv(pos, &pt->x);
- /* vertex 2 */
- pt = &points[tmp_triangles[i][1]];
- gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2fv(pos, &pt->x);
- /* vertex 3 */
- pt = &points[tmp_triangles[i][2]];
- gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2fv(pos, &pt->x);
- }
-
- immEnd();
- immUnbindProgram();
- }
-
- /* clear memory */
- if (tmp_triangles) {
- MEM_freeN(tmp_triangles);
- }
- if (points2d) {
- MEM_freeN(points2d);
- }
-}
-
-/* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */
-static void gp_draw_stroke_buffer(
- const tGPspoint *points, int totpoints, short thickness,
- short dflag, short sflag, float ink[4], float fill_ink[4])
-{
- int draw_points = 0;
-
- /* error checking */
- if ((points == NULL) || (totpoints <= 0))
- return;
-
- /* check if buffer can be drawn */
- if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
- return;
-
- if (sflag & GP_STROKE_ERASER) {
- /* don't draw stroke at all! */
- return;
- }
-
- GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
-
- const tGPspoint *pt = points;
-
- if (totpoints == 1) {
- /* if drawing a single point, draw it larger */
- GPU_point_size((float)(thickness + 2) * points->pressure);
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
- immBegin(GPU_PRIM_POINTS, 1);
- gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2fv(pos, &pt->x);
- }
- else {
- float oldpressure = points[0].pressure;
-
- /* draw stroke curve */
- GPU_line_width(max_ff(oldpressure * thickness, 1.0));
- immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
- immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints);
-
- /* TODO: implement this with a geometry shader to draw one continuous tapered stroke */
-
- 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 (fabsf(pt->pressure - oldpressure) > 0.2f) {
- /* need to have 2 points to avoid immEnd assert error */
- if (draw_points < 2) {
- gp_set_tpoint_varying_color(pt - 1, ink, color);
- immVertex2fv(pos, &(pt - 1)->x);
- }
-
- immEnd();
- draw_points = 0;
-
- GPU_line_width(max_ff(pt->pressure * thickness, 1.0f));
- immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1);
-
- /* need to roll-back one point to ensure that there are no gaps in the stroke */
- if (i != 0) {
- gp_set_tpoint_varying_color(pt - 1, ink, color);
- immVertex2fv(pos, &(pt - 1)->x);
- draw_points++;
- }
-
- oldpressure = pt->pressure; /* reset our threshold */
- }
-
- /* now the point we want */
- gp_set_tpoint_varying_color(pt, ink, color);
- immVertex2fv(pos, &pt->x);
- draw_points++;
- }
- /* need to have 2 points to avoid immEnd assert error */
- if (draw_points < 2) {
- gp_set_tpoint_varying_color(pt - 1, ink, color);
- immVertex2fv(pos, &(pt - 1)->x);
- }
- }
-
- immEnd();
- immUnbindProgram();
-
- // draw fill
- if (fill_ink[3] > GPENCIL_ALPHA_OPACITY_THRESH) {
- gp_draw_stroke_buffer_fill(points, totpoints, fill_ink);
- }
-}
-
/* --------- 2D Stroke Drawing Helpers --------- */
/* change in parameter list */
static void gp_calc_2d_stroke_fxy(const float pt[3], short sflag, int offsx, int offsy, int winx, int winy, float r_co[2])
@@ -318,45 +156,6 @@ static void gp_calc_2d_stroke_fxy(const float pt[3], short sflag, int offsx, int
}
/* ----------- Volumetric Strokes --------------- */
-/* draw a 2D buffer stroke in "volumetric" style
- * NOTE: the stroke buffer doesn't have any coordinate offsets/transforms
- */
-static void gp_draw_stroke_volumetric_buffer(
- const tGPspoint *points, int totpoints, short thickness,
- short dflag, const float ink[4])
-{
- /* error checking */
- if ((points == NULL) || (totpoints <= 0))
- return;
-
- /* check if buffer can be drawn */
- if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
- return;
-
- GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
- GPU_enable_program_point_size();
- immBegin(GPU_PRIM_POINTS, totpoints);
-
- const tGPspoint *pt = points;
- for (int i = 0; i < totpoints; i++, pt++) {
- gp_set_tpoint_varying_color(pt, ink, color);
-
- /* TODO: scale based on view transform (zoom level) */
- immAttr1f(size, pt->pressure * thickness);
-
- immVertex2f(pos, pt->x, pt->y);
- }
-
- immEnd();
- immUnbindProgram();
- GPU_disable_program_point_size();
-}
-
/* draw a 2D strokes in "volumetric" style */
static void gp_draw_stroke_volumetric_2d(
const bGPDspoint *points, int totpoints, short thickness,
@@ -570,8 +369,9 @@ static int gp_set_filling_texture(Image *image, short flag)
return (int)GL_INVALID_OPERATION;
}
- GPU_create_gl_tex(bind, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D,
- false, false, image);
+ GPU_create_gl_tex(
+ bind, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D,
+ false, false, image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -719,9 +519,12 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
immUniform1f("objscale", obj_scale);
int keep_size = (int)((tgpw->gpd) && (tgpw->gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS));
immUniform1i("keep_size", keep_size);
- immUniform1i("pixfactor", tgpw->gpd->pixfactor);
+ immUniform1f("pixfactor", tgpw->gpd->pixfactor);
/* xray mode always to 3D space to avoid wrong zdepth calculation (T60051) */
immUniform1i("xraymode", GP_XRAY_3DSPACE);
+ immUniform1i("caps_start", (int)tgpw->gps->caps[0]);
+ immUniform1i("caps_end", (int)tgpw->gps->caps[1]);
+ immUniform1i("fill_stroke", (int)tgpw->is_fill_stroke);
/* draw stroke curve */
GPU_line_width(max_ff(curpressure * thickness, 1.0f));
@@ -732,23 +535,22 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
/* first point for adjacency (not drawn) */
if (i == 0) {
gp_set_point_varying_color(points, ink, attr_id.color);
- immAttr1f(attr_id.thickness, max_ff(curpressure * thickness, 1.0f));
+
if ((cyclic) && (totpoints > 2)) {
+ immAttr1f(attr_id.thickness, max_ff((points + totpoints - 1)->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 1)->x);
}
else {
+ immAttr1f(attr_id.thickness, max_ff((points + 1)->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + 1)->x);
}
- mul_v3_fl(fpt, -1.0f);
immVertex3fv(attr_id.pos, fpt);
}
/* set point */
gp_set_point_varying_color(pt, ink, attr_id.color);
- immAttr1f(attr_id.thickness, max_ff(curpressure * thickness, 1.0f));
+ immAttr1f(attr_id.thickness, max_ff(pt->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &pt->x);
immVertex3fv(attr_id.pos, fpt);
-
- curpressure = pt->pressure;
}
if (cyclic && totpoints > 2) {
@@ -764,10 +566,9 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
}
/* last adjacency point (not drawn) */
else {
- gp_set_point_varying_color(points + totpoints - 1, ink, attr_id.color);
- immAttr1f(attr_id.thickness, max_ff(curpressure * thickness, 1.0f));
+ gp_set_point_varying_color(points + totpoints - 2, ink, attr_id.color);
+ immAttr1f(attr_id.thickness, max_ff((points + totpoints - 2)->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 2)->x);
- mul_v3_fl(fpt, -1.0f);
immVertex3fv(attr_id.pos, fpt);
}
@@ -1028,6 +829,10 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
/* calculate thickness */
sthickness = gps->thickness + tgpw->lthick;
+ if (tgpw->is_fill_stroke) {
+ sthickness = (short)max_ii(1, sthickness / 2);
+ }
+
if (sthickness <= 0) {
continue;
}
@@ -1099,9 +904,10 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
/* 3D Lines - OpenGL primitives-based */
if (gps->totpoints == 1) {
if (tgpw->disable_fill != 1) {
- gp_draw_stroke_point(gps->points, sthickness, tgpw->dflag, gps->flag,
- tgpw->offsx, tgpw->offsy, tgpw->winx, tgpw->winy,
- tgpw->diff_mat, ink);
+ gp_draw_stroke_point(
+ gps->points, sthickness, tgpw->dflag, gps->flag,
+ tgpw->offsx, tgpw->offsy, tgpw->winx, tgpw->winy,
+ tgpw->diff_mat, ink);
}
}
else {
@@ -1184,166 +990,6 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
GPU_disable_program_point_size();
}
-/* Draw selected verts for strokes being edited */
-static void gp_draw_strokes_edit(
- bGPdata *gpd, const bGPDframe *gpf, int offsx, int offsy, int winx, int winy, short dflag,
- short lflag, const float diff_mat[4][4], float alpha)
-{
- /* if alpha 0 do not draw */
- if (alpha == 0.0f)
- return;
-
- const bool no_xray = (dflag & GP_DRAWDATA_NO_XRAY) != 0;
- int mask_orig = 0;
-
- /* set up depth masks... */
- if (dflag & GP_DRAWDATA_ONLY3D) {
- if (no_xray) {
- glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
- glDepthMask(0);
- GPU_depth_test(true);
-
- /* first arg is normally rv3d->dist, but this isn't
- * available here and seems to work quite well without */
- bglPolygonOffset(1.0f, 1.0f);
- }
- }
-
- GPU_enable_program_point_size();
-
- /* 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)
- 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)
- continue;
-
- /* verify color lock */
- {
- Material *ma = gpd->mat[gps->mat_nr];
- MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL;
-
- if (gp_style != NULL) {
- if (gp_style->flag & GP_STYLE_COLOR_HIDE) {
- continue;
- }
- if (((lflag & GP_LAYER_UNLOCK_COLOR) == 0) && (gp_style->flag & GP_STYLE_COLOR_LOCKED)) {
- continue;
- }
- }
- }
-
- /* Get size of verts:
- * - The selected state needs to be larger than the unselected state so that
- * they stand out more.
- * - We use the theme setting for size of the unselected verts
- */
- float bsize = UI_GetThemeValuef(TH_GP_VERTEX_SIZE);
- float vsize;
- if ((int)bsize > 8) {
- vsize = 10.0f;
- bsize = 8.0f;
- }
- else {
- vsize = bsize + 2;
- }
-
- /* for now, we assume that the base color of the points is not too close to the real color */
- /* set color using material */
- Material *ma = gpd->mat[gps->mat_nr];
- MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL;
-
- float selectColor[4];
- UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, selectColor);
- selectColor[3] = alpha;
-
- GPUVertFormat *format = immVertexFormat();
- uint pos; /* specified later */
- uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
-
- if (gps->flag & GP_STROKE_3DSPACE) {
- pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
- }
- else {
- pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR);
- }
-
- immBegin(GPU_PRIM_POINTS, gps->totpoints);
-
- /* Draw start and end point differently if enabled stroke direction hint */
- bool show_direction_hint = (gpd->flag & GP_DATA_SHOW_DIRECTION) && (gps->totpoints > 1);
-
- /* Draw all the stroke points (selected or not) */
- bGPDspoint *pt = gps->points;
- float fpt[3];
- for (int i = 0; i < gps->totpoints; i++, pt++) {
- /* size and color first */
- if (show_direction_hint && i == 0) {
- /* start point in green bigger */
- immAttr3f(color, 0.0f, 1.0f, 0.0f);
- immAttr1f(size, vsize + 4);
- }
- else if (show_direction_hint && (i == gps->totpoints - 1)) {
- /* end point in red smaller */
- immAttr3f(color, 1.0f, 0.0f, 0.0f);
- immAttr1f(size, vsize + 1);
- }
- else if (pt->flag & GP_SPOINT_SELECT) {
- immAttr3fv(color, selectColor);
- immAttr1f(size, vsize);
- }
- else if (gp_style) {
- immAttr3fv(color, gp_style->stroke_rgba);
- immAttr1f(size, bsize);
- }
- else {
- immAttr3f(color, 0.0f, 0.0f, 0.0f);
- immAttr1f(size, bsize);
- }
-
- /* then position */
- if (gps->flag & GP_STROKE_3DSPACE) {
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
- immVertex3fv(pos, fpt);
- }
- else {
- float co[2];
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
- gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
- immVertex2fv(pos, co);
- }
- }
-
- immEnd();
- immUnbindProgram();
- }
-
- GPU_disable_program_point_size();
-
- /* clear depth mask */
- if (dflag & GP_DRAWDATA_ONLY3D) {
- if (no_xray) {
- glDepthMask(mask_orig);
- GPU_depth_test(false);
-
- bglPolygonOffset(0.0, 0.0);
-#if 0
- glDisable(GL_POLYGON_OFFSET_LINE);
- glPolygonOffset(0, 0);
-#endif
- }
- }
-}
-
/* ----- General Drawing ------ */
@@ -1378,7 +1024,7 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in
tgpw.dflag = dflag;
/* turn on alpha-blending */
- glEnable(GL_BLEND);
+ GPU_blend(true);
for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) {
/* calculate parent position */
ED_gpencil_parent_location(depsgraph, obact, tgpi->gpd, tgpil->gpl, tgpw.diff_mat);
@@ -1396,7 +1042,7 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in
gp_draw_strokes(&tgpw);
}
}
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
/* wrapper to draw strokes for filling operator */
@@ -1405,113 +1051,6 @@ void ED_gp_draw_fill(tGPDdraw *tgpw)
gp_draw_strokes(tgpw);
}
-/* loop over gpencil data layers, drawing them */
-static void gp_draw_data_layers(RegionView3D *rv3d,
- const Brush *brush, float alpha, Object *ob, bGPdata *gpd,
- int offsx, int offsy, int winx, int winy, int cfra, int dflag)
-{
- float diff_mat[4][4];
- tGPDdraw tgpw;
-
- tgpw.rv3d = rv3d;
- tgpw.depsgraph = NULL; /* XXX: This is not used here */
- tgpw.ob = ob;
- tgpw.gpd = gpd;
- tgpw.gpl = NULL;
- tgpw.gpf = NULL;
- tgpw.t_gpf = NULL;
- tgpw.offsx = offsx;
- tgpw.offsy = offsy;
- tgpw.winx = winx;
- tgpw.winy = winy;
- tgpw.dflag = dflag;
-
- for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* calculate parent position */
- ED_gpencil_parent_location(tgpw.depsgraph, ob, gpd, gpl, diff_mat);
-
- short lthick = brush->size + gpl->line_change;
-
- /* don't draw layer if hidden */
- 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)
- continue;
-
- /* set basic stroke thickness */
- GPU_line_width(lthick);
-
- /* Add layer drawing settings to the set of "draw flags"
- * NOTE: If the setting doesn't apply, it *must* be cleared,
- * as dflag's carry over from the previous layer
- */
-
- /* xray... */
- SET_FLAG_FROM_TEST(dflag, gpl->flag & GP_LAYER_NO_XRAY, GP_DRAWDATA_NO_XRAY);
-
- /* volumetric strokes... */
- SET_FLAG_FROM_TEST(dflag, gpl->flag & GP_LAYER_VOLUMETRIC, GP_DRAWDATA_VOLUMETRIC);
-
- tgpw.gpl = gpl;
- tgpw.gpf = gpf;
- tgpw.t_gpf = gpf; // XXX?
- tgpw.lthick = gpl->line_change;
- tgpw.opacity = gpl->opacity;
- copy_v4_v4(tgpw.tintcolor, gpl->tintcolor);
- tgpw.onion = false;
- tgpw.custonion = false;
- copy_m4_m4(tgpw.diff_mat, diff_mat);
-
- /* draw the strokes already in active frame */
- gp_draw_strokes(&tgpw);
-
- /* Draw verts of selected strokes
- * - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering
- * - locked layers can't be edited, so there's no point showing these verts
- * as they will have no bearings on what gets edited
- * - only show when in editmode, since operators shouldn't work otherwise
- * (NOTE: doing it this way means that the toggling editmode shows visible change immediately)
- */
- /* XXX: perhaps we don't want to show these when users are drawing... */
- if ((G.f & G_FLAG_RENDER_VIEWPORT) == 0 &&
- (gpl->flag & GP_LAYER_LOCKED) == 0 &&
- (gpd->flag & GP_DATA_STROKE_EDITMODE))
- {
- gp_draw_strokes_edit(gpd, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, diff_mat, alpha);
- }
-
- /* Check if may need to draw the active stroke cache, only if this layer is the active layer
- * that is being edited. (Stroke buffer is currently stored in gp-data)
- */
- if (ED_gpencil_session_active() && (gpl->flag & GP_LAYER_ACTIVE) &&
- (gpf->flag & GP_FRAME_PAINT))
- {
- /* Buffer stroke needs to be drawn with a different linestyle
- * to help differentiate them from normal strokes.
- *
- * It should also be noted that sbuffer contains temporary point types
- * i.e. tGPspoints NOT bGPDspoints
- */
- if (gpd->runtime.mode == GP_STYLE_MODE_DOTS) {
- gp_draw_stroke_volumetric_buffer(
- gpd->runtime.sbuffer,
- gpd->runtime.sbuffer_size, lthick,
- dflag, gpd->runtime.scolor);
- }
- else {
- gp_draw_stroke_buffer(
- gpd->runtime.sbuffer,
- gpd->runtime.sbuffer_size, lthick,
- dflag, gpd->runtime.sbuffer_sflag,
- gpd->runtime.scolor, gpd->runtime.sfill);
- }
- }
- }
-}
-
/* draw a short status message in the top-right corner */
static void UNUSED_FUNCTION(gp_draw_status_text)(const bGPdata *gpd, ARegion *ar)
{
@@ -1557,199 +1096,3 @@ static void UNUSED_FUNCTION(gp_draw_status_text)(const bGPdata *gpd, ARegion *ar
GPU_blend(false);
}
}
-
-/* draw grease-pencil datablock */
-static void gp_draw_data(RegionView3D *rv3d,
- const Brush *brush, float alpha, Object *ob, bGPdata *gpd,
- int offsx, int offsy, int winx, int winy, int cfra, int dflag)
-{
- /* turn on smooth lines (i.e. anti-aliasing) */
- GPU_line_smooth(true);
-
- /* XXX: turn on some way of ensuring that the polygon edges get smoothed
- * GL_POLYGON_SMOOTH is nasty and shouldn't be used, as it ends up
- * creating internal white rays due to the ways it accumulates stuff
- */
-
- /* turn on alpha-blending */
- GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- GPU_blend(true);
-
- /* draw! */
- gp_draw_data_layers(rv3d, brush, alpha, ob, gpd, offsx, offsy, winx, winy, cfra, dflag);
-
- /* turn off alpha blending, then smooth lines */
- GPU_blend(false); // alpha blending
- GPU_line_smooth(false); // smooth lines
-}
-
-/* if we have strokes for scenes (3d view)/clips (movie clip editor)
- * and objects/tracks, multiple data blocks have to be drawn */
-static void gp_draw_data_all(
- ViewLayer *view_layer, RegionView3D *rv3d, Scene *scene, bGPdata *gpd,
- int offsx, int offsy, int winx, int winy,
- int cfra, int dflag, const char UNUSED(spacetype))
-{
- bGPdata *gpd_source = NULL;
- Brush *brush = NULL;
- Object *ob = OBACT(view_layer);
- if (scene) {
- ToolSettings *ts = scene->toolsettings;
- brush = BKE_paint_brush(&ts->gp_paint->paint);
-
- if (gpd_source) {
- if (brush != NULL) {
- gp_draw_data(
- rv3d, brush, 1.0f, ob, gpd_source,
- offsx, offsy, winx, winy, cfra, dflag);
- }
- }
- }
-
- /* scene/clip data has already been drawn, only object/track data is drawn here
- * if gpd_source == gpd, we don't have any object/track data and we can skip */
- if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) {
- if (brush != NULL) {
- gp_draw_data(
- rv3d, brush, 1.0f, ob, gpd,
- offsx, offsy, winx, winy, cfra, dflag);
- }
- }
-}
-
-/* ----- Grease Pencil Sketches Drawing API ------ */
-
-
-/* draw grease-pencil sketches to specified 3d-view assuming that matrices are already set correctly
- * Note: this gets called twice - first time with only3d=true to draw 3d-strokes,
- * second time with only3d=false for screen-aligned strokes */
-void ED_gpencil_draw_view3d(
- wmWindowManager *wm,
- Scene *scene,
- ViewLayer *view_layer,
- struct Depsgraph *depsgraph,
- View3D *v3d,
- ARegion *ar,
- bool only3d)
-{
- int dflag = 0;
- RegionView3D *rv3d = ar->regiondata;
- int offsx, offsy, winx, winy;
-
- /* check that we have grease-pencil stuff to draw */
- // XXX: This is the only place that still uses this function
- bGPdata *gpd = ED_gpencil_data_get_active_v3d(view_layer, v3d);
- 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. */
- if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_FLAG_RENDER_VIEWPORT)) {
- rctf rectf;
- ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &rectf, true); /* no shift */
-
- offsx = round_fl_to_int(rectf.xmin);
- offsy = round_fl_to_int(rectf.ymin);
- winx = round_fl_to_int(rectf.xmax - rectf.xmin);
- winy = round_fl_to_int(rectf.ymax - rectf.ymin);
- }
- else {
- offsx = 0;
- offsy = 0;
- winx = ar->winx;
- winy = ar->winy;
- }
-
- /* set flags */
- if (only3d) {
- /* 3D strokes/3D space:
- * - only 3D space points
- * - don't status text either (as it's the wrong space)
- */
- dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS);
- }
-
- if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
- /* don't draw status text when "only render" flag is set */
- dflag |= GP_DRAWDATA_NOSTATUS;
- }
-
- if ((wm == NULL) || ED_screen_animation_playing(wm)) {
- /* don't show onion-skins during animation playback/scrub (i.e. it obscures the poses)
- * OpenGL Renders (i.e. final output), or depth buffer (i.e. not real strokes)
- */
- dflag |= GP_DRAWDATA_NO_ONIONS;
- }
-
- /* draw it! */
- gp_draw_data_all(view_layer, rv3d, scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
-}
-
-/* draw grease-pencil sketches to specified 3d-view for gp object
- * assuming that matrices are already set correctly
- */
-void ED_gpencil_draw_view3d_object(wmWindowManager *wm, Scene *scene, Depsgraph *depsgraph, Object *ob, View3D *v3d, ARegion *ar, bool only3d)
-{
- int dflag = 0;
- RegionView3D *rv3d = ar->regiondata;
- int offsx, offsy, winx, winy;
-
- /* check that we have grease-pencil stuff to draw */
- bGPdata *gpd = ob->data;
- 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. */
- if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_FLAG_RENDER_VIEWPORT)) {
- rctf rectf;
- ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &rectf, true); /* no shift */
-
- offsx = round_fl_to_int(rectf.xmin);
- offsy = round_fl_to_int(rectf.ymin);
- winx = round_fl_to_int(rectf.xmax - rectf.xmin);
- winy = round_fl_to_int(rectf.ymax - rectf.ymin);
- }
- else {
- offsx = 0;
- offsy = 0;
- winx = ar->winx;
- winy = ar->winy;
- }
-
- /* set flags */
- if (only3d) {
- /* 3D strokes/3D space:
- * - only 3D space points
- * - don't status text either (as it's the wrong space)
- */
- dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS);
- }
-
- if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
- /* don't draw status text when "only render" flag is set */
- dflag |= GP_DRAWDATA_NOSTATUS;
- }
-
- if ((wm == NULL) || ED_screen_animation_playing(wm)) {
- /* don't show onion-skins during animation playback/scrub (i.e. it obscures the poses)
- * OpenGL Renders (i.e. final output), or depth buffer (i.e. not real strokes)
- */
- dflag |= GP_DRAWDATA_NO_ONIONS;
- }
-
- /* draw it! */
- ToolSettings *ts = scene->toolsettings;
- Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
- if (brush != NULL) {
- gp_draw_data(rv3d, brush, 1.0f, ob, gpd,
- offsx, offsy, winx, winy, CFRA, dflag);
- }
-}
-
-void ED_gpencil_draw_ex(
- ViewLayer *view_layer, RegionView3D *rv3d, Scene *scene,
- bGPdata *gpd, int winx, int winy, const int cfra, const char spacetype)
-{
- int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D;
-
- gp_draw_data_all(view_layer, rv3d, scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype);
-}
diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil/gpencil_add_monkey.c
index 302a6fb10f6..cd28043a6fe 100644
--- a/source/blender/editors/gpencil/gpencil_add_monkey.c
+++ b/source/blender/editors/gpencil/gpencil_add_monkey.c
@@ -31,6 +31,7 @@
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
+#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_material.h"
@@ -59,10 +60,10 @@ static int gpencil_monkey_color(
}
}
+ int idx;
+
/* create a new one */
- BKE_object_material_slot_add(bmain, ob);
- ma = BKE_material_add_gpencil(bmain, pct->name);
- assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
+ ma = BKE_gpencil_handle_new_material(bmain, ob, pct->name, &idx);
copy_v4_v4(ma->gp_style->stroke_rgba, pct->line);
copy_v4_v4(ma->gp_style->fill_rgba, pct->fill);
@@ -78,7 +79,7 @@ static int gpencil_monkey_color(
ma->gp_style->flag |= GP_STYLE_FILL_SHOW;
}
- return BKE_gpencil_get_material_index(ob, ma) - 1;
+ return idx;
}
/* ***************************************************************** */
@@ -1445,10 +1446,6 @@ void ED_gpencil_create_monkey(bContext *C, Object *ob, float mat[4][4])
/* set first color as active */
ob->actcol = color_Black + 1;
- Material *ma = give_current_material(ob, ob->actcol);
- if (ma != NULL) {
- BKE_brush_update_material(bmain, ma, NULL);
- }
/* layers */
/* NOTE: For now, we just add new layers, to make it easier to separate out old/new instances */
diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c
index e02fc4bf801..c56cb94c58d 100644
--- a/source/blender/editors/gpencil/gpencil_add_stroke.c
+++ b/source/blender/editors/gpencil/gpencil_add_stroke.c
@@ -31,6 +31,7 @@
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
+#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_material.h"
@@ -47,7 +48,8 @@ typedef struct ColorTemplate {
} ColorTemplate;
/* Add color an ensure duplications (matched by name) */
-static int gp_stroke_material(Main *bmain, Object *ob, const ColorTemplate *pct)
+static int gp_stroke_material(
+ Main *bmain, Object *ob, const ColorTemplate *pct, const bool fill)
{
short *totcol = give_totcolp(ob);
Material *ma = NULL;
@@ -58,19 +60,19 @@ static int gp_stroke_material(Main *bmain, Object *ob, const ColorTemplate *pct)
}
}
+ int idx;
+
/* create a new one */
- BKE_object_material_slot_add(bmain, ob);
- ma = BKE_material_add_gpencil(bmain, pct->name);
- assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
+ ma = BKE_gpencil_handle_new_material(bmain, ob, pct->name, &idx);
copy_v4_v4(ma->gp_style->stroke_rgba, pct->line);
copy_v4_v4(ma->gp_style->fill_rgba, pct->fill);
- if (pct->fill) {
+ if (fill) {
ma->gp_style->flag |= GP_STYLE_FILL_SHOW;
}
- return BKE_gpencil_get_material_index(ob, ma) - 1;
+ return idx;
}
/* ***************************************************************** */
@@ -219,19 +221,15 @@ void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4])
bGPDstroke *gps;
/* create colors */
- int color_black = gp_stroke_material(bmain, ob, &gp_stroke_material_black);
- gp_stroke_material(bmain, ob, &gp_stroke_material_white);
- gp_stroke_material(bmain, ob, &gp_stroke_material_red);
- gp_stroke_material(bmain, ob, &gp_stroke_material_green);
- gp_stroke_material(bmain, ob, &gp_stroke_material_blue);
- gp_stroke_material(bmain, ob, &gp_stroke_material_grey);
+ int color_black = gp_stroke_material(bmain, ob, &gp_stroke_material_black, false);
+ gp_stroke_material(bmain, ob, &gp_stroke_material_white, false);
+ gp_stroke_material(bmain, ob, &gp_stroke_material_red, false);
+ gp_stroke_material(bmain, ob, &gp_stroke_material_green, false);
+ gp_stroke_material(bmain, ob, &gp_stroke_material_blue, false);
+ gp_stroke_material(bmain, ob, &gp_stroke_material_grey, true);
/* set first color as active and in brushes */
ob->actcol = color_black + 1;
- Material *ma = give_current_material(ob, ob->actcol);
- if (ma != NULL) {
- BKE_brush_update_material(bmain, ma, NULL);
- }
/* layers */
bGPDlayer *colors = BKE_gpencil_layer_addnew(gpd, "Colors", false);
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index 97f5db96a89..a482eb837e7 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -576,14 +576,14 @@ static int gpencil_generate_weights_exec(bContext *C, wmOperator *op)
GpencilModifierData *md = BKE_gpencil_modifiers_findByType(ob_eval, eGpencilModifierType_Armature);
if (md == NULL) {
BKE_report(op->reports, RPT_ERROR,
- "The grease pencil object need an Armature modifier");
+ "The grease pencil object need an Armature modifier");
return OPERATOR_CANCELLED;
}
ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md;
if (mmd->object == NULL) {
BKE_report(op->reports, RPT_ERROR,
- "Armature modifier is not valid or wrong defined");
+ "Armature modifier is not valid or wrong defined");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index ee1838af22a..6b646566996 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -176,18 +176,54 @@ static void gpsculpt_compute_lock_axis(tGP_BrushEditData *gso, bGPDspoint *pt, c
return;
}
- ToolSettings *ts = gso->scene->toolsettings;
- int axis = ts->gp_sculpt.lock_axis;
+ const ToolSettings *ts = gso->scene->toolsettings;
+ const View3DCursor *cursor = &gso->scene->cursor;
+ const int axis = ts->gp_sculpt.lock_axis;
/* lock axis control */
- if (axis == 1) {
- pt->x = save_pt[0];
- }
- if (axis == 2) {
- pt->y = save_pt[1];
- }
- if (axis == 3) {
- pt->z = save_pt[2];
+ switch (axis) {
+ case GP_LOCKAXIS_X:
+ {
+ pt->x = save_pt[0];
+ break;
+ }
+ case GP_LOCKAXIS_Y:
+ {
+ pt->y = save_pt[1];
+ break;
+ }
+ case GP_LOCKAXIS_Z:
+ {
+ pt->z = save_pt[2];
+ break;
+ }
+ case GP_LOCKAXIS_CURSOR:
+ {
+ /* compute a plane with cursor normal and position of the point
+ before do the sculpt */
+ const float scale[3] = { 1.0f, 1.0f, 1.0f };
+ float plane_normal[3] = { 0.0f, 0.0f, 1.0f };
+ float plane[4];
+ float mat[4][4];
+ float r_close[3];
+
+ loc_eul_size_to_mat4(mat,
+ cursor->location,
+ cursor->rotation_euler,
+ scale);
+
+ mul_mat3_m4_v3(mat, plane_normal);
+ plane_from_point_normal_v3(plane, save_pt, plane_normal);
+
+ /* find closest point to the plane with the new position */
+ closest_to_plane_v3(r_close, plane, &pt->x);
+ copy_v3_v3(&pt->x, r_close);
+ break;
+ }
+ default:
+ {
+ break;
+ }
}
}
@@ -1065,14 +1101,10 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
/* Fix color references */
Material *ma = BLI_ghash_lookup(data->new_colors, &new_stroke->mat_nr);
- if ((ma) && (BKE_gpencil_get_material_index(ob, ma) > 0)) {
- gps->mat_nr = BKE_gpencil_get_material_index(ob, ma) - 1;
- CLAMP_MIN(gps->mat_nr, 0);
+ gps->mat_nr = BKE_gpencil_get_material_index(ob, ma);
+ if (!ma || gps->mat_nr) {
+ gps->mat_nr = 0;
}
- else {
- gps->mat_nr = 0; /* only if the color is not found */
- }
-
/* Adjust all the stroke's points, so that the strokes
* get pasted relative to where the cursor is now
*/
@@ -1269,7 +1301,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
if (found == false) {
/* STOP HERE! Nothing to paste! */
BKE_report(op->reports, RPT_ERROR,
- "Copy some strokes to the clipboard before using the Clone brush to paste copies of them");
+ "Copy some strokes to the clipboard before using the Clone brush to paste copies of them");
MEM_freeN(gso);
op->customdata = NULL;
@@ -1853,8 +1885,7 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve
/* the operator cannot work while play animation */
if (is_playing) {
- BKE_report(op->reports, RPT_ERROR,
- "Cannot sculpt while play animation");
+ BKE_report(op->reports, RPT_ERROR, "Cannot sculpt while play animation");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index cfcfc49b081..e3d57149d0f 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -89,6 +89,18 @@
/* Datablock Operators */
/* ******************* Add New Data ************************ */
+static bool gp_data_add_poll(bContext *C)
+{
+ Object *obact = CTX_data_active_object(C);
+ if (obact && obact->type == OB_GPENCIL) {
+ if (obact->mode != OB_MODE_OBJECT) {
+ return false;
+ }
+ }
+
+ /* the base line we have is that we have somewhere to add Grease Pencil data */
+ return ED_gpencil_data_get_pointers(C, NULL) != NULL;
+}
/* add new datablock - wrapper around API */
static int gp_data_add_exec(bContext *C, wmOperator *op)
@@ -153,7 +165,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot)
/* callbacks */
ot->exec = gp_data_add_exec;
- ot->poll = gp_add_poll;
+ ot->poll = gp_data_add_poll;
}
/* ******************* Unlink Data ************************ */
@@ -163,6 +175,13 @@ static bool gp_data_unlink_poll(bContext *C)
{
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
+ /* only unlink annotation datablocks */
+ if ((gpd_ptr != NULL) && (*gpd_ptr != NULL)) {
+ bGPdata *gpd = (*gpd_ptr);
+ if ((gpd->flag & GP_DATA_ANNOTATIONS) == 0) {
+ return false;
+ }
+ }
/* if we have access to some active data, make sure there's a datablock before enabling this */
return (gpd_ptr && *gpd_ptr);
}
@@ -194,9 +213,9 @@ static int gp_data_unlink_exec(bContext *C, wmOperator *op)
void GPENCIL_OT_data_unlink(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Grease Pencil Unlink";
+ ot->name = "Annotation Unlink";
ot->idname = "GPENCIL_OT_data_unlink";
- ot->description = "Unlink active Grease Pencil data-block";
+ ot->description = "Unlink active Annotation data-block";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* callbacks */
@@ -502,15 +521,10 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op)
* otherwise add the slot with the material
*/
Material *ma_src = give_current_material(ob_src, gps_src->mat_nr + 1);
- int idx = BKE_gpencil_get_material_index(ob_dst, ma_src);
- if (idx == 0) {
- BKE_object_material_slot_add(bmain, ob_dst);
- assign_material(bmain, ob_dst, ma_src, ob_dst->totcol, BKE_MAT_ASSIGN_USERPREF);
- idx = ob_dst->totcol;
- }
+ int idx = BKE_gpencil_handle_material(bmain, ob_dst, ma_src);
/* reasign the stroke material to the right slot in destination object */
- gps_dst->mat_nr = idx - 1;
+ gps_dst->mat_nr = idx;
/* add new stroke to frame */
BLI_addtail(&gpf_dst->strokes, gps_dst);
@@ -1365,7 +1379,7 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *op)
}
}
/* try to find slot */
- int idx = BKE_gpencil_get_material_index(ob, ma) - 1;
+ int idx = BKE_gpencil_get_material_index(ob, ma);
if (idx < 0) {
return OPERATOR_CANCELLED;
}
@@ -2040,10 +2054,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
for (short i = 0; i < *totcol; i++) {
Material *tmp_ma = give_current_material(ob_src, i + 1);
- if (BKE_gpencil_get_material_index(ob_dst, tmp_ma) == 0) {
- BKE_object_material_slot_add(bmain, ob_dst);
- assign_material(bmain, ob_dst, tmp_ma, ob_dst->totcol, BKE_MAT_ASSIGN_USERPREF);
- }
+ BKE_gpencil_handle_material(bmain, ob_dst, tmp_ma);
}
/* duplicate bGPDlayers */
@@ -2073,24 +2084,12 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
invert_m4_m4(inverse_diff_mat, diff_mat);
Material *ma_src = NULL;
- int idx;
for (bGPDframe *gpf = gpl_new->frames.first; gpf; gpf = gpf->next) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* reasign material. Look old material and try to find in dst */
ma_src = give_current_material(ob_src, gps->mat_nr + 1);
- if (ma_src != NULL) {
- idx = BKE_gpencil_get_material_index(ob_dst, ma_src);
- if (idx > 0) {
- gps->mat_nr = idx - 1;
- }
- else {
- gps->mat_nr = 0;
- }
- }
- else {
- gps->mat_nr = 0;
- }
+ gps->mat_nr = BKE_gpencil_handle_material(bmain, ob_dst, ma_src);
bGPDspoint *pt;
int i;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 088282c0f02..99d37f87da7 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -563,7 +563,7 @@ static int gpencil_hideselect_toggle_exec(bContext *C, wmOperator *UNUSED(op))
void GPENCIL_OT_selection_opacity_toggle(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Hide Selection";
+ ot->name = "Hide Selected";
ot->idname = "GPENCIL_OT_selection_opacity_toggle";
ot->description = "Hide/Unhide selected points for Grease Pencil strokes setting alpha factor";
@@ -757,11 +757,11 @@ void GPENCIL_OT_duplicate(wmOperatorType *ot)
/* ************** Extrude Selected Strokes **************** */
/* helper to copy a point to temp area */
-static void copy_point(
+static void copy_move_point(
bGPDstroke *gps,
bGPDspoint *temp_points,
MDeformVert *temp_dverts,
- int from_idx, int to_idx)
+ int from_idx, int to_idx, const bool copy)
{
bGPDspoint *pt = &temp_points[from_idx];
bGPDspoint *pt_final = &gps->points[to_idx];
@@ -779,7 +779,13 @@ static void copy_point(
MDeformVert *dvert_final = &gps->dvert[to_idx];
dvert_final->totweight = dvert->totweight;
- dvert_final->dw = dvert->dw;
+ /* if copy, duplicate memory, otherwise move only the pointer */
+ if (copy) {
+ dvert_final->dw = MEM_dupallocN(dvert->dw);
+ }
+ else {
+ dvert_final->dw = dvert->dw;
+ }
}
}
@@ -794,7 +800,7 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
const bool do_last = ((pt_last->flag & GP_SPOINT_SELECT) && (pt_start != pt_last));
const bool do_stroke = (do_first || do_last);
- /* review points in the midle of stroke to create new strokes */
+ /* review points in the middle of stroke to create new strokes */
for (int i = 0; i < gps->totpoints; i++) {
/* skip first and last point */
if ((i == 0) || (i == gps->totpoints - 1)) {
@@ -822,7 +828,7 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
BLI_insertlinkafter(&gpf->strokes, gps, gps_new);
/* copy selected point data to new stroke */
- copy_point(gps_new, gps->points, gps->dvert, i, 0);
+ copy_move_point(gps_new, gps->points, gps->dvert, i, 0, true);
/* deselect orinal point */
pt->flag &= ~GP_SPOINT_SELECT;
@@ -863,14 +869,14 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
/* move points to new position */
for (int i = 0; i < oldtotpoints; i++) {
- copy_point(gps, temp_points, temp_dverts, i, i2);
+ copy_move_point(gps, temp_points, temp_dverts, i, i2, false);
i2++;
}
gps->flag |= GP_STROKE_RECALC_GEOMETRY;
/* if first point, add new point at the begining */
if (do_first) {
- copy_point(gps, temp_points, temp_dverts, 0, 0);
+ copy_move_point(gps, temp_points, temp_dverts, 0, 0, true);
/* deselect old */
pt = &gps->points[1];
pt->flag &= ~GP_SPOINT_SELECT;
@@ -881,8 +887,9 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
/* if last point, add new point at the end */
if (do_last) {
- copy_point(gps, temp_points, temp_dverts,
- oldtotpoints - 1, gps->totpoints - 1);
+ copy_move_point(
+ gps, temp_points, temp_dverts,
+ oldtotpoints - 1, gps->totpoints - 1, true);
/* deselect old */
pt = &gps->points[gps->totpoints - 2];
@@ -1073,10 +1080,7 @@ GHash *gp_copybuf_validate_colormap(bContext *C)
char *ma_name = BLI_ghashIterator_getValue(&gh_iter);
Material *ma = BLI_ghash_lookup(name_to_ma, ma_name);
- if (ma != NULL && BKE_gpencil_get_material_index(ob, ma) == 0) {
- BKE_object_material_slot_add(bmain, ob);
- assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
- }
+ BKE_gpencil_handle_material(bmain, ob, ma);
/* Store this mapping (for use later when pasting) */
if (!BLI_ghash_haskey(new_colors, POINTER_FROM_INT(*key))) {
@@ -1330,14 +1334,8 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
/* Remap material */
Material *ma = BLI_ghash_lookup(new_colors, POINTER_FROM_INT(new_stroke->mat_nr));
- if ((ma) && (BKE_gpencil_get_material_index(ob, ma) > 0)) {
- new_stroke->mat_nr = BKE_gpencil_get_material_index(ob, ma) - 1;
- CLAMP_MIN(new_stroke->mat_nr, 0);
- }
- else {
- new_stroke->mat_nr = 0; /* only if the color is not found */
- }
-
+ new_stroke->mat_nr = BKE_gpencil_get_material_index(ob, ma);
+ BLI_assert(new_stroke->mat_nr >= 0); /* have to add the material first */
}
}
}
@@ -2600,8 +2598,9 @@ void GPENCIL_OT_snap_to_cursor(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- ot->prop = RNA_def_boolean(ot->srna, "use_offset", true, "With Offset",
- "Offset the entire stroke instead of selected points only");
+ ot->prop = RNA_def_boolean(
+ ot->srna, "use_offset", true, "With Offset",
+ "Offset the entire stroke instead of selected points only");
}
/* ------------------------------- */
@@ -3278,6 +3277,8 @@ typedef enum eGP_ReprojectModes {
GP_REPROJECT_VIEW,
/* Reprojected on to the scene geometry */
GP_REPROJECT_SURFACE,
+ /* Reprojected on 3D cursor orientation */
+ GP_REPROJECT_CURSOR,
} eGP_ReprojectModes;
static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
@@ -3332,9 +3333,17 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
gp_point_to_xy_fl(&gsc, gps, &pt2, &xy[0], &xy[1]);
/* Project stroke in one axis */
- if (ELEM(mode, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE, GP_REPROJECT_TOP)) {
- ED_gp_get_drawing_reference(scene, ob, gpl,
- ts->gpencil_v3d_align, origin);
+ if (ELEM(mode, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE,
+ GP_REPROJECT_TOP, GP_REPROJECT_CURSOR))
+ {
+ if (mode != GP_REPROJECT_CURSOR) {
+ ED_gp_get_drawing_reference(
+ scene, ob, gpl,
+ ts->gpencil_v3d_align, origin);
+ }
+ else {
+ copy_v3_v3(origin, scene->cursor.location);
+ }
int axis = 0;
switch (mode) {
@@ -3353,6 +3362,11 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
axis = 2;
break;
}
+ case GP_REPROJECT_CURSOR:
+ {
+ axis = 3;
+ break;
+ }
default:
{
axis = 1;
@@ -3360,8 +3374,9 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
}
}
- ED_gp_project_point_to_plane(ob, rv3d, origin,
- axis, &pt2);
+ ED_gp_project_point_to_plane(
+ scene, ob, rv3d, origin,
+ axis, &pt2);
copy_v3_v3(&pt->x, &pt2.x);
@@ -3423,6 +3438,8 @@ void GPENCIL_OT_reproject(wmOperatorType *ot)
"using 'Cursor' Stroke Placement"},
{GP_REPROJECT_SURFACE, "SURFACE", 0, "Surface",
"Reproject the strokes on to the scene geometry, as if drawn using 'Surface' placement"},
+ {GP_REPROJECT_CURSOR, "CURSOR", 0, "Cursor",
+ "Reproject the strokes using the orienation of 3D cursor"},
{0, NULL, 0, NULL, NULL},
};
@@ -3666,8 +3683,9 @@ void GPENCIL_OT_stroke_subdivide(wmOperatorType *ot)
RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, 2.0f, "Smooth", "", 0.0f, 2.0f);
prop = RNA_def_int(ot->srna, "repeat", 1, 1, 10, "Repeat", "", 1, 5);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- RNA_def_boolean(ot->srna, "only_selected", true, "Selected Points",
- "Smooth only selected points in the stroke");
+ RNA_def_boolean(
+ ot->srna, "only_selected", true, "Selected Points",
+ "Smooth only selected points in the stroke");
RNA_def_boolean(ot->srna, "smooth_position", true, "Position", "");
RNA_def_boolean(ot->srna, "smooth_thickness", true, "Thickness", "");
RNA_def_boolean(ot->srna, "smooth_strength", false, "Strength", "");
@@ -3894,9 +3912,6 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
gpd_dst = BKE_gpencil_data_addnew(bmain, gpd_src->id.name + 2);
ob_dst->data = (bGPdata *)gpd_dst;
- int totslots = ob_dst->totcol;
- int totadd = 0;
-
/* loop old datablock and separate parts */
if ((mode == GP_SEPARATE_POINT) || (mode == GP_SEPARATE_STROKE)) {
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
@@ -3941,21 +3956,8 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
}
/* add duplicate materials */
- ma = give_current_material(ob, gps->mat_nr + 1);
- idx = BKE_gpencil_get_material_index(ob_dst, ma);
- if (idx == 0) {
-
- totadd++;
- ob_dst->actcol = totadd;
- ob_dst->totcol = totadd;
-
- if (totadd > totslots) {
- BKE_object_material_slot_add(bmain, ob_dst);
- }
-
- assign_material(bmain, ob_dst, ma, ob_dst->totcol, BKE_MAT_ASSIGN_USERPREF);
- idx = totadd;
- }
+ ma = give_current_material(ob, gps->mat_nr + 1); /* XXX same material can be in multiple slots */
+ idx = BKE_gpencil_handle_material(bmain, ob_dst, ma);
/* selected points mode */
if (mode == GP_SEPARATE_POINT) {
@@ -3963,7 +3965,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps);
/* reasign material */
- gps_dst->mat_nr = idx - 1;
+ gps_dst->mat_nr = idx;
/* link to destination frame */
BLI_addtail(&gpf_dst->strokes, gps_dst);
@@ -3989,7 +3991,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
/* relink to destination frame */
BLI_addtail(&gpf_dst->strokes, gps);
/* reasign material */
- gps->mat_nr = idx - 1;
+ gps->mat_nr = idx;
}
}
}
@@ -4027,21 +4029,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
continue;
}
ma = give_current_material(ob, gps->mat_nr + 1);
- idx = BKE_gpencil_get_material_index(ob_dst, ma);
- if (idx == 0) {
- totadd++;
- ob_dst->actcol = totadd;
- ob_dst->totcol = totadd;
-
- if (totadd > totslots) {
- BKE_object_material_slot_add(bmain, ob_dst);
- }
-
- assign_material(bmain, ob_dst, ma, ob_dst->totcol, BKE_MAT_ASSIGN_USERPREF);
- idx = totadd;
- }
- /* reasign material */
- gps->mat_nr = idx - 1;
+ gps->mat_nr = BKE_gpencil_handle_material(bmain, ob_dst, ma);
}
}
}
@@ -4224,8 +4212,9 @@ void GPENCIL_OT_stroke_smooth(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_float(ot->srna, "factor", 0.5f, 0.0f, 2.0f, "Factor", "", 0.0f, 2.0f);
- RNA_def_boolean(ot->srna, "only_selected", true, "Selected Points",
- "Smooth only selected points in the stroke");
+ RNA_def_boolean(
+ ot->srna, "only_selected", true, "Selected Points",
+ "Smooth only selected points in the stroke");
RNA_def_boolean(ot->srna, "smooth_position", true, "Position", "");
RNA_def_boolean(ot->srna, "smooth_thickness", true, "Thickness", "");
RNA_def_boolean(ot->srna, "smooth_strength", false, "Strength", "");
@@ -4306,7 +4295,7 @@ static void gpencil_cutter_dissolve(bGPDlayer *hit_layer, bGPDstroke *hit_stroke
}
}
gp_stroke_delete_tagged_points(
- hit_layer->actframe, hit_stroke, gpsn, GP_SPOINT_TAG, false, 1);
+ hit_layer->actframe, hit_stroke, gpsn, GP_SPOINT_TAG, false, 1);
}
}
@@ -4365,7 +4354,7 @@ static int gpencil_cutter_lasso_select(
float r_hita[3], r_hitb[3];
if (gps->totpoints > 1) {
ED_gpencil_select_stroke_segment(
- gpl, gps, pt, true, true, scale, r_hita, r_hitb);
+ gpl, gps, pt, true, true, scale, r_hita, r_hitb);
}
/* avoid infinite loops */
if (gps->totpoints > oldtot) {
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 680568a96c5..5922872070d 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -132,6 +132,8 @@ typedef struct tGPDfill {
int fill_simplylvl;
/** boundary limits drawing mode */
int fill_draw_mode;
+ /* scaling factor */
+ short fill_factor;
/** number of elements currently in cache */
short sbuffer_size;
@@ -146,6 +148,13 @@ typedef struct tGPDfill {
BLI_Stack *stack;
/** handle for drawing strokes while operator is running 3d stuff */
void *draw_handle_3d;
+
+ /* tmp size x */
+ int bwinx;
+ /* tmp size y */
+ int bwiny;
+ rcti brect;
+
} tGPDfill;
@@ -232,7 +241,7 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
tgpw.disable_fill = 1;
tgpw.dflag |= (GP_DRAWFILLS_ONLY3D | GP_DRAWFILLS_NOSTATUS);
- glEnable(GL_BLEND);
+ GPU_blend(true);
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* calculate parent position */
@@ -271,23 +280,27 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
tgpw.t_gpf = gpf;
/* reduce thickness to avoid gaps */
- tgpw.lthick = gpl->line_change - 4;
+ tgpw.is_fill_stroke = (tgpf->fill_draw_mode == GP_FILL_DMODE_CONTROL) ? false : true ;
+ tgpw.lthick = gpl->line_change;
tgpw.opacity = 1.0;
copy_v4_v4(tgpw.tintcolor, ink);
tgpw.onion = true;
tgpw.custonion = true;
+ bool textured_stroke = (gp_style->stroke_style == GP_STYLE_STROKE_STYLE_TEXTURE);
+
/* normal strokes */
- if ((tgpf->fill_draw_mode == GP_FILL_DMODE_STROKE) ||
- (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH))
+ if (((tgpf->fill_draw_mode == GP_FILL_DMODE_STROKE) ||
+ (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) &&
+ !textured_stroke)
{
ED_gp_draw_fill(&tgpw);
-
}
/* 3D Lines with basic shapes and invisible lines */
if ((tgpf->fill_draw_mode == GP_FILL_DMODE_CONTROL) ||
- (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH))
+ (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH) ||
+ textured_stroke)
{
gp_draw_basic_stroke(
tgpf, gps, tgpw.diff_mat, gps->flag & GP_STROKE_CYCLIC, ink,
@@ -296,21 +309,49 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
}
}
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
/* draw strokes in offscreen buffer */
-static void gp_render_offscreen(tGPDfill *tgpf)
+static bool gp_render_offscreen(tGPDfill *tgpf)
{
bool is_ortho = false;
float winmat[4][4];
if (!tgpf->gpd) {
- return;
+ return false;
}
+ /* set temporary new size */
+ tgpf->bwinx = tgpf->ar->winx;
+ tgpf->bwiny = tgpf->ar->winy;
+ tgpf->brect = tgpf->ar->winrct;
+
+ /* resize ar */
+ tgpf->ar->winrct.xmin = 0;
+ tgpf->ar->winrct.ymin = 0;
+ tgpf->ar->winrct.xmax = (int)tgpf->ar->winx * tgpf->fill_factor;
+ tgpf->ar->winrct.ymax = (int)tgpf->ar->winy * tgpf->fill_factor;
+ tgpf->ar->winx = (short)abs(tgpf->ar->winrct.xmax - tgpf->ar->winrct.xmin);
+ tgpf->ar->winy = (short)abs(tgpf->ar->winrct.ymax - tgpf->ar->winrct.ymin);
+
+ /* save new size */
+ tgpf->sizex = (int)tgpf->ar->winx;
+ tgpf->sizey = (int)tgpf->ar->winy;
+
+ /* adjust center */
+ float center[2];
+ center[0] = (float)tgpf->center[0] * ((float)tgpf->ar->winx / (float)tgpf->bwinx);
+ center[1] = (float)tgpf->center[1] * ((float)tgpf->ar->winy / (float)tgpf->bwiny);
+ round_v2i_v2fl(tgpf->center, center);
+
char err_out[256] = "unknown";
GPUOffScreen *offscreen = GPU_offscreen_create(tgpf->sizex, tgpf->sizey, 0, true, false, err_out);
+ if (offscreen == NULL) {
+ printf("GPencil - Fill - Unable to create fill buffer\n");
+ return false;
+ }
+
GPU_offscreen_bind(offscreen, true);
uint flag = IB_rect | IB_rectfloat;
ImBuf *ibuf = IMB_allocImBuf(tgpf->sizex, tgpf->sizey, 32, flag);
@@ -328,18 +369,6 @@ static void gp_render_offscreen(tGPDfill *tgpf)
perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clip_start, clip_end);
}
- /* set temporary new size */
- int bwinx = tgpf->ar->winx;
- int bwiny = tgpf->ar->winy;
- rcti brect = tgpf->ar->winrct;
-
- tgpf->ar->winx = (short)tgpf->sizex;
- tgpf->ar->winy = (short)tgpf->sizey;
- tgpf->ar->winrct.xmin = 0;
- tgpf->ar->winrct.ymin = 0;
- tgpf->ar->winrct.xmax = tgpf->sizex;
- tgpf->ar->winrct.ymax = tgpf->sizey;
-
GPU_matrix_push_projection();
GPU_matrix_identity_set();
GPU_matrix_push();
@@ -349,8 +378,8 @@ static void gp_render_offscreen(tGPDfill *tgpf)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ED_view3d_update_viewmat(
- tgpf->depsgraph, tgpf->scene, tgpf->v3d, tgpf->ar,
- NULL, winmat, NULL);
+ tgpf->depsgraph, tgpf->scene, tgpf->v3d, tgpf->ar,
+ NULL, winmat, NULL);
/* set for opengl */
GPU_matrix_projection_set(tgpf->rv3d->winmat);
GPU_matrix_set(tgpf->rv3d->viewmat);
@@ -359,11 +388,6 @@ static void gp_render_offscreen(tGPDfill *tgpf)
float ink[4] = {1.0f, 0.0f, 0.0f, 1.0f};
gp_draw_datablock(tgpf, ink);
- /* restore size */
- tgpf->ar->winx = (short)bwinx;
- tgpf->ar->winy = (short)bwiny;
- tgpf->ar->winrct = brect;
-
GPU_matrix_pop_projection();
GPU_matrix_pop();
@@ -386,6 +410,8 @@ static void gp_render_offscreen(tGPDfill *tgpf)
/* switch back to window-system-provided framebuffer */
GPU_offscreen_unbind(offscreen, true);
GPU_offscreen_free(offscreen);
+
+ return true;
}
/* return pixel data (rgba) at index */
@@ -459,7 +485,8 @@ static bool is_leak_narrow(ImBuf *ibuf, const int maxpixel, int limit, int index
}
}
else {
- t_a = true; /* edge of image*/
+ /* edge of image*/
+ t_a = true;
break;
}
}
@@ -474,7 +501,8 @@ static bool is_leak_narrow(ImBuf *ibuf, const int maxpixel, int limit, int index
}
}
else {
- t_b = true; /* edge of image*/
+ /* edge of image*/
+ t_b = true;
break;
}
}
@@ -543,7 +571,7 @@ static void gpencil_boundaryfill_area(tGPDfill *tgpf)
/* calculate index of the seed point using the position of the mouse */
int index = (tgpf->sizex * tgpf->center[1]) + tgpf->center[0];
- if ((index >= 0) && (index < maxpixel)) {
+ if ((index >= 0) && (index <= maxpixel)) {
BLI_stack_push(stack, &index);
}
@@ -561,6 +589,7 @@ static void gpencil_boundaryfill_area(tGPDfill *tgpf)
*/
while (!BLI_stack_is_empty(stack)) {
int v;
+
BLI_stack_pop(stack, &v);
get_pixel(ibuf, v, rgba);
@@ -568,7 +597,7 @@ static void gpencil_boundaryfill_area(tGPDfill *tgpf)
if (true) { /* Was: 'rgba' */
/* check if no border(red) or already filled color(green) */
if ((rgba[0] != 1.0f) && (rgba[1] != 1.0f)) {
- /* fill current pixel */
+ /* fill current pixel with green */
set_pixel(ibuf, v, fill_col);
/* add contact pixels */
@@ -580,22 +609,22 @@ static void gpencil_boundaryfill_area(tGPDfill *tgpf)
}
}
/* pixel right */
- if (v + 1 < maxpixel) {
+ if (v + 1 <= maxpixel) {
index = v + 1;
if (!is_leak_narrow(ibuf, maxpixel, tgpf->fill_leak, v, LEAK_HORZ)) {
BLI_stack_push(stack, &index);
}
}
/* pixel top */
- if (v + tgpf->sizex < maxpixel) {
- index = v + tgpf->sizex;
+ if (v + ibuf->x <= maxpixel) {
+ index = v + ibuf->x;
if (!is_leak_narrow(ibuf, maxpixel, tgpf->fill_leak, v, LEAK_VERT)) {
BLI_stack_push(stack, &index);
}
}
/* pixel bottom */
- if (v - tgpf->sizex >= 0) {
- index = v - tgpf->sizex;
+ if (v - ibuf->x >= 0) {
+ index = v - ibuf->x;
if (!is_leak_narrow(ibuf, maxpixel, tgpf->fill_leak, v, LEAK_VERT)) {
BLI_stack_push(stack, &index);
}
@@ -625,7 +654,7 @@ static void gpencil_clean_borders(tGPDfill *tgpf)
int pixel = 0;
/* horizontal lines */
- for (idx = 0; idx < ibuf->x - 1; idx++) {
+ for (idx = 0; idx < ibuf->x; idx++) {
/* bottom line */
set_pixel(ibuf, idx, fill_col);
/* top line */
@@ -649,12 +678,117 @@ static void gpencil_clean_borders(tGPDfill *tgpf)
tgpf->ima->id.tag |= LIB_TAG_DOIT;
}
+/* Naive dilate
+ *
+ * Expand green areas into enclosing red areas.
+ * Using stack prevents creep when replacing colors directly.
+ * -----------
+ * XXXXXXX
+ * XoooooX
+ * XXooXXX
+ * XXXX
+ * -----------
+ */
+static void dilate(ImBuf *ibuf)
+{
+ BLI_Stack *stack = BLI_stack_new(sizeof(int), __func__);
+ const float green[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
+ const int maxpixel = (ibuf->x * ibuf->y) - 1;
+ /* detect pixels and expand into red areas */
+ for (int v = maxpixel; v != 0; v--) {
+ float color[4];
+ int index;
+ int tp = 0;
+ int bm = 0;
+ int lt = 0;
+ int rt = 0;
+ get_pixel(ibuf, v, color);
+ if (color[1] == 1.0f) {
+ /* pixel left */
+ if (v - 1 >= 0) {
+ index = v - 1;
+ get_pixel(ibuf, index, color);
+ if (color[0] == 1.0f) {
+ BLI_stack_push(stack, &index);
+ lt = index;
+ }
+ }
+ /* pixel right */
+ if (v + 1 <= maxpixel) {
+ index = v + 1;
+ get_pixel(ibuf, index, color);
+ if (color[0] == 1.0f) {
+ BLI_stack_push(stack, &index);
+ rt = index;
+ }
+ }
+ /* pixel top */
+ if (v + ibuf->x <= maxpixel) {
+ index = v + ibuf->x;
+ get_pixel(ibuf, index, color);
+ if (color[0] == 1.0f) {
+ BLI_stack_push(stack, &index);
+ tp = index;
+ }
+ }
+ /* pixel bottom */
+ if (v - ibuf->x >= 0) {
+ index = v - ibuf->x;
+ get_pixel(ibuf, index, color);
+ if (color[0] == 1.0f) {
+ BLI_stack_push(stack, &index);
+ bm = index;
+ }
+ }
+ /* pixel top-left */
+ if (tp && lt) {
+ index = tp - 1;
+ get_pixel(ibuf, index, color);
+ if (color[0] == 1.0f) {
+ BLI_stack_push(stack, &index);
+ }
+ }
+ /* pixel top-right */
+ if (tp && rt) {
+ index = tp + 1;
+ get_pixel(ibuf, index, color);
+ if (color[0] == 1.0f) {
+ BLI_stack_push(stack, &index);
+ }
+ }
+ /* pixel bottom-left */
+ if (bm && lt) {
+ index = bm - 1;
+ get_pixel(ibuf, index, color);
+ if (color[0] == 1.0f) {
+ BLI_stack_push(stack, &index);
+ }
+ }
+ /* pixel bottom-right */
+ if (bm && rt) {
+ index = bm + 1;
+ get_pixel(ibuf, index, color);
+ if (color[0] == 1.0f) {
+ BLI_stack_push(stack, &index);
+ }
+ }
+ }
+ }
+ /* set dilated pixels */
+ while (!BLI_stack_is_empty(stack)) {
+ int v;
+ BLI_stack_pop(stack, &v);
+ set_pixel(ibuf, v, green);
+ }
+ BLI_stack_free(stack);
+}
+
/* Get the outline points of a shape using Moore Neighborhood algorithm
*
* This is a Blender customized version of the general algorithm described
* in https://en.wikipedia.org/wiki/Moore_neighborhood
*/
-static void gpencil_get_outline_points(tGPDfill *tgpf)
+static void gpencil_get_outline_points(tGPDfill *tgpf)
{
ImBuf *ibuf;
float rgba[4];
@@ -686,6 +820,9 @@ static void gpencil_get_outline_points(tGPDfill *tgpf)
ibuf = BKE_image_acquire_ibuf(tgpf->ima, NULL, &lock);
int imagesize = ibuf->x * ibuf->y;
+ /* dilate */
+ dilate(ibuf);
+
/* find the initial point to start outline analysis */
for (int idx = imagesize - 1; idx != 0; idx--) {
get_pixel(ibuf, idx, rgba);
@@ -835,9 +972,9 @@ static void gpencil_points_from_stack(tGPDfill *tgpf)
while (!BLI_stack_is_empty(tgpf->stack)) {
int v[2];
BLI_stack_pop(tgpf->stack, &v);
- point2D->x = v[0];
- point2D->y = v[1];
-
+ copy_v2fl_v2i(&point2D->x, v);
+ /* shift points to center of pixel */
+ add_v2_fl(&point2D->x, 0.5f);
point2D->pressure = 1.0f;
point2D->strength = 1.0f;
point2D->time = 0.0f;
@@ -880,12 +1017,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
gps->flag |= GP_STROKE_CYCLIC;
gps->flag |= GP_STROKE_3DSPACE;
- gps->mat_nr = BKE_gpencil_get_material_index(tgpf->ob, tgpf->mat) - 1;
- if (gps->mat_nr < 0) {
- BKE_object_material_slot_add(tgpf->bmain, tgpf->ob);
- assign_material(tgpf->bmain, tgpf->ob, tgpf->mat, tgpf->ob->totcol, BKE_MAT_ASSIGN_USERPREF);
- gps->mat_nr = tgpf->ob->totcol - 1;
- }
+ gps->mat_nr = BKE_gpencil_handle_material(tgpf->bmain, tgpf->ob, tgpf->mat);
/* allocate memory for storage points */
gps->totpoints = tgpf->sbuffer_size;
@@ -962,7 +1094,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
tgpf->scene, tgpf->ob, tgpf->gpl,
ts->gpencil_v3d_align, origin);
ED_gp_project_stroke_to_plane(
- tgpf->ob, tgpf->rv3d, gps, origin,
+ tgpf->scene, tgpf->ob, tgpf->rv3d, gps, origin,
tgpf->lock_axis - 1);
}
@@ -1018,19 +1150,28 @@ static void gpencil_fill_draw_3d(const bContext *C, ARegion *UNUSED(ar), void *a
/* check if context is suitable for filling */
static bool gpencil_fill_poll(bContext *C)
{
+ Object *obact = CTX_data_active_object(C);
+
if (ED_operator_regionactive(C)) {
ScrArea *sa = CTX_wm_area(C);
if (sa->spacetype == SPACE_VIEW3D) {
- return 1;
+ if ((obact == NULL) ||
+ (obact->type != OB_GPENCIL) ||
+ (obact->mode != OB_MODE_PAINT_GPENCIL))
+ {
+ return false;
+ }
+
+ return true;
}
else {
CTX_wm_operator_poll_msg_set(C, "Active region not valid for filling operator");
- return 0;
+ return false;
}
}
else {
CTX_wm_operator_poll_msg_set(C, "Active region not set");
- return 0;
+ return false;
}
}
@@ -1076,18 +1217,20 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
tgpf->fill_threshold = brush->gpencil_settings->fill_threshold;
tgpf->fill_simplylvl = brush->gpencil_settings->fill_simplylvl;
tgpf->fill_draw_mode = brush->gpencil_settings->fill_draw_mode;
+ tgpf->fill_factor = (short)max_ii(1, min_ii((int)brush->gpencil_settings->fill_factor, 8));
+
+ int totcol = tgpf->ob->totcol;
/* get color info */
- Material *ma = BKE_gpencil_get_material_from_brush(brush);
- /* if no brush defaults, get material and color info */
- if ((ma == NULL) || (ma->gp_style == NULL)) {
- ma = BKE_gpencil_material_ensure(bmain, tgpf->ob);
- /* assign always the first material to the brush */
- brush->gpencil_settings->material = give_current_material(tgpf->ob, 1);
- }
+ Material *ma = BKE_gpencil_current_input_brush_material(bmain, tgpf->ob, brush);
tgpf->mat = ma;
+ /* check whether the material was newly added */
+ if (totcol != tgpf->ob->totcol) {
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_PROPERTIES, NULL);
+ }
+
/* init undo */
gpencil_undo_init(tgpf->gpd);
@@ -1242,30 +1385,33 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
tgpf->center[0] = event->mval[0];
tgpf->center[1] = event->mval[1];
- /* save size */
- tgpf->sizex = ar->winx;
- tgpf->sizey = ar->winy;
-
/* render screen to temp image */
- gp_render_offscreen(tgpf);
+ if ( gp_render_offscreen(tgpf) ) {
+
+ /* apply boundary fill */
+ gpencil_boundaryfill_area(tgpf);
- /* apply boundary fill */
- gpencil_boundaryfill_area(tgpf);
+ /* clean borders to avoid infinite loops */
+ gpencil_clean_borders(tgpf);
- /* clean borders to avoid infinite loops */
- gpencil_clean_borders(tgpf);
+ /* analyze outline */
+ gpencil_get_outline_points(tgpf);
- /* analyze outline */
- gpencil_get_outline_points(tgpf);
+ /* create array of points from stack */
+ gpencil_points_from_stack(tgpf);
- /* create array of points from stack */
- gpencil_points_from_stack(tgpf);
+ /* create z-depth array for reproject */
+ gpencil_get_depth_array(tgpf);
- /* create z-depth array for reproject */
- gpencil_get_depth_array(tgpf);
+ /* create stroke and reproject */
+ gpencil_stroke_from_buffer(tgpf);
+
+ }
- /* create stroke and reproject */
- gpencil_stroke_from_buffer(tgpf);
+ /* restore size */
+ tgpf->ar->winx = (short)tgpf->bwinx;
+ tgpf->ar->winy = (short)tgpf->bwiny;
+ tgpf->ar->winrct = tgpf->brect;
/* free temp stack data */
if (tgpf->stack) {
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 4fba83a5f02..aa47319e3d9 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -92,6 +92,7 @@ typedef struct tGPDdraw {
float tintcolor[4]; /* tint color */
bool onion; /* onion flag */
bool custonion; /* use custom onion colors */
+ bool is_fill_stroke; /* use fill tool */
float diff_mat[4][4]; /* matrix */
} tGPDdraw;
diff --git a/source/blender/editors/gpencil/gpencil_old.c b/source/blender/editors/gpencil/gpencil_old.c
index b1924b3cacd..47654b69da4 100644
--- a/source/blender/editors/gpencil/gpencil_old.c
+++ b/source/blender/editors/gpencil/gpencil_old.c
@@ -112,9 +112,7 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *UNUSED(op))
for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
/* create material slot */
- BKE_object_material_slot_add(bmain, ob);
- Material *ma = BKE_material_add_gpencil(bmain, palcolor->info);
- assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
+ Material *ma = BKE_gpencil_handle_new_material(bmain, ob, palcolor->info, NULL);
/* copy color settings */
MaterialGPencilStyle *gp_style = ma->gp_style;
@@ -187,7 +185,7 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *UNUSED(op))
* to put them into from here...
*/
printf("WARNING: Old Grease Pencil data ('%s') still exists on Object '%s'\n",
- ob->gpd->id.name + 2, ob->id.name + 2);
+ ob->gpd->id.name + 2, ob->id.name + 2);
}
}
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index a9d680fd7d9..b66956b090d 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -302,6 +302,12 @@ static bool gpencil_draw_poll(bContext *C)
return false;
}
+ ToolSettings *ts = CTX_data_scene(C)->toolsettings;
+ if (!ts->gp_paint->paint.brush) {
+ CTX_wm_operator_poll_msg_set(C, "Grease Pencil has no active paint tool");
+ return false;
+ }
+
return true;
}
else {
@@ -398,7 +404,9 @@ static void gp_reproject_toplane(tGPsdata *p, bGPDstroke *gps)
/* get drawing origin */
gp_get_3d_reference(p, origin);
- ED_gp_project_stroke_to_plane(obact, rv3d, gps, origin, p->lock_axis - 1);
+ ED_gp_project_stroke_to_plane(
+ p->scene, obact, rv3d, gps,
+ origin, p->lock_axis - 1);
}
/* convert screen-coordinates to buffer-coordinates */
@@ -426,8 +434,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[
* - nothing more needs to be done here, since view_autodist_simple() has already done it
*/
- /* verify valid zdepth, if it's wrong, the default drawing mode is used
- * and the function doesn't return now */
+ /* verify valid zdepth, if it's wrong, the default drawing mode is used
+ * and the function doesn't return now */
if ((depth == NULL) || (*depth <= 1.0f)) {
return;
}
@@ -501,11 +509,11 @@ static void gp_brush_jitter(
static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const float mval[2])
{
float mvec[2];
- float sen = brush->gpencil_settings->draw_angle_factor; /* sensitivity */;
+ float sen = brush->gpencil_settings->draw_angle_factor; /* sensitivity */
float fac;
float mpressure;
- /* default angle of brush in radians */;
+ /* default angle of brush in radians */
float angle = brush->gpencil_settings->draw_angle;
/* angle vector of the brush with full thickness */
float v0[2] = { cos(angle), sin(angle) };
@@ -752,11 +760,11 @@ static short gp_stroke_addpoint(
gp_get_3d_reference(p, origin);
/* reproject current */
ED_gpencil_tpoint_to_point(p->ar, origin, pt, &spt);
- ED_gp_project_point_to_plane(obact, rv3d, origin, p->lock_axis - 1, &spt);
+ ED_gp_project_point_to_plane(p->scene, obact, rv3d, origin, p->lock_axis - 1, &spt);
/* reproject previous */
ED_gpencil_tpoint_to_point(p->ar, origin, ptb, &spt2);
- ED_gp_project_point_to_plane(obact, rv3d, origin, p->lock_axis - 1, &spt2);
+ ED_gp_project_point_to_plane(p->scene, obact, rv3d, origin, p->lock_axis - 1, &spt2);
p->totpixlen += len_v3v3(&spt.x, &spt2.x) / pixsize;
pt->uv_fac = p->totpixlen;
if ((gp_style) && (gp_style->sima)) {
@@ -830,7 +838,7 @@ static short gp_stroke_addpoint(
if (gpencil_project_check(p)) {
view3d_region_operator_needs_opengl(p->win, p->ar);
ED_view3d_autodist_init(
- p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+ p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
}
/* convert screen-coordinates to appropriate coordinates (and store them) */
@@ -1215,7 +1223,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
}
/* Save material index */
- gps->mat_nr = BKE_gpencil_get_material_index(p->ob, p->material) - 1;
+ gps->mat_nr = BKE_gpencil_get_material_index_for_brush(p->ob, p->brush);
/* calculate UVs along the stroke */
ED_gpencil_calc_stroke_uv(obact, gps);
@@ -1355,11 +1363,10 @@ static void gp_free_stroke(bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps)
* to avoid that segments gets the end points rounded.
* The round caps breaks the artistic effect.
*/
-static void gp_stroke_soft_refine(bGPDstroke *gps, const float cull_thresh)
+static void gp_stroke_soft_refine(bGPDstroke *gps)
{
bGPDspoint *pt = NULL;
- bGPDspoint *pt_before = NULL;
- bGPDspoint *pt_after = NULL;
+ bGPDspoint *pt2 = NULL;
int i;
/* check if enough points*/
@@ -1367,41 +1374,25 @@ static void gp_stroke_soft_refine(bGPDstroke *gps, const float cull_thresh)
return;
}
- /* loop all points from second to last minus one
- * to untag any point that is not surrounded by tagged points
- */
+ /* loop all points to untag any point that next is not tagged */
pt = gps->points;
for (i = 1; i < gps->totpoints - 1; i++, pt++) {
if (pt->flag & GP_SPOINT_TAG) {
- pt_before = &gps->points[i - 1];
- pt_after = &gps->points[i + 1];
-
- /* if any of the side points are not tagged, mark to keep */
- if (((pt_before->flag & GP_SPOINT_TAG) == 0) ||
- ((pt_after->flag & GP_SPOINT_TAG) == 0))
- {
- if (pt->pressure > cull_thresh) {
- pt->flag |= GP_SPOINT_TEMP_TAG;
- }
- }
- else {
- /* reduce opacity of extreme points */
- if ((pt_before->flag & GP_SPOINT_TAG) == 0) {
- pt_before->strength *= 0.5f;
- }
- if ((pt_after->flag & GP_SPOINT_TAG) == 0) {
- pt_after->strength *= 0.5f;
- }
+ pt2 = &gps->points[i + 1];
+ if ((pt2->flag & GP_SPOINT_TAG) == 0) {
+ pt->flag &= ~GP_SPOINT_TAG;
}
}
}
- /* now untag temp tagged */
- pt = gps->points;
- for (i = 1; i < gps->totpoints - 1; i++, pt++) {
- if (pt->flag & GP_SPOINT_TEMP_TAG) {
- pt->flag &= ~GP_SPOINT_TAG;
- pt->flag &= ~GP_SPOINT_TEMP_TAG;
+ /* loop reverse all points to untag any point that previous is not tagged */
+ pt = &gps->points[gps->totpoints - 1];
+ for (i = gps->totpoints - 1; i > 0; i--, pt--) {
+ if (pt->flag & GP_SPOINT_TAG) {
+ pt2 = &gps->points[i - 1];
+ if ((pt2->flag & GP_SPOINT_TAG) == 0) {
+ pt->flag &= ~GP_SPOINT_TAG;
+ }
}
}
}
@@ -1473,19 +1464,15 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
}
}
else {
- /* Pressure threshold at which stroke should be culled: Calculated as pressure value
- * below which we would have invisible strokes
- */
- const float cull_thresh = (gps->thickness) ? 1.0f / ((float)gps->thickness) : 1.0f;
+ /* Pressure threshold at which stroke should be culled */
+ const float cull_thresh = 0.005f;
/* Amount to decrease the pressure of each point with each stroke */
- // TODO: Fetch from toolsettings, or compute based on thickness instead?
const float strength = 0.1f;
/* Perform culling? */
bool do_cull = false;
-
/* Clear Tags
*
* Note: It's better this way, as we are sure that
@@ -1551,20 +1538,24 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
if (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_SOFT) {
float f_strength = eraser->gpencil_settings->era_strength_f / 100.0f;
float f_thickness = eraser->gpencil_settings->era_thickness_f / 100.0f;
+ float influence = 0.0f;
if (pt0) {
- pt0->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc0) * strength * f_strength * 0.5f;
+ influence = gp_stroke_eraser_calc_influence(p, mval, radius, pc0);
+ pt0->strength -= influence * strength * f_strength * 0.5f;
CLAMP_MIN(pt0->strength, 0.0f);
- pt0->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc0) * strength * f_thickness * 0.5f;
+ pt0->pressure -= influence * strength * f_thickness * 0.5f;
}
- pt1->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength * f_strength;
+ influence = gp_stroke_eraser_calc_influence(p, mval, radius, pc1);
+ pt1->strength -= influence * strength * f_strength;
CLAMP_MIN(pt1->strength, 0.0f);
- pt1->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength * f_thickness;
+ pt1->pressure -= influence * strength * f_thickness;
- pt2->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength * f_strength * 0.5f;
+ influence = gp_stroke_eraser_calc_influence(p, mval, radius, pc2);
+ pt2->strength -= influence * strength * f_strength * 0.5f;
CLAMP_MIN(pt2->strength, 0.0f);
- pt2->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength * f_thickness * 0.5f;
+ pt2->pressure -= influence * strength * f_thickness * 0.5f;
/* if invisible, delete point */
if ((pt0) &&
@@ -1611,7 +1602,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
/* if soft eraser, must analyze points to be sure the stroke ends
* don't get rounded */
if (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_SOFT) {
- gp_stroke_soft_refine(gps, cull_thresh);
+ gp_stroke_soft_refine(gps);
}
gp_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
@@ -1832,31 +1823,10 @@ static void gp_init_colors(tGPsdata *p)
bGPdata *gpd = p->gpd;
Brush *brush = p->brush;
- Material *ma = NULL;
MaterialGPencilStyle *gp_style = NULL;
/* use brush material */
- ma = BKE_gpencil_get_material_from_brush(brush);
-
- /* if no brush defaults, get material and color info
- * NOTE: Ensures that everything we need will exist...
- */
- if ((ma == NULL) || (ma->gp_style == NULL)) {
- BKE_gpencil_material_ensure(p->bmain, p->ob);
-
- /* assign always the first material to the brush */
- p->material = give_current_material(p->ob, 1);
- brush->gpencil_settings->material = p->material;
- }
- else {
- p->material = ma;
- }
-
- /* check if the material is already on object material slots and add it if missing */
- if (BKE_gpencil_get_material_index(p->ob, p->material) == 0) {
- BKE_object_material_slot_add(p->bmain, p->ob);
- assign_material(p->bmain, p->ob, ma, p->ob->totcol, BKE_MAT_ASSIGN_USERPREF);
- }
+ p->material = BKE_gpencil_current_input_brush_material(p->bmain, p->ob, brush);
/* assign color information to temp tGPsdata */
gp_style = p->material->gp_style;
@@ -1994,7 +1964,14 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
/* NOTE: This is only done for 3D view, as Materials aren't used for
* annotations in 2D editors
*/
+ int totcol = p->ob->totcol;
+
gp_init_colors(p);
+
+ /* check whether the material was newly added */
+ if (totcol != p->ob->totcol) {
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_PROPERTIES, NULL);
+ }
}
/* lock axis (in some modes, disable) */
@@ -2306,10 +2283,11 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
immUniform1f("dash_width", 12.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_circle_wire_2d(shdr_pos, x, y, p->radius,
- /* XXX Dashed shader gives bad results with sets of small segments currently,
- * temp hack around the issue. :( */
- max_ii(8, p->radius / 2)); /* was fixed 40 */
+ imm_draw_circle_wire_2d(
+ shdr_pos, x, y, p->radius,
+ /* XXX Dashed shader gives bad results with sets of small segments currently,
+ * temp hack around the issue. :( */
+ max_ii(8, p->radius / 2)); /* was fixed 40 */
immUnbindProgram();
@@ -2392,6 +2370,8 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
gpencil_undo_finish();
/* cleanup */
+ WM_cursor_modal_set(p->win, CURSOR_STD);
+
gp_paint_cleanup(p);
gp_session_cleanup(p);
ED_gpencil_toggle_brush_cursor(C, true, NULL);
@@ -2469,7 +2449,6 @@ static void gpencil_draw_cursor_set(tGPsdata *p)
}
else {
WM_cursor_modal_set(p->win, CURSOR_NONE);
-
}
}
@@ -2478,25 +2457,6 @@ static void gpencil_draw_status_indicators(bContext *C, tGPsdata *p)
{
/* header prints */
switch (p->status) {
-
-#if 0 /* FIXME, this never runs! */
- switch (p->paintmode) {
- case GP_PAINTMODE_DRAW_POLY:
- /* Provide usage tips, since this is modal, and unintuitive without hints */
- ED_workspace_status_text(
- C, IFACE_(
- "Annotation Create Poly: LMB click to place next stroke vertex | "
- "ESC/Enter to end (or click outside this area)"
- ));
- break;
- default:
- /* Do nothing - the others are self explanatory, exit quickly once the mouse is released
- * Showing any text would just be annoying as it would flicker.
- */
- break;
- }
-#endif
-
case GP_STATUS_IDLING:
{
/* print status info */
@@ -3381,8 +3341,7 @@ static void gpencil_add_missing_events(bContext *C, wmOperator *op, const wmEven
interp_v2_v2v2(pt, a, b, 0.5f);
sub_v2_v2v2(pt, b, pt);
/* create fake event */
- gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C),
- pt[0], pt[1]);
+ gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]);
}
else if (dist >= factor) {
int slices = 2 + (int)((dist - 1.0) / factor);
@@ -3391,8 +3350,9 @@ static void gpencil_add_missing_events(bContext *C, wmOperator *op, const wmEven
interp_v2_v2v2(pt, a, b, n * i);
sub_v2_v2v2(pt, b, pt);
/* create fake event */
- gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C),
- pt[0], pt[1]);
+ gpencil_draw_apply_event(
+ C, op, event, CTX_data_depsgraph(C),
+ pt[0], pt[1]);
}
}
}
@@ -3595,8 +3555,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (G.debug & G_DEBUG) {
printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n",
- current_region, p->ar, event->x, event->y,
- p->sa->totrct.xmin, p->sa->totrct.ymin, p->sa->totrct.xmax, p->sa->totrct.ymax);
+ current_region, p->ar, event->x, event->y,
+ p->sa->totrct.xmin, p->sa->totrct.ymin, p->sa->totrct.xmax, p->sa->totrct.ymax);
}
if (current_region) {
@@ -3684,7 +3644,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)) && guide->use_guide) {
+ if (((p->flags & GP_PAINTFLAG_FIRSTRUN) == 0) || (guide->use_guide)) {
gpencil_add_missing_events(C, op, event, p);
}
@@ -3772,7 +3732,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* event doesn't need to be handled */
#if 0
printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n",
- event->type, event->type == MIDDLEMOUSE, event->type == MOUSEMOVE);
+ event->type, event->type == MIDDLEMOUSE, event->type == MOUSEMOVE);
#endif
break;
}
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index a7f0d2c47f4..f6571773706 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -137,29 +137,10 @@ static void gp_init_colors(tGPDprimitive *p)
bGPdata *gpd = p->gpd;
Brush *brush = p->brush;
- Material *ma = NULL;
MaterialGPencilStyle *gp_style = NULL;
/* use brush material */
- ma = BKE_gpencil_get_material_from_brush(brush);
-
- /* if no brush defaults, get material and color info */
- if ((ma == NULL) || (ma->gp_style == NULL)) {
- BKE_gpencil_material_ensure(p->bmain, p->ob);
-
- /* assign always the first material to the brush */
- p->mat = give_current_material(p->ob, 1);
- brush->gpencil_settings->material = p->mat;
- }
- else {
- p->mat = ma;
- }
-
- /* check if the material is already on object material slots and add it if missing */
- if (BKE_gpencil_get_material_index(p->ob, p->mat) == 0) {
- BKE_object_material_slot_add(p->bmain, p->ob);
- assign_material(p->bmain, p->ob, ma, p->ob->totcol, BKE_MAT_ASSIGN_USERPREF);
- }
+ p->mat = BKE_gpencil_current_input_brush_material(p->bmain, p->ob, brush);
/* assign color information to temp data */
gp_style = p->mat->gp_style;
@@ -350,7 +331,7 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
gps->flag |= GP_STROKE_3DSPACE;
- gps->mat_nr = BKE_gpencil_get_material_index(tgpi->ob, tgpi->mat) - 1;
+ gps->mat_nr = BKE_gpencil_get_material_index(tgpi->ob, tgpi->mat);
/* allocate memory for storage points, but keep empty */
gps->totpoints = 0;
@@ -412,32 +393,33 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi
if (tgpi->type == GP_STROKE_LINE) {
BLI_strncpy(
- msg_str,
- IFACE_("Line: ESC to cancel, LMB set origin, Enter/MMB to confirm, WHEEL/+- to adjust subdivision number, Shift to align, Alt to center, E: extrude"),
- UI_MAX_DRAW_STR);
+ msg_str,
+ IFACE_("Line: ESC to cancel, LMB set origin, Enter/MMB to confirm, WHEEL/+- to adjust subdivision number, Shift to align, Alt to center, E: extrude"),
+ UI_MAX_DRAW_STR);
}
else if (tgpi->type == GP_STROKE_BOX) {
BLI_strncpy(
- msg_str,
- IFACE_("Rectangle: ESC to cancel, LMB set origin, Enter/MMB to confirm, WHEEL/+- to adjust subdivision number, Shift to square, Alt to center"),
- UI_MAX_DRAW_STR);
+ msg_str,
+ IFACE_("Rectangle: ESC to cancel, LMB set origin, Enter/MMB to confirm, WHEEL/+- to adjust subdivision number, Shift to square, Alt to center"),
+ UI_MAX_DRAW_STR);
}
else if (tgpi->type == GP_STROKE_CIRCLE) {
BLI_strncpy(
- msg_str,
- IFACE_("Circle: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge number, Shift to square, Alt to center"),
- UI_MAX_DRAW_STR);
+ msg_str,
+ IFACE_("Circle: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge number, Shift to square, Alt to center"),
+ UI_MAX_DRAW_STR);
}
else if (tgpi->type == GP_STROKE_ARC) {
- BLI_strncpy(msg_str,
- IFACE_("Arc: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge number, Shift to square, Alt to center, M: Flip, E: extrude"),
- UI_MAX_DRAW_STR);
+ BLI_strncpy(
+ msg_str,
+ IFACE_("Arc: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge number, Shift to square, Alt to center, M: Flip, E: extrude"),
+ UI_MAX_DRAW_STR);
}
else if (tgpi->type == GP_STROKE_CURVE) {
BLI_strncpy(
- msg_str,
- IFACE_("Curve: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge number, Shift to square, Alt to center, E: extrude"),
- UI_MAX_DRAW_STR);
+ msg_str,
+ IFACE_("Curve: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge number, Shift to square, Alt to center, E: extrude"),
+ UI_MAX_DRAW_STR);
}
if (ELEM(tgpi->type, GP_STROKE_CIRCLE, GP_STROKE_ARC, GP_STROKE_LINE, GP_STROKE_BOX)) {
@@ -531,7 +513,7 @@ static void gp_primitive_line(tGPDprimitive *tgpi, tGPspoint *points2D)
interp_v2_v2v2(&p2d->x, tgpi->start, tgpi->end, a);
a += step;
}
-
+
float color[4];
UI_GetThemeColor4fv(TH_GIZMO_PRIMARY, color);
gp_primitive_set_cp(tgpi, tgpi->end, color, BIG_SIZE_CTL);
@@ -852,7 +834,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
const float fac = p2d->rnd[0] * exfactor * jitter;
/* vector */
- float mvec[2], svec[2];;
+ float mvec[2], svec[2];
if (i > 0) {
mvec[0] = (p2d->x - (p2d - 1)->x);
mvec[1] = (p2d->y - (p2d - 1)->y);
@@ -924,15 +906,20 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* get origin to reproject point */
float origin[3];
- ED_gp_get_drawing_reference(tgpi->scene, tgpi->ob, tgpi->gpl,
- ts->gpencil_v3d_align, origin);
+ ED_gp_get_drawing_reference(
+ tgpi->scene, tgpi->ob, tgpi->gpl,
+ ts->gpencil_v3d_align, origin);
/* reproject current */
ED_gpencil_tpoint_to_point(tgpi->ar, origin, tpt, &spt);
- ED_gp_project_point_to_plane(tgpi->ob, tgpi->rv3d, origin, tgpi->lock_axis - 1, &spt);
+ ED_gp_project_point_to_plane(
+ tgpi->scene, tgpi->ob, tgpi->rv3d,
+ origin, tgpi->lock_axis - 1, &spt);
/* reproject previous */
ED_gpencil_tpoint_to_point(tgpi->ar, origin, tptb, &spt2);
- ED_gp_project_point_to_plane(tgpi->ob, tgpi->rv3d, origin, tgpi->lock_axis - 1, &spt2);
+ ED_gp_project_point_to_plane(
+ tgpi->scene, tgpi->ob, tgpi->rv3d,
+ origin, tgpi->lock_axis - 1, &spt2);
tgpi->totpixlen += len_v3v3(&spt.x, &spt2.x) / pixsize;
tpt->uv_fac = tgpi->totpixlen;
if ((gp_style) && (gp_style->sima)) {
@@ -987,10 +974,12 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* reproject to plane */
if (!is_depth) {
float origin[3];
- ED_gp_get_drawing_reference(tgpi->scene, tgpi->ob, tgpi->gpl,
- ts->gpencil_v3d_align, origin);
+ ED_gp_get_drawing_reference(
+ tgpi->scene, tgpi->ob, tgpi->gpl,
+ ts->gpencil_v3d_align, origin);
ED_gp_project_stroke_to_plane(
- tgpi->ob, tgpi->rv3d, gps, origin, ts->gp_sculpt.lock_axis - 1);
+ tgpi->scene, tgpi->ob, tgpi->rv3d, gps,
+ origin, ts->gp_sculpt.lock_axis - 1);
}
/* if parented change position relative to parent object */
@@ -1122,7 +1111,7 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
tgpi->gpd->runtime.tot_cp_points = 0;
/* getcolor info */
- tgpi->mat = BKE_gpencil_material_ensure(bmain, tgpi->ob);
+ tgpi->mat = BKE_gpencil_current_input_toolsettings_material(bmain, tgpi->ob, ts);
/* set parameters */
tgpi->type = RNA_enum_get(op->ptr, "type");
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 0862a8661a3..99bbf10cdc1 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -877,7 +877,7 @@ static bool gp_stroke_do_circle_sel(
float r_hita[3], r_hitb[3];
bool hit_select = (bool)(pt1->flag & GP_SPOINT_SELECT);
ED_gpencil_select_stroke_segment(
- gpl, gps, pt1, hit_select, false, scale, r_hita, r_hitb);
+ gpl, gps, pt1, hit_select, false, scale, r_hita, r_hitb);
}
/* Ensure that stroke selection is in sync with its points */
@@ -942,8 +942,8 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
{
changed |= gp_stroke_do_circle_sel(
- gpl, gps, &gsc, mx, my, radius, select, &rect,
- gpstroke_iter.diff_mat, selectmode, scale);
+ gpl, gps, &gsc, mx, my, radius, select, &rect,
+ gpstroke_iter.diff_mat, selectmode, scale);
}
GP_EDITABLE_STROKES_END(gpstroke_iter);
@@ -1066,7 +1066,7 @@ static int gpencil_generic_select_exec(
bool hit_select = (bool)(pt->flag & GP_SPOINT_SELECT);
float r_hita[3], r_hitb[3];
ED_gpencil_select_stroke_segment(
- gpl, gps, pt, hit_select, false, scale, r_hita, r_hitb);
+ gpl, gps, pt, hit_select, false, scale, r_hita, r_hitb);
}
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 5f703808d53..6601bfe9d2f 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -75,6 +75,7 @@
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
+#include "GPU_state.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -259,24 +260,6 @@ bool ED_gpencil_data_owner_is_annotation(PointerRNA *owner_ptr)
return ((owner_ptr) && (owner_ptr->type != &RNA_Object));
}
-/* -------------------------------------------------------- */
-
-// XXX: this should be removed... We really shouldn't duplicate logic like this!
-bGPdata *ED_gpencil_data_get_active_v3d(ViewLayer *view_layer, View3D *v3d)
-{
- Base *base = view_layer->basact;
- bGPdata *gpd = NULL;
-
- /* We have to make sure active object is actually visible and selected, else we must use default scene gpd,
- * to be consistent with ED_gpencil_data_get_active's behavior.
- */
- if (base && BASE_SELECTED(v3d, base)) {
- if (base->object->type == OB_GPENCIL)
- gpd = base->object->data;
- }
- return gpd ? gpd : NULL;
-}
-
/* ******************************************************** */
/* Keyframe Indicator Checks */
@@ -796,8 +779,9 @@ bool gp_point_xy_to_3d(const GP_SpaceConversion *gsc, Scene *scene, const float
const RegionView3D *rv3d = gsc->ar->regiondata;
float rvec[3];
- ED_gp_get_drawing_reference(scene, gsc->ob, gsc->gpl,
- scene->toolsettings->gpencil_v3d_align, rvec);
+ ED_gp_get_drawing_reference(
+ scene, gsc->ob, gsc->gpl,
+ scene->toolsettings->gpencil_v3d_align, rvec);
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
@@ -936,8 +920,12 @@ void ED_gpencil_project_stroke_to_view(bContext *C, bGPDlayer *gpl, bGPDstroke *
* Reproject all points of the stroke to a plane locked to axis to avoid stroke offset
*/
void ED_gp_project_stroke_to_plane(
- const Object *ob, const RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis)
+ const Scene *scene, const Object *ob,
+ const RegionView3D *rv3d, bGPDstroke *gps,
+ const float origin[3], const int axis)
{
+ const ToolSettings *ts = scene->toolsettings;
+ const View3DCursor *cursor = &scene->cursor;
float plane_normal[3];
float vn[3];
@@ -952,12 +940,36 @@ void ED_gp_project_stroke_to_plane(
*/
ED_view3d_global_to_vector(rv3d, origin, plane_normal);
}
- else {
+ else if (axis < 3) {
plane_normal[axis] = 1.0f;
/* if object, apply object rotation */
if (ob && (ob->type == OB_GPENCIL)) {
- mul_mat3_m4_v3(ob->obmat, plane_normal);
+ float mat[4][4];
+ copy_m4_m4(mat, ob->obmat);
+
+ /* move origin to cursor */
+ if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) {
+ copy_v3_v3(mat[3], cursor->location);
+ }
+
+ mul_mat3_m4_v3(mat, plane_normal);
+ }
+ }
+ else {
+ float scale[3] = { 1.0f, 1.0f, 1.0f };
+ plane_normal[2] = 1.0f;
+ float mat[4][4];
+ loc_eul_size_to_mat4(mat,
+ cursor->location,
+ cursor->rotation_euler,
+ scale);
+
+ /* move origin to object */
+ if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) {
+ copy_v3_v3(mat[3], ob->obmat[3]);
}
+
+ mul_mat3_m4_v3(mat, plane_normal);
}
/* Reproject the points in the plane */
@@ -983,8 +995,12 @@ void ED_gp_project_stroke_to_plane(
* \param[in, out] pt : Point to affect
*/
void ED_gp_project_point_to_plane(
- const Object *ob, const RegionView3D *rv3d, const float origin[3], const int axis, bGPDspoint *pt)
+ const Scene *scene, const Object *ob,
+ const RegionView3D *rv3d, const float origin[3],
+ const int axis, bGPDspoint *pt)
{
+ const ToolSettings *ts = scene->toolsettings;
+ const View3DCursor *cursor = &scene->cursor;
float plane_normal[3];
float vn[3];
@@ -999,14 +1015,37 @@ void ED_gp_project_point_to_plane(
*/
ED_view3d_global_to_vector(rv3d, origin, plane_normal);
}
- else {
+ else if (axis < 3) {
plane_normal[axis] = 1.0f;
/* if object, apply object rotation */
if (ob && (ob->type == OB_GPENCIL)) {
- mul_mat3_m4_v3(ob->obmat, plane_normal);
+ float mat[4][4];
+ copy_m4_m4(mat, ob->obmat);
+
+ /* move origin to cursor */
+ if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) {
+ copy_v3_v3(mat[3], cursor->location);
+ }
+
+ mul_mat3_m4_v3(mat, plane_normal);
}
}
+ else {
+ float scale[3] = { 1.0f, 1.0f, 1.0f };
+ plane_normal[2] = 1.0f;
+ float mat[4][4];
+ loc_eul_size_to_mat4(mat,
+ cursor->location,
+ cursor->rotation_euler,
+ scale);
+ /* move origin to object */
+ if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) {
+ copy_v3_v3(mat[3], ob->obmat[3]);
+ }
+
+ mul_mat3_m4_v3(mat, plane_normal);
+ }
/* Reproject the points in the plane */
/* get a vector from the point with the current view direction of the viewport */
@@ -1284,17 +1323,6 @@ void ED_gpencil_add_defaults(bContext *C, Object *ob)
Main *bmain = CTX_data_main(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- /* first try to reuse default material */
- if (ob->actcol > 0) {
- Material *ma = give_current_material(ob, ob->actcol);
- if ((ma) && (ma->gp_style == NULL)) {
- BKE_material_init_gpencil_settings(ma);
- }
- }
-
- /* ensure color exist */
- BKE_gpencil_material_ensure(bmain, ob);
-
BKE_paint_ensure(ts, (Paint **)&ts->gp_paint);
Paint *paint = &ts->gp_paint->paint;
/* if not exist, create a new one */
@@ -1303,6 +1331,9 @@ void ED_gpencil_add_defaults(bContext *C, Object *ob)
BKE_brush_gpencil_presets(C);
}
+ /* ensure a color exists and is assigned to object */
+ BKE_gpencil_current_input_toolsettings_material(bmain, ob, ts);
+
/* ensure multiframe falloff curve */
if (ts->gp_sculpt.cur_falloff == NULL) {
ts->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
@@ -1571,8 +1602,8 @@ void ED_gpencil_brush_draw_eraser(Brush *brush, int x, int y)
const uint shdr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
+ GPU_line_smooth(true);
+ GPU_blend(true);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
immUniformColor4ub(255, 100, 100, 20);
@@ -1599,8 +1630,8 @@ void ED_gpencil_brush_draw_eraser(Brush *brush, int x, int y)
immUnbindProgram();
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
+ GPU_blend(false);
+ GPU_line_smooth(false);
}
static bool gp_brush_cursor_poll(bContext *C)
@@ -1614,7 +1645,6 @@ static bool gp_brush_cursor_poll(bContext *C)
/* Helper callback for drawing the cursor itself */
static void gp_brush_cursor_draw(bContext *C, int x, int y, void *customdata)
{
- Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
ARegion *ar = CTX_wm_region(C);
@@ -1671,30 +1701,27 @@ static void gp_brush_cursor_draw(bContext *C, int x, int y, void *customdata)
}
/* get current drawing color */
- ma = BKE_gpencil_get_material_from_brush(brush);
- if (ma == NULL) {
- BKE_gpencil_material_ensure(bmain, ob);
- /* assign the first material to the brush */
- ma = give_current_material(ob, 1);
- brush->gpencil_settings->material = ma;
- }
- gp_style = ma->gp_style;
-
- /* after some testing, display the size of the brush is not practical because
- * is too disruptive and the size of cursor does not change with zoom factor.
- * The decision was to use a fix size, instead of brush->thickness value.
- */
- if ((gp_style) && (GPENCIL_PAINT_MODE(gpd)) &&
- ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
- ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) &&
- (brush->gpencil_tool == GPAINT_TOOL_DRAW))
- {
- radius = 2.0f;
- copy_v3_v3(color, gp_style->stroke_rgba);
- }
- else {
- radius = 5.0f;
- copy_v3_v3(color, brush->add_col);
+ ma = BKE_gpencil_get_material_for_brush(ob, brush);
+
+ if (ma) {
+ gp_style = ma->gp_style;
+
+ /* after some testing, display the size of the brush is not practical because
+ * is too disruptive and the size of cursor does not change with zoom factor.
+ * The decision was to use a fix size, instead of brush->thickness value.
+ */
+ if ((gp_style) && (GPENCIL_PAINT_MODE(gpd)) &&
+ ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
+ ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) &&
+ (brush->gpencil_tool == GPAINT_TOOL_DRAW))
+ {
+ radius = 2.0f;
+ copy_v3_v3(color, gp_style->stroke_rgba);
+ }
+ else {
+ radius = 5.0f;
+ copy_v3_v3(color, brush->add_col);
+ }
}
}
@@ -1720,8 +1747,8 @@ static void gp_brush_cursor_draw(bContext *C, int x, int y, void *customdata)
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
+ GPU_line_smooth(true);
+ GPU_blend(true);
/* Inner Ring: Color from UI panel */
immUniformColor4f(color[0], color[1], color[2], 0.8f);
@@ -1741,15 +1768,15 @@ static void gp_brush_cursor_draw(bContext *C, int x, int y, void *customdata)
immUniformColor4f(darkcolor[0], darkcolor[1], darkcolor[2], 0.8f);
imm_draw_circle_wire_2d(pos, x, y, radius + 1, 40);
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
+ GPU_blend(false);
+ GPU_line_smooth(false);
/* Draw line for lazy mouse */
if ((last_mouse_position) &&
(brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP))
{
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
+ GPU_line_smooth(true);
+ GPU_blend(true);
copy_v3_v3(color, brush->add_col);
immUniformColor4f(color[0], color[1], color[2], 0.8f);
@@ -1762,8 +1789,8 @@ static void gp_brush_cursor_draw(bContext *C, int x, int y, void *customdata)
last_mouse_position[1] + ar->winrct.ymin);
immEnd();
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
+ GPU_blend(false);
+ GPU_line_smooth(false);
}
immUnbindProgram();
@@ -2217,8 +2244,8 @@ int ED_gpencil_select_stroke_segment(
int direction = 0;
float(*points2d)[2] = MEM_mallocN(sizeof(*points2d) * gps->totpoints, "GP Stroke temp 2d points");
BKE_gpencil_stroke_2d_flat_ref(
- gps->points, gps->totpoints,
- gps->points, gps->totpoints, points2d, scale, &direction);
+ gps->points, gps->totpoints,
+ gps->points, gps->totpoints, points2d, scale, &direction);
GHash *all_2d = BLI_ghash_ptr_new(__func__);
@@ -2229,9 +2256,9 @@ int ED_gpencil_select_stroke_segment(
/* the extremes of the stroke are scaled to improve collision detection
* for near lines */
BKE_gpencil_stroke_2d_flat_ref(
- gps->points, gps->totpoints,
- gps_iter->points, gps_iter->totpoints, points2d_iter,
- scale, &direction);
+ gps->points, gps->totpoints,
+ gps_iter->points, gps_iter->totpoints, points2d_iter,
+ scale, &direction);
BLI_ghash_insert(all_2d, gps_iter, points2d_iter);
}
@@ -2255,7 +2282,7 @@ int ED_gpencil_select_stroke_segment(
copy_v2_v2(p2d_a2, points2d[i2]);
hit_a = gpencil_check_collision(
- gps, gps_array, all_2d, totstrokes, p2d_a1, p2d_a2, r_hit2d);
+ gps, gps_array, all_2d, totstrokes, p2d_a1, p2d_a2, r_hit2d);
if (select) {
pta1->flag |= GP_SPOINT_SELECT;
@@ -2289,7 +2316,7 @@ int ED_gpencil_select_stroke_segment(
copy_v2_v2(p2d_a2, points2d[i2]);
hit_b = gpencil_check_collision(
- gps, gps_array, all_2d, totstrokes, p2d_a1, p2d_a2, r_hit2d);
+ gps, gps_array, all_2d, totstrokes, p2d_a1, p2d_a2, r_hit2d);
if (select) {
pta1->flag |= GP_SPOINT_SELECT;
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index 35e04106f31..9cb308d5145 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -103,7 +103,6 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
float xzoom, float yzoom, float color[4]);
void set_inverted_drawing(int enable);
-void setlinestyle(int nr);
/* own working polygon offset */
float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist);
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 305e6eaa097..6dccc55d3ff 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -548,7 +548,13 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level);
/* Draw the given channel */
void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc, size_t channel_index);
/* Draw the widgets for the given channel */
-void ANIM_channel_draw_widgets(const struct bContext *C, bAnimContext *ac, bAnimListElem *ale, struct uiBlock *block, float yminc, float ymaxc, size_t channel_index);
+void ANIM_channel_draw_widgets(
+ const struct bContext *C,
+ bAnimContext *ac,
+ bAnimListElem *ale,
+ struct uiBlock *block,
+ rctf *rect,
+ size_t channel_index);
/* ------------------------ Editing API -------------------------- */
@@ -729,7 +735,7 @@ float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FC
if (smode == ACHANNEL_SETFLAG_INVERT) (channel)->flag ^= (sflag); \
else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag |= (sflag); \
else (channel)->flag &= ~(sflag); \
- }
+ } ((void)0)
/* set/clear/toggle macro, where the flag is negative
* - channel - channel with a 'flag' member that we're setting
@@ -741,7 +747,7 @@ float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FC
if (smode == ACHANNEL_SETFLAG_INVERT) (channel)->flag ^= (sflag); \
else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag &= ~(sflag); \
else (channel)->flag |= (sflag); \
- }
+ } ((void)0)
/* --------- anim_deps.c, animation updates -------- */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 3d4ca7bf3be..d469c0ea8a0 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -154,11 +154,12 @@ void ED_armature_from_edit(struct Main *bmain, struct bArmature *arm);
void ED_armature_to_edit(struct bArmature *arm);
void ED_armature_edit_free(struct bArmature *arm);
-void ED_armature_edit_deselect_all(struct Object *obedit);
-void ED_armature_edit_deselect_all_visible(struct Object *obedit);
+bool ED_armature_edit_deselect_all(struct Object *obedit);
+bool ED_armature_edit_deselect_all_visible(struct Object *obedit);
-void ED_armature_edit_deselect_all_multi(struct Object **objects, uint objects_len);
-void ED_armature_edit_deselect_all_visible_multi(struct Object **objects, uint objects_len);
+bool ED_armature_edit_deselect_all_multi_ex(struct Base **bases, uint bases_len);
+bool ED_armature_edit_deselect_all_visible_multi_ex(struct Base **bases, uint bases_len);
+bool ED_armature_edit_deselect_all_visible_multi(struct bContext *C);
bool ED_armature_pose_select_pick_with_buffer(
struct ViewLayer *view_layer, struct View3D *v3d, struct Base *base, const unsigned int *buffer, short hits,
@@ -239,8 +240,9 @@ bool ED_object_posemode_exit_ex(struct Main *bmain, struct Object *ob);
bool ED_object_posemode_exit(struct bContext *C, struct Object *ob);
bool ED_object_posemode_enter_ex(struct Main *bmain, struct Object *ob);
bool ED_object_posemode_enter(struct bContext *C, struct Object *ob);
+bool ED_pose_deselect_all_multi_ex(struct Base **bases, uint bases_len, int select_mode, const bool ignore_visibility);
+bool ED_pose_deselect_all_multi(struct bContext *C, int select_mode, const bool ignore_visibility);
bool ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility);
-void ED_pose_deselect_all_multi(struct Object **objects, uint objects_len, int select_mode, const bool ignore_visibility);
void ED_pose_bone_select_tag_update(struct Object *ob);
void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
void ED_pose_recalculate_paths(struct bContext *C, struct Scene *scene, struct Object *ob, bool current_frame_only);
diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h
index b585dc766d7..3e8821efbd0 100644
--- a/source/blender/editors/include/ED_curve.h
+++ b/source/blender/editors/include/ED_curve.h
@@ -25,6 +25,7 @@
#define __ED_CURVE_H__
struct BPoint;
+struct Base;
struct BezTriple;
struct Curve;
struct EditNurb;
@@ -56,17 +57,18 @@ struct Nurb *ED_curve_add_nurbs_primitive(struct bContext *C, struct Object *obe
bool ED_curve_nurb_select_check(struct View3D *v3d, struct Nurb *nu);
int ED_curve_nurb_select_count(struct View3D *v3d, struct Nurb *nu);
-void ED_curve_nurb_select_all(struct Nurb *nu);
-void ED_curve_nurb_deselect_all(struct Nurb *nu);
+bool ED_curve_nurb_select_all(const struct Nurb *nu);
+bool ED_curve_nurb_deselect_all(const struct Nurb *nu);
int join_curve_exec(struct bContext *C, struct wmOperator *op);
/* editcurve_select.c */
bool ED_curve_select_check(struct View3D *v3d, struct EditNurb *editnurb);
-void ED_curve_deselect_all(struct EditNurb *editnurb);
-void ED_curve_deselect_all_multi(struct Object **objects, int objects_len);
-void ED_curve_select_all(struct EditNurb *editnurb);
-void ED_curve_select_swap(struct EditNurb *editnurb, bool hide_handles);
+bool ED_curve_deselect_all(struct EditNurb *editnurb);
+bool ED_curve_deselect_all_multi_ex(struct Base **bases, int bases_len);
+bool ED_curve_deselect_all_multi(struct bContext *C);
+bool ED_curve_select_all(struct EditNurb *editnurb);
+bool ED_curve_select_swap(struct EditNurb *editnurb, bool hide_handles);
int ED_curve_select_count(struct View3D *v3d, struct EditNurb *editnurb);
/* editcurve_undo.c */
diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h
index 53b65292b6a..48effda37ef 100644
--- a/source/blender/editors/include/ED_gizmo_library.h
+++ b/source/blender/editors/include/ED_gizmo_library.h
@@ -184,10 +184,11 @@ enum {
ED_GIZMO_DIAL_DRAW_FLAG_NOP = 0,
ED_GIZMO_DIAL_DRAW_FLAG_CLIP = (1 << 0),
ED_GIZMO_DIAL_DRAW_FLAG_FILL = (1 << 1),
- ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR = (1 << 2),
- ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y = (1 << 3),
+ ED_GIZMO_DIAL_DRAW_FLAG_FILL_SELECT = (1 << 2),
+ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR = (1 << 3),
+ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y = (1 << 4),
/* Always show the angle value as an arc in the dial. */
- ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE = (1 << 4),
+ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE = (1 << 5),
};
/* -------------------------------------------------------------------- */
@@ -198,7 +199,8 @@ enum {
ED_GIZMO_MOVE_DRAW_FLAG_NOP = 0,
/* only for solid shapes */
ED_GIZMO_MOVE_DRAW_FLAG_FILL = (1 << 0),
- ED_GIZMO_MOVE_DRAW_FLAG_ALIGN_VIEW = (1 << 1),
+ ED_GIZMO_MOVE_DRAW_FLAG_FILL_SELECT = (1 << 1),
+ ED_GIZMO_MOVE_DRAW_FLAG_ALIGN_VIEW = (1 << 2),
};
enum {
@@ -245,6 +247,7 @@ void ED_gizmotypes_dial_3d_draw_util(
const float matrix_final[4][4],
const float line_width,
const float color[4],
+ const bool select,
struct Dial3dParams *params);
#endif /* __ED_GIZMO_LIBRARY_H__ */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index e331032bd6e..1f86a8c7f46 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -135,30 +135,14 @@ void ED_gpencil_strokes_copybuf_free(void);
/* ------------ Grease-Pencil Drawing API ------------------ */
/* drawgpencil.c */
-void ED_gpencil_draw_2dimage(const struct bContext *C);
-void ED_gpencil_draw_view2d(const struct bContext *C, bool onlyv2d);
-void ED_gpencil_draw_view3d(
- struct wmWindowManager *wm,
- struct Scene *scene,
- struct ViewLayer *view_layer,
- struct Depsgraph *depsgraph,
- struct View3D *v3d,
- struct ARegion *ar,
- bool only3d);
-void ED_gpencil_draw_view3d_annotations(
+void ED_annotation_draw_2dimage(const struct bContext *C);
+void ED_annotation_draw_view2d(const struct bContext *C, bool onlyv2d);
+void ED_annotation_draw_view3d(
struct Scene *scene, struct Depsgraph *depsgraph,
struct View3D *v3d, struct ARegion *ar,
bool only3d);
-void ED_gpencil_draw_view3d_object(
- struct wmWindowManager *wm,
+void ED_annotation_draw_ex(
struct Scene *scene,
- struct Depsgraph *depsgraph,
- struct Object *ob,
- struct View3D *v3d,
- struct ARegion *ar,
- bool only3d);
-void ED_gpencil_draw_ex(
- struct ViewLayer *view_layer, struct RegionView3D *rv3d, struct Scene *scene,
struct bGPdata *gpd, int winx, int winy,
const int cfra, const char spacetype);
@@ -225,9 +209,11 @@ void ED_gpencil_add_defaults(struct bContext *C, struct Object *ob);
void ED_gpencil_setup_modes(struct bContext *C, struct bGPdata *gpd, int newmode);
void ED_gp_project_stroke_to_plane(
+ const struct Scene *scene,
const struct Object *ob, const struct RegionView3D *rv3d,
struct bGPDstroke *gps, const float origin[3], const int axis);
void ED_gp_project_point_to_plane(
+ const struct Scene *scene,
const struct Object *ob, const struct RegionView3D *rv3d,
const float origin[3], const int axis, struct bGPDspoint *pt);
void ED_gp_get_drawing_reference(
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 240ed427479..bc5e21e4e08 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -37,7 +37,8 @@ struct wmWindowManager;
/* image_edit.c, exported for transform */
struct Image *ED_space_image(struct SpaceImage *sima);
-void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Object *obedit, struct Image *ima);
+void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Object *obedit, struct Image *ima, bool automatic);
+void ED_space_image_auto_set(const struct bContext *C, struct SpaceImage *sima);
struct Mask *ED_space_image_get_mask(struct SpaceImage *sima);
void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);
diff --git a/source/blender/editors/include/ED_lattice.h b/source/blender/editors/include/ED_lattice.h
index 98a091861d1..f65f47c40ad 100644
--- a/source/blender/editors/include/ED_lattice.h
+++ b/source/blender/editors/include/ED_lattice.h
@@ -24,6 +24,7 @@
#ifndef __ED_LATTICE_H__
#define __ED_LATTICE_H__
+struct Base;
struct Object;
struct UndoType;
struct wmKeyConfig;
@@ -33,9 +34,12 @@ void ED_operatortypes_lattice(void);
void ED_keymap_lattice(struct wmKeyConfig *keyconf);
/* editlattice_select.c */
-void ED_lattice_flags_set(struct Object *obedit, int flag);
+bool ED_lattice_flags_set(struct Object *obedit, int flag);
bool ED_lattice_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
+bool ED_lattice_deselect_all_multi_ex(struct Base **bases, const uint bases_len);
+bool ED_lattice_deselect_all_multi(struct bContext *C);
+
/* editlattice_undo.c */
void ED_lattice_undosys_type(struct UndoType *ut);
diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h
index e1033866193..2683631e85f 100644
--- a/source/blender/editors/include/ED_mball.h
+++ b/source/blender/editors/include/ED_mball.h
@@ -24,6 +24,7 @@
#ifndef __ED_MBALL_H__
#define __ED_MBALL_H__
+struct Base;
struct Object;
struct UndoType;
struct bContext;
@@ -37,6 +38,9 @@ struct MetaElem *ED_mball_add_primitive(struct bContext *C, struct Object *obedi
bool ED_mball_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
+bool ED_mball_deselect_all_multi_ex(struct Base **bases, uint bases_len);
+bool ED_mball_deselect_all_multi(struct bContext *C);
+
void ED_mball_editmball_free(struct Object *obedit);
void ED_mball_editmball_make(struct Object *obedit);
void ED_mball_editmball_load(struct Object *obedit);
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 7318df8adab..9e68c4a03ae 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -203,6 +203,9 @@ void EDBM_select_swap(struct BMEditMesh *em); /* exported for UV */
bool EDBM_select_interior_faces(struct BMEditMesh *em);
void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc); /* rename? */
+bool EDBM_mesh_deselect_all_multi_ex(struct Base **bases, const uint bases_len);
+bool EDBM_mesh_deselect_all_multi(struct bContext *C);
+
extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs;
/* editmesh_preselect_edgering.c */
@@ -237,15 +240,15 @@ void EDBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd
/* editface.c */
void paintface_flush_flags(struct bContext *C, struct Object *ob, short flag);
bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle);
-int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int sel_op);
-void paintface_deselect_all_visible(struct bContext *C, struct Object *ob, int action, bool flush_flags);
+bool do_paintface_box_select(struct ViewContext *vc, const struct rcti *rect, int sel_op);
+bool paintface_deselect_all_visible(struct bContext *C, struct Object *ob, int action, bool flush_flags);
void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], const bool select);
bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]);
void paintface_hide(struct bContext *C, struct Object *ob, const bool unselected);
void paintface_reveal(struct bContext *C, struct Object *ob, const bool select);
-void paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
+bool paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags);
void paintvert_select_ungrouped(struct Object *ob, bool extend, bool flush_flags);
void paintvert_flush_flags(struct Object *ob);
void paintvert_tag_select_update(struct bContext *C, struct Object *ob);
@@ -365,9 +368,15 @@ int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em, struct Me
int ED_mesh_mirror_get_vert(struct Object *ob, int index);
-bool ED_mesh_pick_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size, bool use_zbuf);
-bool ED_mesh_pick_face(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size);
-bool ED_mesh_pick_face_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size);
+bool ED_mesh_pick_vert(
+ struct bContext *C, struct Object *ob, const int mval[2], uint dist_px, bool use_zbuf,
+ uint *r_index);
+bool ED_mesh_pick_face(
+ struct bContext *C, struct Object *ob, const int mval[2], uint dist_px,
+ uint *r_index);
+bool ED_mesh_pick_face_vert(
+ struct bContext *C, struct Object *ob, const int mval[2], uint dist_px,
+ uint *r_index);
struct MDeformVert *ED_mesh_active_dvert_get_em(struct Object *ob, struct BMVert **r_eve);
@@ -377,8 +386,8 @@ struct MDeformVert *ED_mesh_active_dvert_get_only(struct Object *ob);
void EDBM_mesh_stats_multi(struct Object **objects, const uint objects_len, int totelem[3], int totelem_sel[3]);
void EDBM_mesh_elem_index_ensure_multi(struct Object **objects, const uint objects_len, const char htype);
-#define ED_MESH_PICK_DEFAULT_VERT_SIZE 50
-#define ED_MESH_PICK_DEFAULT_FACE_SIZE 3
+#define ED_MESH_PICK_DEFAULT_VERT_DIST 25
+#define ED_MESH_PICK_DEFAULT_FACE_DIST 1
#define USE_LOOPSLIDE_HACK
diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index bbecffee9c0..9cb0eb870ab 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -53,11 +53,12 @@ void PE_update_object(
struct Object *ob, int useflag);
/* selection tools */
-int PE_mouse_particles(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
-int PE_box_select(struct bContext *C, const struct rcti *rect, const int sel_op);
-bool PE_circle_select(struct bContext *C, int sel_op, const int mval[2], float rad);
+bool PE_mouse_particles(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
+bool PE_box_select(struct bContext *C, const struct rcti *rect, const int sel_op);
+bool PE_circle_select(struct bContext *C, const int sel_op, const int mval[2], float rad);
int PE_lasso_select(struct bContext *C, const int mcords[][2], const short moves, const int sel_op);
-void PE_deselect_all_visible(struct PTCacheEdit *edit);
+bool PE_deselect_all_visible_ex(struct PTCacheEdit *edit);
+bool PE_deselect_all_visible(struct bContext *C);
/* particle_edit_undo.c */
void ED_particle_undosys_type(struct UndoType *ut);
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h
index d0deefbe7b0..fd6818d6717 100644
--- a/source/blender/editors/include/ED_render.h
+++ b/source/blender/editors/include/ED_render.h
@@ -34,6 +34,7 @@ struct Render;
struct Scene;
struct ScrArea;
struct bContext;
+struct bScreen;
struct wmWindowManager;
/* render_ops.c */
@@ -44,6 +45,7 @@ void ED_operatortypes_render(void);
void ED_render_engine_changed(struct Main *bmain);
void ED_render_engine_area_exit(struct Main *bmain, struct ScrArea *sa);
+void ED_render_view_layer_changed(struct Main *bmain, struct bScreen *sc);
/* Callbacks handling data update events coming from depsgraph. */
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 5d4f0919c44..f44f951123a 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -41,6 +41,7 @@ struct Main;
struct MenuType;
struct PropertyRNA;
struct Scene;
+struct SpaceLink;
struct ViewLayer;
struct WorkSpace;
struct WorkSpaceInstanceHook;
@@ -195,6 +196,7 @@ void ED_screens_navigation_bar_tools_menu_create(struct bContext *C, struct u
bool ED_screen_stereo3d_required(const struct bScreen *screen, const struct Scene *scene);
Scene *ED_screen_scene_find(const struct bScreen *screen, const struct wmWindowManager *wm);
Scene *ED_screen_scene_find_with_window(const struct bScreen *screen, const struct wmWindowManager *wm, struct wmWindow **r_window);
+ScrArea *ED_screen_area_find_with_spacedata(const bScreen *screen, const struct SpaceLink *sl, const bool only_visible);
struct wmWindow *ED_screen_window_find(const struct bScreen *screen, const struct wmWindowManager *wm);
void ED_screen_preview_render(const struct bScreen *screen, int size_x, int size_y, unsigned int *r_rect) ATTR_NONNULL();
diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index ce234b5fb12..31b642165cd 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -37,7 +37,7 @@ struct rcti;
/* sculpt.c */
void ED_operatortypes_sculpt(void);
void ED_sculpt_redraw_planes_get(float planes[4][4], struct ARegion *ar, struct Object *ob);
-int ED_sculpt_mask_box_select(struct bContext *C, struct ViewContext *vc, const struct rcti *rect, bool select);
+bool ED_sculpt_mask_box_select(struct bContext *C, struct ViewContext *vc, const struct rcti *rect, bool select);
/* sculpt_undo.c */
void ED_sculpt_undosys_type(struct UndoType *ut);
diff --git a/source/blender/editors/include/ED_select_utils.h b/source/blender/editors/include/ED_select_utils.h
index a7b9ac7e6c9..04ea1769c09 100644
--- a/source/blender/editors/include/ED_select_utils.h
+++ b/source/blender/editors/include/ED_select_utils.h
@@ -21,7 +21,7 @@
#ifndef __ED_SELECT_UTILS_H__
#define __ED_SELECT_UTILS_H__
-struct KDTree;
+struct KDTree_1d;
enum {
SEL_TOGGLE = 0,
@@ -55,7 +55,7 @@ int ED_select_op_action(const eSelectOp sel_op, const bool is_select, const bool
int ED_select_op_action_deselected(const eSelectOp sel_op, const bool is_select, const bool is_inside);
int ED_select_similar_compare_float(const float delta, const float thresh, const int compare);
-bool ED_select_similar_compare_float_tree(const struct KDTree *tree, const float length, const float thresh, const int compare);
+bool ED_select_similar_compare_float_tree(const struct KDTree_1d *tree, const float length, const float thresh, const int compare);
eSelectOp ED_select_op_modal(const eSelectOp sel_op, const bool is_first);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 131069bfb5f..02ea0027938 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -348,16 +348,24 @@ float ED_view3d_radius_to_dist(
void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned pos);
/* backbuffer select and draw support */
-void ED_view3d_backbuf_validate_with_select_mode(struct ViewContext *vc, short select_mode);
-void ED_view3d_backbuf_validate(struct ViewContext *vc);
-struct ImBuf *ED_view3d_backbuf_read(
- struct ViewContext *vc, int xmin, int ymin, int xmax, int ymax);
-unsigned int ED_view3d_backbuf_sample_rect(
- struct ViewContext *vc, const int mval[2], int size,
- unsigned int min, unsigned int max, float *r_dist);
-int ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float dist);
-unsigned int ED_view3d_backbuf_sample(
+void ED_view3d_backbuf_depth_validate(struct ViewContext *vc);
+int ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float dist);
+
+void ED_view3d_select_id_validate(struct ViewContext *vc);
+void ED_view3d_select_id_validate_with_select_mode(
+ struct ViewContext *vc, short select_mode);
+
+uint ED_view3d_select_id_sample(
struct ViewContext *vc, int x, int y);
+uint *ED_view3d_select_id_read(
+ struct ViewContext *vc,
+ int xmin, int ymin, int xmax, int ymax,
+ uint *r_buf_len);
+uint *ED_view3d_select_id_read_rect(
+ struct ViewContext *vc, const struct rcti *rect, uint *r_buf_len);
+uint ED_view3d_select_id_read_nearest(
+ struct ViewContext *vc, const int mval[2],
+ const uint min, const uint max, uint *r_dist);
bool ED_view3d_autodist(
struct Depsgraph *depsgraph, struct ARegion *ar, struct View3D *v3d,
@@ -427,7 +435,6 @@ void ED_view3d_check_mats_rv3d(struct RegionView3D *rv3d);
# define ED_view3d_clear_mats_rv3d(rv3d) (void)(rv3d)
# define ED_view3d_check_mats_rv3d(rv3d) (void)(rv3d)
#endif
-int ED_view3d_view_layer_set(int lay, const bool *values, int *active);
struct RV3DMatrixStore *ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d);
void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat);
@@ -443,7 +450,7 @@ void ED_view3d_draw_offscreen(
int drawtype,
struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
float winmat[4][4], bool do_sky, bool is_persp, const char *viewname,
- struct GPUFXSettings *fx_settings,
+ struct GPUFXSettings *fx_settings, bool do_color_managment,
struct GPUOffScreen *ofs, struct GPUViewport *viewport);
void ED_view3d_draw_setup_view(
struct wmWindow *win, struct Depsgraph *depsgraph, struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 59658b0fcdb..419fe961cec 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -709,7 +709,7 @@ DEF_ICON_BLANK(241)
DEF_ICON_BLANK(242)
DEF_ICON_BLANK(243)
DEF_ICON_BLANK(244)
-DEF_ICON_BLANK(245)
+DEF_ICON(ORIENTATION_CURSOR)
DEF_ICON(NORMALS_VERTEX)
DEF_ICON(NORMALS_FACE)
DEF_ICON(NORMALS_VERTEX_FACE)
@@ -883,23 +883,19 @@ DEF_ICON(VIEW_ZOOM)
/* brush icons */
-DEF_ICON_COLOR(BRUSH_ADD)
DEF_ICON_COLOR(BRUSH_BLOB)
DEF_ICON_COLOR(BRUSH_BLUR)
DEF_ICON_COLOR(BRUSH_CLAY)
DEF_ICON_COLOR(BRUSH_CLAY_STRIPS)
DEF_ICON_COLOR(BRUSH_CLONE)
DEF_ICON_COLOR(BRUSH_CREASE)
-DEF_ICON_COLOR(BRUSH_DARKEN)
DEF_ICON_COLOR(BRUSH_FILL)
DEF_ICON_COLOR(BRUSH_FLATTEN)
DEF_ICON_COLOR(BRUSH_GRAB)
DEF_ICON_COLOR(BRUSH_INFLATE)
DEF_ICON_COLOR(BRUSH_LAYER)
-DEF_ICON_COLOR(BRUSH_LIGHTEN)
DEF_ICON_COLOR(BRUSH_MASK)
DEF_ICON_COLOR(BRUSH_MIX)
-DEF_ICON_COLOR(BRUSH_MULTIPLY)
DEF_ICON_COLOR(BRUSH_NUDGE)
DEF_ICON_COLOR(BRUSH_PINCH)
DEF_ICON_COLOR(BRUSH_SCRAPE)
@@ -908,39 +904,11 @@ DEF_ICON_COLOR(BRUSH_SMEAR)
DEF_ICON_COLOR(BRUSH_SMOOTH)
DEF_ICON_COLOR(BRUSH_SNAKE_HOOK)
DEF_ICON_COLOR(BRUSH_SOFTEN)
-DEF_ICON_COLOR(BRUSH_SUBTRACT)
DEF_ICON_COLOR(BRUSH_TEXDRAW)
DEF_ICON_COLOR(BRUSH_TEXFILL)
DEF_ICON_COLOR(BRUSH_TEXMASK)
DEF_ICON_COLOR(BRUSH_THUMB)
DEF_ICON_COLOR(BRUSH_ROTATE)
-DEF_ICON_COLOR(BRUSH_VERTEXDRAW)
-
- /* Matcaps */
-DEF_ICON_COLOR(MATCAP_01)
-DEF_ICON_COLOR(MATCAP_02)
-DEF_ICON_COLOR(MATCAP_03)
-DEF_ICON_COLOR(MATCAP_04)
-DEF_ICON_COLOR(MATCAP_05)
-DEF_ICON_COLOR(MATCAP_06)
-DEF_ICON_COLOR(MATCAP_07)
-DEF_ICON_COLOR(MATCAP_08)
-DEF_ICON_COLOR(MATCAP_09)
-DEF_ICON_COLOR(MATCAP_10)
-DEF_ICON_COLOR(MATCAP_11)
-DEF_ICON_COLOR(MATCAP_12)
-DEF_ICON_COLOR(MATCAP_13)
-DEF_ICON_COLOR(MATCAP_14)
-DEF_ICON_COLOR(MATCAP_15)
-DEF_ICON_COLOR(MATCAP_16)
-DEF_ICON_COLOR(MATCAP_17)
-DEF_ICON_COLOR(MATCAP_18)
-DEF_ICON_COLOR(MATCAP_19)
-DEF_ICON_COLOR(MATCAP_20)
-DEF_ICON_COLOR(MATCAP_21)
-DEF_ICON_COLOR(MATCAP_22)
-DEF_ICON_COLOR(MATCAP_23)
-DEF_ICON_COLOR(MATCAP_24)
/* grease pencil sculpt */
DEF_ICON_COLOR(GPBRUSH_SMOOTH)
@@ -953,14 +921,12 @@ DEF_ICON_COLOR(GPBRUSH_PINCH)
DEF_ICON_COLOR(GPBRUSH_RANDOMIZE)
DEF_ICON_COLOR(GPBRUSH_CLONE)
DEF_ICON_COLOR(GPBRUSH_WEIGHT)
-
DEF_ICON_COLOR(GPBRUSH_PENCIL)
DEF_ICON_COLOR(GPBRUSH_PEN)
DEF_ICON_COLOR(GPBRUSH_INK)
DEF_ICON_COLOR(GPBRUSH_INKNOISE)
DEF_ICON_COLOR(GPBRUSH_BLOCK)
DEF_ICON_COLOR(GPBRUSH_MARKER)
-DEF_ICON_COLOR(GPBRUSH_CUSTOM)
DEF_ICON_COLOR(GPBRUSH_FILL)
DEF_ICON_COLOR(GPBRUSH_ERASE_SOFT)
DEF_ICON_COLOR(GPBRUSH_ERASE_HARD)
@@ -1049,8 +1015,6 @@ DEF_ICON_COLOR(EVENT_ESC)
DEF_ICON_COLOR(EVENT_TAB)
DEF_ICON_COLOR(EVENT_PAGEUP)
DEF_ICON_COLOR(EVENT_PAGEDOWN)
-DEF_ICON_COLOR(EVENT_HOME)
-DEF_ICON_COLOR(EVENT_END)
DEF_ICON_COLOR(EVENT_RETURN)
/* add as needed. */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d9b2b09a117..9f189b63ad5 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -181,7 +181,7 @@ enum {
UI_BUT_DRAG_LOCK = 1 << 10,
/** grayed out and uneditable */
UI_BUT_DISABLED = 1 << 11,
- UI_BUT_COLOR_LOCK = 1 << 12,
+
UI_BUT_ANIMATED = 1 << 13,
UI_BUT_ANIMATED_KEY = 1 << 14,
UI_BUT_DRIVEN = 1 << 15,
@@ -193,14 +193,17 @@ enum {
UI_BUT_IMMEDIATE = 1 << 20,
UI_BUT_NO_UTF8 = 1 << 21,
- /** used to flag if color hsv-circle should keep luminance */
- UI_BUT_VEC_SIZE_LOCK = 1 << 22,
- /** cubic saturation for the color wheel */
- UI_BUT_COLOR_CUBIC = 1 << 23,
+ /** For popups, pressing return activates this button, overriding the highlighted button.
+ * For non-popups this is just used as a display hint for the user to let them
+ * know the action which is activated when pressing return (file selector for eg). */
+ UI_BUT_ACTIVE_DEFAULT = 1 << 23,
+
/** This but is "inside" a list item (currently used to change theme colors). */
UI_BUT_LIST_ITEM = 1 << 24,
/** edit this button as well as the active button (not just dragging) */
UI_BUT_DRAG_MULTI = 1 << 25,
+ /** Use for popups to start editing the button on initialization. */
+ UI_BUT_ACTIVATE_ON_INIT = 1 << 26,
/** #uiBut.str contains #UI_SEP_CHAR, used for key shortcuts */
UI_BUT_HAS_SEP_CHAR = 1 << 27,
@@ -594,8 +597,8 @@ typedef enum {
void UI_block_bounds_set_normal(struct uiBlock *block, int addval);
void UI_block_bounds_set_text(uiBlock *block, int addval);
-void UI_block_bounds_set_popup(uiBlock *block, int addval, int mx, int my);
-void UI_block_bounds_set_menu(uiBlock *block, int addvall, int mx, int my);
+void UI_block_bounds_set_popup(uiBlock *block, int addval, const int bounds_offset[2]);
+void UI_block_bounds_set_menu(uiBlock *block, int addval, const int bounds_offset[2]);
void UI_block_bounds_set_centered(uiBlock *block, int addval);
void UI_block_bounds_set_explicit(uiBlock *block, int minx, int miny, int maxx, int maxy);
@@ -631,6 +634,7 @@ void UI_but_type_set_menu_from_pulldown(uiBut *but);
/* special button case, only draw it when used actively, for outliner etc */
bool UI_but_active_only(const struct bContext *C, struct ARegion *ar, uiBlock *block, uiBut *but);
+bool UI_block_active_only_flagged_buttons(const struct bContext *C, struct ARegion *ar, struct uiBlock *block);
void UI_but_execute(const struct bContext *C, uiBut *but);
@@ -836,6 +840,7 @@ uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA
eAutoPropButsReturn uiDefAutoButsRNA(
uiLayout *layout, struct PointerRNA *ptr,
bool (*check_prop)(struct PointerRNA *ptr, struct PropertyRNA *prop, void *user_data), void *user_data,
+ struct PropertyRNA *prop_activate_init,
eButLabelAlign label_align, const bool compact);
/* use inside searchfunc to add items */
@@ -843,7 +848,7 @@ bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, i
/* bfunc gets search item *poin as arg2, or if NULL the old string */
void UI_but_func_search_set(
uiBut *but, uiButSearchCreateFunc cfunc, uiButSearchFunc sfunc,
- void *arg1, uiButHandleFunc bfunc, void *active);
+ void *arg, bool free_arg, uiButHandleFunc bfunc, void *active);
/* height in pixels, it's using hardcoded values still */
int UI_searchbox_size_y(void);
int UI_searchbox_size_x(void);
@@ -906,7 +911,7 @@ int UI_autocomplete_end(AutoComplete *autocpl, char *autoname);
* not clear yet so we postpone that. */
void UI_panels_begin(const struct bContext *C, struct ARegion *ar);
-void UI_panels_end(const struct bContext *C, struct ARegion *ar, int *x, int *y);
+void UI_panels_end(const struct bContext *C, struct ARegion *ar, int *r_x, int *r_y);
void UI_panels_draw(const struct bContext *C, struct ARegion *ar);
struct Panel *UI_panel_find_by_type(struct ListBase *lb, struct PanelType *pt);
@@ -916,7 +921,7 @@ struct Panel *UI_panel_begin(
bool *r_open);
void UI_panel_end(uiBlock *block, int width, int height);
void UI_panels_scale(struct ARegion *ar, float new_width);
-void UI_panel_label_offset(struct uiBlock *block, int *x, int *y);
+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);
@@ -1034,7 +1039,7 @@ enum {
uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, struct uiStyle *style);
void UI_block_layout_set_current(uiBlock *block, uiLayout *layout);
-void UI_block_layout_resolve(uiBlock *block, int *x, int *y);
+void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y);
void UI_region_message_subscribe(struct ARegion *ar, struct wmMsgBus *mbus);
@@ -1053,6 +1058,8 @@ void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but);
void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
void uiLayoutSetActive(uiLayout *layout, bool active);
+void uiLayoutSetActiveDefault(uiLayout *layout, bool active_default);
+void uiLayoutSetActivateInit(uiLayout *layout, bool active);
void uiLayoutSetEnabled(uiLayout *layout, bool enabled);
void uiLayoutSetRedAlert(uiLayout *layout, bool redalert);
void uiLayoutSetAlignment(uiLayout *layout, char alignment);
@@ -1068,6 +1075,8 @@ int uiLayoutGetLocalDir(const uiLayout *layout);
int uiLayoutGetOperatorContext(uiLayout *layout);
bool uiLayoutGetActive(uiLayout *layout);
+bool uiLayoutGetActiveDefault(uiLayout *layout);
+bool uiLayoutGetActivateInit(uiLayout *layout);
bool uiLayoutGetEnabled(uiLayout *layout);
bool uiLayoutGetRedAlert(uiLayout *layout);
int uiLayoutGetAlignment(uiLayout *layout);
@@ -1186,6 +1195,8 @@ void uiTemplateComponentMenu(uiLayout *layout, struct PointerRNA *ptr, const cha
void uiTemplateNodeSocket(uiLayout *layout, struct bContext *C, float *color);
void uiTemplateCacheFile(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname);
+struct ColorBand *UI_block_get_colorband_from_template_menu(struct uiBlock *block);
+
/* Default UIList class name, keep in sync with its declaration in bl_ui/__init__.py */
#define UI_UL_DEFAULT_CLASS_NAME "UI_UL_list"
void uiTemplateList(
@@ -1235,7 +1246,17 @@ void uiItemFullOMenuHold_ptr(
PointerRNA *r_opptr);
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon);
-void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon);
+void uiItemFullR(
+ uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag,
+ const char *name, int icon);
+void uiItemFullR_with_popover(
+ uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag,
+ const char *name, int icon,
+ const char *panel_type);
+void uiItemFullR_with_menu(
+ uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag,
+ const char *name, int icon,
+ const char *menu_type);
void uiItemEnumR_prop(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, PropertyRNA *prop, int value);
void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, const char *propname, int value);
void uiItemEnumR_string_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *value, const char *name, int icon);
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 85b2ccf2077..ae2f0269a9c 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -366,6 +366,7 @@ void UI_GetThemeColor3ubv(int colorid, unsigned char col[3]);
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4]);
// get a theme color from specified space type
+void UI_GetThemeColorType3fv(int colorid, int spacetype, float col[3]);
void UI_GetThemeColorType3ubv(int colorid, int spacetype, unsigned char col[3]);
void UI_GetThemeColorType4ubv(int colorid, int spacetype, unsigned char col[4]);
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 8c944760972..98e00eab9c9 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -209,19 +209,19 @@ bool UI_view2d_view_to_region_rcti_clip(struct View2D *v2d, const struct rctf *
struct View2D *UI_view2d_fromcontext(const struct bContext *C);
struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C);
-void UI_view2d_scale_get(struct View2D *v2d, float *x, float *y);
-void UI_view2d_scale_get_inverse(struct View2D *v2d, float *x, float *y);
+void UI_view2d_scale_get(struct View2D *v2d, float *r_x, float *r_y);
+void UI_view2d_scale_get_inverse(struct View2D *v2d, float *r_x, float *r_y);
-void UI_view2d_center_get(struct View2D *v2d, float *x, float *y);
+void UI_view2d_center_get(struct View2D *v2d, float *r_x, float *r_y);
void UI_view2d_center_set(struct View2D *v2d, float x, float y);
void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac);
char UI_view2d_mouse_in_scrollers_ex(
- const struct ARegion *ar, struct View2D *v2d, int x, int y,
+ const struct ARegion *ar, const struct View2D *v2d, int x, int y,
int *r_scroll);
char UI_view2d_mouse_in_scrollers(
- const struct ARegion *ar, struct View2D *v2d, int x, int y);
+ const struct ARegion *ar, const struct View2D *v2d, int x, int y);
/* cached text drawing in v2d, to allow pixel-aligned draw as post process */
void UI_view2d_text_cache_add(struct View2D *v2d, float x, float y,
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index ffb13e9facf..098a1e7c8a2 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -85,10 +85,15 @@
/* prototypes. */
static void ui_but_to_pixelrect(struct rcti *rect, const struct ARegion *ar, struct uiBlock *block, struct uiBut *but);
static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p);
+static void ui_def_but_rna__panel_type(bContext *UNUSED(C), uiLayout *layout, void *but_p);
+static void ui_def_but_rna__menu_type(bContext *UNUSED(C), uiLayout *layout, void *but_p);
/* avoid unneeded calls to ui_but_value_get */
#define UI_BUT_VALUE_UNSET DBL_MAX
-#define UI_GET_BUT_VALUE_INIT(_but, _value) if (_value == DBL_MAX) { (_value) = ui_but_value_get(_but); } (void)0
+#define UI_GET_BUT_VALUE_INIT(_but, _value) \
+ if (_value == DBL_MAX) { \
+ (_value) = ui_but_value_get(_but); \
+ } ((void)0)
#define B_NOP -1
@@ -163,7 +168,9 @@ float ui_block_to_window_scale(const ARegion *ar, uiBlock *block)
/* We could have function for this to avoid dummy arg. */
float dummy_x;
float min_y = 0, max_y = 1;
+ dummy_x = 0.0f;
ui_block_to_window_fl(ar, block, &dummy_x, &min_y);
+ dummy_x = 0.0f;
ui_block_to_window_fl(ar, block, &dummy_x, &max_y);
return max_y - min_y;
}
@@ -343,8 +350,9 @@ static void ui_block_bounds_calc_text(uiBlock *block, float offset)
if (!ELEM(bt->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) {
j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
- if (j > i)
+ if (j > i) {
i = j;
+ }
}
if (bt->next && bt->rect.xmin < bt->next->rect.xmin) {
@@ -401,8 +409,12 @@ void ui_block_bounds_calc(uiBlock *block)
/* hardcoded exception... but that one is annoying with larger safety */
bt = block->buttons.first;
- if (bt && STREQLEN(bt->str, "ERROR", 5)) xof = 10;
- else xof = 40;
+ if (bt && STREQLEN(bt->str, "ERROR", 5)) {
+ xof = 10;
+ }
+ else {
+ xof = 40;
+ }
block->safety.xmin = block->rect.xmin - xof;
block->safety.ymin = block->rect.ymin - xof;
@@ -493,8 +505,8 @@ static void ui_block_bounds_calc_popup(
/* offset block based on mouse position, user offset is scaled
* along in case we resized the block in ui_block_bounds_calc_text */
- raw_x = rect.xmin = xy[0] + block->rect.xmin + (block->mx * width) / oldwidth;
- raw_y = rect.ymin = xy[1] + block->rect.ymin + (block->my * height) / oldheight;
+ raw_x = rect.xmin = xy[0] + block->rect.xmin + (block->bounds_offset[0] * width) / oldwidth;
+ raw_y = rect.ymin = xy[1] + block->rect.ymin + (block->bounds_offset[1] * height) / oldheight;
rect.xmax = rect.xmin + width;
rect.ymax = rect.ymin + height;
@@ -521,8 +533,9 @@ static void ui_block_bounds_calc_popup(
/* used for various cases */
void UI_block_bounds_set_normal(uiBlock *block, int addval)
{
- if (block == NULL)
+ if (block == NULL) {
return;
+ }
block->bounds = addval;
block->bounds_type = UI_BLOCK_BOUNDS;
@@ -536,21 +549,33 @@ void UI_block_bounds_set_text(uiBlock *block, int addval)
}
/* used for block popups */
-void UI_block_bounds_set_popup(uiBlock *block, int addval, int mx, int my)
+void UI_block_bounds_set_popup(uiBlock *block, int addval, const int bounds_offset[2])
{
block->bounds = addval;
block->bounds_type = UI_BLOCK_BOUNDS_POPUP_MOUSE;
- block->mx = mx;
- block->my = my;
+ if (bounds_offset != NULL) {
+ block->bounds_offset[0] = bounds_offset[0];
+ block->bounds_offset[1] = bounds_offset[1];
+ }
+ else {
+ block->bounds_offset[0] = 0;
+ block->bounds_offset[1] = 0;
+ }
}
/* used for menu popups */
-void UI_block_bounds_set_menu(uiBlock *block, int addval, int mx, int my)
+void UI_block_bounds_set_menu(uiBlock *block, int addval, const int bounds_offset[2])
{
block->bounds = addval;
block->bounds_type = UI_BLOCK_BOUNDS_POPUP_MENU;
- block->mx = mx;
- block->my = my;
+ if (bounds_offset != NULL) {
+ block->bounds_offset[0] = bounds_offset[0];
+ block->bounds_offset[1] = bounds_offset[1];
+ }
+ else {
+ block->bounds_offset[0] = 0;
+ block->bounds_offset[1] = 0;
+ }
}
/* used for centered popups, i.e. splash */
@@ -596,16 +621,16 @@ static bool ui_but_equals_old(const uiBut *but, const uiBut *oldbut)
{
/* various properties are being compared here, hopefully sufficient
* to catch all cases, but it is simple to add more checks later */
- if (but->retval != oldbut->retval) return false;
- if (but->rnapoin.data != oldbut->rnapoin.data) return false;
- if (but->rnaprop != oldbut->rnaprop || but->rnaindex != oldbut->rnaindex) return false;
- if (but->func != oldbut->func) return false;
- if (but->funcN != oldbut->funcN) return false;
- if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return false;
- if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return false;
+ if (but->retval != oldbut->retval) { return false; }
+ if (but->rnapoin.data != oldbut->rnapoin.data) { return false; }
+ if (but->rnaprop != oldbut->rnaprop || but->rnaindex != oldbut->rnaindex) { return false; }
+ if (but->func != oldbut->func) { return false; }
+ if (but->funcN != oldbut->funcN) { return false; }
+ if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) { return false; }
+ if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) { return false; }
if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) ||
- (but->pointype != oldbut->pointype))) return false;
- if (but->optype != oldbut->optype) return false;
+ (but->pointype != oldbut->pointype))) { return false; }
+ if (but->optype != oldbut->optype) { return false; }
return true;
}
@@ -710,9 +735,12 @@ static bool ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBu
if (oldbut->poin != (char *)oldbut) {
SWAP(char *, oldbut->poin, but->poin);
SWAP(void *, oldbut->func_argN, but->func_argN);
- SWAP(void *, oldbut->tip_argN, but->tip_argN);
}
+ /* Move tooltip from new to old. */
+ SWAP(uiButToolTipFunc, oldbut->tip_func, but->tip_func);
+ SWAP(void *, oldbut->tip_argN, but->tip_argN);
+
oldbut->flag = (oldbut->flag & ~flag_copy) | (but->flag & flag_copy);
oldbut->drawflag = (oldbut->drawflag & ~drawflag_copy) | (but->drawflag & drawflag_copy);
@@ -809,6 +837,24 @@ bool UI_but_active_only(const bContext *C, ARegion *ar, uiBlock *block, uiBut *b
return true;
}
+bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *ar, uiBlock *block)
+{
+ bool done = false;
+ for (uiBut *but = block->buttons.first; but; but = but->next) {
+ if (!done && ui_but_is_editable(but)) {
+ if (but->flag & UI_BUT_ACTIVATE_ON_INIT) {
+ if (UI_but_active_only(C, ar, block, but)) {
+ done = true;
+ }
+ }
+ }
+ but->flag &= ~UI_BUT_ACTIVATE_ON_INIT;
+ }
+ return done;
+}
+
+
+
/* simulate button click */
void UI_but_execute(const bContext *C, uiBut *but)
{
@@ -856,8 +902,9 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
int tot_missing = 0;
/* only do it before bounding */
- if (block->rect.xmin != block->rect.xmax)
+ if (block->rect.xmin != block->rect.xmax) {
return;
+ }
for (pass = 0; pass < 2; pass++) {
/* 2 Passes, on for first letter only, second for any letter if first fails
@@ -884,11 +931,13 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
if (pass == 0) {
/* Skip to next delimiter on first pass (be picky) */
- while (isalpha(*str_pt))
+ while (isalpha(*str_pt)) {
str_pt++;
+ }
- if (*str_pt)
+ if (*str_pt) {
str_pt++;
+ }
}
else {
/* just step over every char second pass and find first usable key */
@@ -1105,7 +1154,10 @@ static bool ui_but_event_property_operator_string(
if ((but->type == UI_BTYPE_BUT_MENU) &&
(but_parent && but_parent->rnaprop) &&
(RNA_property_type(but_parent->rnaprop) == PROP_ENUM) &&
- (but_parent->menu_create_func == ui_def_but_rna__menu))
+ ELEM(but_parent->menu_create_func,
+ ui_def_but_rna__menu,
+ ui_def_but_rna__panel_type,
+ ui_def_but_rna__menu_type))
{
prop_enum_value = (int)but->hardmin;
ptr = &but_parent->rnapoin;
@@ -1370,8 +1422,9 @@ void UI_block_update_from_old(const bContext *C, uiBlock *block)
uiBut *but_old;
uiBut *but;
- if (!block->oldblock)
+ if (!block->oldblock) {
return;
+ }
but_old = block->oldblock->buttons.first;
@@ -1418,15 +1471,17 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
if (but->optype) {
wmOperatorType *ot = but->optype;
- if (but->context)
+ if (but->context) {
CTX_store_set((bContext *)C, but->context);
+ }
if (ot == NULL || WM_operator_poll_context((bContext *)C, ot, but->opcontext) == 0) {
but->flag |= UI_BUT_DISABLED;
}
- if (but->context)
+ if (but->context) {
CTX_store_set((bContext *)C, NULL);
+ }
}
ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
@@ -1506,10 +1561,12 @@ void ui_fontscale(short *points, float aspect)
//aspect = sqrt(aspect);
pointsf /= aspect;
- if (aspect > 1.0f)
+ if (aspect > 1.0f) {
*points = ceilf(pointsf);
- else
+ }
+ else {
*points = floorf(pointsf);
+ }
}
}
@@ -1533,11 +1590,13 @@ void UI_block_draw(const bContext *C, uiBlock *block)
/* get menu region or area region */
ar = CTX_wm_menu(C);
- if (!ar)
+ if (!ar) {
ar = CTX_wm_region(C);
+ }
- if (!block->endblock)
+ if (!block->endblock) {
UI_block_end(C, block);
+ }
/* we set this only once */
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
@@ -1559,12 +1618,15 @@ void UI_block_draw(const bContext *C, uiBlock *block)
wmOrtho2_region_pixelspace(ar);
/* back */
- if (block->flag & UI_BLOCK_RADIAL)
+ if (block->flag & UI_BLOCK_RADIAL) {
ui_draw_pie_center(block);
- else if (block->flag & UI_BLOCK_POPOVER)
+ }
+ else if (block->flag & UI_BLOCK_POPOVER) {
ui_draw_popover_back(ar, &style, block, &rect);
- else if (block->flag & UI_BLOCK_LOOP)
+ }
+ else if (block->flag & UI_BLOCK_LOOP) {
ui_draw_menu_back(&style, block, &rect);
+ }
else if (block->panel) {
bool show_background = ar->alignment != RGN_ALIGN_FLOAT;
ui_draw_aligned_panel(
@@ -1583,8 +1645,9 @@ void UI_block_draw(const bContext *C, uiBlock *block)
/* XXX: figure out why invalid coordinates happen when closing render window */
/* and material preview is redrawn in main window (temp fix for bug #23848) */
- if (rect.xmin < rect.xmax && rect.ymin < rect.ymax)
+ if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) {
ui_draw_but(C, ar, &style, but, &rect);
+ }
}
}
@@ -1667,13 +1730,17 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
case UI_BTYPE_ICON_TOGGLE:
case UI_BTYPE_CHECKBOX:
UI_GET_BUT_VALUE_INIT(but, *value);
- if (*value != (double)but->hardmin) is_push = true;
+ if (*value != (double)but->hardmin) {
+ is_push = true;
+ }
break;
case UI_BTYPE_ICON_TOGGLE_N:
case UI_BTYPE_TOGGLE_N:
case UI_BTYPE_CHECKBOX_N:
UI_GET_BUT_VALUE_INIT(but, *value);
- if (*value == 0.0) is_push = true;
+ if (*value == 0.0) {
+ is_push = true;
+ }
break;
case UI_BTYPE_ROW:
case UI_BTYPE_LISTROW:
@@ -1696,10 +1763,14 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
UI_GET_BUT_VALUE_INIT(but, *value);
/* support for rna enum buts */
if (but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) {
- if ((int)*value & (int)but->hardmax) is_push = true;
+ if ((int)*value & (int)but->hardmax) {
+ is_push = true;
+ }
}
else {
- if (*value == (double)but->hardmax) is_push = true;
+ if (*value == (double)but->hardmax) {
+ is_push = true;
+ }
}
break;
default:
@@ -1748,74 +1819,6 @@ void UI_block_lock_clear(uiBlock *block)
* this either works with the pointed to data, or can work with
* an edit override pointer while dragging for example */
-/* Get PointerRNA which will point to a data inside of an evaluated
- * ID datablock.
- */
-static PointerRNA ui_but_evaluated_rnapoin_get(uiBut *but)
-{
- BLI_assert(but->rnaprop != NULL);
- /* TODO(sergey): evil_C sounds.. EVIL! Any clear way to avoid this? */
- PointerRNA rnapoin_eval = but->rnapoin;
- /* If there is no animation or drivers, it doesn't matter if we read value
- * from evaluated datablock or from original one.
- *
- * Reading from original one is much faster, since we don't need to do any
- * PointerRNA remapping or hash lookup.
- */
- if (BKE_animdata_from_id(but->rnapoin.id.data) == NULL) {
- return rnapoin_eval;
- }
- /* Same goes for the properties which can not be animated. */
- if (!RNA_property_animateable(&but->rnapoin, but->rnaprop)) {
- return rnapoin_eval;
- }
- Depsgraph *depsgraph = CTX_data_depsgraph(but->block->evil_C);
- /* ID pointer we can always remap, they are inside of depsgraph. */
- rnapoin_eval.id.data =
- DEG_get_evaluated_id(depsgraph, rnapoin_eval.id.data);
- /* Some of ID datablocks do not have their evaluated copy inside
- * of dependency graph. If it's such datablock, no need to worry about
- * data pointer.
- */
- if (rnapoin_eval.id.data == but->rnapoin.id.data) {
- return rnapoin_eval;
- }
- /* For the data pointer it's getting a bit more involved, since it can
- * whether be and ID, or can be a property deep inside of ID.
- *
- * We start from checking if it's an ID, since that is the less involved
- * code path, and probably is executed in most of the cases.
- */
- if (but->rnapoin.data == but->rnapoin.id.data) {
- rnapoin_eval.data = DEG_get_evaluated_id(depsgraph, rnapoin_eval.data);
- return rnapoin_eval;
- }
- /* We aren't as lucky as we thought we are :(
- *
- * Since we don't know what the property is, we get it's RNA path
- * relative to the original ID, and then we decent down from evaluated
- * ID to the same property.
- *
- * This seems to be most straightforward way to get sub-data pointers
- * which can be buried deep inside of ID block.
- */
- const char *rna_path =
- RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
- if (rna_path != NULL) {
- PointerRNA id_ptr;
- RNA_id_pointer_create(rnapoin_eval.id.data, &id_ptr);
- if (!RNA_path_resolve_full(&id_ptr,
- rna_path,
- &rnapoin_eval,
- NULL, NULL))
- {
- /* TODO(sergey): Anything to do here to recover? */
- }
- MEM_freeN((void *)rna_path);
- }
- return rnapoin_eval;
-}
-
/* for buttons pointing to color for example */
void ui_but_v3_get(uiBut *but, float vec[3])
{
@@ -1831,18 +1834,16 @@ void ui_but_v3_get(uiBut *but, float vec[3])
zero_v3(vec);
- PointerRNA rnapoin_eval = ui_but_evaluated_rnapoin_get(but);
-
if (RNA_property_type(prop) == PROP_FLOAT) {
- int tot = RNA_property_array_length(&rnapoin_eval, prop);
+ int tot = RNA_property_array_length(&but->rnapoin, prop);
BLI_assert(tot > 0);
if (tot == 3) {
- RNA_property_float_get_array(&rnapoin_eval, prop, vec);
+ RNA_property_float_get_array(&but->rnapoin, prop, vec);
}
else {
tot = min_ii(tot, 3);
for (a = 0; a < tot; a++) {
- vec[a] = RNA_property_float_get_index(&rnapoin_eval, prop, a);
+ vec[a] = RNA_property_float_get_index(&but->rnapoin, prop, a);
}
}
}
@@ -1913,25 +1914,30 @@ void ui_but_v3_set(uiBut *but, const float vec[3])
bool ui_but_is_float(const uiBut *but)
{
- if (but->pointype == UI_BUT_POIN_FLOAT && but->poin)
+ if (but->pointype == UI_BUT_POIN_FLOAT && but->poin) {
return true;
+ }
- if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT)
+ if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT) {
return true;
+ }
return false;
}
bool ui_but_is_bool(const uiBut *but)
{
- if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_TAB))
+ if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_TAB)) {
return true;
+ }
- if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_BOOLEAN)
+ if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_BOOLEAN) {
return true;
+ }
- if ((but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) && (but->type == UI_BTYPE_ROW))
+ if ((but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) && (but->type == UI_BTYPE_ROW)) {
return true;
+ }
return false;
}
@@ -1942,17 +1948,20 @@ bool ui_but_is_unit(const uiBut *but)
UnitSettings *unit = but->block->unit;
const int unit_type = UI_but_unit_type_get(but);
- if (unit_type == PROP_UNIT_NONE)
+ if (unit_type == PROP_UNIT_NONE) {
return false;
+ }
#if 1 /* removed so angle buttons get correct snapping */
- if (ui_but_is_unit_radians_ex(unit, unit_type))
+ if (ui_but_is_unit_radians_ex(unit, unit_type)) {
return false;
+ }
#endif
/* for now disable time unit conversion */
- if (unit_type == PROP_UNIT_TIME)
+ if (unit_type == PROP_UNIT_TIME) {
return false;
+ }
if (unit->system == USER_UNIT_NONE) {
if (unit_type != PROP_UNIT_ROTATION) {
@@ -1968,20 +1977,25 @@ bool ui_but_is_unit(const uiBut *but)
*/
bool ui_but_is_compatible(const uiBut *but_a, const uiBut *but_b)
{
- if (but_a->type != but_b->type)
+ if (but_a->type != but_b->type) {
return false;
- if (but_a->pointype != but_b->pointype)
+ }
+ if (but_a->pointype != but_b->pointype) {
return false;
+ }
if (but_a->rnaprop) {
/* skip 'rnapoin.data', 'rnapoin.id.data'
* allow different data to have the same props edited at once */
- if (but_a->rnapoin.type != but_b->rnapoin.type)
+ if (but_a->rnapoin.type != but_b->rnapoin.type) {
return false;
- if (RNA_property_type(but_a->rnaprop) != RNA_property_type(but_b->rnaprop))
+ }
+ if (RNA_property_type(but_a->rnaprop) != RNA_property_type(but_b->rnaprop)) {
return false;
- if (RNA_property_subtype(but_a->rnaprop) != RNA_property_subtype(but_b->rnaprop))
+ }
+ if (RNA_property_subtype(but_a->rnaprop) != RNA_property_subtype(but_b->rnaprop)) {
return false;
+ }
}
return true;
@@ -2014,37 +2028,45 @@ double ui_but_value_get(uiBut *but)
PropertyRNA *prop;
double value = 0.0;
- if (but->editval) { return *(but->editval); }
- if (but->poin == NULL && but->rnapoin.data == NULL) return 0.0;
+ if (but->editval) {
+ return *(but->editval);
+ }
+ if (but->poin == NULL && but->rnapoin.data == NULL) {
+ return 0.0;
+ }
if (but->rnaprop) {
prop = but->rnaprop;
BLI_assert(but->rnaindex != -1);
- PointerRNA rnapoin_eval = ui_but_evaluated_rnapoin_get(but);
-
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
- if (RNA_property_array_check(prop))
- value = RNA_property_boolean_get_index(&rnapoin_eval, prop, but->rnaindex);
- else
- value = RNA_property_boolean_get(&rnapoin_eval, prop);
+ if (RNA_property_array_check(prop)) {
+ value = RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex);
+ }
+ else {
+ value = RNA_property_boolean_get(&but->rnapoin, prop);
+ }
break;
case PROP_INT:
- if (RNA_property_array_check(prop))
- value = RNA_property_int_get_index(&rnapoin_eval, prop, but->rnaindex);
- else
- value = RNA_property_int_get(&rnapoin_eval, prop);
+ if (RNA_property_array_check(prop)) {
+ value = RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex);
+ }
+ else {
+ value = RNA_property_int_get(&but->rnapoin, prop);
+ }
break;
case PROP_FLOAT:
- if (RNA_property_array_check(prop))
- value = RNA_property_float_get_index(&rnapoin_eval, prop, but->rnaindex);
- else
- value = RNA_property_float_get(&rnapoin_eval, prop);
+ if (RNA_property_array_check(prop)) {
+ value = RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex);
+ }
+ else {
+ value = RNA_property_float_get(&but->rnapoin, prop);
+ }
break;
case PROP_ENUM:
- value = RNA_property_enum_get(&rnapoin_eval, prop);
+ value = RNA_property_enum_get(&but->rnapoin, prop);
break;
default:
value = 0.0;
@@ -2078,22 +2100,28 @@ void ui_but_value_set(uiBut *but, double value)
if (RNA_property_editable(&but->rnapoin, prop)) {
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
- if (RNA_property_array_check(prop))
+ if (RNA_property_array_check(prop)) {
RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value);
- else
+ }
+ else {
RNA_property_boolean_set(&but->rnapoin, prop, value);
+ }
break;
case PROP_INT:
- if (RNA_property_array_check(prop))
+ if (RNA_property_array_check(prop)) {
RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, (int)value);
- else
+ }
+ else {
RNA_property_int_set(&but->rnapoin, prop, (int)value);
+ }
break;
case PROP_FLOAT:
- if (RNA_property_array_check(prop))
+ if (RNA_property_array_check(prop)) {
RNA_property_float_set_index(&but->rnapoin, prop, but->rnaindex, value);
- else
+ }
+ else {
RNA_property_float_set(&but->rnapoin, prop, value);
+ }
break;
case PROP_ENUM:
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
@@ -2131,21 +2159,29 @@ void ui_but_value_set(uiBut *but, double value)
}
else if (but->pointype == UI_BUT_POIN_FLOAT) {
float fval = (float)value;
- if (fval >= -0.00001f && fval <= 0.00001f) fval = 0.0f; /* prevent negative zero */
+ if (fval >= -0.00001f && fval <= 0.00001f) {
+ /* prevent negative zero */
+ fval = 0.0f;
+ }
value = fval;
}
/* then set value with possible edit override */
- if (but->editval)
+ if (but->editval) {
value = *but->editval = value;
- else if (but->pointype == UI_BUT_POIN_CHAR)
+ }
+ else if (but->pointype == UI_BUT_POIN_CHAR) {
value = *((char *)but->poin) = (char)value;
- else if (but->pointype == UI_BUT_POIN_SHORT)
+ }
+ else if (but->pointype == UI_BUT_POIN_SHORT) {
value = *((short *)but->poin) = (short)value;
- else if (but->pointype == UI_BUT_POIN_INT)
+ }
+ else if (but->pointype == UI_BUT_POIN_INT) {
value = *((int *)but->poin) = (int)value;
- else if (but->pointype == UI_BUT_POIN_FLOAT)
+ }
+ else if (but->pointype == UI_BUT_POIN_FLOAT) {
value = *((float *)but->poin) = (float)value;
+ }
}
ui_but_update_select_flag(but, &value);
@@ -2153,10 +2189,12 @@ void ui_but_value_set(uiBut *but, double value)
int ui_but_string_get_max_length(uiBut *but)
{
- if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU))
+ if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
return but->hardmax;
- else
+ }
+ else {
return UI_MAX_DRAW_STR;
+ }
}
uiBut *ui_but_drag_multi_edit_get(uiBut *but)
@@ -2281,14 +2319,20 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va
int unit_type = UI_but_unit_type_get(but);
int precision;
- if (unit->scale_length < 0.0001f) unit->scale_length = 1.0f; // XXX do_versions
+ if (unit->scale_length < 0.0001f) {
+ unit->scale_length = 1.0f; // XXX do_versions
+ }
/* Use precision override? */
if (float_precision == -1) {
/* Sanity checks */
precision = (int)but->a2;
- if (precision > UI_PRECISION_FLOAT_MAX) precision = UI_PRECISION_FLOAT_MAX;
- else if (precision == -1) precision = 2;
+ if (precision > UI_PRECISION_FLOAT_MAX) {
+ precision = UI_PRECISION_FLOAT_MAX;
+ }
+ else if (precision == -1) {
+ precision = 2;
+ }
}
else {
precision = float_precision;
@@ -2411,12 +2455,27 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
value = ui_but_value_get(but);
+ PropertySubType subtype = PROP_NONE;
+ if (but->rnaprop) {
+ subtype = RNA_property_subtype(but->rnaprop);
+ }
+
if (ui_but_is_float(but)) {
+ int prec = (float_precision == -1) ? ui_but_calc_float_precision(but, value) : float_precision;
+
if (ui_but_is_unit(but)) {
- ui_get_but_string_unit(but, str, maxlen, value, false, float_precision);
+ ui_get_but_string_unit(but, str, maxlen, value, false, prec);
+ }
+ else if (subtype == PROP_FACTOR) {
+ if (U.factor_display_type == USER_FACTOR_AS_FACTOR) {
+ BLI_snprintf(str, maxlen, "%.*f", prec, value);
+ }
+ else {
+ BLI_snprintf(str, maxlen, "%.*f", MAX2(0, prec - 2), value * 100);
+ }
+
}
else {
- int prec = (float_precision == -1) ? ui_but_calc_float_precision(but, value) : float_precision;
if (use_exp_float) {
const int int_digits_num = integer_digits_f(value);
if (int_digits_num < -6 || int_digits_num > 12) {
@@ -2514,44 +2573,80 @@ static bool ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char
return user_string_to_number(C, str, unit, type, r_value);
}
-bool ui_but_string_set_eval_num(bContext *C, uiBut *but, const char *str, double *r_value)
+static bool ui_number_from_string(bContext *C, const char *str, double *r_value)
{
- bool ok = false;
-
#ifdef WITH_PYTHON
+ return BPY_execute_string_as_number(C, NULL, str, true, r_value);
+#else
+ *r_value = atof(str);
+ return true;
+#endif
+}
- if (str[0] != '\0') {
- bool is_unit_but = (ui_but_is_float(but) && ui_but_is_unit(but));
- /* only enable verbose if we won't run again with units */
- if (BPY_execute_string_as_number(C, NULL, str, is_unit_but == false, r_value)) {
- /* if the value parsed ok without unit conversion
- * this button may still need a unit multiplier */
- if (is_unit_but) {
- char str_new[128];
-
- BLI_snprintf(str_new, sizeof(str_new), "%f", *r_value);
- ok = ui_set_but_string_eval_num_unit(C, but, str_new, r_value);
- }
- else {
- ok = true; /* parse normal string via py (no unit conversion needed) */
- }
+static bool ui_number_from_string_factor(bContext *C, const char *str, double *r_value)
+{
+ int len = strlen(str);
+ if (BLI_strn_endswith(str, "%", len)) {
+ char *str_new = BLI_strdupn(str, len - 1);
+ bool success = ui_number_from_string(C, str_new, r_value);
+ MEM_freeN(str_new);
+ *r_value /= 100.0;
+ return success;
+ }
+ else {
+ if (!ui_number_from_string(C, str, r_value)) {
+ return false;
}
- else if (is_unit_but) {
- /* parse failed, this is a unit but so run replacements and parse again */
- ok = ui_set_but_string_eval_num_unit(C, but, str, r_value);
+ if (U.factor_display_type == USER_FACTOR_AS_PERCENTAGE) {
+ *r_value /= 100.0;
}
+ return true;
}
+}
-#else /* WITH_PYTHON */
-
- *r_value = atof(str);
- ok = true;
+static bool ui_number_from_string_percentage(bContext *C, const char *str, double *r_value)
+{
+ int len = strlen(str);
+ if (BLI_strn_endswith(str, "%", len)) {
+ char *str_new = BLI_strdupn(str, len - 1);
+ bool success = ui_number_from_string(C, str_new, r_value);
+ MEM_freeN(str_new);
+ return success;
+ }
+ else {
+ return ui_number_from_string(C, str, r_value);
+ }
+}
- UNUSED_VARS(C, but);
+bool ui_but_string_set_eval_num(bContext *C, uiBut *but, const char *str, double *r_value)
+{
+ if (str[0] == '\0') {
+ *r_value = 0.0;
+ return true;
+ }
-#endif /* WITH_PYTHON */
+ PropertySubType subtype = PROP_NONE;
+ if (but->rnaprop) {
+ subtype = RNA_property_subtype(but->rnaprop);
+ }
- return ok;
+ if (ui_but_is_float(but)) {
+ if (ui_but_is_unit(but)) {
+ return ui_set_but_string_eval_num_unit(C, but, str, r_value);
+ }
+ else if (subtype == PROP_FACTOR) {
+ return ui_number_from_string_factor(C, str, r_value);
+ }
+ else if (subtype == PROP_PERCENTAGE) {
+ return ui_number_from_string_percentage(C, str, r_value);
+ }
+ else {
+ return ui_number_from_string(C, str, r_value);
+ }
+ }
+ else {
+ return ui_number_from_string(C, str, r_value);
+ }
}
/* just the assignment/free part */
@@ -2693,8 +2788,8 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
}
/* not that we use hard limits here */
- if (value < (double)but->hardmin) value = but->hardmin;
- if (value > (double)but->hardmax) value = but->hardmax;
+ if (value < (double)but->hardmin) { value = but->hardmin; }
+ if (value > (double)but->hardmax) { value = but->hardmax; }
ui_but_value_set(but, value);
return true;
@@ -2727,12 +2822,15 @@ static double soft_range_round_up(double value, double max)
* checking for 0.0 prevents floating point exceptions */
double newmax = (value != 0.0) ? pow(10.0, ceil(log(value) / M_LN10)) : 0.0;
- if (newmax * 0.2 >= max && newmax * 0.2 >= value)
+ if (newmax * 0.2 >= max && newmax * 0.2 >= value) {
return newmax * 0.2;
- else if (newmax * 0.5 >= max && newmax * 0.5 >= value)
+ }
+ else if (newmax * 0.5 >= max && newmax * 0.5 >= value) {
return newmax * 0.5;
- else
+ }
+ else {
return newmax;
+ }
}
static double soft_range_round_down(double value, double max)
@@ -2741,12 +2839,15 @@ static double soft_range_round_down(double value, double max)
* checking for 0.0 prevents floating point exceptions */
double newmax = (value != 0.0) ? pow(10.0, floor(log(value) / M_LN10)) : 0.0;
- if (newmax * 5.0 <= max && newmax * 5.0 <= value)
+ if (newmax * 5.0 <= max && newmax * 5.0 <= value) {
return newmax * 5.0;
- else if (newmax * 2.0 <= max && newmax * 2.0 <= value)
+ }
+ else if (newmax * 2.0 <= max && newmax * 2.0 <= value) {
return newmax * 2.0;
- else
+ }
+ else {
return newmax;
+ }
}
/* note: this could be split up into functions which handle arrays and not */
@@ -2810,22 +2911,28 @@ static void ui_set_but_soft_range(uiBut *but)
/* if the value goes out of the soft/max range, adapt the range */
if (value_min + 1e-10 < softmin) {
- if (value_min < 0.0)
+ if (value_min < 0.0) {
softmin = -soft_range_round_up(-value_min, -softmin);
- else
+ }
+ else {
softmin = soft_range_round_down(value_min, softmin);
+ }
- if (softmin < (double)but->hardmin)
+ if (softmin < (double)but->hardmin) {
softmin = (double)but->hardmin;
+ }
}
if (value_max - 1e-10 > softmax) {
- if (value_max < 0.0)
+ if (value_max < 0.0) {
softmax = -soft_range_round_down(-value_max, -softmax);
- else
+ }
+ else {
softmax = soft_range_round_up(value_max, softmax);
+ }
- if (softmax > (double)but->hardmax)
+ if (softmax > (double)but->hardmax) {
softmax = but->hardmax;
+ }
}
but->softmin = softmin;
@@ -2866,7 +2973,7 @@ static void ui_but_free(const bContext *C, uiBut *but)
MEM_freeN(but->hold_argN);
}
- if (!but->editstr && but->free_search_arg) {
+ if (but->free_search_arg) {
MEM_SAFE_FREE(but->search_arg);
}
@@ -2970,8 +3077,9 @@ void UI_blocklist_free_inactive(const bContext *C, ListBase *lb)
BLI_remlink(lb, block);
UI_block_free(C, block);
}
- else
+ else {
block->active = 0;
+ }
}
}
}
@@ -3031,8 +3139,9 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, sh
BLI_strncpy(block->name, name, sizeof(block->name));
- if (region)
+ if (region) {
UI_block_region_set(block, region);
+ }
/* Set window matrix and aspect for region and OpenGL state. */
ui_update_window_matrix(window, region, block);
@@ -3080,6 +3189,16 @@ static void ui_but_build_drawstr_float(uiBut *but, double value)
int prec = ui_but_calc_float_precision(but, value);
STR_CONCATF(but->drawstr, slen, "%.*f px", prec, value);
}
+ else if (subtype == PROP_FACTOR) {
+ int precision = ui_but_calc_float_precision(but, value);
+
+ if (U.factor_display_type == USER_FACTOR_AS_FACTOR) {
+ STR_CONCATF(but->drawstr, slen, "%.*f", precision, value);
+ }
+ else {
+ STR_CONCATF(but->drawstr, slen, "%.*f %%", MAX2(0, precision - 2), value * 100);
+ }
+ }
else if (ui_but_is_unit(but)) {
char new_str[sizeof(but->drawstr)];
ui_get_but_string_unit(but, new_str, sizeof(new_str), value, true, -1);
@@ -3116,7 +3235,7 @@ static void ui_but_build_drawstr_int(uiBut *but, int value)
* \param validate: When set, this function may change the button value.
* Otherwise treat the button value as read-only.
*/
-void ui_but_update_ex(uiBut *but, const bool validate)
+static void ui_but_update_ex(uiBut *but, const bool validate)
{
/* if something changed in the button */
double value = UI_BUT_VALUE_UNSET;
@@ -3124,7 +3243,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
ui_but_update_select_flag(but, &value);
/* only update soft range while not editing */
- if (!(but->editval || but->editstr || but->editvec)) {
+ if (!ui_but_is_editing(but)) {
if ((but->rnaprop != NULL) ||
(but->poin && (but->pointype & UI_BUT_POIN_TYPES)))
{
@@ -3255,14 +3374,18 @@ void ui_but_update_ex(uiBut *but, const bool validate)
char *str = but->drawstr;
but->drawstr[0] = '\0';
- if (but->modifier_key & KM_SHIFT)
+ if (but->modifier_key & KM_SHIFT) {
str += BLI_strcpy_rlen(str, "Shift ");
- if (but->modifier_key & KM_CTRL)
+ }
+ if (but->modifier_key & KM_CTRL) {
str += BLI_strcpy_rlen(str, "Ctrl ");
- if (but->modifier_key & KM_ALT)
+ }
+ if (but->modifier_key & KM_ALT) {
str += BLI_strcpy_rlen(str, "Alt ");
- if (but->modifier_key & KM_OSKEY)
+ }
+ if (but->modifier_key & KM_OSKEY) {
str += BLI_strcpy_rlen(str, "Cmd ");
+ }
(void)str; /* UNUSED */
}
@@ -3270,8 +3393,9 @@ void ui_but_update_ex(uiBut *but, const bool validate)
BLI_strncpy(but->drawstr, "Press a key", UI_MAX_DRAW_STR);
}
}
- else
+ else {
BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+ }
break;
@@ -3285,8 +3409,9 @@ void ui_but_update_ex(uiBut *but, const bool validate)
}
/* if we are doing text editing, this will override the drawstr */
- if (but->editstr)
+ if (but->editstr) {
but->drawstr[0] = '\0';
+ }
/* text clipping moved to widget drawing code itself */
}
@@ -3304,7 +3429,9 @@ void ui_but_update_edited(uiBut *but)
void UI_block_align_begin(uiBlock *block)
{
/* if other align was active, end it */
- if (block->flag & UI_BUT_ALIGN) UI_block_align_end(block);
+ if (block->flag & UI_BUT_ALIGN) {
+ UI_block_align_end(block);
+ }
block->flag |= UI_BUT_ALIGN_DOWN;
block->alignnr++;
@@ -3404,16 +3531,18 @@ static uiBut *ui_def_but(
but->block = block; /* pointer back, used for frontbuffer status, and picker */
- if ((block->flag & UI_BUT_ALIGN) && ui_but_can_align(but))
+ if ((block->flag & UI_BUT_ALIGN) && ui_but_can_align(but)) {
but->alignnr = block->alignnr;
+ }
but->func = block->func;
but->func_arg1 = block->func_arg1;
but->func_arg2 = block->func_arg2;
but->funcN = block->funcN;
- if (block->func_argN)
+ if (block->func_argN) {
but->func_argN = MEM_dupallocN(block->func_argN);
+ }
but->pos = -1; /* cursor invisible */
@@ -3472,8 +3601,9 @@ static uiBut *ui_def_but(
BLI_addtail(&block->buttons, but);
- if (block->curlayout)
+ if (block->curlayout) {
ui_layout_add_but(block->curlayout, but);
+ }
#ifdef WITH_PYTHON
/* if the 'UI_OT_editsource' is running, extract the source info from the button */
@@ -3544,16 +3674,20 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
/* Columns and row estimation. Ignore simple separators here. */
columns = (nbr_entries_nosepr + 20) / 20;
- if (columns < 1)
+ if (columns < 1) {
columns = 1;
- if (columns > 8)
+ }
+ if (columns > 8) {
columns = (nbr_entries_nosepr + 25) / 25;
+ }
rows = totitems / columns;
- if (rows < 1)
+ if (rows < 1) {
rows = 1;
- while (rows * columns < totitems)
+ }
+ while (rows * columns < totitems) {
rows++;
+ }
if (block->flag & UI_BLOCK_NO_FLIP) {
/* Title at the top for menus with categories. */
@@ -3633,6 +3767,59 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
block->flag |= UI_BLOCK_IS_FLIP;
}
+static void ui_def_but_rna__panel_type(bContext *C, uiLayout *layout, void *but_p)
+{
+ uiBut *but = but_p;
+ const char *panel_type = but->func_argN;
+ PanelType *pt = WM_paneltype_find(panel_type, true);
+ if (pt) {
+ ui_item_paneltype_func(C, layout, pt);
+ }
+ else {
+ char msg[256];
+ SNPRINTF(msg, "Missing Panel: %s", panel_type);
+ uiItemL(layout, msg, ICON_NONE);
+ }
+}
+
+void ui_but_rna_menu_convert_to_panel_type(uiBut *but, const char *panel_type)
+{
+ BLI_assert(but->type == UI_BTYPE_MENU);
+ BLI_assert(but->menu_create_func == ui_def_but_rna__menu);
+ BLI_assert((void *)but->poin == but);
+ but->menu_create_func = ui_def_but_rna__panel_type;
+ but->func_argN = BLI_strdup(panel_type);
+}
+
+bool ui_but_menu_draw_as_popover(const uiBut *but)
+{
+ return (but->menu_create_func == ui_def_but_rna__panel_type);
+}
+
+static void ui_def_but_rna__menu_type(bContext *C, uiLayout *layout, void *but_p)
+{
+ uiBut *but = but_p;
+ const char *menu_type = but->func_argN;
+ MenuType *mt = WM_menutype_find(menu_type, true);
+ if (mt) {
+ ui_item_menutype_func(C, layout, mt);
+ }
+ else {
+ char msg[256];
+ SNPRINTF(msg, "Missing Menu: %s", menu_type);
+ uiItemL(layout, msg, ICON_NONE);
+ }
+}
+
+void ui_but_rna_menu_convert_to_menu_type(uiBut *but, const char *menu_type)
+{
+ BLI_assert(but->type == UI_BTYPE_MENU);
+ BLI_assert(but->menu_create_func == ui_def_but_rna__menu);
+ BLI_assert((void *)but->poin == but);
+ but->menu_create_func = ui_def_but_rna__menu_type;
+ but->func_argN = BLI_strdup(menu_type);
+}
+
static void ui_but_submenu_enable(uiBlock *block, uiBut *but)
{
but->flag |= UI_BUT_ICON_SUBMENU;
@@ -3717,8 +3904,9 @@ static uiBut *ui_def_but_rna(
icon = RNA_property_ui_icon(prop);
}
- if (!tip && proptype != PROP_ENUM)
+ if (!tip && proptype != PROP_ENUM) {
tip = RNA_property_ui_description(prop);
+ }
if (min == max || a1 == -1 || a2 == -1) {
if (proptype == PROP_INT) {
@@ -3731,10 +3919,12 @@ static uiBut *ui_def_but_rna(
min = hardmin;
max = hardmax;
}
- if (a1 == -1)
+ if (a1 == -1) {
a1 = step;
- if (a2 == -1)
+ }
+ if (a2 == -1) {
a2 = 0;
+ }
}
else if (proptype == PROP_FLOAT) {
float hardmin, hardmax, softmin, softmax, step, precision;
@@ -3746,10 +3936,12 @@ static uiBut *ui_def_but_rna(
min = hardmin;
max = hardmax;
}
- if (a1 == -1)
+ if (a1 == -1) {
a1 = step;
- if (a2 == -1)
+ }
+ if (a2 == -1) {
a2 = precision;
+ }
}
else if (proptype == PROP_STRING) {
min = 0;
@@ -3764,10 +3956,12 @@ static uiBut *ui_def_but_rna(
but->rnapoin = *ptr;
but->rnaprop = prop;
- if (RNA_property_array_check(but->rnaprop))
+ if (RNA_property_array_check(but->rnaprop)) {
but->rnaindex = index;
- else
+ }
+ else {
but->rnaindex = 0;
+ }
if (icon) {
ui_def_but_icon(but, icon, UI_HAS_ICON);
@@ -3829,10 +4023,12 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *
uiBut *but;
if (!str) {
- if (ot && ot->srna)
+ if (ot && ot->srna) {
str = RNA_struct_ui_name(ot->srna);
- else
+ }
+ else {
str = "";
+ }
}
if ((!tip || tip[0] == '\0') && ot && ot->srna) {
@@ -3916,15 +4112,17 @@ void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name)
int a;
for (a = 0; a < autocpl->maxlen - 1; a++) {
- if (startname[a] == 0 || startname[a] != name[a])
+ if (startname[a] == 0 || startname[a] != name[a]) {
break;
+ }
}
/* found a match */
if (startname[a] == 0) {
autocpl->matches++;
/* first match */
- if (truncate[0] == 0)
+ if (truncate[0] == 0) {
BLI_strncpy(truncate, name, autocpl->maxlen);
+ }
else {
/* remove from truncate what is not in bone->name */
for (a = 0; a < autocpl->maxlen - 1; a++) {
@@ -3932,8 +4130,9 @@ void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name)
truncate[a] = 0;
break;
}
- else if (truncate[a] != name[a])
+ else if (truncate[a] != name[a]) {
truncate[a] = 0;
+ }
}
}
}
@@ -4038,7 +4237,9 @@ uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext
uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0);
- if (str == NULL && ot == NULL) str = opname;
+ if (str == NULL && ot == NULL) {
+ str = opname;
+ }
return uiDefButO_ptr(block, type, ot, opcontext, str, x, y, width, height, tip);
}
@@ -4198,8 +4399,9 @@ uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int o
uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0);
- if (str && str[0] == '\0')
+ if (str && str[0] == '\0') {
return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x, y, width, height, tip);
+ }
return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x, y, width, height, tip);
}
@@ -4212,9 +4414,11 @@ int UI_blocklist_min_y_get(ListBase *lb)
uiBlock *block;
int min = 0;
- for (block = lb->first; block; block = block->next)
- if (block == lb->first || block->rect.ymin < min)
+ for (block = lb->first; block; block = block->next) {
+ if (block == lb->first || block->rect.ymin < min) {
min = block->rect.ymin;
+ }
+ }
return min;
}
@@ -4230,15 +4434,23 @@ void UI_block_order_flip(uiBlock *block)
uiBut *but;
float centy, miny = 10000, maxy = -10000;
- if (U.uiflag & USER_MENUFIXEDORDER)
+ if (U.uiflag & USER_MENUFIXEDORDER) {
return;
- else if (block->flag & UI_BLOCK_NO_FLIP)
+ }
+ else if (block->flag & UI_BLOCK_NO_FLIP) {
return;
+ }
for (but = block->buttons.first; but; but = but->next) {
- if (but->drawflag & UI_BUT_ALIGN) return;
- if (but->rect.ymin < miny) miny = but->rect.ymin;
- if (but->rect.ymax > maxy) maxy = but->rect.ymax;
+ if (but->drawflag & UI_BUT_ALIGN) {
+ return;
+ }
+ if (but->rect.ymin < miny) {
+ miny = but->rect.ymin;
+ }
+ if (but->rect.ymax > maxy) {
+ maxy = but->rect.ymax;
+ }
}
/* mirror trick */
centy = (miny + maxy) / 2.0f;
@@ -4624,7 +4836,7 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle
void UI_but_func_search_set(
uiBut *but,
uiButSearchCreateFunc search_create_func,
- uiButSearchFunc search_func, void *arg,
+ uiButSearchFunc search_func, void *arg, bool free_arg,
uiButHandleFunc bfunc, void *active)
{
/* needed since callers don't have access to internal functions
@@ -4633,9 +4845,14 @@ void UI_but_func_search_set(
search_create_func = ui_searchbox_create_generic;
}
+ if (but->free_search_arg) {
+ MEM_SAFE_FREE(but->search_arg);
+ }
+
but->search_create_func = search_create_func;
but->search_func = search_func;
but->search_arg = arg;
+ but->free_search_arg = free_arg;
if (bfunc) {
#ifdef DEBUG
@@ -4650,8 +4867,9 @@ void UI_but_func_search_set(
/* search buttons show red-alert if item doesn't exist, not for menus */
if (0 == (but->block->flag & UI_BLOCK_LOOP)) {
/* skip empty buttons, not all buttons need input, we only show invalid */
- if (but->drawstr[0])
+ if (but->drawstr[0]) {
ui_but_search_refresh(but);
+ }
}
}
@@ -4680,8 +4898,9 @@ static void operator_enum_search_cb(const struct bContext *C, void *but, const c
/* note: need to give the index rather than the
* identifier because the enum can be freed */
if (BLI_strcasestr(item->name, str)) {
- if (false == UI_search_item_add(items, item->name, POINTER_FROM_INT(item->value), item->icon))
+ if (false == UI_search_item_add(items, item->name, POINTER_FROM_INT(item->value), item->icon)) {
break;
+ }
}
}
@@ -4724,7 +4943,7 @@ uiBut *uiDefSearchButO_ptr(
but = uiDefSearchBut(block, arg, retval, icon, maxlen, x, y, width, height, a1, a2, tip);
UI_but_func_search_set(
but, ui_searchbox_create_generic, operator_enum_search_cb,
- but, operator_enum_call_cb, NULL);
+ but, false, operator_enum_call_cb, NULL);
but->optype = ot;
but->opcontext = WM_OP_EXEC_DEFAULT;
@@ -4800,21 +5019,26 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
if (but->tip_func) {
tmp = but->tip_func(C, but->tip_argN, but->tip);
}
- else if (but->tip && but->tip[0])
+ else if (but->tip && but->tip[0]) {
tmp = BLI_strdup(but->tip);
- else
+ }
+ else {
type = BUT_GET_RNA_TIP; /* Fail-safe solution... */
+ }
}
if (type == BUT_GET_RNAPROP_IDENTIFIER) {
- if (but->rnaprop)
+ if (but->rnaprop) {
tmp = BLI_strdup(RNA_property_identifier(but->rnaprop));
+ }
}
else if (type == BUT_GET_RNASTRUCT_IDENTIFIER) {
- if (but->rnaprop && but->rnapoin.data)
+ if (but->rnaprop && but->rnapoin.data) {
tmp = BLI_strdup(RNA_struct_identifier(but->rnapoin.type));
- else if (but->optype)
+ }
+ else if (but->optype) {
tmp = BLI_strdup(but->optype->idname);
+ }
else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) {
MenuType *mt = UI_but_menutype_get(but);
if (mt) {
@@ -4830,21 +5054,25 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
}
else if (ELEM(type, BUT_GET_RNA_LABEL, BUT_GET_RNA_TIP)) {
if (but->rnaprop) {
- if (type == BUT_GET_RNA_LABEL)
+ if (type == BUT_GET_RNA_LABEL) {
tmp = BLI_strdup(RNA_property_ui_name(but->rnaprop));
+ }
else {
const char *t = RNA_property_ui_description(but->rnaprop);
- if (t && t[0])
+ if (t && t[0]) {
tmp = BLI_strdup(t);
+ }
}
}
else if (but->optype) {
- if (type == BUT_GET_RNA_LABEL)
+ if (type == BUT_GET_RNA_LABEL) {
tmp = BLI_strdup(RNA_struct_ui_name(but->optype->srna));
+ }
else {
const char *t = RNA_struct_ui_description(but->optype->srna);
- if (t && t[0])
+ if (t && t[0]) {
tmp = BLI_strdup(t);
+ }
}
}
else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) {
@@ -4852,12 +5080,14 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
if (mt) {
/* not all menus are from python */
if (mt->ext.srna) {
- if (type == BUT_GET_RNA_LABEL)
+ if (type == BUT_GET_RNA_LABEL) {
tmp = BLI_strdup(RNA_struct_ui_name(mt->ext.srna));
+ }
else {
const char *t = RNA_struct_ui_description(mt->ext.srna);
- if (t && t[0])
+ if (t && t[0]) {
tmp = BLI_strdup(t);
+ }
}
}
}
@@ -4865,14 +5095,17 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
}
else if (type == BUT_GET_RNA_LABEL_CONTEXT) {
const char *_tmp = BLT_I18NCONTEXT_DEFAULT;
- if (but->rnaprop)
+ if (but->rnaprop) {
_tmp = RNA_property_translation_context(but->rnaprop);
- else if (but->optype)
+ }
+ else if (but->optype) {
_tmp = RNA_struct_translation_context(but->optype->srna);
+ }
else if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_PULLDOWN)) {
MenuType *mt = UI_but_menutype_get(but);
- if (mt)
+ if (mt) {
_tmp = RNA_struct_translation_context(mt->ext.srna);
+ }
}
if (BLT_is_default_context(_tmp)) {
_tmp = BLT_I18NCONTEXT_DEFAULT_BPYRNA;
@@ -4919,17 +5152,21 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
RNA_property_enum_items_gettexted(C, ptr, prop, &items, &totitems, &free_items);
for (i = 0, item = items; i < totitems; i++, item++) {
- if (item->identifier[0] && item->value == value)
+ if (item->identifier[0] && item->value == value) {
break;
+ }
}
}
if (item && item->identifier) {
- if (type == BUT_GET_RNAENUM_IDENTIFIER)
+ if (type == BUT_GET_RNAENUM_IDENTIFIER) {
tmp = BLI_strdup(item->identifier);
- else if (type == BUT_GET_RNAENUM_LABEL)
+ }
+ else if (type == BUT_GET_RNAENUM_LABEL) {
tmp = BLI_strdup(item->name);
- else if (item->description && item->description[0])
+ }
+ else if (item->description && item->description[0]) {
tmp = BLI_strdup(item->description);
+ }
}
}
}
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c
index 9fc8c8f4bb1..8e7dc792da6 100644
--- a/source/blender/editors/interface/interface_align.c
+++ b/source/blender/editors/interface/interface_align.c
@@ -555,8 +555,12 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
for (but = first; but && but->alignnr == nr; but = but->next) {
if (but->next && but->next->alignnr == nr) {
- if (buts_are_horiz(but, but->next)) cols++;
- else rows++;
+ if (buts_are_horiz(but, but->next)) {
+ cols++;
+ }
+ else {
+ rows++;
+ }
}
}
@@ -565,8 +569,9 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
/* note; how it uses 'flag' in loop below (either set it, or OR it) is confusing */
for (but = first, prev = NULL; but && but->alignnr == nr; prev = but, but = but->next) {
next = but->next;
- if (next && next->alignnr != nr)
+ if (next && next->alignnr != nr) {
next = NULL;
+ }
/* clear old flag */
but->drawflag &= ~UI_BUT_ALIGN;
@@ -574,10 +579,12 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
if (flag == 0) { /* first case */
if (next) {
if (buts_are_horiz(but, next)) {
- if (rows == 0)
+ if (rows == 0) {
flag = UI_BUT_ALIGN_RIGHT;
- else
+ }
+ else {
flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_RIGHT;
+ }
}
else {
flag = UI_BUT_ALIGN_DOWN;
@@ -587,10 +594,12 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
else if (next == NULL) { /* last case */
if (prev) {
if (buts_are_horiz(prev, but)) {
- if (rows == 0)
+ if (rows == 0) {
flag = UI_BUT_ALIGN_LEFT;
- else
+ }
+ else {
flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT;
+ }
}
else {
flag = UI_BUT_ALIGN_TOP;
@@ -611,7 +620,9 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
}
bt = bt->next;
}
- if (bt == NULL || bt->alignnr != nr) flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT;
+ if (bt == NULL || bt->alignnr != nr) {
+ flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT;
+ }
}
}
else {
@@ -624,8 +635,9 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
}
else { /* next button switches to new row */
- if (prev && buts_are_horiz(prev, but))
+ if (prev && buts_are_horiz(prev, but)) {
flag |= UI_BUT_ALIGN_LEFT;
+ }
else {
flag &= ~UI_BUT_ALIGN_LEFT;
flag |= UI_BUT_ALIGN_TOP;
@@ -633,18 +645,21 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
if ((flag & UI_BUT_ALIGN_TOP) == 0) { /* still top row */
if (prev) {
- if (next && buts_are_horiz(but, next))
+ if (next && buts_are_horiz(but, next)) {
flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT;
+ }
else {
/* last button in top row */
flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT;
}
}
- else
+ else {
flag |= UI_BUT_ALIGN_DOWN;
+ }
}
- else
+ else {
flag |= UI_BUT_ALIGN_TOP;
+ }
}
}
@@ -674,8 +689,9 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
prev->rect.ymin = but->rect.ymax;
but->rect.xmin = prev->rect.xmin;
- if (next && buts_are_horiz(but, next) == 0)
+ if (next && buts_are_horiz(but, next) == 0) {
but->rect.xmax = prev->rect.xmax;
+ }
}
else {
/* the previous button is not a single one in its row */
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index c8a9f3b9446..a4476b4d2f1 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -86,16 +86,19 @@ void ui_but_anim_flag(uiBut *but, float cfra)
* we need to correct the frame number to "look inside" the
* remapped action
*/
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
+ }
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
but->flag |= UI_BUT_ANIMATED_KEY;
+ }
/* XXX: this feature is totally broken and useless with NLA */
if (adt == NULL || adt->nla_tracks.first == NULL) {
- if (fcurve_is_changed(but->rnapoin, but->rnaprop, fcu, cfra))
+ if (fcurve_is_changed(but->rnapoin, but->rnaprop, fcu, cfra)) {
but->drawflag |= UI_BUT_ANIMATED_CHANGED;
+ }
}
}
else {
@@ -196,15 +199,17 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
/* button must have RNA-pointer to a numeric-capable property */
if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("ERROR: create expression failed - button has no RNA info attached\n");
+ }
return false;
}
if (RNA_property_array_check(but->rnaprop) != 0) {
if (but->rnaindex == -1) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("ERROR: create expression failed - can't create expression for entire array\n");
+ }
return false;
}
}
@@ -214,8 +219,9 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
* don't allow drivers to be created for them */
id = (ID *)but->rnapoin.id.data;
if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("ERROR: create expression failed - invalid data-block for adding drivers (%p)\n", id);
+ }
return false;
}
@@ -262,8 +268,9 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
fcu = ui_but_get_fcurve(but, NULL, &action, &driven, &special);
- if (fcu == NULL)
+ if (fcu == NULL) {
return;
+ }
if (special) {
/* NLA Strip property */
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 7ed80aac28f..b5eb6302f81 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -110,7 +110,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
- UI_block_bounds_set_popup(block, 6, -50, 26);
+ UI_block_bounds_set_popup(block, 6, (const int[2]){-50, 26});
return block;
}
@@ -139,8 +139,9 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
kmi_id = kmi->id;
/* copy properties, prop can be NULL for reset */
- if (prop)
+ if (prop) {
prop = IDP_CopyProperty(prop);
+ }
WM_keymap_properties_reset(kmi, prop);
/* update and get pointers again */
@@ -159,7 +160,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
- UI_block_bounds_set_popup(block, 6, -50, 26);
+ UI_block_bounds_set_popup(block, 6, (const int[2]){-50, 26});
#ifdef USE_KEYMAP_ADD_HACK
g_kmi_id_hack = kmi_id;
@@ -407,8 +408,9 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
/* second slower test,
* saved people finding keyframe items in menus when its not possible */
- if (is_anim)
+ if (is_anim) {
is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop);
+ }
/* determine if we can key a single component of an array */
const bool is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0;
@@ -678,9 +680,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
/* Pointer properties and string properties with
* prop_search support jumping to target object/bone. */
if (but->rnapoin.data && but->rnaprop) {
- const PropertyType type = RNA_property_type(but->rnaprop);
-
- if ((type == PROP_POINTER) || (type == PROP_STRING && but->type == UI_BTYPE_SEARCH_MENU && but->search_func == ui_rna_collection_search_cb)) {
+ const PropertyType prop_type = RNA_property_type(but->rnaprop);
+ if (((prop_type == PROP_POINTER) ||
+ (prop_type == PROP_STRING &&
+ but->type == UI_BTYPE_SEARCH_MENU &&
+ but->search_func == ui_rna_collection_search_cb)) &&
+ ui_jump_to_target_button_poll(C))
+ {
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Jump To Target"),
ICON_NONE, "UI_OT_jump_to_target_button");
uiItemS(layout);
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 7a9b65ac830..4185339cc92 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -637,7 +637,9 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors *UN
#else
ImBuf *ibuf = (ImBuf *)but->poin;
- if (!ibuf) return;
+ if (!ibuf) {
+ return;
+ }
float facx = 1.0f;
float facy = 1.0f;
@@ -732,8 +734,9 @@ static void histogram_draw_one(
float color[4] = {r, g, b, alpha};
/* that can happen */
- if (res == 0)
+ if (res == 0) {
return;
+ }
GPU_line_smooth(true);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE);
@@ -846,12 +849,15 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors
histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_a, res, is_line, pos);
}
else {
- if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_R)
+ if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_R) {
histogram_draw_one(1.0, 0.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_r, res, is_line, pos);
- if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_G)
+ }
+ if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_G) {
histogram_draw_one(0.0, 1.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_g, res, is_line, pos);
- if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B)
+ }
+ if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B) {
histogram_draw_one(0.0, 0.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_b, res, is_line, pos);
+ }
}
immUnbindProgram();
@@ -891,7 +897,9 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors
float colors_alpha[3][3], colorsycc_alpha[3][3];
float min, max;
- if (scopes == NULL) return;
+ if (scopes == NULL) {
+ return;
+ }
rctf rect = {
.xmin = (float)recti->xmin + 1,
@@ -900,8 +908,9 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors
.ymax = (float)recti->ymax - 1,
};
- if (scopes->wavefrm_yfac < 0.5f)
+ if (scopes->wavefrm_yfac < 0.5f) {
scopes->wavefrm_yfac = 0.98f;
+ }
float w = BLI_rctf_size_x(&rect) - 7;
float h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
float yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) * 0.5f;
@@ -1083,10 +1092,12 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColors
/* min max */
if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA ) {
for (int c = 0; c < 3; c++) {
- if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_RGB_PARADE, SCOPES_WAVEFRM_RGB))
+ if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_RGB_PARADE, SCOPES_WAVEFRM_RGB)) {
immUniformColor3f(colors[c][0] * 0.75f, colors[c][1] * 0.75f, colors[c][2] * 0.75f);
- else
+ }
+ else {
immUniformColor3f(colorsycc[c][0] * 0.75f, colorsycc[c][1] * 0.75f, colorsycc[c][2] * 0.75f);
+ }
min = yofs + scopes->minmax[c][0] * h;
max = yofs + scopes->minmax[c][1] * h;
CLAMP(min, rect.ymin, rect.ymax);
@@ -1125,11 +1136,22 @@ static void vectorscope_draw_target(uint pos, float centerx, float centery, floa
float dangle, dampli, dangle2, dampli2;
rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v, BLI_YUV_ITU_BT709);
- if (u > 0 && v >= 0) tangle = atanf(v / u);
- else if (u > 0 && v < 0) tangle = atanf(v / u) + 2.0f * (float)M_PI;
- else if (u < 0) tangle = atanf(v / u) + (float)M_PI;
- else if (u == 0 && v > 0.0f) tangle = M_PI_2;
- else if (u == 0 && v < 0.0f) tangle = -M_PI_2;
+
+ if (u > 0 && v >= 0) {
+ tangle = atanf(v / u);
+ }
+ else if (u > 0 && v < 0) {
+ tangle = atanf(v / u) + 2.0f * (float)M_PI;
+ }
+ else if (u < 0) {
+ tangle = atanf(v / u) + (float)M_PI;
+ }
+ else if (u == 0 && v > 0.0f) {
+ tangle = M_PI_2;
+ }
+ else if (u == 0 && v < 0.0f) {
+ tangle = -M_PI_2;
+ }
tampli = sqrtf(u * u + v * v);
/* small target vary by 2.5 degree and 2.5 IRE unit */
@@ -1249,8 +1271,9 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, const uiWidgetColo
immEnd();
/* saturation points */
- for (int i = 0; i < 6; i++)
+ for (int i = 0; i < 6; i++) {
vectorscope_draw_target(pos, centerx, centery, diam, colors[i]);
+ }
if (scopes->ok && scopes->vecscope != NULL) {
/* pixel point cloud */
@@ -1291,7 +1314,12 @@ static void ui_draw_colorband_handle_tri_hlight(uint pos, float x1, float y1, fl
static void ui_draw_colorband_handle_tri(uint pos, float x1, float y1, float halfwidth, float height, bool fill)
{
- glEnable(fill ? GL_POLYGON_SMOOTH : GL_LINE_SMOOTH);
+ if (fill) {
+ GPU_polygon_smooth(true);
+ }
+ else {
+ GPU_line_smooth(true);
+ }
immBegin(fill ? GPU_PRIM_TRIS : GPU_PRIM_LINE_LOOP, 3);
immVertex2f(pos, x1 + halfwidth, y1);
@@ -1299,7 +1327,12 @@ static void ui_draw_colorband_handle_tri(uint pos, float x1, float y1, float hal
immVertex2f(pos, x1 - halfwidth, y1);
immEnd();
- glDisable(fill ? GL_POLYGON_SMOOTH : GL_LINE_SMOOTH);
+ if (fill) {
+ GPU_polygon_smooth(false);
+ }
+ else {
+ GPU_line_smooth(false);
+ }
}
static void ui_draw_colorband_handle_box(uint pos, float x1, float y1, float x2, float y2, bool fill)
@@ -1370,16 +1403,20 @@ static void ui_draw_colorband_handle(
ui_draw_colorband_handle_tri(shdr_pos, x, y1 + height, half_width, half_width, true);
- if (active)
+ if (active) {
immUniformColor3ub(196, 196, 196);
- else
+ }
+ else {
immUniformColor3ub(96, 96, 96);
+ }
ui_draw_colorband_handle_tri(shdr_pos, x, y1 + height, half_width, half_width, true);
- if (active)
+ if (active) {
immUniformColor3ub(255, 255, 255);
- else
+ }
+ else {
immUniformColor3ub(128, 128, 128);
+ }
ui_draw_colorband_handle_tri_hlight(shdr_pos, x, y1 + height - 1, (half_width - 1), (half_width - 1));
immUniformColor3ub(0, 0, 0);
@@ -1404,7 +1441,9 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
uint pos_id, col_id;
ColorBand *coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin);
- if (coba == NULL) return;
+ if (coba == NULL) {
+ return;
+ }
float x1 = rect->xmin;
float sizex = rect->xmax - x1;
@@ -1444,8 +1483,9 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
for (int a = 0; a <= sizex; a++) {
float pos = ((float)a) / sizex;
BKE_colorband_evaluate(coba, pos, colf);
- if (display)
+ if (display) {
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
+ }
v1[0] = v2[0] = x1 + a;
@@ -1463,8 +1503,9 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
for (int a = 0; a <= sizex; a++) {
float pos = ((float)a) / sizex;
BKE_colorband_evaluate(coba, pos, colf);
- if (display)
+ if (display) {
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
+ }
v1[0] = v2[0] = x1 + a;
@@ -1543,10 +1584,12 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec
/* transform to button */
GPU_matrix_push();
- if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
+ if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect)) {
size = 0.5f * BLI_rcti_size_x(rect);
- else
+ }
+ else {
size = 0.5f * BLI_rcti_size_y(rect);
+ }
GPU_matrix_translate_2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect));
GPU_matrix_scale_1f(size);
@@ -1582,11 +1625,15 @@ static void ui_draw_but_curve_grid(uint pos, const rcti *rect, float zoomx, floa
{
float dx = step * zoomx;
float fx = rect->xmin + zoomx * (-offsx);
- if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin));
+ if (fx > rect->xmin) {
+ fx -= dx * (floorf(fx - rect->xmin));
+ }
float dy = step * zoomy;
float fy = rect->ymin + zoomy * (-offsy);
- if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin));
+ if (fy > rect->ymin) {
+ fy -= dy * (floorf(fy - rect->ymin));
+ }
float line_count = (
floorf((rect->xmax - fx) / dx) + 1.0f +
@@ -1765,12 +1812,15 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons
immVertex2f(pos, rect->xmin + zoomx * (lum - offsx), rect->ymax);
}
else {
- if (cumap->cur == 0)
+ if (cumap->cur == 0) {
immUniformColor3ub(240, 100, 100);
- else if (cumap->cur == 1)
+ }
+ else if (cumap->cur == 1) {
immUniformColor3ub(100, 240, 100);
- else
+ }
+ else {
immUniformColor3ub(100, 100, 240);
+ }
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymin);
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymax);
@@ -1781,8 +1831,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons
- if (cuma->table == NULL)
+ if (cuma->table == NULL) {
curvemapping_changed(cumap, false);
+ }
CurveMapPoint *cmp = cuma->table;
rctf line_range;
@@ -1822,7 +1873,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons
immVertex2f(pos, fx, fy);
}
immVertex2f(pos, line_range.xmax, rect->ymin);
- immVertex2f(pos, line_range.xmax, rect->ymax);
+ immVertex2f(pos, line_range.xmax, line_range.ymax);
immEnd();
GPU_polygon_smooth(false);
@@ -1927,8 +1978,9 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, const uiWidgetCol
((!scopes->track_preview) ||
(scopes->track_preview->x != width || scopes->track_preview->y != height)))
{
- if (scopes->track_preview)
+ if (scopes->track_preview) {
IMB_freeImBuf(scopes->track_preview);
+ }
ImBuf *tmpibuf = BKE_tracking_sample_pattern(
scopes->frame_width, scopes->frame_height,
@@ -1936,13 +1988,16 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, const uiWidgetCol
&scopes->undist_marker, true, scopes->use_track_mask,
width, height, scopes->track_pos);
if (tmpibuf) {
- if (tmpibuf->rect_float)
+ if (tmpibuf->rect_float) {
IMB_rect_from_float(tmpibuf);
+ }
- if (tmpibuf->rect)
+ if (tmpibuf->rect) {
scopes->track_preview = tmpibuf;
- else
+ }
+ else {
IMB_freeImBuf(tmpibuf);
+ }
}
}
@@ -1991,10 +2046,12 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, const uiWidgetCol
float x2 = pos_sel[i + 1] * (1 - axe);
float y2 = pos_sel[i + 1] * axe;
- if (i % 2 == 1)
+ if (i % 2 == 1) {
immAttr4fv(col, col_sel);
- else
+ }
+ else {
immAttr4fv(col, col_outline);
+ }
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y2);
@@ -2072,16 +2129,18 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, const uiWidgetColors *UNUSE
GPU_blend(true);
immBegin(GPU_PRIM_TRI_FAN, 16);
- for (int a = 0; a < 16; a++)
+ for (int a = 0; a < 16; a++) {
immVertex2f(pos, x + size * si[a], y + size * co[a]);
+ }
immEnd();
immUniformColor4ub(0, 0, 0, 150);
GPU_line_width(1);
GPU_line_smooth(true);
immBegin(GPU_PRIM_LINE_LOOP, 16);
- for (int a = 0; a < 16; a++)
+ for (int a = 0; a < 16; a++) {
immVertex2f(pos, x + size * si[a], y + size * co[a]);
+ }
immEnd();
GPU_line_smooth(false);
GPU_blend(false);
@@ -2190,10 +2249,12 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
{
float rad;
- if (radius > (BLI_rctf_size_y(rct) - 10.0f) * 0.5f)
+ if (radius > (BLI_rctf_size_y(rct) - 10.0f) * 0.5f) {
rad = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f;
- else
+ }
+ else {
rad = radius;
+ }
int a, i = 12;
#if 0
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 112fde4a15c..0f0d2c355e8 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -58,13 +58,14 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Eyedropper 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, "Eyedropper Modal Map", modal_items);
/* assign to operators */
- WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_colorband");
+ WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_colorramp");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_id");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_depth");
@@ -83,14 +84,15 @@ wmKeyMap *eyedropper_colorband_modal_keymap(wmKeyConfig *keyconf)
{0, NULL, 0, NULL, NULL},
};
- wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Eyedropper ColorBand PointSampling Map");
- if (keymap && keymap->modal_items)
+ wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Eyedropper ColorRamp PointSampling Map");
+ if (keymap && keymap->modal_items) {
return keymap;
+ }
- keymap = WM_modalkeymap_add(keyconf, "Eyedropper ColorBand PointSampling Map", modal_items_point);
+ keymap = WM_modalkeymap_add(keyconf, "Eyedropper ColorRamp PointSampling Map", modal_items_point);
/* assign to operators */
- WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_colorband_point");
+ WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_colorramp_point");
return keymap;
}
diff --git a/source/blender/editors/interface/interface_eyedropper_colorband.c b/source/blender/editors/interface/interface_eyedropper_colorband.c
index 98dbb31d049..6c60640b428 100644
--- a/source/blender/editors/interface/interface_eyedropper_colorband.c
+++ b/source/blender/editors/interface/interface_eyedropper_colorband.c
@@ -27,8 +27,8 @@
* - Clicking on points, adding each color to the end of the color-band.
*
* Defines:
- * - #UI_OT_eyedropper_colorband
- * - #UI_OT_eyedropper_colorband_point
+ * - #UI_OT_eyedropper_colorramp
+ * - #UI_OT_eyedropper_colorramp_point
*/
#include "MEM_guardedalloc.h"
@@ -97,6 +97,13 @@ static bool eyedropper_colorband_init(bContext *C, wmOperator *op)
}
if (!band) {
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp);
+ if (ptr.data != NULL) {
+ band = ptr.data;
+ }
+ }
+
+ if (!band) {
return false;
}
@@ -300,15 +307,22 @@ static int eyedropper_colorband_exec(bContext *C, wmOperator *op)
static bool eyedropper_colorband_poll(bContext *C)
{
uiBut *but = UI_context_active_but_get(C);
- return (but && but->type == UI_BTYPE_COLORBAND);
+ if (but && but->type == UI_BTYPE_COLORBAND) {
+ return true;
+ }
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp);
+ if (ptr.data != NULL) {
+ return true;
+ }
+ return false;
}
-void UI_OT_eyedropper_colorband(wmOperatorType *ot)
+void UI_OT_eyedropper_colorramp(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Eyedropper colorband";
- ot->idname = "UI_OT_eyedropper_colorband";
+ ot->idname = "UI_OT_eyedropper_colorramp";
ot->description = "Sample a color band";
/* api callbacks */
@@ -324,11 +338,11 @@ void UI_OT_eyedropper_colorband(wmOperatorType *ot)
/* properties */
}
-void UI_OT_eyedropper_colorband_point(wmOperatorType *ot)
+void UI_OT_eyedropper_colorramp_point(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Eyedropper colorband (points)";
- ot->idname = "UI_OT_eyedropper_colorband_point";
+ ot->idname = "UI_OT_eyedropper_colorramp_point";
ot->description = "Point-sample a color band";
/* api callbacks */
diff --git a/source/blender/editors/interface/interface_eyedropper_driver.c b/source/blender/editors/interface/interface_eyedropper_driver.c
index e1f38860721..dd2656e7fa1 100644
--- a/source/blender/editors/interface/interface_eyedropper_driver.c
+++ b/source/blender/editors/interface/interface_eyedropper_driver.c
@@ -134,10 +134,12 @@ static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *eve
}
/* cleanup */
- if (target_path)
+ if (target_path) {
MEM_freeN(target_path);
- if (dst_path)
+ }
+ if (dst_path) {
MEM_freeN(dst_path);
+ }
}
}
@@ -207,8 +209,12 @@ static int driverdropper_exec(bContext *C, wmOperator *op)
static bool driverdropper_poll(bContext *C)
{
- if (!CTX_wm_window(C)) return 0;
- else return 1;
+ if (!CTX_wm_window(C)) {
+ return 0;
+ }
+ else {
+ return 1;
+ }
}
void UI_OT_eyedropper_driver(wmOperatorType *ot)
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 498e2f07ea4..208c1a90b89 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -111,7 +111,9 @@ static void ui_mouse_motion_keynav_init(struct uiKeyNavLock *keynav, const wmEve
static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEvent *event);
#endif
-/***************** structs and defines ****************/
+/* -------------------------------------------------------------------- */
+/** \name Structs & Defines
+ * \{ */
#define BUTTON_FLASH_DELAY 0.020
#define MENU_SCROLL_INTERVAL 0.1
@@ -389,11 +391,6 @@ typedef struct uiAfterFunc {
} uiAfterFunc;
-
-static bool ui_but_is_interactive(const uiBut *but, const bool labeledit);
-static bool ui_but_contains_pt(uiBut *but, float mx, float my);
-static bool ui_but_contains_point_px(ARegion *ar, uiBut *but, int x, int y);
-static uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, const bool labeledit);
static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state);
static void button_activate_exit(
@@ -412,29 +409,17 @@ static ColorBand but_copypaste_coba = {0};
static CurveMapping but_copypaste_curve = {0};
static bool but_copypaste_curve_alive = false;
-/* ******************** menu navigation helpers ************** */
-enum eSnapType {
- SNAP_OFF = 0,
- SNAP_ON,
- SNAP_ON_SMALL,
-};
+/** \} */
-static enum eSnapType ui_event_to_snap(const wmEvent *event)
-{
- return (event->ctrl) ? (event->shift) ? SNAP_ON_SMALL : SNAP_ON : SNAP_OFF;
-}
-static bool ui_event_is_snap(const wmEvent *event)
-{
- return (ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY) ||
- ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY));
-}
+/* -------------------------------------------------------------------- */
+/** \name UI Queries
+ * \{ */
-static void ui_color_snap_hue(const enum eSnapType snap, float *r_hue)
+bool ui_but_is_editing(const uiBut *but)
{
- const float snap_increment = (snap == SNAP_ON_SMALL) ? 24 : 12;
- BLI_assert(snap != SNAP_OFF);
- *r_hue = roundf((*r_hue) * snap_increment) / snap_increment;
+ uiHandleButtonData *data = but->active;
+ return (data && ELEM(data->state, BUTTON_STATE_TEXT_EDITING, BUTTON_STATE_NUM_EDITING));
}
/* assumes event type is MOUSEPAN */
@@ -455,84 +440,93 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
lastdy += dy;
if (ABS(lastdy) > (int)UI_UNIT_Y) {
- if (U.uiflag2 & USER_TRACKPAD_NATURAL)
+ if (U.uiflag2 & USER_TRACKPAD_NATURAL) {
dy = -dy;
+ }
*val = KM_PRESS;
- if (dy > 0)
+ if (dy > 0) {
*type = WHEELUPMOUSE;
- else
+ }
+ else {
*type = WHEELDOWNMOUSE;
+ }
lastdy = 0;
}
}
}
-static uiBut *ui_but_prev(uiBut *but)
+static bool ui_but_find_select_in_enum__cmp(const uiBut *but_a, const uiBut *but_b)
{
- while (but->prev) {
- but = but->prev;
- if (ui_but_is_editable(but)) return but;
- }
- return NULL;
+ return ((but_a->type == but_b->type) &&
+ (but_a->alignnr == but_b->alignnr) &&
+ (but_a->poin == but_b->poin) &&
+ (but_a->rnapoin.type == but_b->rnapoin.type) &&
+ (but_a->rnaprop == but_b->rnaprop));
}
-static uiBut *ui_but_next(uiBut *but)
+/**
+ * Finds the pressed button in an aligned row (typically an expanded enum).
+ *
+ * \param direction: Use when there may be multiple buttons pressed.
+ */
+uiBut *ui_but_find_select_in_enum(uiBut *but, int direction)
{
- while (but->next) {
- but = but->next;
- if (ui_but_is_editable(but)) return but;
- }
- return NULL;
-}
+ uiBut *but_iter = but;
+ uiBut *but_found = NULL;
+ BLI_assert(ELEM(direction, -1, 1));
-static uiBut *ui_but_first(uiBlock *block)
-{
- uiBut *but;
+ while ((but_iter->prev) &&
+ ui_but_find_select_in_enum__cmp(but_iter->prev, but))
+ {
+ but_iter = but_iter->prev;
+ }
- but = block->buttons.first;
- while (but) {
- if (ui_but_is_editable(but)) return but;
- but = but->next;
+ while (but_iter && ui_but_find_select_in_enum__cmp(but_iter, but)) {
+ if (but_iter->flag & UI_SELECT) {
+ but_found = but_iter;
+ if (direction == 1) {
+ break;
+ }
+ }
+ but_iter = but_iter->next;
}
- return NULL;
+
+ return but_found;
}
-static uiBut *ui_but_last(uiBlock *block)
+static float ui_mouse_scale_warp_factor(const bool shift)
{
- uiBut *but;
-
- but = block->buttons.last;
- while (but) {
- if (ui_but_is_editable(but)) return but;
- but = but->prev;
- }
- return NULL;
+ return shift ? 0.05f : 1.0f;
}
-static bool ui_but_is_cursor_warp(uiBut *but)
+static void ui_mouse_scale_warp(
+ uiHandleButtonData *data, const float mx, const float my,
+ float *r_mx, float *r_my, const bool shift)
{
- if (U.uiflag & USER_CONTINUOUS_MOUSE) {
- if (ELEM(but->type,
- UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_HSVCIRCLE,
- UI_BTYPE_TRACK_PREVIEW, UI_BTYPE_HSVCUBE, UI_BTYPE_CURVE))
- {
- return true;
- }
- }
+ const float fac = ui_mouse_scale_warp_factor(shift);
- return false;
+ /* slow down the mouse, this is fairly picky */
+ *r_mx = (data->dragstartx * (1.0f - fac) + mx * fac);
+ *r_my = (data->dragstarty * (1.0f - fac) + my * fac);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name UI Utilities
+ * \{ */
+
/**
* Ignore mouse movements within some horizontal pixel threshold before starting to drag
*/
static bool ui_but_dragedit_update_mval(uiHandleButtonData *data, int mx)
{
- if (mx == data->draglastx)
+ if (mx == data->draglastx) {
return false;
+ }
if (data->draglock) {
if (ABS(mx - data->dragstartx) <= BUTTON_DRAGLOCK_THRESH) {
@@ -550,35 +544,42 @@ static bool ui_but_dragedit_update_mval(uiHandleButtonData *data, int mx)
return true;
}
-static float ui_mouse_scale_warp_factor(const bool shift)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button Snap Values
+ *
+ * \{ */
+
+enum eSnapType {
+ SNAP_OFF = 0,
+ SNAP_ON,
+ SNAP_ON_SMALL,
+};
+
+static enum eSnapType ui_event_to_snap(const wmEvent *event)
{
- return shift ? 0.05f : 1.0f;
+ return (event->ctrl) ? (event->shift) ? SNAP_ON_SMALL : SNAP_ON : SNAP_OFF;
}
-static void ui_mouse_scale_warp(
- uiHandleButtonData *data, const float mx, const float my,
- float *r_mx, float *r_my, const bool shift)
+static bool ui_event_is_snap(const wmEvent *event)
{
- const float fac = ui_mouse_scale_warp_factor(shift);
-
- /* slow down the mouse, this is fairly picky */
- *r_mx = (data->dragstartx * (1.0f - fac) + mx * fac);
- *r_my = (data->dragstarty * (1.0f - fac) + my * fac);
+ return (ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY) ||
+ ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY));
}
-/* file selectors are exempt from utf-8 checks */
-bool ui_but_is_utf8(const uiBut *but)
+static void ui_color_snap_hue(const enum eSnapType snap, float *r_hue)
{
- if (but->rnaprop) {
- const int subtype = RNA_property_subtype(but->rnaprop);
- return !(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME, PROP_BYTESTRING));
- }
- else {
- return !(but->flag & UI_BUT_NO_UTF8);
- }
+ const float snap_increment = (snap == SNAP_ON_SMALL) ? 24 : 12;
+ BLI_assert(snap != SNAP_OFF);
+ *r_hue = roundf((*r_hue) * snap_increment) / snap_increment;
}
-/* ********************** button apply/revert ************************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button Apply/Revert
+ * \{ */
static ListBase UIAfterFuncs = {NULL, NULL};
@@ -649,8 +650,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
/* exception, this will crash due to removed button otherwise */
but->func(C, but->func_arg1, but->func_arg2);
}
- else
+ else {
after->func = but->func;
+ }
after->func_arg1 = but->func_arg1;
after->func_arg2 = but->func_arg2;
@@ -672,8 +674,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
after->a2 = but->a2;
}
- if (block->handle)
+ if (block->handle) {
after->popup_op = block->handle->popup_op;
+ }
after->optype = but->optype;
after->opcontext = but->opcontext;
@@ -682,8 +685,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
after->rnapoin = but->rnapoin;
after->rnaprop = but->rnaprop;
- if (but->context)
+ if (but->context) {
after->context = CTX_store_copy(but->context);
+ }
but->optype = NULL;
but->opcontext = 0;
@@ -700,9 +704,15 @@ static void ui_apply_but_undo(uiBut *but)
const char *str = NULL;
/* define which string to use for undo */
- if (but->type == UI_BTYPE_MENU) str = but->drawstr;
- else if (but->drawstr[0]) str = but->drawstr;
- else str = but->tip;
+ if (but->type == UI_BTYPE_MENU) {
+ str = but->drawstr;
+ }
+ else if (but->drawstr[0]) {
+ str = but->drawstr;
+ }
+ else {
+ str = but->tip;
+ }
/* fallback, else we don't get an undo! */
if (str == NULL || str[0] == '\0') {
@@ -754,11 +764,13 @@ static void ui_apply_but_funcs_after(bContext *C)
after = *afterf; /* copy to avoid memleak on exit() */
BLI_freelinkN(&funcs, afterf);
- if (after.context)
+ if (after.context) {
CTX_store_set(C, after.context);
+ }
- if (after.popup_op)
+ if (after.popup_op) {
popup_check(C, after.popup_op);
+ }
if (after.opptr) {
/* free in advance to avoid leak on exit */
@@ -766,39 +778,50 @@ static void ui_apply_but_funcs_after(bContext *C)
MEM_freeN(after.opptr);
}
- if (after.optype)
+ if (after.optype) {
WM_operator_name_call_ptr(C, after.optype, after.opcontext, (after.opptr) ? &opptr : NULL);
+ }
- if (after.opptr)
+ if (after.opptr) {
WM_operator_properties_free(&opptr);
+ }
- if (after.rnapoin.data)
+ if (after.rnapoin.data) {
RNA_property_update(C, &after.rnapoin, after.rnaprop);
+ }
if (after.context) {
CTX_store_set(C, NULL);
CTX_store_free(after.context);
}
- if (after.func)
+ if (after.func) {
after.func(C, after.func_arg1, after.func_arg2);
- if (after.funcN)
+ }
+ if (after.funcN) {
after.funcN(C, after.func_argN, after.func_arg2);
- if (after.func_argN)
+ }
+ if (after.func_argN) {
MEM_freeN(after.func_argN);
+ }
- if (after.handle_func)
+ if (after.handle_func) {
after.handle_func(C, after.handle_func_arg, after.retval);
- if (after.butm_func)
+ }
+ if (after.butm_func) {
after.butm_func(C, after.butm_func_arg, after.a2);
+ }
- if (after.rename_func)
+ if (after.rename_func) {
after.rename_func(C, after.rename_arg1, after.rename_orig);
- if (after.rename_orig)
+ }
+ if (after.rename_orig) {
MEM_freeN(after.rename_orig);
+ }
- if (after.undostr[0])
+ if (after.undostr[0]) {
ED_undo_push(C, after.undostr);
+ }
}
}
@@ -821,8 +844,9 @@ static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data)
static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data)
{
- if (but->type == UI_BTYPE_MENU)
+ if (but->type == UI_BTYPE_MENU) {
ui_but_value_set(but, data->value);
+ }
ui_but_update_edited(but);
ui_apply_but_func(C, but);
@@ -832,34 +856,23 @@ static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data
static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data)
{
- double value;
- int w, lvalue, push;
-
- value = ui_but_value_get(but);
- lvalue = (int)value;
-
+ const double value = ui_but_value_get(but);
+ int value_toggle;
if (but->bit) {
- w = UI_BITBUT_TEST(lvalue, but->bitnr);
- if (w) lvalue = UI_BITBUT_CLR(lvalue, but->bitnr);
- else lvalue = UI_BITBUT_SET(lvalue, but->bitnr);
-
- ui_but_value_set(but, (double)lvalue);
- if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
- ui_but_update_edited(but);
- }
+ value_toggle = UI_BITBUT_VALUE_TOGGLED((int)value, but->bitnr);
}
else {
-
- if (value == 0.0) push = 1;
- else push = 0;
-
- if (ELEM(but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N)) push = !push;
- ui_but_value_set(but, (double)push);
- if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
- ui_but_update_edited(but);
+ value_toggle = (value == 0.0);
+ if (ELEM(but->type, UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE_N, UI_BTYPE_CHECKBOX_N)) {
+ value_toggle = !value_toggle;
}
}
+ ui_but_value_set(but, (double)value_toggle);
+ if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) {
+ ui_but_update_edited(but);
+ }
+
ui_apply_but_func(C, but);
data->retval = but->retval;
@@ -887,8 +900,9 @@ static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
{
- if (!data->str)
+ if (!data->str) {
return;
+ }
ui_but_string_set(C, but, data->str);
ui_but_update_edited(but);
@@ -973,8 +987,11 @@ static void ui_apply_but_CURVE(bContext *C, uiBut *but, uiHandleButtonData *data
data->applied = true;
}
-/* ****************** drag drop code *********************** */
+/** \} */
+/* -------------------------------------------------------------------- */
+/** \name Button Drag Multi-Number
+ * \{ */
#ifdef USE_DRAG_MULTINUM
@@ -1221,6 +1238,12 @@ static void ui_multibut_states_apply(bContext *C, uiHandleButtonData *data, uiBl
#endif /* USE_DRAG_MULTINUM */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button Drag Toggle
+ * \{ */
+
#ifdef USE_DRAG_TOGGLE
/* Helpers that wrap boolean functions, to support different kinds of buttons. */
@@ -1460,8 +1483,9 @@ static bool ui_selectcontext_begin(
index = but->rnaindex;
/* for now don't support whole colors */
- if (index == -1)
+ if (index == -1) {
return false;
+ }
/* if there is a valid property that is editable... */
if (ptr.data && prop) {
@@ -1709,30 +1733,11 @@ static void ui_selectcontext_apply(
#endif /* USE_ALLSELECT */
+/** \} */
-static bool ui_but_contains_point_px_icon(uiBut *but, ARegion *ar, const wmEvent *event)
-{
- rcti rect;
- int x = event->x, y = event->y;
-
- ui_window_to_block(ar, but->block, &x, &y);
-
- BLI_rcti_rctf_copy(&rect, &but->rect);
-
- if (but->imb || but->type == UI_BTYPE_COLOR) {
- /* use button size itself */
- }
- else if (but->drawflag & UI_BUT_ICON_LEFT) {
- rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect));
- }
- else {
- int delta = BLI_rcti_size_x(&rect) - BLI_rcti_size_y(&rect);
- rect.xmin += delta / 2;
- rect.xmax -= delta / 2;
- }
-
- return BLI_rcti_isect_pt(&rect, x, y);
-}
+/* -------------------------------------------------------------------- */
+/** \name Button Drag
+ * \{ */
static bool ui_but_drag_init(
bContext *C, uiBut *but,
@@ -1842,7 +1847,11 @@ static bool ui_but_drag_init(
return false;
}
-/* ********************** linklines *********************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button Apply
+ * \{ */
static void ui_apply_but_IMAGE(bContext *C, uiBut *but, uiHandleButtonData *data)
{
@@ -1886,10 +1895,13 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
/* if we cancel and have not applied yet, there is nothing to do,
* otherwise we have to restore the original value again */
if (data->cancel) {
- if (!data->applied)
+ if (!data->applied) {
return;
+ }
- if (data->str) MEM_freeN(data->str);
+ if (data->str) {
+ MEM_freeN(data->str);
+ }
data->str = data->origstr;
data->origstr = NULL;
data->value = data->origvalue;
@@ -1977,10 +1989,12 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
ui_apply_but_BLOCK(C, but, data);
break;
case UI_BTYPE_COLOR:
- if (data->cancel)
+ if (data->cancel) {
ui_apply_but_VEC(C, but, data);
- else
+ }
+ else {
ui_apply_but_BLOCK(C, but, data);
+ }
break;
case UI_BTYPE_BUT_MENU:
ui_apply_but_BUTM(C, but, data);
@@ -2047,7 +2061,11 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
but->editcumap = editcumap;
}
-/* ******************* drop event ******************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button Drop Event
+ * \{ */
/* only call if event type is EVT_DROP */
static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleButtonData *data)
@@ -2074,15 +2092,13 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
}
}
}
-
}
-/* ******************* copy and paste ******************** */
+/** \} */
-static bool ui_but_contains_password(uiBut *but)
-{
- return but->rnaprop && (RNA_property_subtype(but->rnaprop) == PROP_PASSWORD);
-}
+/* -------------------------------------------------------------------- */
+/** \name Button Copy & Paste
+ * \{ */
static void ui_but_get_pasted_text_from_clipboard(char **buf_paste, int *buf_len)
{
@@ -2113,7 +2129,9 @@ static void ui_but_set_float_array(bContext *C, uiBut *but, uiHandleButtonData *
for (int i = 0; i < array_length; i++) {
RNA_property_float_set_index(&but->rnapoin, but->rnaprop, i, values[i]);
}
- if (data) data->value = values[but->rnaindex];
+ if (data) {
+ data->value = values[but->rnaindex];
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -2211,14 +2229,6 @@ static void ui_but_paste_numeric_value(bContext *C, uiBut *but, uiHandleButtonDa
}
}
-static bool ui_but_has_array_value(uiBut *but)
-{
- return (but->rnapoin.data && but->rnaprop &&
- ELEM(RNA_property_subtype(but->rnaprop), PROP_COLOR, PROP_TRANSLATION, PROP_DIRECTION,
- PROP_VELOCITY, PROP_ACCELERATION, PROP_MATRIX, PROP_EULER, PROP_QUATERNION, PROP_AXISANGLE,
- PROP_XYZ, PROP_XYZ_LENGTH, PROP_COLOR_GAMMA, PROP_COORDS));
-}
-
static void ui_but_paste_normalized_vector(bContext *C, uiBut *but, char *buf_paste)
{
float xyz[3];
@@ -2238,16 +2248,19 @@ static void ui_but_copy_color(uiBut *but, char *output, int output_len_max)
{
float rgba[4];
- if (but->rnaprop && get_but_property_array_length(but) == 4)
+ if (but->rnaprop && get_but_property_array_length(but) == 4) {
rgba[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
- else
+ }
+ else {
rgba[3] = 1.0f;
+ }
ui_but_v3_get(but, rgba);
/* convert to linear color to do compatible copy between gamma and non-gamma */
- if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
+ if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
srgb_to_linearrgb_v3_v3(rgba, rgba);
+ }
float_array_to_string(rgba, 4, output, output_len_max);
}
@@ -2301,8 +2314,9 @@ static void ui_but_copy_colorband(uiBut *but)
static void ui_but_paste_colorband(bContext *C, uiBut *but, uiHandleButtonData *data)
{
if (but_copypaste_coba.tot != 0) {
- if (!but->poin)
+ if (!but->poin) {
but->poin = MEM_callocN(sizeof(ColorBand), "colorband");
+ }
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
memcpy(data->coba, &but_copypaste_coba, sizeof(ColorBand));
@@ -2322,8 +2336,9 @@ static void ui_but_copy_curvemapping(uiBut *but)
static void ui_but_paste_curvemapping(bContext *C, uiBut *but)
{
if (but_copypaste_curve_alive) {
- if (!but->poin)
+ if (!but->poin) {
but->poin = MEM_callocN(sizeof(CurveMapping), "curvemapping");
+ }
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
curvemapping_free_data((CurveMapping *) but->poin);
@@ -2343,12 +2358,24 @@ static void ui_but_copy_operator(bContext *C, uiBut *but, char *output, int outp
MEM_freeN(str);
}
-static void ui_but_copy_menu(uiBut *but, char *output, int output_len_max)
+static bool ui_but_copy_menu(uiBut *but, char *output, int output_len_max)
{
MenuType *mt = UI_but_menutype_get(but);
if (mt) {
BLI_snprintf(output, output_len_max, "bpy.ops.wm.call_menu(name=\"%s\")", mt->idname);
+ return true;
+ }
+ return false;
+}
+
+static bool ui_but_copy_popover(uiBut *but, char *output, int output_len_max)
+{
+ PanelType *pt = UI_but_paneltype_get(but);
+ if (pt) {
+ BLI_snprintf(output, output_len_max, "bpy.ops.wm.call_panel(name=\"%s\")", pt->idname);
+ return true;
}
+ return false;
}
static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
@@ -2369,7 +2396,9 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
switch (but->type) {
case UI_BTYPE_NUM:
case UI_BTYPE_NUM_SLIDER:
- if (!has_required_data) break;
+ if (!has_required_data) {
+ break;
+ }
if (copy_array && ui_but_has_array_value(but)) {
ui_but_copy_numeric_array(but, buf, buf_max_len);
}
@@ -2380,20 +2409,26 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
break;
case UI_BTYPE_UNITVEC:
- if (!has_required_data) break;
+ if (!has_required_data) {
+ break;
+ }
ui_but_copy_numeric_array(but, buf, buf_max_len);
is_buf_set = true;
break;
case UI_BTYPE_COLOR:
- if (!has_required_data) break;
+ if (!has_required_data) {
+ break;
+ }
ui_but_copy_color(but, buf, buf_max_len);
is_buf_set = true;
break;
case UI_BTYPE_TEXT:
case UI_BTYPE_SEARCH_MENU:
- if (!has_required_data) break;
+ if (!has_required_data) {
+ break;
+ }
ui_but_copy_text(but, buf, buf_max_len);
is_buf_set = true;
break;
@@ -2413,8 +2448,14 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
case UI_BTYPE_MENU:
case UI_BTYPE_PULLDOWN:
- ui_but_copy_menu(but, buf, buf_max_len);
- is_buf_set = true;
+ if (ui_but_copy_menu(but, buf, buf_max_len)) {
+ is_buf_set = true;
+ }
+ break;
+ case UI_BTYPE_POPOVER:
+ if (ui_but_copy_popover(but, buf, buf_max_len)) {
+ is_buf_set = true;
+ }
break;
default:
@@ -2439,7 +2480,9 @@ static void ui_but_paste(bContext *C, uiBut *but, uiHandleButtonData *data, cons
switch (but->type) {
case UI_BTYPE_NUM:
case UI_BTYPE_NUM_SLIDER:
- if (!has_required_data) break;
+ if (!has_required_data) {
+ break;
+ }
if (paste_array && ui_but_has_array_value(but)) {
ui_but_paste_numeric_array(C, but, data, buf_paste);
}
@@ -2449,18 +2492,24 @@ static void ui_but_paste(bContext *C, uiBut *but, uiHandleButtonData *data, cons
break;
case UI_BTYPE_UNITVEC:
- if (!has_required_data) break;
+ if (!has_required_data) {
+ break;
+ }
ui_but_paste_normalized_vector(C, but, buf_paste);
break;
case UI_BTYPE_COLOR:
- if (!has_required_data) break;
+ if (!has_required_data) {
+ break;
+ }
ui_but_paste_color(C, but, buf_paste);
break;
case UI_BTYPE_TEXT:
case UI_BTYPE_SEARCH_MENU:
- if (!has_required_data) break;
+ if (!has_required_data) {
+ break;
+ }
ui_but_paste_text(C, but, data, buf_paste);
break;
@@ -2479,9 +2528,15 @@ static void ui_but_paste(bContext *C, uiBut *but, uiHandleButtonData *data, cons
MEM_freeN((void *)buf_paste);
}
-/**
- * Password Text
- * =============
+void ui_but_clipboard_free(void)
+{
+ curvemapping_free_data(&but_copypaste_curve);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button Text Password
*
* Functions to convert password strings that should not be displayed
* to asterisk representation (e.g. 'mysecretpasswd' -> '*************')
@@ -2490,7 +2545,8 @@ static void ui_but_paste(bContext *C, uiBut *but, uiHandleButtonData *data, cons
* the cursor position and selection start/end.
*
* \note: remapping is used, because password could contain UTF-8 characters.
- */
+ *
+ * \{ */
static int ui_text_position_from_hidden(uiBut *but, int pos)
{
@@ -2499,8 +2555,9 @@ static int ui_text_position_from_hidden(uiBut *but, int pos)
butstr = (but->editstr) ? but->editstr : but->drawstr;
- for (i = 0, strpos = butstr; i < pos; i++)
+ for (i = 0, strpos = butstr; i < pos; i++) {
strpos = BLI_str_find_next_char_utf8(strpos, NULL);
+ }
return (strpos - butstr);
}
@@ -2515,8 +2572,9 @@ void ui_but_text_password_hide(char password_str[UI_MAX_PASSWORD_STR], uiBut *bu
{
char *butstr;
- if (!(but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_PASSWORD))
+ if (!(but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_PASSWORD)) {
return;
+ }
butstr = (but->editstr) ? but->editstr : but->drawstr;
@@ -2549,7 +2607,13 @@ void ui_but_text_password_hide(char password_str[UI_MAX_PASSWORD_STR], uiBut *bu
}
}
-static void ui_but_text_clear(bContext *C, uiBut *but, uiHandleButtonData *data)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button Text Selection/Editing
+ * \{ */
+
+static void ui_textedit_string_clear_and_exit(bContext *C, uiBut *but, uiHandleButtonData *data)
{
/* most likely NULL, but let's check, and give it temp zero string */
if (!data->str) {
@@ -2561,9 +2625,6 @@ static void ui_but_text_clear(bContext *C, uiBut *but, uiHandleButtonData *data)
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
-
-/* ************* in-button text selection/editing ************* */
-
static void ui_textedit_string_ensure_max_length(uiBut *but, uiHandleButtonData *data, int maxlen)
{
BLI_assert(data->is_str_dynamic);
@@ -2628,8 +2689,10 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
UI_fontstyle_set(fstyle);
- if (fstyle->kerning == 1) /* for BLF_width */
+ if (fstyle->kerning == 1) {
+ /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
ui_but_text_password_hide(password_str, but, false);
@@ -2689,7 +2752,9 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
/* done with tricky distance checks */
pos_i = but->pos;
- if (but->pos <= 0) break;
+ if (but->pos <= 0) {
+ break;
+ }
if (BLI_str_cursor_step_prev_utf8(str, but->ofs, &pos_i)) {
but->pos = pos_i;
str_last = &str[but->pos + but->ofs];
@@ -2699,11 +2764,14 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
}
}
but->pos += but->ofs;
- if (but->pos < 0) but->pos = 0;
+ if (but->pos < 0) {
+ but->pos = 0;
+ }
}
- if (fstyle->kerning == 1)
+ if (fstyle->kerning == 1) {
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
ui_but_text_password_hide(password_str, but, true);
@@ -2712,13 +2780,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data, const float x)
{
- if (x > data->selstartx) data->selextend = EXTEND_RIGHT;
- else if (x < data->selstartx) data->selextend = EXTEND_LEFT;
+ if (x > data->selstartx) { data->selextend = EXTEND_RIGHT; }
+ else if (x < data->selstartx) { data->selextend = EXTEND_LEFT; }
ui_textedit_set_cursor_pos(but, data, x);
- if (data->selextend == EXTEND_RIGHT) but->selend = but->pos;
- else if (data->selextend == EXTEND_LEFT) but->selsta = but->pos;
+ if (data->selextend == EXTEND_RIGHT) { but->selend = but->pos; }
+ else if (data->selextend == EXTEND_LEFT) { but->selsta = but->pos; }
ui_but_update(but);
}
@@ -2872,7 +2940,9 @@ static bool ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directi
bool changed = false;
if (jump == STRCUR_JUMP_ALL) {
- if (len) changed = true;
+ if (len) {
+ changed = true;
+ }
str[0] = '\0';
but->pos = 0;
}
@@ -2917,10 +2987,12 @@ static int ui_textedit_autocomplete(bContext *C, uiBut *but, uiHandleButtonData
str = data->str;
- if (data->searchbox)
+ if (data->searchbox) {
changed = ui_searchbox_autocomplete(C, data->searchbox, but, data->str);
- else
+ }
+ else {
changed = but->autocomplete_func(C, str, but->autofunc_arg);
+ }
but->pos = strlen(str);
but->selsta = but->selend = but->pos;
@@ -3138,9 +3210,6 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
ui_searchbox_free(C, data->searchbox);
data->searchbox = NULL;
- if (but->free_search_arg) {
- MEM_SAFE_FREE(but->search_arg);
- }
}
but->editstr = NULL;
@@ -3161,8 +3230,9 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX))
+ if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX)) {
return;
+ }
for (but = actbut->next; but; but = but->next) {
if (ui_but_is_editable_as_text(but)) {
@@ -3189,8 +3259,9 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX))
+ if (ELEM(actbut->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX)) {
return;
+ }
for (but = actbut->prev; but; but = but->prev) {
if (ui_but_is_editable_as_text(but)) {
@@ -3266,8 +3337,9 @@ static void ui_do_but_textedit(
/* exit on LMB only on RELEASE for searchbox, to mimic other popups,
* and allow multiple menu levels */
- if (data->searchbox)
+ if (data->searchbox) {
inbox = ui_searchbox_inside(data->searchbox, event->x, event->y);
+ }
/* for double click: we do a press again for when you first click on button
* (selects all text, no cursor pos) */
@@ -3288,8 +3360,9 @@ static void ui_do_but_textedit(
}
else if (inbox == false) {
/* if searchbox, click outside will cancel */
- if (data->searchbox)
+ if (data->searchbox) {
data->cancel = data->escapecancel = true;
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
retval = WM_UI_HANDLER_BREAK;
}
@@ -3320,12 +3393,15 @@ static void ui_do_but_textedit(
case XKEY:
case CKEY:
if (IS_EVENT_MOD(event, ctrl, oskey)) {
- if (event->type == VKEY)
+ if (event->type == VKEY) {
changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_PASTE);
- else if (event->type == CKEY)
+ }
+ else if (event->type == CKEY) {
changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_COPY);
- else if (event->type == XKEY)
+ }
+ else if (event->type == XKEY) {
changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_CUT);
+ }
retval = WM_UI_HANDLER_BREAK;
}
@@ -3426,8 +3502,9 @@ static void ui_do_but_textedit(
int autocomplete = ui_textedit_autocomplete(C, but, data);
changed = autocomplete != AUTOCOMPLETE_NO_MATCH;
- if (autocomplete == AUTOCOMPLETE_FULL_MATCH)
+ if (autocomplete == AUTOCOMPLETE_FULL_MATCH) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
}
/* the hotkey here is not well defined, was G.qual so we check all */
else if (IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) {
@@ -3515,12 +3592,14 @@ static void ui_do_but_textedit(
}
but->changed = true;
- if (data->searchbox)
+ if (data->searchbox) {
ui_searchbox_update(C, data->searchbox, but, true); /* true = reset */
+ }
}
- if (changed || (retval == WM_UI_HANDLER_BREAK))
+ if (changed || (retval == WM_UI_HANDLER_BREAK)) {
ED_region_tag_redraw(data->region);
+ }
}
static void ui_do_but_textedit_select(
@@ -3541,8 +3620,9 @@ static void ui_do_but_textedit_select(
break;
}
case LEFTMOUSE:
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
+ }
retval = WM_UI_HANDLER_BREAK;
break;
}
@@ -3553,7 +3633,11 @@ static void ui_do_but_textedit_select(
}
}
-/* ************* number editing for various types ************* */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button Number Editing (various types)
+ * \{ */
static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
{
@@ -3615,7 +3699,11 @@ static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
ED_region_tag_redraw(data->region);
}
-/* ****************** menu opening for various types **************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Menu/Popup Begin/End (various popup types)
+ * \{ */
static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
{
@@ -3638,13 +3726,14 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat
}
break;
case UI_BTYPE_MENU:
- BLI_assert(but->menu_create_func);
- menufunc = but->menu_create_func;
- arg = but->poin;
- break;
case UI_BTYPE_POPOVER:
BLI_assert(but->menu_create_func);
- popoverfunc = but->menu_create_func;
+ if ((but->type == UI_BTYPE_POPOVER) || ui_but_menu_draw_as_popover(but)) {
+ popoverfunc = but->menu_create_func;
+ }
+ else {
+ menufunc = but->menu_create_func;
+ }
arg = but->poin;
break;
case UI_BTYPE_COLOR:
@@ -3663,18 +3752,21 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat
if (func || handlefunc) {
data->menu = ui_popup_block_create(C, data->region, but, func, handlefunc, arg);
- if (but->block->handle)
+ if (but->block->handle) {
data->menu->popup = but->block->handle->popup;
+ }
}
else if (menufunc) {
data->menu = ui_popup_menu_create(C, data->region, but, menufunc, arg);
- if (but->block->handle)
+ if (but->block->handle) {
data->menu->popup = but->block->handle->popup;
+ }
}
else if (popoverfunc) {
data->menu = ui_popover_panel_create(C, data->region, but, popoverfunc, arg);
- if (but->block->handle)
+ if (but->block->handle) {
data->menu->popup = but->block->handle->popup;
+ }
}
#ifdef USE_ALLSELECT
@@ -3687,7 +3779,9 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat
#endif
/* this makes adjacent blocks auto open from now on */
- //if (but->block->auto_open == 0) but->block->auto_open = 1;
+ //if (but->block->auto_open == 0) {
+ // but->block->auto_open = 1;
+ //}
}
static void ui_block_open_end(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -3709,8 +3803,9 @@ int ui_but_menu_direction(uiBut *but)
{
uiHandleButtonData *data = but->active;
- if (data && data->menu)
+ if (data && data->menu) {
return data->menu->direction;
+ }
return 0;
}
@@ -3739,7 +3834,11 @@ static uiBut *ui_but_list_row_text_activate(
return NULL;
}
-/* ***************** events for different button types *************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Events for Various Button Types
+ * \{ */
#ifdef USE_DRAG_TOGGLE
/* Shared by any button that supports drag-toggle. */
@@ -3793,8 +3892,9 @@ static int ui_do_but_BUT(
}
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE && but->block->handle) {
/* regular buttons will be 'UI_SELECT', menu items 'UI_ACTIVE' */
- if (!(but->flag & (UI_SELECT | UI_ACTIVE)))
+ if (!(but->flag & (UI_SELECT | UI_ACTIVE))) {
data->cancel = true;
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -3805,8 +3905,9 @@ static int ui_do_but_BUT(
}
else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
- if (!(but->flag & UI_SELECT))
+ if (!(but->flag & UI_SELECT)) {
data->cancel = true;
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -3834,12 +3935,14 @@ static int ui_do_but_HOTKEYEVT(
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
/* only cancel if click outside the button */
- if (ui_but_contains_point_px(but->active->region, but, event->x, event->y) == 0) {
+ if (ui_but_contains_point_px(but, but->active->region, event->x, event->y) == 0) {
/* data->cancel doesn't work, this button opens immediate */
- if (but->flag & UI_BUT_IMMEDIATE)
+ if (but->flag & UI_BUT_IMMEDIATE) {
ui_but_value_set(but, 0);
- else
+ }
+ else {
data->cancel = true;
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -3847,20 +3950,30 @@ static int ui_do_but_HOTKEYEVT(
/* always set */
but->modifier_key = 0;
- if (event->shift) but->modifier_key |= KM_SHIFT;
- if (event->alt) but->modifier_key |= KM_ALT;
- if (event->ctrl) but->modifier_key |= KM_CTRL;
- if (event->oskey) but->modifier_key |= KM_OSKEY;
+ if (event->shift) {
+ but->modifier_key |= KM_SHIFT;
+ }
+ if (event->alt) {
+ but->modifier_key |= KM_ALT;
+ }
+ if (event->ctrl) {
+ but->modifier_key |= KM_CTRL;
+ }
+ if (event->oskey) {
+ but->modifier_key |= KM_OSKEY;
+ }
ui_but_update(but);
ED_region_tag_redraw(data->region);
if (event->val == KM_PRESS) {
if (ISHOTKEY(event->type) && (event->type != ESCKEY)) {
- if (WM_key_event_string(event->type, false)[0])
+ if (WM_key_event_string(event->type, false)[0]) {
ui_but_value_set(but, event->type);
- else
+ }
+ else {
data->cancel = true;
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
@@ -3895,10 +4008,12 @@ static int ui_do_but_KEYEVT(
}
if (event->val == KM_PRESS) {
- if (WM_key_event_string(event->type, false)[0])
+ if (WM_key_event_string(event->type, false)[0]) {
ui_but_value_set(but, event->type);
- else
+ }
+ else {
data->cancel = true;
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -3983,7 +4098,7 @@ static int ui_do_but_TEX(
const bool has_icon_extra = ui_but_icon_extra_get(but) == UI_BUT_ICONEXTRA_CLEAR;
if (has_icon_extra && ui_but_is_mouse_over_icon_extra(data->region, but, &event->x)) {
- ui_but_text_clear(C, but, data);
+ ui_textedit_string_clear_and_exit(C, but, data);
}
else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
@@ -4020,7 +4135,7 @@ static int ui_do_but_SEARCH_UNLINK(
if (event->val == KM_RELEASE) {
/* unlink */
if (extra_icon_type == UI_BUT_ICONEXTRA_CLEAR) {
- ui_but_text_clear(C, but, data);
+ ui_textedit_string_clear_and_exit(C, but, data);
}
/* eyedropper */
else if (extra_icon_type == UI_BUT_ICONEXTRA_EYEDROPPER) {
@@ -4216,21 +4331,22 @@ static float ui_numedit_apply_snapf(
}
if (snap == SNAP_ON) {
- if (softrange < 2.10f) tempf = roundf(tempf * 10.0f) * 0.1f;
- else if (softrange < 21.0f) tempf = roundf(tempf);
- else tempf = roundf(tempf * 0.1f) * 10.0f;
+ if (softrange < 2.10f) { tempf = roundf(tempf * 10.0f) * 0.1f; }
+ else if (softrange < 21.0f) { tempf = roundf(tempf); }
+ else { tempf = roundf(tempf * 0.1f) * 10.0f; }
}
else if (snap == SNAP_ON_SMALL) {
- if (softrange < 2.10f) tempf = roundf(tempf * 100.0f) * 0.01f;
- else if (softrange < 21.0f) tempf = roundf(tempf * 10.0f) * 0.1f;
- else tempf = roundf(tempf);
+ if (softrange < 2.10f) { tempf = roundf(tempf * 100.0f) * 0.01f; }
+ else if (softrange < 21.0f) { tempf = roundf(tempf * 10.0f) * 0.1f; }
+ else { tempf = roundf(tempf); }
}
else {
BLI_assert(0);
}
- if (fac != 1.0f)
+ if (fac != 1.0f) {
tempf *= fac;
+ }
}
return tempf;
@@ -4240,8 +4356,9 @@ static float ui_numedit_apply_snap(
int temp, float softmin, float softmax,
const enum eSnapType snap)
{
- if (temp == softmin || temp == softmax)
+ if (temp == softmin || temp == softmax) {
return temp;
+ }
switch (snap) {
case SNAP_OFF:
@@ -4306,9 +4423,9 @@ static bool ui_numedit_but_NUM(
}
}
else {
- if (softrange > 256) fac = 1.0; /* 1px == 1 */
- else if (softrange > 32) fac = 1.0 / 2.0; /* 2px == 1 */
- else fac = 1.0 / 16.0; /* 16px == 1? */
+ if (softrange > 256) { fac = 1.0; } /* 1px == 1 */
+ else if (softrange > 32) { fac = 1.0 / 2.0; } /* 2px == 1 */
+ else { fac = 1.0 / 16.0; } /* 16px == 1? */
temp = data->startvalue + (((double)mx - data->dragstartx) * (double)fac);
temp = ui_numedit_apply_snap(temp, softmin, softmax, snap);
@@ -4355,9 +4472,9 @@ static bool ui_numedit_but_NUM(
non_linear_pixel_map = 250.0f;
/* prevent large ranges from getting too out of control */
- if (softrange > 600) deler = powf(softrange, 0.75f);
- else if (softrange < 25) deler = 50.0;
- else if (softrange < 100) deler = 100.0;
+ if (softrange > 600) { deler = powf(softrange, 0.75f); }
+ else if (softrange < 25) { deler = 50.0; }
+ else if (softrange < 100) { deler = 100.0; }
}
deler /= fac;
@@ -4561,7 +4678,9 @@ static int ui_do_but_NUM(
#endif
fac = 1.0f;
- if (event->shift) fac /= 10.0f;
+ if (event->shift) {
+ fac /= 10.0f;
+ }
if (ui_numedit_but_NUM(but, data, (ui_but_is_cursor_warp(but) ? screen_mx : mx), is_motion, snap, fac)) {
ui_numedit_apply(C, block, but, data);
@@ -4599,10 +4718,12 @@ static int ui_do_but_NUM(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value - 1;
- if (temp >= softmin && temp <= softmax)
+ if (temp >= softmin && temp <= softmax) {
data->value = (double)temp;
- else
+ }
+ else {
data->cancel = true;
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -4610,10 +4731,12 @@ static int ui_do_but_NUM(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value + 1;
- if (temp >= softmin && temp <= softmax)
+ if (temp >= softmin && temp <= softmax) {
data->value = (double)temp;
- else
+ }
+ else {
data->cancel = true;
+ }
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -4626,7 +4749,9 @@ static int ui_do_but_NUM(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value - (UI_PRECISION_FLOAT_SCALE * but->a1);
- if (tempf < softmin) tempf = softmin;
+ if (tempf < softmin) {
+ tempf = softmin;
+ }
data->value = tempf;
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -4635,7 +4760,9 @@ static int ui_do_but_NUM(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value + (UI_PRECISION_FLOAT_SCALE * but->a1);
- if (tempf > softmax) tempf = softmax;
+ if (tempf > softmax) {
+ tempf = softmax;
+ }
data->value = tempf;
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -4659,12 +4786,10 @@ static bool ui_numedit_but_SLI(
int mx, const bool is_horizontal, const bool is_motion,
const bool snap, const bool shift)
{
- float deler, f, tempf, softmin, softmax, softrange;
+ float cursor_x_range, f, tempf, softmin, softmax, softrange;
int temp, lvalue;
bool changed = false;
float mx_fl, my_fl;
- /* note, 'offs' is really from the widget drawing rounded corners see 'widget_numslider' */
- float offs;
/* prevent unwanted drag adjustments, test motion so modifier keys refresh. */
if ((but->type != UI_BTYPE_SCROLL) &&
@@ -4682,20 +4807,18 @@ static bool ui_numedit_but_SLI(
ui_mouse_scale_warp(data, mx, mx, &mx_fl, &my_fl, shift);
if (but->type == UI_BTYPE_NUM_SLIDER) {
- offs = (BLI_rctf_size_y(&but->rect) / 2.0f);
- deler = BLI_rctf_size_x(&but->rect) - offs;
+ cursor_x_range = BLI_rctf_size_x(&but->rect);
}
else if (but->type == UI_BTYPE_SCROLL) {
const float size = (is_horizontal) ? BLI_rctf_size_x(&but->rect) : -BLI_rctf_size_y(&but->rect);
- deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1);
- offs = 0.0;
+ cursor_x_range = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1);
}
else {
- offs = (BLI_rctf_size_y(&but->rect) / 2.0f);
- deler = (BLI_rctf_size_x(&but->rect) - offs);
+ float offs = (BLI_rctf_size_y(&but->rect) / 2.0f);
+ cursor_x_range = (BLI_rctf_size_x(&but->rect) - offs);
}
- f = (mx_fl - data->dragstartx) / deler + data->dragfstart;
+ f = (mx_fl - data->dragstartx) / cursor_x_range + data->dragfstart;
CLAMP(f, 0.0f, 1.0f);
@@ -4704,11 +4827,11 @@ static bool ui_numedit_but_SLI(
if (ui_but_is_cursor_warp(but)) {
/* OK but can go outside bounds */
if (is_horizontal) {
- data->ungrab_mval[0] = (but->rect.xmin + offs) + (f * deler);
+ data->ungrab_mval[0] = but->rect.xmin + (f * cursor_x_range);
data->ungrab_mval[1] = BLI_rctf_cent_y(&but->rect);
}
else {
- data->ungrab_mval[1] = (but->rect.ymin + offs) + (f * deler);
+ data->ungrab_mval[1] = but->rect.ymin + (f * cursor_x_range);
data->ungrab_mval[0] = BLI_rctf_cent_x(&but->rect);
}
BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval);
@@ -4728,14 +4851,14 @@ static bool ui_numedit_but_SLI(
if (shift) {
if (tempf == softmin || tempf == softmax) {}
- else if (softrange < 2.10f) tempf = roundf(tempf * 100.0f) * 0.01f;
- else if (softrange < 21.0f) tempf = roundf(tempf * 10.0f) * 0.1f;
- else tempf = roundf(tempf);
+ else if (softrange < 2.10f) { tempf = roundf(tempf * 100.0f) * 0.01f; }
+ else if (softrange < 21.0f) { tempf = roundf(tempf * 10.0f) * 0.1f; }
+ else { tempf = roundf(tempf); }
}
else {
- if (softrange < 2.10f) tempf = roundf(tempf * 10.0f) * 0.1f;
- else if (softrange < 21.0f) tempf = roundf(tempf);
- else tempf = roundf(tempf * 0.1f) * 10.0f;
+ if (softrange < 2.10f) { tempf = roundf(tempf * 10.0f) * 0.1f; }
+ else if (softrange < 21.0f) { tempf = roundf(tempf); }
+ else { tempf = roundf(tempf * 0.1f) * 10.0f; }
}
}
else {
@@ -4810,10 +4933,12 @@ static int ui_do_but_SLI(
else if (event->type == LEFTMOUSE && event->alt) {
int halfpos = BLI_rctf_cent_x(&but->rect);
click = 2;
- if (mx < halfpos)
+ if (mx < halfpos) {
mx = but->rect.xmin;
- else
+ }
+ else {
mx = but->rect.xmax;
+ }
}
#endif
else if (event->type == LEFTMOUSE) {
@@ -4923,22 +5048,34 @@ static int ui_do_but_SLI(
f = softmin + f * softrange;
if (!ui_but_is_float(but)) {
- if (f < temp) temp--;
- else temp++;
+ if (f < temp) {
+ temp--;
+ }
+ else {
+ temp++;
+ }
- if (temp >= softmin && temp <= softmax)
+ if (temp >= softmin && temp <= softmax) {
data->value = temp;
- else
+ }
+ else {
data->cancel = true;
+ }
}
else {
- if (f < tempf) tempf -= 0.01f;
- else tempf += 0.01f;
+ if (f < tempf) {
+ tempf -= 0.01f;
+ }
+ else {
+ tempf += 0.01f;
+ }
- if (tempf >= softmin && tempf <= softmax)
+ if (tempf >= softmin && tempf <= softmax) {
data->value = tempf;
- else
+ }
+ else {
data->cancel = true;
+ }
}
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -4985,8 +5122,9 @@ static int ui_do_but_SCROLL(
}
/* UNUSED - otherwise code is ok, add back if needed */
#if 0
- else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS)
+ else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) {
click = 1;
+ }
#endif
}
}
@@ -5305,10 +5443,12 @@ static int ui_do_but_COLOR(
ui_but_v3_get(but, col);
rgb_to_hsv_compat_v(col, hsv);
- if (event->type == WHEELDOWNMOUSE)
+ if (event->type == WHEELDOWNMOUSE) {
hsv[2] = clamp_f(hsv[2] - 0.05f, 0.0f, 1.0f);
- else if (event->type == WHEELUPMOUSE)
+ }
+ else if (event->type == WHEELUPMOUSE) {
hsv[2] = clamp_f(hsv[2] + 0.05f, 0.0f, 1.0f);
+ }
else {
float fac = 0.005 * (event->y - event->prevy);
hsv[2] = clamp_f(hsv[2] + fac, 0.0f, 1.0f);
@@ -5422,8 +5562,9 @@ static int ui_do_but_UNITVEC(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_UNITVEC(but, data, mx, my, snap))
+ if (ui_numedit_but_UNITVEC(but, data, mx, my, snap)) {
ui_numedit_apply(C, block, but, data);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -5432,8 +5573,9 @@ static int ui_do_but_UNITVEC(
if ((event->type == MOUSEMOVE) || ui_event_is_snap(event)) {
if (mx != data->draglastx || my != data->draglasty || event->type != MOUSEMOVE) {
const enum eSnapType snap = ui_event_to_snap(event);
- if (ui_numedit_but_UNITVEC(but, data, mx, my, snap))
+ if (ui_numedit_but_UNITVEC(but, data, mx, my, snap)) {
ui_numedit_apply(C, block, but, data);
+ }
}
}
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
@@ -5453,34 +5595,46 @@ static void clamp_axis_max_v3(float v[3], const float max)
const float v_max = max_fff(v[0], v[1], v[2]);
if (v_max > max) {
mul_v3_fl(v, max / v_max);
- if (v[0] > max) v[0] = max;
- if (v[1] > max) v[1] = max;
- if (v[2] > max) v[2] = max;
+ if (v[0] > max) {
+ v[0] = max;
+ }
+ if (v[1] > max) {
+ v[1] = max;
+ }
+ if (v[2] > max) {
+ v[2] = max;
+ }
}
}
static void ui_rgb_to_color_picker_HSVCUBE_compat_v(uiBut *but, const float rgb[3], float hsv[3])
{
- if (but->a1 == UI_GRAD_L_ALT)
+ if (but->a1 == UI_GRAD_L_ALT) {
rgb_to_hsl_compat_v(rgb, hsv);
- else
+ }
+ else {
rgb_to_hsv_compat_v(rgb, hsv);
+ }
}
static void ui_rgb_to_color_picker_HSVCUBE_v(uiBut *but, const float rgb[3], float hsv[3])
{
- if (but->a1 == UI_GRAD_L_ALT)
+ if (but->a1 == UI_GRAD_L_ALT) {
rgb_to_hsl_v(rgb, hsv);
- else
+ }
+ else {
rgb_to_hsv_v(rgb, hsv);
+ }
}
static void ui_color_picker_to_rgb_HSVCUBE_v(uiBut *but, const float hsv[3], float rgb[3])
{
- if (but->a1 == UI_GRAD_L_ALT)
+ if (but->a1 == UI_GRAD_L_ALT) {
hsl_to_rgb_v(hsv, rgb);
- else
+ }
+ else {
hsv_to_rgb_v(hsv, rgb);
+ }
}
static bool ui_numedit_but_HSVCUBE(
@@ -5689,8 +5843,9 @@ static int ui_do_but_HSVCUBE(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0))
+ if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0)) {
ui_numedit_apply(C, block, but, data);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -5751,8 +5906,9 @@ static int ui_do_but_HSVCUBE(
if (mx != data->draglastx || my != data->draglasty || event->type != MOUSEMOVE) {
const enum eSnapType snap = ui_event_to_snap(event);
- if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0))
+ if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0)) {
ui_numedit_apply(C, block, but, data);
+ }
}
}
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
@@ -5803,13 +5959,19 @@ static bool ui_numedit_but_HSVCIRCLE(
/* exception, when using color wheel in 'locked' value state:
* allow choosing a hue for black values, by giving a tiny increment */
- if (but->flag & UI_BUT_COLOR_LOCK) {
+ if (cpicker->use_color_lock) {
if (U.color_picker_type == USER_CP_CIRCLE_HSV) { // lock
- if (hsv[2] == 0.f) hsv[2] = 0.0001f;
+ if (hsv[2] == 0.f) {
+ hsv[2] = 0.0001f;
+ }
}
else {
- if (hsv[2] == 0.0f) hsv[2] = 0.0001f;
- if (hsv[2] >= 0.9999f) hsv[2] = 0.9999f;
+ if (hsv[2] == 0.0f) {
+ hsv[2] = 0.0001f;
+ }
+ if (hsv[2] >= 0.9999f) {
+ hsv[2] = 0.9999f;
+ }
}
}
@@ -5824,17 +5986,18 @@ static bool ui_numedit_but_HSVCIRCLE(
ui_rgb_to_color_picker_compat_v(rgbo, hsvo);
/* and original position */
- ui_hsvcircle_pos_from_vals(but, &rect, hsvo, &xpos, &ypos);
+ ui_hsvcircle_pos_from_vals(cpicker, &rect, hsvo, &xpos, &ypos);
mx_fl = xpos - (data->dragstartx - mx_fl);
my_fl = ypos - (data->dragstarty - my_fl);
}
- ui_hsvcircle_vals_from_pos(hsv, hsv + 1, &rect, mx_fl, my_fl);
+ ui_hsvcircle_vals_from_pos(&rect, mx_fl, my_fl, hsv, hsv + 1);
- if ((but->flag & UI_BUT_COLOR_CUBIC) && (U.color_picker_type == USER_CP_CIRCLE_HSV))
+ if ((cpicker->use_color_cubic) && (U.color_picker_type == USER_CP_CIRCLE_HSV)) {
hsv[1] = 1.0f - sqrt3f(1.0f - hsv[1]);
+ }
if (snap != SNAP_OFF) {
ui_color_snap_hue(snap, &hsv[0]);
@@ -5842,8 +6005,10 @@ static bool ui_numedit_but_HSVCIRCLE(
ui_color_picker_to_rgb_v(hsv, rgb);
- if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
- normalize_v3_length(rgb, but->a2);
+ if ((cpicker->use_luminosity_lock)) {
+ if (!is_zero_v3(rgb)) {
+ normalize_v3_length(rgb, cpicker->luminosity_lock_value);
+ }
}
ui_color_picker_to_scene_linear_space(but, rgb);
@@ -5897,13 +6062,19 @@ static void ui_ndofedit_but_HSVCIRCLE(
/* exception, when using color wheel in 'locked' value state:
* allow choosing a hue for black values, by giving a tiny increment */
- if (but->flag & UI_BUT_COLOR_LOCK) {
+ if (cpicker->use_color_lock) {
if (U.color_picker_type == USER_CP_CIRCLE_HSV) { // lock
- if (hsv[2] == 0.f) hsv[2] = 0.0001f;
+ if (hsv[2] == 0.f) {
+ hsv[2] = 0.0001f;
+ }
}
else {
- if (hsv[2] == 0.f) hsv[2] = 0.0001f;
- if (hsv[2] == 1.f) hsv[2] = 0.9999f;
+ if (hsv[2] == 0.f) {
+ hsv[2] = 0.0001f;
+ }
+ if (hsv[2] == 1.f) {
+ hsv[2] = 0.9999f;
+ }
}
}
@@ -5915,8 +6086,10 @@ static void ui_ndofedit_but_HSVCIRCLE(
ui_color_picker_to_rgb_v(hsv, data->vec);
- if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
- normalize_v3_length(data->vec, but->a2);
+ if (cpicker->use_luminosity_lock) {
+ if (!is_zero_v3(data->vec)) {
+ normalize_v3_length(data->vec, cpicker->luminosity_lock_value);
+ }
}
ui_color_picker_to_scene_linear_space(but, data->vec);
@@ -5945,8 +6118,9 @@ static int ui_do_but_HSVCIRCLE(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0))
+ if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0)) {
ui_numedit_apply(C, block, but, data);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -6037,11 +6211,13 @@ static bool ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int m
float dx;
bool changed = false;
- if (data->draglastx == mx)
+ if (data->draglastx == mx) {
return changed;
+ }
- if (data->coba->tot == 0)
+ if (data->coba->tot == 0) {
return changed;
+ }
dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect);
data->dragcbd->pos += dx;
@@ -6090,7 +6266,10 @@ static int ui_do_but_COLORBAND(
for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) {
xco = but->rect.xmin + (cbd->pos * BLI_rctf_size_x(&but->rect));
xco = ABS(xco - mx);
- if (a == coba->cur) xco += 5; // selected one disadvantage
+ if (a == coba->cur) {
+ /* Selected one disadvantage. */
+ xco += 5;
+ }
if (xco < mindist) {
coba->cur = a;
mindist = xco;
@@ -6108,8 +6287,9 @@ static int ui_do_but_COLORBAND(
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_COLORBAND(but, data, mx))
+ if (ui_numedit_but_COLORBAND(but, data, mx)) {
ui_numedit_apply(C, block, but, data);
+ }
}
}
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
@@ -6161,8 +6341,9 @@ static bool ui_numedit_but_CURVE(
d[0] = mx - data->dragstartx;
d[1] = my - data->dragstarty;
- if (len_squared_v2(d) < (3.0f * 3.0f))
+ if (len_squared_v2(d) < (3.0f * 3.0f)) {
snap = false;
+ }
}
if (data->dragsel != -1) {
@@ -6185,8 +6366,9 @@ static bool ui_numedit_but_CURVE(
cmp[a].x = 0.125f * roundf(8.0f * cmp[a].x);
cmp[a].y = 0.125f * roundf(8.0f * cmp[a].y);
}
- if (cmp[a].x != origx || cmp[a].y != origy)
+ if (cmp[a].x != origx || cmp[a].y != origy) {
moved_point = true;
+ }
cmp_last = &cmp[a];
}
@@ -6220,14 +6402,18 @@ static bool ui_numedit_but_CURVE(
/* clamp for clip */
if (cumap->flag & CUMA_DO_CLIP) {
- if (cumap->curr.xmin - fx < cumap->clipr.xmin)
+ if (cumap->curr.xmin - fx < cumap->clipr.xmin) {
fx = cumap->curr.xmin - cumap->clipr.xmin;
- else if (cumap->curr.xmax - fx > cumap->clipr.xmax)
+ }
+ else if (cumap->curr.xmax - fx > cumap->clipr.xmax) {
fx = cumap->curr.xmax - cumap->clipr.xmax;
- if (cumap->curr.ymin - fy < cumap->clipr.ymin)
+ }
+ if (cumap->curr.ymin - fy < cumap->clipr.ymin) {
fy = cumap->curr.ymin - cumap->clipr.ymin;
- else if (cumap->curr.ymax - fy > cumap->clipr.ymax)
+ }
+ else if (cumap->curr.ymax - fy > cumap->clipr.ymax) {
fy = cumap->curr.ymax - cumap->clipr.ymax;
+ }
}
cumap->curr.xmin -= fx;
@@ -6361,8 +6547,9 @@ static int ui_do_but_CURVE(
if (event->type == MOUSEMOVE) {
if (event->x != data->draglastx || event->y != data->draglasty) {
- if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0))
+ if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0)) {
ui_numedit_apply(C, block, but, data);
+ }
}
}
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
@@ -6374,8 +6561,9 @@ static int ui_do_but_CURVE(
if (data->dragchange == false) {
/* deselect all, select one */
if (!event->shift) {
- for (a = 0; a < cuma->totpoint; a++)
+ for (a = 0; a < cuma->totpoint; a++) {
cmp[a].flag &= ~CUMA_SELECT;
+ }
cmp[data->dragsel].flag |= CUMA_SELECT;
}
}
@@ -6435,8 +6623,9 @@ static int ui_do_but_HISTOGRAM(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_HISTOGRAM(but, data, mx, my))
+ if (ui_numedit_but_HISTOGRAM(but, data, mx, my)) {
ui_numedit_apply(C, block, but, data);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -6459,8 +6648,9 @@ static int ui_do_but_HISTOGRAM(
}
else if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_HISTOGRAM(but, data, mx, my))
+ if (ui_numedit_but_HISTOGRAM(but, data, mx, my)) {
ui_numedit_apply(C, block, but, data);
+ }
}
}
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
@@ -6510,8 +6700,9 @@ static int ui_do_but_WAVEFORM(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_WAVEFORM(but, data, mx, my))
+ if (ui_numedit_but_WAVEFORM(but, data, mx, my)) {
ui_numedit_apply(C, block, but, data);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -6534,8 +6725,9 @@ static int ui_do_but_WAVEFORM(
}
else if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_WAVEFORM(but, data, mx, my))
+ if (ui_numedit_but_WAVEFORM(but, data, mx, my)) {
ui_numedit_apply(C, block, but, data);
+ }
}
}
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
@@ -6565,8 +6757,9 @@ static bool ui_numedit_but_TRACKPREVIEW(
}
if (!scopes->track_locked) {
- if (scopes->marker->framenr != scopes->framenr)
+ if (scopes->marker->framenr != scopes->framenr) {
scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr);
+ }
scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_rctf_size_x(&but->block->rect);
@@ -6602,8 +6795,9 @@ static int ui_do_but_TRACKPREVIEW(
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0))
+ if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0)) {
ui_numedit_apply(C, block, but, data);
+ }
return WM_UI_HANDLER_BREAK;
}
@@ -6618,8 +6812,9 @@ static int ui_do_but_TRACKPREVIEW(
}
else if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0))
+ if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0)) {
ui_numedit_apply(C, block, but, data);
+ }
}
}
else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
@@ -6778,10 +6973,13 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
retval = ui_do_but_BUT(C, but, data, event);
break;
case UI_BTYPE_COLOR:
- if (but->a1 == -1) /* signal to prevent calling up color picker */
+ if (but->a1 == -1) {
+ /* signal to prevent calling up color picker */
retval = ui_do_but_EXIT(C, but, data, event);
- else
+ }
+ else {
retval = ui_do_but_COLOR(C, but, data, event);
+ }
break;
case UI_BTYPE_UNITVEC:
retval = ui_do_but_UNITVEC(C, block, but, data, event);
@@ -6888,336 +7086,25 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
return retval;
}
-/* ************************ button utilities *********************** */
-
-static bool ui_but_contains_pt(uiBut *but, float mx, float my)
-{
- return BLI_rctf_isect_pt(&but->rect, mx, my);
-}
-
-void ui_but_pie_dir(RadialDirection dir, float vec[2])
-{
- float angle;
-
- BLI_assert(dir != UI_RADIAL_NONE);
-
- angle = DEG2RADF((float)ui_radial_dir_to_angle[dir]);
- vec[0] = cosf(angle);
- vec[1] = sinf(angle);
-}
-
-static bool ui_but_isect_pie_seg(uiBlock *block, uiBut *but)
-{
- const float angle_range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_4 : M_PI_4 / 2.0;
- float vec[2];
-
- if (block->pie_data.flags & UI_PIE_INVALID_DIR)
- return false;
-
- ui_but_pie_dir(but->pie_dir, vec);
-
- if (saacos(dot_v2v2(vec, block->pie_data.pie_dir)) < angle_range)
- return true;
-
- return false;
-}
+/** \} */
-static bool ui_but_find_select_in_enum__cmp(const uiBut *but_a, const uiBut *but_b)
-{
- return ((but_a->type == but_b->type) &&
- (but_a->alignnr == but_b->alignnr) &&
- (but_a->poin == but_b->poin) &&
- (but_a->rnapoin.type == but_b->rnapoin.type) &&
- (but_a->rnaprop == but_b->rnaprop));
-}
-
-/**
- * Finds the pressed button in an aligned row (typically an expanded enum).
- *
- * \param direction: Use when there may be multiple buttons pressed.
- */
-uiBut *ui_but_find_select_in_enum(uiBut *but, int direction)
-{
- uiBut *but_iter = but;
- uiBut *but_found = NULL;
- BLI_assert(ELEM(direction, -1, 1));
-
- while ((but_iter->prev) &&
- ui_but_find_select_in_enum__cmp(but_iter->prev, but))
- {
- but_iter = but_iter->prev;
- }
-
- while (but_iter && ui_but_find_select_in_enum__cmp(but_iter, but)) {
- if (but_iter->flag & UI_SELECT) {
- but_found = but_iter;
- if (direction == 1) {
- break;
- }
- }
- but_iter = but_iter->next;
- }
-
- return but_found;
-}
-
-uiBut *ui_but_find_active_in_region(ARegion *ar)
-{
- uiBlock *block;
- uiBut *but;
-
- for (block = ar->uiblocks.first; block; block = block->next)
- for (but = block->buttons.first; but; but = but->next)
- if (but->active)
- return but;
-
- return NULL;
-}
-
-bool ui_but_is_active(ARegion *ar)
-{
- return (ui_but_find_active_in_region(ar) != NULL);
-}
-
-/* is called by notifier */
-void UI_screen_free_active_but(const bContext *C, bScreen *screen)
-{
- wmWindow *win = CTX_wm_window(C);
-
- ED_screen_areas_iter(win, screen, area) {
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
- uiBut *but = ui_but_find_active_in_region(region);
- if (but) {
- uiHandleButtonData *data = but->active;
-
- if (data->menu == NULL && data->searchbox == NULL)
- if (data->state == BUTTON_STATE_HIGHLIGHT)
- ui_but_active_free(C, but);
- }
- }
- }
-}
-
-
-
-/* returns true if highlighted button allows drop of names */
-/* called in region context */
-bool UI_but_active_drop_name(bContext *C)
-{
- ARegion *ar = CTX_wm_region(C);
- uiBut *but = ui_but_find_active_in_region(ar);
-
- if (but) {
- if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU))
- return 1;
- }
-
- return 0;
-}
-
-bool UI_but_active_drop_color(bContext *C)
-{
- ARegion *ar = CTX_wm_region(C);
-
- if (ar) {
- uiBut *but = ui_but_find_active_in_region(ar);
-
- if (but && but->type == UI_BTYPE_COLOR)
- return true;
- }
-
- return false;
-}
+/* -------------------------------------------------------------------- */
+/** \name Button Tool Tip
+ * \{ */
static void ui_blocks_set_tooltips(ARegion *ar, const bool enable)
{
uiBlock *block;
- if (!ar)
+ if (!ar) {
return;
+ }
/* we disabled buttons when when they were already shown, and
* re-enable them on mouse move */
- for (block = ar->uiblocks.first; block; block = block->next)
- block->tooltipdisabled = !enable;
-}
-
-static bool ui_region_contains_point_px(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;
- }
-
- /* also, check that with view2d, that the mouse is not over the scrollbars
- * NOTE: care is needed here, since the mask rect may include the scrollbars
- * even when they are not visible, so we need to make a copy of the mask to
- * use to check
- */
- if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) {
- View2D *v2d = &ar->v2d;
- int mx, my;
-
- /* 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;
- }
- }
-
- return true;
-}
-
-static bool ui_but_contains_point_px(ARegion *ar, uiBut *but, 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;
-
- ui_window_to_block_fl(ar, block, &mx, &my);
-
- if (but->pie_dir != UI_RADIAL_NONE) {
- if (!ui_but_isect_pie_seg(block, but)) {
- return false;
- }
- }
- else if (!ui_but_contains_pt(but, mx, my)) {
- return false;
- }
-
- return true;
-}
-
-/**
- * Can we mouse over the button or is it hidden/disabled/layout.
- * \note ctrl is kind of a hack currently,
- * so that non-embossed UI_BTYPE_TEXT button behaves as a label when ctrl is not pressed.
- */
-static bool ui_but_is_interactive(const uiBut *but, const bool labeledit)
-{
- /* note, UI_BTYPE_LABEL is included for highlights, this allows drags */
- if ((but->type == UI_BTYPE_LABEL) && but->dragpoin == NULL)
- return false;
- if (ELEM(but->type, UI_BTYPE_ROUNDBOX, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_LISTBOX))
- return false;
- if (but->flag & UI_HIDDEN)
- return false;
- if (but->flag & UI_SCROLLED)
- return false;
- if ((but->type == UI_BTYPE_TEXT) && (but->dt == UI_EMBOSS_NONE) && !labeledit)
- return false;
- if ((but->type == UI_BTYPE_LISTROW) && labeledit)
- return false;
-
- return true;
-}
-
-/* x and y are only used in case event is NULL... */
-static 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;
-
-// 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;
- ui_window_to_block_fl(ar, block, &mx, &my);
-
- for (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)) {
- butover = but;
- break;
- }
- }
- else if (ui_but_contains_pt(but, mx, my)) {
- 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_pt(&block->rect, mx, my)) {
- break;
- }
- }
- }
-
- return butover;
-}
-
-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);
-}
-
-
-static uiBut *ui_list_find_mouse_over_ex(ARegion *ar, int x, int y)
-{
- uiBlock *block;
- uiBut *but;
- float mx, my;
-
- if (!ui_region_contains_point_px(ar, x, y))
- return NULL;
-
for (block = ar->uiblocks.first; block; block = block->next) {
- mx = x;
- my = y;
- ui_window_to_block_fl(ar, block, &mx, &my);
-
- for (but = block->buttons.last; but; but = but->prev) {
- if (but->type == UI_BTYPE_LISTBOX && ui_but_contains_pt(but, mx, my)) {
- return but;
- }
- }
+ block->tooltipdisabled = !enable;
}
-
- return NULL;
-}
-
-static uiBut *ui_list_find_mouse_over(ARegion *ar, const wmEvent *event)
-{
- return ui_list_find_mouse_over_ex(ar, event->x, event->y);
-}
-
-/* ****************** button state handling **************************/
-
-static bool button_modal_state(uiHandleButtonState state)
-{
- return ELEM(state,
- BUTTON_STATE_WAIT_RELEASE,
- BUTTON_STATE_WAIT_KEY_EVENT,
- BUTTON_STATE_NUM_EDITING,
- BUTTON_STATE_TEXT_EDITING,
- BUTTON_STATE_TEXT_SELECTING,
- BUTTON_STATE_MENU_OPEN);
}
/**
@@ -7296,13 +7183,31 @@ static void button_tooltip_timer_reset(bContext *C, uiBut *but)
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button State Handling
+ * \{ */
+
+static bool button_modal_state(uiHandleButtonState state)
+{
+ return ELEM(state,
+ BUTTON_STATE_WAIT_RELEASE,
+ BUTTON_STATE_WAIT_KEY_EVENT,
+ BUTTON_STATE_NUM_EDITING,
+ BUTTON_STATE_TEXT_EDITING,
+ BUTTON_STATE_TEXT_SELECTING,
+ BUTTON_STATE_MENU_OPEN);
+}
+
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state)
{
uiHandleButtonData *data;
data = but->active;
- if (data->state == state)
+ if (data->state == state) {
return;
+ }
/* highlight has timers for tooltips and auto open */
if (state == BUTTON_STATE_HIGHLIGHT) {
@@ -7342,17 +7247,21 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
}
/* text editing */
- if (state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING)
+ if (state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING) {
ui_textedit_begin(C, but, data);
- else if (data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING)
+ }
+ else if (data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING) {
ui_textedit_end(C, but, data);
- else if (data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING)
+ }
+ else if (data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING) {
ui_textedit_end(C, but, data);
+ }
/* number editing */
if (state == BUTTON_STATE_NUM_EDITING) {
- if (ui_but_is_cursor_warp(but))
+ if (ui_but_is_cursor_warp(but)) {
WM_cursor_grab_enable(CTX_wm_window(C), true, true, NULL);
+ }
ui_numedit_begin(but, data);
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
@@ -7388,10 +7297,12 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
}
}
/* menu open */
- if (state == BUTTON_STATE_MENU_OPEN)
+ if (state == BUTTON_STATE_MENU_OPEN) {
ui_block_open_begin(C, but, data);
- else if (data->state == BUTTON_STATE_MENU_OPEN)
+ }
+ else if (data->state == BUTTON_STATE_MENU_OPEN) {
ui_block_open_end(C, but, data);
+ }
/* add a short delay before exiting, to ensure there is some feedback */
if (state == BUTTON_STATE_WAIT_FLASH) {
@@ -7415,8 +7326,9 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
* but not for popups, because we already have a window level handler*/
if (!(but->block->handle && but->block->handle->popup)) {
if (button_modal_state(state)) {
- if (!button_modal_state(data->state))
+ if (!button_modal_state(data->state)) {
WM_event_add_ui_handler(C, &data->window->modalhandlers, ui_handler_region_menu, NULL, data, 0);
+ }
}
else {
if (button_modal_state(data->state)) {
@@ -7439,8 +7351,9 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
* highlight when not in a popup menu, we remove because data used in
* button below popup might have been removed by action of popup. Needs
* a more reliable solution... */
- if (state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP))
+ if (state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP)) {
ui_but_update(but);
+ }
}
/* redraw */
@@ -7480,9 +7393,11 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
/* we disable auto_open in the block after a threshold, because we still
* want to allow auto opening adjacent menus even if no button is activated
* in between going over to the other button, but only for a short while */
- if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open == true)
- if (but->block->auto_open_last + BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer())
+ if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open == true) {
+ if (but->block->auto_open_last + BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer()) {
but->block->auto_open = false;
+ }
+ }
if (type == BUTTON_ACTIVATE_OVER) {
data->used_mouse = true;
@@ -7491,8 +7406,9 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
/* activate right away */
if (but->flag & UI_BUT_IMMEDIATE) {
- if (but->type == UI_BTYPE_HOTKEY_EVENT)
+ if (but->type == UI_BTYPE_HOTKEY_EVENT) {
button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
+ }
/* .. more to be added here */
}
@@ -7508,15 +7424,18 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
if (subblock) {
subbut = ui_but_first(subblock);
- if (subbut)
+ if (subbut) {
ui_handle_button_activate(C, subar, subbut, BUTTON_ACTIVATE);
+ }
}
}
}
- else if (type == BUTTON_ACTIVATE_TEXT_EDITING)
+ else if (type == BUTTON_ACTIVATE_TEXT_EDITING) {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
- else if (type == BUTTON_ACTIVATE_APPLY)
+ }
+ else if (type == BUTTON_ACTIVATE_APPLY) {
button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH);
+ }
if (but->type == UI_BTYPE_GRIP) {
const bool horizontal = (BLI_rctf_size_x(&but->rect) < BLI_rctf_size_y(&but->rect));
@@ -7552,12 +7471,14 @@ static void button_activate_exit(
}
/* ensure we are in the exit state */
- if (data->state != BUTTON_STATE_EXIT)
+ if (data->state != BUTTON_STATE_EXIT) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
/* apply the button action or value */
- if (!onfree)
+ if (!onfree) {
ui_apply_but(C, block, but, data, false);
+ }
#ifdef USE_DRAG_MULTINUM
if (data->multi_data.has_mbuts) {
@@ -7607,14 +7528,16 @@ static void button_activate_exit(
#endif
/* popup menu memory */
- if (block->flag & UI_BLOCK_POPUP_MEMORY)
+ if (block->flag & UI_BLOCK_POPUP_MEMORY) {
ui_popup_menu_memory_set(block, but);
+ }
}
/* disable tooltips until mousemove + last active flag */
for (block = data->region->uiblocks.first; block; block = block->next) {
- for (bt = block->buttons.first; bt; bt = bt->next)
+ for (bt = block->buttons.first; bt; bt = bt->next) {
bt->flag &= ~UI_BUT_LAST_ACTIVE;
+ }
block->tooltipdisabled = 1;
}
@@ -7622,10 +7545,12 @@ static void button_activate_exit(
ui_blocks_set_tooltips(data->region, false);
/* clean up */
- if (data->str)
+ if (data->str) {
MEM_freeN(data->str);
- if (data->origstr)
+ }
+ if (data->origstr) {
MEM_freeN(data->origstr);
+ }
#ifdef USE_ALLSELECT
ui_selectcontext_end(but, &data->select_others);
@@ -7647,14 +7572,16 @@ static void button_activate_exit(
but->flag &= ~(UI_ACTIVE | UI_SELECT);
but->flag |= UI_BUT_LAST_ACTIVE;
- if (!onfree)
+ if (!onfree) {
ui_but_update(but);
+ }
/* adds empty mousemove in queue for re-init handler, in case mouse is
* still over a button. We cannot just check for this ourselves because
* at this point the mouse may be over a button in another region */
- if (mousemove)
+ if (mousemove) {
WM_event_add_mousemove(C);
+ }
}
void ui_but_active_free(const bContext *C, uiBut *but)
@@ -7683,10 +7610,12 @@ static uiBut *ui_context_button_active(ARegion *ar, bool (*but_check_cb)(uiBut *
/* find active button */
for (block = ar->uiblocks.first; block; block = block->next) {
for (but = block->buttons.first; but; but = but->next) {
- if (but->active)
+ if (but->active) {
activebut = but;
- else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
+ }
+ else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) {
activebut = but;
+ }
}
}
@@ -7856,7 +7785,11 @@ void UI_context_update_anim_flag(const bContext *C)
}
}
-/************** handle activating a button *************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Button Activation Handling
+ * \{ */
static uiBut *ui_but_find_open_event(ARegion *ar, const wmEvent *event)
{
@@ -7864,9 +7797,11 @@ static uiBut *ui_but_find_open_event(ARegion *ar, const wmEvent *event)
uiBut *but;
for (block = ar->uiblocks.first; block; block = block->next) {
- for (but = block->buttons.first; but; but = but->next)
- if (but == event->customdata)
+ for (but = block->buttons.first; but; but = but->next) {
+ if (but == event->customdata) {
return but;
+ }
+ }
}
return NULL;
}
@@ -7953,7 +7888,7 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu
uiBut *oldbut;
uiHandleButtonData *data;
- oldbut = ui_but_find_active_in_region(ar);
+ oldbut = ui_region_find_active_but(ar);
if (oldbut) {
data = oldbut->active;
data->cancel = true;
@@ -7963,7 +7898,37 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu
button_activate_init(C, ar, but, type);
}
-/************ handle events for an activated button ***********/
+/**
+ * Use for key accelerator or default key to activate the button even if its not active.
+ */
+static bool ui_handle_button_activate_by_type(bContext *C, ARegion *ar, uiBut *but)
+{
+ if (but->type == UI_BTYPE_BUT_MENU) {
+ /* mainly for operator buttons */
+ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY);
+ }
+ else if (ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN)) {
+ /* open sub-menus (like right arrow key) */
+ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN);
+ }
+ else if (but->type == UI_BTYPE_MENU) {
+ /* activate menu items */
+ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE);
+ }
+ else {
+#ifdef DEBUG
+ printf("%s: error, unhandled type: %u\n", __func__, but->type);
+#endif
+ return false;
+ }
+ return true;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Handle Events for Activated Buttons
+ * \{ */
static bool ui_button_value_default(uiBut *but, double *r_value)
{
@@ -8026,7 +7991,11 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
data->cancel = false;
button_activate_state(C, but, BUTTON_STATE_EXIT);
retval = WM_UI_HANDLER_BREAK;
- block->handle->menuretval = UI_RETURN_OK;
+ /* Cancel because this `but` handles all events and we don't want
+ * the parent button's update function to do anything.
+ *
+ * Causes issues with buttons defined by #uiItemFullR_with_popover. */
+ block->handle->menuretval = UI_RETURN_CANCEL;
}
else if (ui_but_is_editable_as_text(but)) {
ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_TEXT_EDITING);
@@ -8046,7 +8015,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
/* always deactivate button for pie menus,
* else moving to blank space will leave activated */
if ((!ui_block_is_menu(block) || ui_block_is_pie_menu(block)) &&
- !ui_but_contains_point_px(ar, but, event->x, event->y))
+ !ui_but_contains_point_px(but, ar, event->x, event->y))
{
exit = true;
}
@@ -8073,7 +8042,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
WM_event_remove_timer(data->wm, data->window, data->autoopentimer);
data->autoopentimer = NULL;
- if (ui_but_contains_point_px(ar, but, event->x, event->y) || but->active) {
+ if (ui_but_contains_point_px(but, ar, event->x, event->y) || but->active) {
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
}
}
@@ -8125,14 +8094,15 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
{
/* deselect the button when moving the mouse away */
/* also de-activate for buttons that only show highlights */
- if (ui_but_contains_point_px(ar, but, event->x, event->y)) {
+ if (ui_but_contains_point_px(but, ar, event->x, event->y)) {
/* Drag on a hold button (used in the toolbar) now opens it immediately. */
if (data->hold_action_timer) {
if (but->flag & UI_SELECT) {
- if ((abs(event->x - event->prevx)) > 2 ||
- (abs(event->y - event->prevy)) > 2)
- {
+ if (len_manhattan_v2v2_int(&event->x, &event->prevx) <= WM_EVENT_CURSOR_MOTION_THRESHOLD) {
+ /* pass */
+ }
+ else {
WM_event_remove_timer(data->wm, data->window, data->hold_action_timer);
data->hold_action_timer = WM_event_add_timer(data->wm, data->window, TIMER, 0.0f);
}
@@ -8297,8 +8267,9 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar,
/* if type still is mousepan, we call it handled, since delta-y accumulate */
/* also see wm_event_system.c do_wheel_ui hack */
- if (type == MOUSEPAN)
+ if (type == MOUSEPAN) {
retval = WM_UI_HANDLER_BREAK;
+ }
}
if (val == KM_PRESS) {
@@ -8414,10 +8385,12 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u
/* copy over return values from the closing menu */
if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) {
- if (but->type == UI_BTYPE_COLOR)
+ if (but->type == UI_BTYPE_COLOR) {
copy_v3_v3(data->vec, menu->retvec);
- else if (but->type == UI_BTYPE_MENU)
+ }
+ else if (but->type == UI_BTYPE_MENU) {
data->value = menu->retvalue;
+ }
}
if (menu->menuretval & UI_RETURN_UPDATE) {
@@ -8433,13 +8406,14 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u
/* now change button state or exit, which will close the submenu */
if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) {
- if (menu->menuretval != UI_RETURN_OK)
+ if (menu->menuretval != UI_RETURN_OK) {
data->cancel = true;
+ }
button_activate_exit(C, but, data, true, false);
}
else if (menu->menuretval & UI_RETURN_OUT) {
- if (event->type == MOUSEMOVE && ui_but_contains_point_px(data->region, but, event->x, event->y)) {
+ if (event->type == MOUSEMOVE && ui_but_contains_point_px(but, data->region, event->x, event->y)) {
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
}
else {
@@ -8456,7 +8430,11 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u
}
}
-/* ************************* menu handling *******************************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Menu Towards (mouse motion logic)
+ * \{ */
/**
* Function used to prevent losing the open menu when using nested pull-downs,
@@ -8477,10 +8455,12 @@ static void ui_mouse_motion_towards_init_ex(uiPopupBlockHandle *menu, const int
menu->towards_xy[0] = xy[0];
menu->towards_xy[1] = xy[1];
- if (force)
+ if (force) {
menu->towardstime = DBL_MAX; /* unlimited time */
- else
+ }
+ else {
menu->towardstime = PIL_check_seconds_timer();
+ }
}
}
@@ -8528,8 +8508,9 @@ static bool ui_mouse_motion_towards_check(
return false;
}
- if (len_squared_v2v2(oldp, newp) < (4.0f * 4.0f))
+ if (len_squared_v2v2(oldp, newp) < (4.0f * 4.0f)) {
return menu->dotowards;
+ }
/* verify that we are moving towards one of the edges of the
* menu block, in other words, in the triangle formed by the
@@ -8566,12 +8547,14 @@ static bool ui_mouse_motion_towards_check(
isect_point_tri_v2(newp, oldp, p3, p4) ||
isect_point_tri_v2(newp, oldp, p4, p1));
- if (!closer)
+ if (!closer) {
menu->dotowards = false;
+ }
/* 1 second timer */
- if (PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH)
+ if (PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH) {
menu->dotowards = false;
+ }
return menu->dotowards;
}
@@ -8596,87 +8579,136 @@ static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEve
}
#endif /* USE_KEYNAV_LIMIT */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Menu Scroll
+ * \{ */
+
static char ui_menu_scroll_test(uiBlock *block, int my)
{
if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) {
- if (block->flag & UI_BLOCK_CLIPTOP)
- if (my > block->rect.ymax - UI_MENU_SCROLL_MOUSE)
+ if (block->flag & UI_BLOCK_CLIPTOP) {
+ if (my > block->rect.ymax - UI_MENU_SCROLL_MOUSE) {
return 't';
- if (block->flag & UI_BLOCK_CLIPBOTTOM)
- if (my < block->rect.ymin + UI_MENU_SCROLL_MOUSE)
+ }
+ }
+ if (block->flag & UI_BLOCK_CLIPBOTTOM) {
+ if (my < block->rect.ymin + UI_MENU_SCROLL_MOUSE) {
return 'b';
+ }
+ }
}
return 0;
}
-static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my, uiBut *to_bt)
+static void ui_menu_scroll_apply_offset_y(ARegion *ar, uiBlock *block, float dy)
{
- uiBut *bt;
- float dy = 0.0f;
-
- if (to_bt) {
- /* scroll to activated button */
- if (block->flag & UI_BLOCK_CLIPTOP) {
- if (to_bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW)
- dy = block->rect.ymax - to_bt->rect.ymax - UI_MENU_SCROLL_ARROW;
+ BLI_assert(dy != 0.0f);
+ if (dy < 0.0f) {
+ /* stop at top item, extra 0.5 unit Y makes it snap nicer */
+ float ymax = -FLT_MAX;
+ for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ ymax = max_ff(ymax, bt->rect.ymax);
}
- if (block->flag & UI_BLOCK_CLIPBOTTOM) {
- if (to_bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW)
- dy = block->rect.ymin - to_bt->rect.ymin + UI_MENU_SCROLL_ARROW;
+ if (ymax + dy - UI_UNIT_Y * 0.5f < block->rect.ymax - UI_MENU_SCROLL_PAD) {
+ dy = block->rect.ymax - ymax - UI_MENU_SCROLL_PAD;
}
}
else {
- /* scroll when mouse over arrow buttons */
- char test = ui_menu_scroll_test(block, my);
-
- if (test == 't')
- dy = -UI_UNIT_Y; /* scroll to the top */
- else if (test == 'b')
- dy = UI_UNIT_Y; /* scroll to the bottom */
+ /* stop at bottom item, extra 0.5 unit Y makes it snap nicer */
+ float ymin = FLT_MAX;
+ for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ ymin = min_ff(ymin, bt->rect.ymin);
+ }
+ if (ymin + dy + UI_UNIT_Y * 0.5f > block->rect.ymin + UI_MENU_SCROLL_PAD) {
+ dy = block->rect.ymin - ymin + UI_MENU_SCROLL_PAD;
+ }
}
- if (dy != 0.0f) {
- if (dy < 0.0f) {
- /* stop at top item, extra 0.5 unit Y makes it snap nicer */
- float ymax = -FLT_MAX;
+ /* remember scroll offset for refreshes */
+ block->handle->scrolloffset += dy;
- for (bt = block->buttons.first; bt; bt = bt->next)
- ymax = max_ff(ymax, bt->rect.ymax);
+ /* apply scroll offset */
+ for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
+ bt->rect.ymin += dy;
+ bt->rect.ymax += dy;
+ }
- if (ymax + dy - UI_UNIT_Y * 0.5f < block->rect.ymax - UI_MENU_SCROLL_PAD)
- dy = block->rect.ymax - ymax - UI_MENU_SCROLL_PAD;
- }
- else {
- /* stop at bottom item, extra 0.5 unit Y makes it snap nicer */
- float ymin = FLT_MAX;
+ /* set flags again */
+ ui_popup_block_scrolltest(block);
- for (bt = block->buttons.first; bt; bt = bt->next)
- ymin = min_ff(ymin, bt->rect.ymin);
+ ED_region_tag_redraw(ar);
+}
- if (ymin + dy + UI_UNIT_Y * 0.5f > block->rect.ymin + UI_MENU_SCROLL_PAD)
- dy = block->rect.ymin - ymin + UI_MENU_SCROLL_PAD;
+/** Scroll to activated button. */
+static bool ui_menu_scroll_to_but(ARegion *ar, uiBlock *block, uiBut *but_target)
+{
+ float dy = 0.0;
+ if (block->flag & UI_BLOCK_CLIPTOP) {
+ if (but_target->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW) {
+ dy = block->rect.ymax - but_target->rect.ymax - UI_MENU_SCROLL_ARROW;
}
-
- /* remember scroll offset for refreshes */
- block->handle->scrolloffset += dy;
-
- /* apply scroll offset */
- for (bt = block->buttons.first; bt; bt = bt->next) {
- bt->rect.ymin += dy;
- bt->rect.ymax += dy;
+ }
+ if (block->flag & UI_BLOCK_CLIPBOTTOM) {
+ if (but_target->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW) {
+ dy = block->rect.ymin - but_target->rect.ymin + UI_MENU_SCROLL_ARROW;
}
+ }
+ if (dy != 0.0f) {
+ ui_menu_scroll_apply_offset_y(ar, block, dy);
+ return true;
+ }
+ return false;
+}
- /* set flags again */
- ui_popup_block_scrolltest(block);
-
- ED_region_tag_redraw(ar);
+/** Scroll to y location (in block space, see #ui_window_to_block). */
+static bool ui_menu_scroll_to_y(ARegion *ar, uiBlock *block, int y)
+{
+ const char test = ui_menu_scroll_test(block, y);
+ float dy = 0.0f;
+ if (test == 't') {
+ dy = -UI_UNIT_Y; /* scroll to the top */
+ }
+ else if (test == 'b') {
+ dy = UI_UNIT_Y; /* scroll to the bottom */
+ }
+ if (dy != 0.0f) {
+ ui_menu_scroll_apply_offset_y(ar, block, dy);
+ return true;
+ }
+ return false;
+}
- return 1;
+static bool ui_menu_scroll_step(ARegion *ar, uiBlock *block, const int scroll_dir)
+{
+ int my;
+ if (scroll_dir == 1) {
+ if ((block->flag & UI_BLOCK_CLIPTOP) == 0) {
+ return false;
+ }
+ my = block->rect.ymax + UI_UNIT_Y;
+ }
+ else if (scroll_dir == -1) {
+ if ((block->flag & UI_BLOCK_CLIPBOTTOM) == 0) {
+ return false;
+ }
+ my = block->rect.ymin - UI_UNIT_Y;
+ }
+ else {
+ BLI_assert(0);
+ return false;
}
- return 0;
+ return ui_menu_scroll_to_y(ar, block, my);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Menu Event Handling
+ * \{ */
+
/**
* Special function to handle nested menus.
* let the parent menu get the event.
@@ -8704,7 +8736,7 @@ static bool ui_menu_pass_event_to_parent_if_nonactive(
static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu)
{
ARegion *ar = menu->region;
- uiBut *but = ui_but_find_active_in_region(ar);
+ uiBut *but = ui_region_find_active_but(ar);
int retval;
if (but) {
@@ -8720,7 +8752,7 @@ static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlock
/* pass, needed to click-exit outside of non-flaoting menus */
}
else if ((!ELEM(event->type, MOUSEMOVE, WHEELUPMOUSE, WHEELDOWNMOUSE, MOUSEPAN)) && ISMOUSE(event->type)) {
- if (!ui_but_contains_point_px(but->active->region, but, event->x, event->y)) {
+ if (!ui_but_contains_point_px(but, but->active->region, event->x, event->y)) {
but = NULL;
}
}
@@ -8730,13 +8762,21 @@ static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlock
ScrArea *ctx_area = CTX_wm_area(C);
ARegion *ctx_region = CTX_wm_region(C);
- if (menu->ctx_area) CTX_wm_area_set(C, menu->ctx_area);
- if (menu->ctx_region) CTX_wm_region_set(C, menu->ctx_region);
+ if (menu->ctx_area) {
+ CTX_wm_area_set(C, menu->ctx_area);
+ }
+ if (menu->ctx_region) {
+ CTX_wm_region_set(C, menu->ctx_region);
+ }
retval = ui_handle_button_event(C, event, but);
- if (menu->ctx_area) CTX_wm_area_set(C, ctx_area);
- if (menu->ctx_region) CTX_wm_region_set(C, ctx_region);
+ if (menu->ctx_area) {
+ CTX_wm_area_set(C, ctx_area);
+ }
+ if (menu->ctx_region) {
+ CTX_wm_region_set(C, ctx_region);
+ }
}
else {
retval = ui_handle_button_over(C, event, ar);
@@ -8762,10 +8802,12 @@ float ui_block_calc_pie_segment(uiBlock *block, const float event_xy[2])
len = normalize_v2_v2(block->pie_data.pie_dir, seg2);
- if (len < U.pie_menu_threshold * U.dpi_fac)
+ if (len < U.pie_menu_threshold * U.dpi_fac) {
block->pie_data.flags |= UI_PIE_INVALID_DIR;
- else
+ }
+ else {
block->pie_data.flags &= ~UI_PIE_INVALID_DIR;
+ }
return len;
}
@@ -8795,7 +8837,7 @@ static int ui_handle_menu_event(
inside_title = inside && ((my + (UI_UNIT_Y * 1.5f)) > block->rect.ymax);
/* if there's an active modal button, don't check events or outside, except for search menu */
- but = ui_but_find_active_in_region(ar);
+ but = ui_region_find_active_but(ar);
#ifdef USE_DRAG_POPUP
if (menu->is_grab) {
@@ -8829,8 +8871,9 @@ static int ui_handle_menu_event(
}
}
else if (event->type == TIMER) {
- if (event->customdata == menu->scrolltimer)
- ui_menu_scroll(ar, block, my, NULL);
+ if (event->customdata == menu->scrolltimer) {
+ ui_menu_scroll_to_y(ar, block, my);
+ }
}
else {
/* for ui_mouse_motion_towards_block */
@@ -8840,10 +8883,12 @@ static int ui_handle_menu_event(
}
/* add menu scroll timer, if needed */
- if (ui_menu_scroll_test(block, my))
- if (menu->scrolltimer == NULL)
+ if (ui_menu_scroll_test(block, my)) {
+ if (menu->scrolltimer == NULL) {
menu->scrolltimer =
WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, MENU_SCROLL_INTERVAL);
+ }
+ }
}
/* first block own event func */
@@ -8879,9 +8924,11 @@ static int ui_handle_menu_event(
/* Closing sub-levels of pull-downs. */
case LEFTARROWKEY:
- if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP))
- if (block->saferct.first)
+ if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
+ if (block->saferct.first) {
menu->menuretval = UI_RETURN_OUT;
+ }
+ }
retval = WM_UI_HANDLER_BREAK;
break;
@@ -8890,28 +8937,51 @@ static int ui_handle_menu_event(
case RIGHTARROWKEY:
if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
- if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval))
+ if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) {
break;
+ }
- but = ui_but_find_active_in_region(ar);
+ but = ui_region_find_active_but(ar);
if (!but) {
/* no item active, we make first active */
- if (block->direction & UI_DIR_UP) but = ui_but_last(block);
- else but = ui_but_first(block);
+ if (block->direction & UI_DIR_UP) {
+ but = ui_but_last(block);
+ }
+ else {
+ but = ui_but_first(block);
+ }
}
- if (but && ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN))
+ if (but && ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN)) {
ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN);
+ }
}
retval = WM_UI_HANDLER_BREAK;
break;
- case UPARROWKEY:
- case DOWNARROWKEY:
case WHEELUPMOUSE:
case WHEELDOWNMOUSE:
+ {
+ if (IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) {
+ /* pass */
+ }
+ else if (!ui_block_is_menu(block)) {
+ const int scroll_dir = (event->type == WHEELUPMOUSE) ? 1 : -1;
+ if (ui_menu_scroll_step(ar, block, scroll_dir)) {
+ if (but) {
+ but->active->cancel = true;
+ button_activate_exit(C, but, but->active, false, false);
+ }
+ WM_event_add_mousemove(C);
+ }
+ break;
+ }
+ ATTR_FALLTHROUGH;
+ }
+ case UPARROWKEY:
+ case DOWNARROWKEY:
case MOUSEPAN:
/* arrowkeys: only handle for block_loop blocks */
if (IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) {
@@ -8922,22 +8992,24 @@ static int ui_handle_menu_event(
int val = event->val;
/* convert pan to scrollwheel */
- if (type == MOUSEPAN)
+ if (type == MOUSEPAN) {
ui_pan_to_scroll(event, &type, &val);
+ }
if (val == KM_PRESS) {
const bool is_next =
(ELEM(type, DOWNARROWKEY, WHEELDOWNMOUSE) ==
((block->flag & UI_BLOCK_IS_FLIP) != 0));
- if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval))
+ if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) {
break;
+ }
#ifdef USE_KEYNAV_LIMIT
ui_mouse_motion_keynav_init(&menu->keynav_state, event);
#endif
- but = ui_but_find_active_in_region(ar);
+ but = ui_region_find_active_but(ar);
if (but) {
/* next button */
but = is_next ? ui_but_next(but) : ui_but_prev(but);
@@ -8954,7 +9026,7 @@ static int ui_handle_menu_event(
if (but) {
ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE);
- ui_menu_scroll(ar, block, my, but);
+ ui_menu_scroll_to_but(ar, block, but);
}
}
@@ -8964,40 +9036,71 @@ static int ui_handle_menu_event(
break;
case ONEKEY: case PAD1:
- act = 1; ATTR_FALLTHROUGH;
+ act = 1;
+ ATTR_FALLTHROUGH;
case TWOKEY: case PAD2:
- if (act == 0) act = 2; ATTR_FALLTHROUGH;
+ if (act == 0) {
+ act = 2;
+ }
+ ATTR_FALLTHROUGH;
case THREEKEY: case PAD3:
- if (act == 0) act = 3; ATTR_FALLTHROUGH;
+ if (act == 0) {
+ act = 3;
+ }
+ ATTR_FALLTHROUGH;
case FOURKEY: case PAD4:
- if (act == 0) act = 4; ATTR_FALLTHROUGH;
+ if (act == 0) {
+ act = 4;
+ }
+ ATTR_FALLTHROUGH;
case FIVEKEY: case PAD5:
- if (act == 0) act = 5; ATTR_FALLTHROUGH;
+ if (act == 0) {
+ act = 5;
+ }
+ ATTR_FALLTHROUGH;
case SIXKEY: case PAD6:
- if (act == 0) act = 6; ATTR_FALLTHROUGH;
+ if (act == 0) {
+ act = 6;
+ }
+ ATTR_FALLTHROUGH;
case SEVENKEY: case PAD7:
- if (act == 0) act = 7; ATTR_FALLTHROUGH;
+ if (act == 0) {
+ act = 7;
+ }
+ ATTR_FALLTHROUGH;
case EIGHTKEY: case PAD8:
- if (act == 0) act = 8; ATTR_FALLTHROUGH;
+ if (act == 0) {
+ act = 8;
+ }
+ ATTR_FALLTHROUGH;
case NINEKEY: case PAD9:
- if (act == 0) act = 9; ATTR_FALLTHROUGH;
+ if (act == 0) {
+ act = 9;
+ }
+ ATTR_FALLTHROUGH;
case ZEROKEY: case PAD0:
- if (act == 0) act = 10;
+ if (act == 0) {
+ act = 10;
+ }
if ((block->flag & UI_BLOCK_NUMSELECT) && event->val == KM_PRESS) {
int count;
- if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval))
+ if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) {
break;
+ }
- if (event->alt) act += 10;
+ if (event->alt) {
+ act += 10;
+ }
count = 0;
for (but = block->buttons.first; but; but = but->next) {
bool doit = false;
- if (!ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE))
+ if (!ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) {
count++;
+ }
/* exception for rna layer buts */
if (but->rnapoin.data && but->rnaprop &&
@@ -9067,27 +9170,18 @@ static int ui_handle_menu_event(
if ((event->val == KM_PRESS || event->val == KM_DBL_CLICK) &&
!IS_EVENT_MOD(event, shift, ctrl, oskey))
{
- if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval))
+ if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) {
break;
+ }
for (but = block->buttons.first; but; but = but->next) {
if (!(but->flag & UI_BUT_DISABLED) && but->menu_key == event->type) {
- if (ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_BUT_MENU)) {
- /* mainly for operator buttons */
- ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY);
- }
- else if (ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN)) {
- /* open sub-menus (like right arrow key) */
- ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN);
- }
- else if (but->type == UI_BTYPE_MENU) {
- /* activate menu items */
- ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE);
+ if (but->type == UI_BTYPE_BUT) {
+ UI_but_execute(C, but);
}
else {
- printf("%s: error, but->menu_key type: %u\n", __func__, but->type);
+ ui_handle_button_activate_by_type(C, ar, but);
}
-
break;
}
}
@@ -9117,16 +9211,20 @@ static int ui_handle_menu_event(
if (ELEM(event->val, KM_PRESS, KM_DBL_CLICK)) {
if ((is_parent_menu == false) && (U.uiflag & USER_MENUOPENAUTO) == 0) {
/* for root menus, allow clicking to close */
- if (block->flag & (UI_BLOCK_OUT_1))
+ if (block->flag & (UI_BLOCK_OUT_1)) {
menu->menuretval = UI_RETURN_OK;
- else
+ }
+ else {
menu->menuretval = UI_RETURN_OUT;
+ }
}
else if (saferct && !BLI_rctf_isect_pt(&saferct->parent, event->x, event->y)) {
- if (block->flag & (UI_BLOCK_OUT_1))
+ if (block->flag & (UI_BLOCK_OUT_1)) {
menu->menuretval = UI_RETURN_OK;
- else
+ }
+ else {
menu->menuretval = UI_RETURN_OUT;
+ }
}
}
else if (ELEM(event->val, KM_RELEASE, KM_CLICK)) {
@@ -9155,16 +9253,30 @@ static int ui_handle_menu_event(
menu->menuretval = UI_RETURN_CANCEL;
}
else if (ELEM(event->type, RETKEY, PADENTER) && event->val == KM_PRESS) {
- /* enter will always close this block, we let the event
- * get handled by the button if it is activated, otherwise we cancel */
- if (!ui_but_find_active_in_region(ar))
- menu->menuretval = UI_RETURN_CANCEL | UI_RETURN_POPUP_OK;
+ uiBut *but_default = ui_region_find_first_but_test_flag(ar, UI_BUT_ACTIVE_DEFAULT, UI_HIDDEN);
+ if ((but_default != NULL) && (but_default->active == NULL)) {
+ if (but_default->type == UI_BTYPE_BUT) {
+ UI_but_execute(C, but_default);
+ }
+ else {
+ ui_handle_button_activate_by_type(C, ar, but_default);
+ }
+ }
+ else {
+ uiBut *but_active = ui_region_find_active_but(ar);
+
+ /* enter will always close this block, we let the event
+ * get handled by the button if it is activated, otherwise we cancel */
+ if (but_active == NULL) {
+ menu->menuretval = UI_RETURN_CANCEL | UI_RETURN_POPUP_OK;
+ }
+ }
}
#ifdef USE_DRAG_POPUP
else if ((event->type == LEFTMOUSE) && (event->val == KM_PRESS) &&
(inside && is_floating && inside_title))
{
- if (!but || !ui_but_contains_point_px(ar, but, event->x, event->y)) {
+ if (!but || !ui_but_contains_point_px(but, ar, event->x, event->y)) {
if (but) {
UI_but_tooltip_timer_remove(C, but);
}
@@ -9189,22 +9301,27 @@ static int ui_handle_menu_event(
* events we check all preceding block rects too to make
* arrow keys navigation work */
if (event->type != MOUSEMOVE || saferct == block->saferct.first) {
- if (BLI_rctf_isect_pt(&saferct->parent, (float)event->x, (float)event->y))
+ if (BLI_rctf_isect_pt(&saferct->parent, (float)event->x, (float)event->y)) {
break;
- if (BLI_rctf_isect_pt(&saferct->safety, (float)event->x, (float)event->y))
+ }
+ if (BLI_rctf_isect_pt(&saferct->safety, (float)event->x, (float)event->y)) {
break;
+ }
}
}
/* strict check, and include the parent rect */
if (!menu->dotowards && !saferct) {
- if (block->flag & (UI_BLOCK_OUT_1))
+ if (block->flag & (UI_BLOCK_OUT_1)) {
menu->menuretval = UI_RETURN_OK;
- else
+ }
+ else {
menu->menuretval = UI_RETURN_OUT;
+ }
}
- else if (menu->dotowards && event->type == MOUSEMOVE)
+ else if (menu->dotowards && event->type == MOUSEMOVE) {
retval = WM_UI_HANDLER_BREAK;
+ }
}
}
@@ -9239,12 +9356,15 @@ static int ui_handle_menu_event(
/* if we set a menu return value, ensure we continue passing this on to
* lower menus and buttons, so always set continue then, and if we are
* inside the region otherwise, ensure we swallow the event */
- if (menu->menuretval)
+ if (menu->menuretval) {
return WM_UI_HANDLER_CONTINUE;
- else if (inside)
+ }
+ else if (inside) {
return WM_UI_HANDLER_BREAK;
- else
+ }
+ else {
return retval;
+ }
}
static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu)
@@ -9258,7 +9378,7 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo
ar = menu->region;
block = ar->uiblocks.first;
- but = ui_but_find_active_in_region(ar);
+ but = ui_region_find_active_but(ar);
BLI_assert(but);
@@ -9283,8 +9403,9 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo
* will actually close the submenu too */
ui_handle_button_return_submenu(C, event, but);
- if (update)
+ if (update) {
submenu->menuretval = 0;
+ }
}
if (block->flag & (UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_POPOVER)) {
@@ -9314,7 +9435,7 @@ static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *b
if (but->type == UI_BTYPE_MENU) {
/* forcing the pie menu to close will not handle menus */
if (!force_close) {
- uiBut *active_but = ui_but_find_active_in_region(menu->region);
+ uiBut *active_but = ui_region_find_active_but(menu->region);
if (active_but) {
button_activate_exit(C, active_but, active_but->active, false, false);
@@ -9362,13 +9483,15 @@ static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandl
{
uiBut *active_but;
- if (but == NULL)
+ if (but == NULL) {
return WM_UI_HANDLER_BREAK;
+ }
- active_but = ui_but_find_active_in_region(menu->region);
+ active_but = ui_region_find_active_but(menu->region);
- if (active_but)
+ if (active_but) {
button_activate_exit(C, active_but, active_but->active, false, false);
+ }
button_activate_init(C, menu->region, but, BUTTON_ACTIVATE_OVER);
return ui_but_pie_menu_apply(C, menu, but, false);
@@ -9400,7 +9523,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
is_click_style = (block->pie_data.flags & UI_PIE_CLICK_STYLE);
/* if there's an active modal button, don't check events or outside, except for search menu */
- but = ui_but_find_active_in_region(ar);
+ but = ui_region_find_active_but(ar);
if (menu->scrolltimer == NULL) {
menu->scrolltimer =
@@ -9479,7 +9602,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
}
if (len_sq < 1.0f) {
- but = ui_but_find_active_in_region(menu->region);
+ but = ui_region_find_active_but(menu->region);
if (but) {
return ui_but_pie_menu_apply(C, menu, but, true);
@@ -9506,13 +9629,14 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
block->pie_data.flags |= UI_PIE_CLICK_STYLE;
}
else {
- but = ui_but_find_active_in_region(menu->region);
+ but = ui_region_find_active_but(menu->region);
if (but && (U.pie_menu_confirm > 0) &&
(dist >= U.dpi_fac * (U.pie_menu_threshold + U.pie_menu_confirm)))
{
- if (but)
+ if (but) {
return ui_but_pie_menu_apply(C, menu, but, true);
+ }
}
retval = ui_but_pie_menu_apply(C, menu, but, true);
@@ -9645,7 +9769,7 @@ static int ui_handle_menus_recursive(
bool do_towards_reinit = false;
/* check if we have a submenu, and handle events for it first */
- but = ui_but_find_active_in_region(menu->region);
+ but = ui_region_find_active_but(menu->region);
data = (but) ? but->active : NULL;
submenu = (data) ? data->menu : NULL;
@@ -9695,7 +9819,7 @@ static int ui_handle_menus_recursive(
if (block->flag & (UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_POPOVER)) {
/* when there is a active search button and we close it,
* we need to reinit the mouse coords [#35346] */
- if (ui_but_find_active_in_region(menu->region) != but) {
+ if (ui_region_find_active_but(menu->region) != but) {
do_towards_reinit = true;
}
}
@@ -9745,7 +9869,11 @@ void UI_popup_menu_retval_set(const uiBlock *block, const int retval, const bool
}
}
-/* *************** UI event handlers **************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name UI Event Handlers
+ * \{ */
static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(userdata))
{
@@ -9762,7 +9890,7 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use
}
/* either handle events for already activated button or try to activate */
- but = ui_but_find_active_in_region(ar);
+ but = ui_region_find_active_but(ar);
listbox = ui_list_find_mouse_over(ar, event);
retval = ui_handler_panel_region(C, event, ar, listbox ? listbox : but);
@@ -9779,15 +9907,18 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use
}
if (retval == WM_UI_HANDLER_CONTINUE) {
- if (but)
+ if (but) {
retval = ui_handle_button_event(C, event, but);
- else
+ }
+ else {
retval = ui_handle_button_over(C, event, ar);
+ }
}
/* re-enable tooltips */
- if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy))
+ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) {
ui_blocks_set_tooltips(ar, true);
+ }
/* delayed apply callbacks */
ui_apply_but_funcs_after(C);
@@ -9801,18 +9932,23 @@ static void ui_region_handler_remove(bContext *C, void *UNUSED(userdata))
ARegion *ar;
ar = CTX_wm_region(C);
- if (ar == NULL) return;
+ if (ar == NULL) {
+ return;
+ }
UI_blocklist_free(C, &ar->uiblocks);
sc = CTX_wm_screen(C);
- if (sc == NULL) return;
+ if (sc == NULL) {
+ return;
+ }
/* delayed apply callbacks, but not for screen level regions, those
* we rather do at the very end after closing them all, which will
* be done in ui_region_handler/window */
- if (BLI_findindex(&sc->regionbase, ar) == -1)
+ if (BLI_findindex(&sc->regionbase, ar) == -1) {
ui_apply_but_funcs_after(C);
+ }
}
/* handle buttons at the window level, modal, for example while
@@ -9824,10 +9960,11 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE
int retval = WM_UI_HANDLER_CONTINUE;
ar = CTX_wm_menu(C);
- if (!ar)
+ if (!ar) {
ar = CTX_wm_region(C);
+ }
- but = ui_but_find_active_in_region(ar);
+ but = ui_region_find_active_but(ar);
if (but) {
bScreen *screen = CTX_wm_screen(C);
@@ -9896,8 +10033,9 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE
}
/* re-enable tooltips */
- if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy))
+ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) {
ui_blocks_set_tooltips(ar, true);
+ }
/* delayed apply callbacks */
ui_apply_but_funcs_after(C);
@@ -9968,20 +10106,24 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
#endif
if ((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) {
- if (temp.popup_func)
+ if (temp.popup_func) {
temp.popup_func(C, temp.popup_arg, temp.retvalue);
- if (temp.optype)
+ }
+ if (temp.optype) {
WM_operator_name_call_ptr(C, temp.optype, temp.opcontext, NULL);
+ }
}
- else if (temp.cancel_func)
+ else if (temp.cancel_func) {
temp.cancel_func(C, temp.popup_arg);
+ }
WM_event_add_mousemove(C);
}
else {
/* re-enable tooltips */
- if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy))
+ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) {
ui_blocks_set_tooltips(menu->region, true);
+ }
}
/* delayed apply callbacks */
@@ -9991,8 +10133,9 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
/* reaqcuire window in case pie invalidates it somehow */
wmWindow *win = CTX_wm_window(C);
- if (win)
+ if (win) {
win->last_pie_event = EVENT_NONE;
+ }
}
CTX_wm_region_set(C, menu_region);
@@ -10080,8 +10223,9 @@ bool UI_textbutton_activate_rna(
}
}
}
- if (but)
+ if (but) {
break;
+ }
}
if (but) {
@@ -10100,12 +10244,15 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut)
uiBut *but = NULL;
for (block = ar->uiblocks.first; block; block = block->next) {
- for (but = block->buttons.first; but; but = but->next)
- if (but == actbut && but->type == UI_BTYPE_TEXT)
+ for (but = block->buttons.first; but; but = but->next) {
+ if (but == actbut && but->type == UI_BTYPE_TEXT) {
break;
+ }
+ }
- if (but)
+ if (but) {
break;
+ }
}
if (but) {
@@ -10117,8 +10264,63 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut)
}
}
+/** \} */
-void ui_but_clipboard_free(void)
+/* -------------------------------------------------------------------- */
+/** \name Public Utilities
+ * \{ */
+
+/* is called by notifier */
+void UI_screen_free_active_but(const bContext *C, bScreen *screen)
{
- curvemapping_free_data(&but_copypaste_curve);
+ wmWindow *win = CTX_wm_window(C);
+
+ ED_screen_areas_iter(win, screen, area) {
+ for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ uiBut *but = ui_region_find_active_but(region);
+ if (but) {
+ uiHandleButtonData *data = but->active;
+
+ if (data->menu == NULL && data->searchbox == NULL) {
+ if (data->state == BUTTON_STATE_HIGHLIGHT) {
+ ui_but_active_free(C, but);
+ }
+ }
+ }
+ }
+ }
+}
+
+
+/* returns true if highlighted button allows drop of names */
+/* called in region context */
+bool UI_but_active_drop_name(bContext *C)
+{
+ ARegion *ar = CTX_wm_region(C);
+ uiBut *but = ui_region_find_active_but(ar);
+
+ if (but) {
+ if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
+ return 1;
+ }
+ }
+
+ return 0;
}
+
+bool UI_but_active_drop_color(bContext *C)
+{
+ ARegion *ar = CTX_wm_region(C);
+
+ if (ar) {
+ uiBut *but = ui_region_find_active_but(ar);
+
+ if (but && but->type == UI_BTYPE_COLOR) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/** \} */
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index ae9ee152d0f..dcfeaf64699 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -92,7 +92,7 @@ typedef struct IconImage {
int w;
int h;
uint *rect;
- uchar *datatoc_rect;
+ const uchar *datatoc_rect;
int datatoc_size;
} IconImage;
@@ -206,8 +206,9 @@ static DrawInfo *def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs,
iimg->rect = MEM_mallocN(size * size * sizeof(uint), "icon_rect");
/* Here we store the rect in the icon - same as before */
- if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0)
+ if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) {
memcpy(iimg->rect, bbuf->rect, size * size * sizeof(int));
+ }
else {
/* this code assumes square images */
imgsize = bbuf->x;
@@ -475,7 +476,7 @@ static void init_brush_icons(void)
di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_BUFFER, 0); \
di->data.buffer.image->datatoc_rect = rect; \
di->data.buffer.image->datatoc_size = size; \
- }
+ } ((void)0)
/* end INIT_BRUSH_ICON */
const int w = 96; /* warning, brush size hardcoded in C, but it gets scaled */
@@ -613,7 +614,7 @@ static void init_event_icons(void)
di->data.input.icon = icon_id; \
di->data.input.next = di_next; \
di_next = di; \
- }
+ } ((void)0)
/* end INIT_EVENT_ICON */
const int w = 16; /* DUMMY */
@@ -674,15 +675,17 @@ static void init_event_icons(void)
static void icon_verify_datatoc(IconImage *iimg)
{
/* if it has own rect, things are all OK */
- if (iimg->rect)
+ if (iimg->rect) {
return;
+ }
if (iimg->datatoc_rect) {
ImBuf *bbuf = IMB_ibImageFromMemory(iimg->datatoc_rect,
iimg->datatoc_size, IB_rect, NULL, "<matcap icon>");
/* w and h were set on initialize */
- if (bbuf->x != iimg->h && bbuf->y != iimg->w)
+ if (bbuf->x != iimg->h && bbuf->y != iimg->w) {
IMB_scaleImBuf(bbuf, iimg->w, iimg->h);
+ }
iimg->rect = bbuf->rect;
bbuf->rect = NULL;
@@ -718,17 +721,21 @@ static void init_internal_icons(void)
}
}
#endif
- if (b16buf == NULL)
- b16buf = IMB_ibImageFromMemory((uchar *)datatoc_blender_icons16_png,
+ if (b16buf == NULL) {
+ b16buf = IMB_ibImageFromMemory((const uchar *)datatoc_blender_icons16_png,
datatoc_blender_icons16_png_size, IB_rect, NULL, "<blender icons>");
- if (b16buf)
+ }
+ if (b16buf) {
IMB_premultiply_alpha(b16buf);
+ }
- if (b32buf == NULL)
- b32buf = IMB_ibImageFromMemory((uchar *)datatoc_blender_icons32_png,
+ if (b32buf == NULL) {
+ b32buf = IMB_ibImageFromMemory((const uchar *)datatoc_blender_icons32_png,
datatoc_blender_icons32_png_size, IB_rect, NULL, "<blender icons>");
- if (b32buf)
+ }
+ if (b32buf) {
IMB_premultiply_alpha(b32buf);
+ }
if (b16buf && b32buf) {
/* Free existing texture if any. */
@@ -835,8 +842,9 @@ static void init_iconfile_list(struct ListBase *list)
BLI_listbase_clear(list);
icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
- if (icondir == NULL)
+ if (icondir == NULL) {
return;
+ }
totfile = BLI_filelist_dir_contents(icondir, &dir);
@@ -944,8 +952,9 @@ void UI_icons_free_drawinfo(void *drawinfo)
if (di) {
if (di->type == ICON_TYPE_BUFFER) {
if (di->data.buffer.image) {
- if (di->data.buffer.image->rect)
+ if (di->data.buffer.image->rect) {
MEM_freeN(di->data.buffer.image->rect);
+ }
MEM_freeN(di->data.buffer.image);
}
}
@@ -1008,8 +1017,9 @@ int UI_icon_get_width(int icon_id)
icon = BKE_icon_get(icon_id);
if (icon == NULL) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
+ }
return 0;
}
@@ -1025,8 +1035,9 @@ int UI_icon_get_height(int icon_id)
{
Icon *icon = BKE_icon_get(icon_id);
if (icon == NULL) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
+ }
return 0;
}
@@ -1069,8 +1080,9 @@ static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
uint render_size = UI_preview_render_size(size);
if (!prv_img) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s, error: requested preview image does not exist", __func__);
+ }
}
else if (!prv_img->rect[size]) {
prv_img->w[size] = render_size;
@@ -1105,8 +1117,9 @@ static void ui_studiolight_free_function(StudioLight *sl, void *data)
wmWindowManager *wm = data;
/* Happens if job was canceled or already finished. */
- if (wm == NULL)
+ if (wm == NULL) {
return;
+ }
// get icons_id, get icons and kill wm jobs
if (sl->icon_id_radiance) {
@@ -1195,8 +1208,9 @@ static void icon_set_image(
const bContext *C, Scene *scene, ID *id, PreviewImage *prv_img, enum eIconSizes size, const bool use_job)
{
if (!prv_img) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: no preview image for this ID: %s\n", __func__, id->name);
+ }
return;
}
@@ -1321,8 +1335,9 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
immDrawPixelsTex(&state, draw_x, draw_y, draw_w, draw_h, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect,
1.0f, 1.0f, col);
- if (ima)
+ if (ima) {
IMB_freeImBuf(ima);
+ }
}
/* High enough to make a difference, low enough so that
@@ -1353,8 +1368,9 @@ void UI_icon_draw_cache_begin(void)
static void icon_draw_cache_flush_ex(void)
{
- if (g_icon_draw_cache.calls == 0)
+ if (g_icon_draw_cache.calls == 0) {
return;
+ }
/* We need to flush widget base first to ensure correct ordering. */
UI_widgetbase_draw_cache_flush();
@@ -1388,8 +1404,9 @@ void UI_icon_draw_cache_end(void)
g_icon_draw_cache.enabled = false;
/* Don't change blend state if it's not needed. */
- if (g_icon_draw_cache.calls == 0)
+ if (g_icon_draw_cache.calls == 0) {
return;
+ }
GPU_blend(true);
icon_draw_cache_flush_ex();
@@ -1418,8 +1435,12 @@ static void icon_draw_texture_cached(
call->tex.ymin = iy * icongltex.invh;
call->tex.ymax = (iy + ih) * icongltex.invh;
- if (rgb) copy_v4_fl4(call->color, rgb[0], rgb[1], rgb[2], alpha);
- else copy_v4_fl(call->color, alpha);
+ if (rgb) {
+ copy_v4_fl4(call->color, rgb[0], rgb[1], rgb[2], alpha);
+ }
+ else {
+ copy_v4_fl(call->color, alpha);
+ }
if (g_icon_draw_cache.calls == ICON_DRAW_CACHE_SIZE) {
icon_draw_cache_flush_ex();
@@ -1453,8 +1474,12 @@ static void icon_draw_texture(
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
GPU_shader_bind(shader);
- if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha);
- else glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
+ if (rgb) {
+ glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha);
+ }
+ else {
+ glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
+ }
glUniform1i(GPU_shader_get_uniform_ensure(shader, "image"), 0);
glUniform4f(GPU_shader_get_uniform_ensure(shader, "rect_icon"), x1, y1, x2, y2);
@@ -1496,8 +1521,9 @@ static void icon_draw_size(
alpha *= btheme->tui.icon_alpha;
if (icon == NULL) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
+ }
return;
}
@@ -1583,7 +1609,10 @@ static void icon_draw_size(
#ifndef WITH_HEADLESS
icon_verify_datatoc(iimg);
#endif
- if (!iimg->rect) return; /* something has gone wrong! */
+ if (!iimg->rect) {
+ /* something has gone wrong! */
+ return;
+ }
icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, desaturate);
}
@@ -1592,7 +1621,10 @@ static void icon_draw_size(
if (pi) {
/* no create icon on this level in code */
- if (!pi->rect[size]) return; /* something has gone wrong! */
+ if (!pi->rect[size]) {
+ /* Something has gone wrong! */
+ return;
+ }
/* Preview images use premultiplied alpha. */
GPU_blend_set_func_separate(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
@@ -1643,8 +1675,9 @@ static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
PreviewImage *pi = BKE_previewimg_id_ensure(id);
enum eIconSizes i;
- if (!pi)
+ if (!pi) {
return;
+ }
for (i = 0; i < NUM_ICON_SIZES; i++) {
/* check if rect needs to be created; changed
@@ -1809,8 +1842,9 @@ int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big
{
ID *id = NULL;
- if (!ptr->data)
+ if (!ptr->data) {
return rnaicon;
+ }
/* try ID, material, texture or dynapaint slot */
if (RNA_struct_is_ID(ptr->type)) {
@@ -1825,12 +1859,15 @@ int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big
else if (RNA_struct_is_a(ptr->type, &RNA_DynamicPaintSurface)) {
DynamicPaintSurface *surface = ptr->data;
- if (surface->format == MOD_DPAINT_SURFACE_F_PTEX)
+ if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) {
return ICON_SHADING_TEXTURE;
- else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX)
+ }
+ else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
return ICON_OUTLINER_DATA_MESH;
- else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ)
+ }
+ else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
return ICON_FILE_IMAGE;
+ }
}
else if (RNA_struct_is_a(ptr->type, &RNA_StudioLight)) {
StudioLight *sl = ptr->data;
diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c
index e77b47d19e5..2af9bbf9e88 100644
--- a/source/blender/editors/interface/interface_icons_event.c
+++ b/source/blender/editors/interface/interface_icons_event.c
@@ -126,8 +126,8 @@ static void icon_draw_rect_input_line_prim(
const int prim,
const char lines[][2], int lines_len)
{
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
+ GPU_line_smooth(true);
+ GPU_blend(true);
BLI_assert(ELEM(prim, GPU_PRIM_LINE_LOOP, GPU_PRIM_LINE_STRIP));
const uint pos_id = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -144,8 +144,8 @@ static void icon_draw_rect_input_line_prim(
}
immEnd();
immUnbindProgram();
- glDisable(GL_LINE_SMOOTH);
- glDisable(GL_BLEND);
+ GPU_line_smooth(false);
+ GPU_blend(false);
}
void icon_draw_rect_input(
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 82d6115fbbb..3580b2ff3a5 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -50,52 +50,7 @@ struct wmTimer;
#define RNA_NO_INDEX -1
#define RNA_ENUM_VALUE -2
-/* visual types for drawing */
-/* for time being separated from functional types */
-typedef enum {
- /* default */
- UI_WTYPE_REGULAR,
-
- /* standard set */
- UI_WTYPE_LABEL,
- UI_WTYPE_TOGGLE,
- UI_WTYPE_CHECKBOX,
- UI_WTYPE_RADIO,
- UI_WTYPE_NUMBER,
- UI_WTYPE_SLIDER,
- UI_WTYPE_EXEC,
- UI_WTYPE_TOOLBAR_ITEM,
- UI_WTYPE_TAB,
- UI_WTYPE_TOOLTIP,
-
- /* strings */
- UI_WTYPE_NAME,
- UI_WTYPE_NAME_LINK,
- UI_WTYPE_POINTER_LINK,
- UI_WTYPE_FILENAME,
-
- /* menus */
- UI_WTYPE_MENU_RADIO,
- UI_WTYPE_MENU_ICON_RADIO,
- UI_WTYPE_MENU_POINTER_LINK,
- UI_WTYPE_MENU_NODE_LINK,
-
- UI_WTYPE_PULLDOWN,
- UI_WTYPE_MENU_ITEM,
- UI_WTYPE_MENU_ITEM_RADIAL,
- UI_WTYPE_MENU_BACK,
-
- /* specials */
- UI_WTYPE_ICON,
- UI_WTYPE_ICON_LABEL,
- UI_WTYPE_SWATCH,
- UI_WTYPE_RGB_PICKER,
- UI_WTYPE_UNITVEC,
- UI_WTYPE_BOX,
- UI_WTYPE_SCROLL,
- UI_WTYPE_LISTITEM,
- UI_WTYPE_PROGRESSBAR,
-} uiWidgetTypeEnum;
+#define UI_MENU_PADDING (int)(0.2f * UI_UNIT_Y)
#define UI_MENU_WIDTH_MIN (UI_UNIT_Y * 9)
/* some extra padding added to menus containing submenu icons */
@@ -160,9 +115,11 @@ extern const short ui_radial_dir_to_angle[8];
/* bit button defines */
/* Bit operations */
-#define UI_BITBUT_TEST(a, b) ( ( (a) & 1 << (b) ) != 0)
-#define UI_BITBUT_SET(a, b) ( (a) | 1 << (b) )
-#define UI_BITBUT_CLR(a, b) ( (a) & ~(1 << (b)) )
+#define UI_BITBUT_TEST(a, b) (((a) & (1 << (b))) != 0)
+#define UI_BITBUT_VALUE_TOGGLED(a, b) ((a) ^ (1 << (b)))
+#define UI_BITBUT_VALUE_ENABLED(a, b) ((a) | (1 << (b)))
+#define UI_BITBUT_VALUE_DISABLED(a, b) ((a) & ~(1 << (b)))
+
/* bit-row */
#define UI_BITBUT_ROW(min, max) (((max) >= 31 ? 0xFFFFFFFF : (1 << ((max) + 1)) - 1) - ((min) ? ((1 << (min)) - 1) : 0) )
@@ -339,6 +296,11 @@ typedef struct ColorPicker {
/** Initial color data (detect changes). */
float color_data_init[3];
bool is_init;
+ /** Cubic saturation for the color wheel. */
+ bool use_color_cubic;
+ bool use_color_lock;
+ bool use_luminosity_lock;
+ float luminosity_lock_value;
} ColorPicker;
typedef struct ColorPickerData {
@@ -440,7 +402,8 @@ struct uiBlock {
/** for doing delayed */
eBlockBoundsCalc bounds_type;
- int mx, my;
+ /** Offset to use when calculating bounds (in pixels). */
+ int bounds_offset[2];
/** for doing delayed */
int bounds, minbounds;
@@ -501,10 +464,10 @@ extern void ui_but_v3_get(uiBut *but, float vec[3]);
extern void ui_but_v3_set(uiBut *but, const float vec[3]);
extern void ui_hsvcircle_vals_from_pos(
- float *val_rad, float *val_dist, const rcti *rect,
- const float mx, const float my);
-extern void ui_hsvcircle_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xpos, float *ypos);
-extern void ui_hsvcube_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp);
+ const rcti *rect, const float mx, const float my,
+ float *r_val_rad, float *r_val_dist);
+extern void ui_hsvcircle_pos_from_vals(const ColorPicker *cpicker, const rcti *rect, const float *hsv, float *xpos, float *ypos);
+extern void ui_hsvcube_pos_from_vals(const struct uiBut *but, const rcti *rect, const float *hsv, float *xp, float *yp);
extern void ui_but_string_get_ex(
uiBut *but, char *str, const size_t maxlen,
@@ -522,7 +485,10 @@ extern uiButExtraIconType ui_but_icon_extra_get(uiBut *but);
extern void ui_but_default_set(struct bContext *C, const bool all, const bool use_afterfunc);
-extern void ui_but_update_ex(uiBut *but, const bool validate);
+extern void ui_but_rna_menu_convert_to_panel_type(struct uiBut *but, const char *panel_type);
+extern void ui_but_rna_menu_convert_to_menu_type(struct uiBut *but, const char *menu_type);
+extern bool ui_but_menu_draw_as_popover(const uiBut *but);
+
extern void ui_but_update(uiBut *but);
extern void ui_but_update_edited(uiBut *but);
extern bool ui_but_is_float(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
@@ -530,7 +496,6 @@ extern bool ui_but_is_bool(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
extern bool ui_but_is_unit(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
extern bool ui_but_is_compatible(const uiBut *but_a, const uiBut *but_b) ATTR_WARN_UNUSED_RESULT;
extern bool ui_but_is_rna_valid(uiBut *but) ATTR_WARN_UNUSED_RESULT;
-extern bool ui_but_is_utf8(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
extern bool ui_but_supports_cycling(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
extern int ui_but_is_pushed_ex(uiBut *but, double *value) ATTR_WARN_UNUSED_RESULT;
@@ -613,7 +578,7 @@ struct uiPopupBlockHandle {
rctf prev_block_rect;
rctf prev_butrct;
short prev_dir1, prev_dir2;
- int prev_mx, prev_my;
+ int prev_bounds_offset[2];
/* Maximum estimated size to avoid having to reposition on refresh. */
float max_size_x, max_size_y;
@@ -726,13 +691,10 @@ extern void ui_but_activate_over(struct bContext *C, struct ARegion *ar, uiBut *
extern void ui_but_execute_begin(struct bContext *C, struct ARegion *ar, uiBut *but, void **active_back);
extern void ui_but_execute_end(struct bContext *C, struct ARegion *ar, uiBut *but, void *active_back);
extern void ui_but_active_free(const struct bContext *C, uiBut *but);
-extern bool ui_but_is_active(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT;
extern int ui_but_menu_direction(uiBut *but);
extern void ui_but_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, const bool restore);
extern uiBut *ui_but_find_select_in_enum(uiBut *but, int direction);
-extern uiBut *ui_but_find_active_in_region(struct ARegion *ar);
-extern uiBut *ui_but_find_mouse_over(struct ARegion *ar, const struct wmEvent *event);
-void ui_but_pie_dir(RadialDirection dir, float vec[2]);
+bool ui_but_is_editing(const uiBut *but);
float ui_block_calc_pie_segment(struct uiBlock *block, const float event_xy[2]);
void ui_but_add_shortcut(uiBut *but, const char *key_str, const bool do_strip);
@@ -787,11 +749,8 @@ void ui_draw_popover_back(ARegion *ar, struct uiStyle *style, uiBlock *block, rc
void ui_draw_pie_center(uiBlock *block);
const struct uiWidgetColors *ui_tooltip_get_theme(void);
-void ui_draw_widget_back_color(
- uiWidgetTypeEnum type, bool use_shadow, const rcti *rect,
- const float color[4]);
-void ui_draw_widget_back(
- uiWidgetTypeEnum type, bool use_shadow, const rcti *rect);
+void ui_draw_widget_menu_back_color(const rcti *rect, bool use_shadow, const float color[4]);
+void ui_draw_widget_menu_back(const rcti *rect, bool use_shadow);
void ui_draw_tooltip_background(struct uiStyle *UNUSED(style), uiBlock *block, rcti *rect);
extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
@@ -829,6 +788,7 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but);
void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop);
void ui_layout_list_set_labels_active(uiLayout *layout);
/* menu callback */
+void ui_item_menutype_func(struct bContext *C, struct uiLayout *layout, void *arg_mt);
void ui_item_paneltype_func(struct bContext *C, struct uiLayout *layout, void *arg_pt);
/* interface_align.c */
@@ -849,15 +809,47 @@ void ui_but_anim_decorate_cb(struct bContext *C, void *arg_but, void *arg_dummy)
void ui_but_anim_decorate_update_from_flag(uiBut *but);
/* interface_query.c */
-bool ui_but_is_editable(const uiBut *but);
-bool ui_but_is_editable_as_text(const uiBut *but);
-bool ui_but_is_toggle(const uiBut *but);
-bool ui_but_is_popover_once_compat(const uiBut *but);
+bool ui_but_is_editable(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
+bool ui_but_is_editable_as_text(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
+bool ui_but_is_toggle(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
+bool ui_but_is_interactive(const uiBut *but, const bool labeledit) ATTR_WARN_UNUSED_RESULT;
+bool ui_but_is_utf8(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
+bool ui_but_is_popover_once_compat(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
+bool ui_but_has_array_value(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
+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_point_px_icon(
+ const uiBut *but, struct ARegion *ar, const struct wmEvent *event) ATTR_WARN_UNUSED_RESULT;
+bool ui_but_contains_point_px(
+ const uiBut *but, const struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT;
+
+uiBut *ui_list_find_mouse_over(struct ARegion *ar, const struct wmEvent *event) ATTR_WARN_UNUSED_RESULT;
-extern bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
-extern bool ui_block_is_popover(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
-extern bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
-extern bool ui_block_is_popup_any(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
+uiBut *ui_but_find_mouse_over_ex(struct ARegion *ar, const int x, const int y, 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_list_find_mouse_over_ex(struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT;
+
+bool ui_but_contains_password(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
+
+uiBut *ui_but_prev(uiBut *but) ATTR_WARN_UNUSED_RESULT;
+uiBut *ui_but_next(uiBut *but) ATTR_WARN_UNUSED_RESULT;
+uiBut *ui_but_first(uiBlock *block) ATTR_WARN_UNUSED_RESULT;
+uiBut *ui_but_last(uiBlock *block) ATTR_WARN_UNUSED_RESULT;
+
+bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
+bool ui_block_is_popover(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
+bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
+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;
/* interface_context_menu.c */
bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but);
@@ -871,8 +863,8 @@ struct wmKeyMap *eyedropper_colorband_modal_keymap(struct wmKeyConfig *keyconf);
void UI_OT_eyedropper_color(struct wmOperatorType *ot);
/* interface_eyedropper_colorband.c */
-void UI_OT_eyedropper_colorband(struct wmOperatorType *ot);
-void UI_OT_eyedropper_colorband_point(struct wmOperatorType *ot);
+void UI_OT_eyedropper_colorramp(struct wmOperatorType *ot);
+void UI_OT_eyedropper_colorramp_point(struct wmOperatorType *ot);
/* interface_eyedropper_datablock.c */
void UI_OT_eyedropper_id(struct wmOperatorType *ot);
@@ -899,4 +891,8 @@ typedef struct uiRNACollectionSearch {
} uiRNACollectionSearch;
void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char *str, uiSearchItems *items);
+/* interface_ops.c */
+bool ui_jump_to_target_button_poll(struct bContext *C);
+
+
#endif /* __INTERFACE_INTERN_H__ */
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b0ac22898b6..6c4389aabd9 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -160,6 +160,8 @@ struct uiLayout {
short space;
bool align;
bool active;
+ bool active_default;
+ bool activate_init;
bool enabled;
bool redalert;
bool keepaspect;
@@ -235,8 +237,9 @@ static int ui_item_fit(int item, int pos, int all, int available, bool is_last,
if (all > available) {
/* contents is bigger than available space */
- if (is_last)
+ if (is_last) {
return available - pos;
+ }
else {
float width = *extra_pixel + (item * available) / (float)all;
*extra_pixel = width - (int)width;
@@ -246,8 +249,9 @@ static int ui_item_fit(int item, int pos, int all, int available, bool is_last,
else {
/* contents is smaller or equal to available space */
if (alignment == UI_LAYOUT_ALIGN_EXPAND) {
- if (is_last)
+ if (is_last) {
return available - pos;
+ }
else {
float width = *extra_pixel + (item * available) / (float)all;
*extra_pixel = width - (int)width;
@@ -285,8 +289,9 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool
bool variable;
const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f);
- if (icon && !name[0])
+ if (icon && !name[0]) {
return unit_x; /* icon only */
+ }
variable = ui_layout_variable_size(layout);
@@ -314,14 +319,22 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h)
if (item->type == ITEM_BUTTON) {
uiButtonItem *bitem = (uiButtonItem *)item;
- if (r_w) *r_w = BLI_rctf_size_x(&bitem->but->rect);
- if (r_h) *r_h = BLI_rctf_size_y(&bitem->but->rect);
+ if (r_w) {
+ *r_w = BLI_rctf_size_x(&bitem->but->rect);
+ }
+ if (r_h) {
+ *r_h = BLI_rctf_size_y(&bitem->but->rect);
+ }
}
else {
uiLayout *litem = (uiLayout *)item;
- if (r_w) *r_w = litem->w;
- if (r_h) *r_h = litem->h;
+ if (r_w) {
+ *r_w = litem->w;
+ }
+ if (r_h) {
+ *r_h = litem->h;
+ }
}
}
@@ -330,12 +343,20 @@ static void ui_item_offset(uiItem *item, int *r_x, int *r_y)
if (item->type == ITEM_BUTTON) {
uiButtonItem *bitem = (uiButtonItem *)item;
- if (r_x) *r_x = bitem->but->rect.xmin;
- if (r_y) *r_y = bitem->but->rect.ymin;
+ if (r_x) {
+ *r_x = bitem->but->rect.xmin;
+ }
+ if (r_y) {
+ *r_y = bitem->but->rect.ymin;
+ }
}
else {
- if (r_x) *r_x = 0;
- if (r_y) *r_y = 0;
+ if (r_x) {
+ *r_x = 0;
+ }
+ if (r_y) {
+ *r_y = 0;
+ }
}
}
@@ -374,10 +395,12 @@ static void ui_item_move(uiItem *item, int delta_xmin, int delta_xmax)
else {
uiLayout *litem = (uiLayout *)item;
- if (delta_xmin > 0)
+ if (delta_xmin > 0) {
litem->x += delta_xmin;
- else
+ }
+ else {
litem->w += delta_xmax;
+ }
}
}
@@ -405,10 +428,12 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, bool
{
uiLayout *sub;
- if (uiLayoutGetLocalDir(test) == UI_LAYOUT_HORIZONTAL)
+ if (uiLayoutGetLocalDir(test) == UI_LAYOUT_HORIZONTAL) {
sub = uiLayoutRow(layout, align);
- else
+ }
+ else {
sub = uiLayoutColumn(layout, align);
+ }
sub->space = 0;
return sub;
@@ -427,14 +452,17 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
if (!shift) {
RNA_property_boolean_set_index(ptr, prop, index, true);
- for (i = 0; i < len; i++)
- if (i != index)
+ for (i = 0; i < len; i++) {
+ if (i != index) {
RNA_property_boolean_set_index(ptr, prop, i, 0);
+ }
+ }
RNA_property_update(C, ptr, prop);
- for (cbut = but->block->buttons.first; cbut; cbut = cbut->next)
+ for (cbut = but->block->buttons.first; cbut; cbut = cbut->next) {
ui_but_update(cbut);
+ }
}
}
@@ -503,36 +531,42 @@ static void ui_item_array(
const uint layer_flag = (1u << layer_num);
if (layer_used & layer_flag) {
- if (layer_active & layer_flag)
+ if (layer_active & layer_flag) {
icon = ICON_LAYER_ACTIVE;
- else
+ }
+ else {
icon = ICON_LAYER_USED;
+ }
}
else {
icon = ICON_BLANK1;
}
but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth);
- if (subtype == PROP_LAYER_MEMBER)
+ if (subtype == PROP_LAYER_MEMBER) {
UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num));
+ }
}
for (a = 0; a < colbuts; a++) {
const int layer_num = a + len / 2 + b * colbuts;
const uint layer_flag = (1u << layer_num);
if (layer_used & layer_flag) {
- if (layer_active & layer_flag)
+ if (layer_active & layer_flag) {
icon = ICON_LAYER_ACTIVE;
- else
+ }
+ else {
icon = ICON_LAYER_USED;
+ }
}
else {
icon = ICON_BLANK1;
}
but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth);
- if (subtype == PROP_LAYER_MEMBER)
+ if (subtype == PROP_LAYER_MEMBER) {
UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num));
+ }
}
UI_block_align_end(block);
@@ -546,7 +580,10 @@ static void ui_item_array(
UI_block_layout_set_current(block, uiLayoutAbsolute(layout, true));
totdim = RNA_property_array_dimension(ptr, prop, dim_size);
- if (totdim != 2) return; /* only 2D matrices supported in UI so far */
+ if (totdim != 2) {
+ /* Only 2D matrices supported in UI so far. */
+ return;
+ }
w /= dim_size[0];
/* h /= dim_size[1]; */ /* UNUSED */
@@ -556,8 +593,9 @@ static void ui_item_array(
row = a / dim_size[0];
but = uiDefAutoButR(block, ptr, prop, a, "", ICON_NONE, x + w * col, y + (dim_size[1] * UI_UNIT_Y) - (row * UI_UNIT_Y), w, UI_UNIT_Y);
- if (slider && but->type == UI_BTYPE_NUM)
+ if (slider && but->type == UI_BTYPE_NUM) {
but->type = UI_BTYPE_NUM_SLIDER;
+ }
}
}
else if (subtype == PROP_DIRECTION && !expand) {
@@ -607,12 +645,15 @@ static void ui_item_array(
min_ii(w, ui_text_icon_width(layout, str_buf, icon, false)) : w);
but = uiDefAutoButR(block, ptr, prop, a, str_buf, icon, 0, 0, width_item, UI_UNIT_Y);
- if (slider && but->type == UI_BTYPE_NUM)
+ if (slider && but->type == UI_BTYPE_NUM) {
but->type = UI_BTYPE_NUM_SLIDER;
- if (toggle && but->type == UI_BTYPE_CHECKBOX)
+ }
+ if (toggle && but->type == UI_BTYPE_CHECKBOX) {
but->type = UI_BTYPE_TOGGLE;
- if ((a == 0) && (subtype == PROP_AXISANGLE))
+ }
+ if ((a == 0) && (subtype == PROP_AXISANGLE)) {
UI_but_unit_type_set(but, PROP_UNIT_ROTATION);
+ }
}
if (boolarr) {
@@ -664,10 +705,12 @@ static void ui_item_enum_expand_exec(
BLI_assert(RNA_property_type(prop) == PROP_ENUM);
- if (radial)
+ if (radial) {
RNA_property_enum_items_gettexted_all(block->evil_C, ptr, prop, &item_array, NULL, &free);
- else
+ }
+ else {
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item_array, NULL, &free);
+ }
/* we dont want nested rows, cols in menus */
if (radial) {
@@ -720,12 +763,15 @@ static void ui_item_enum_expand_exec(
value = item->value;
itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0);
- if (icon && name[0] && !icon_only)
+ 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)
+ }
+ 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
+ }
+ 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. */
@@ -733,8 +779,9 @@ static void ui_item_enum_expand_exec(
UI_but_func_set(but, ui_item_enum_expand_handle, but, POINTER_FROM_INT(value));
}
- if (uiLayoutGetLocalDir(layout) != UI_LAYOUT_HORIZONTAL)
+ 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). */
@@ -783,7 +830,7 @@ static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_
*
* \param w_hint: For varying width layout, this becomes the label width.
* Otherwise it's used to fit both items into it.
- **/
+ */
static uiBut *ui_item_with_label(
uiLayout *layout, uiBlock *block, const char *name, int icon,
PointerRNA *ptr, PropertyRNA *prop, int index,
@@ -848,8 +895,9 @@ static uiBut *ui_item_with_label(
but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, prop_but_width, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
UI_but_func_set(but, ui_keymap_but_cb, but, NULL);
- if (flag & UI_ITEM_R_IMMEDIATE)
+ if (flag & UI_ITEM_R_IMMEDIATE) {
UI_but_flag_enable(but, UI_BUT_IMMEDIATE);
+ }
}
}
else {
@@ -886,8 +934,9 @@ void UI_context_active_but_prop_get_filebrowser(
*r_prop = NULL;
*r_is_undo = false;
- if (!ar)
+ if (!ar) {
return;
+ }
for (block = ar->uiblocks.first; block; block = block->next) {
for (but = block->buttons.first; but; but = but->next) {
@@ -931,8 +980,9 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
UI_block_layout_set_current(block, layout);
- if (!name)
+ if (!name) {
name = "";
+ }
w = ui_text_icon_width(layout, name, 0, 0);
@@ -957,14 +1007,17 @@ static uiBut *uiItemFullO_ptr_ex(
int w;
if (!name) {
- if (ot && ot->srna && (flag & UI_ITEM_R_ICON_ONLY) == 0)
+ if (ot && ot->srna && (flag & UI_ITEM_R_ICON_ONLY) == 0) {
name = RNA_struct_ui_name(ot->srna);
- else
+ }
+ else {
name = "";
+ }
}
- if (layout->root->type == UI_LAYOUT_MENU && !icon)
+ if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
+ }
/* create button */
UI_block_layout_set_current(block, layout);
@@ -992,8 +1045,9 @@ static uiBut *uiItemFullO_ptr_ex(
assert(but->optype != NULL);
/* text alignment for toolbar buttons */
- if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon)
+ if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon) {
but->drawflag |= UI_BUT_TEXT_LEFT;
+ }
if (flag & UI_ITEM_R_NO_BG) {
layout->emboss = prev_emboss;
@@ -1003,8 +1057,13 @@ static uiBut *uiItemFullO_ptr_ex(
but->flag |= UI_SELECT_DRAW;
}
- if (layout->redalert)
+ if (layout->redalert) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
+ }
+
+ if (layout->active_default) {
+ UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT);
+ }
/* assign properties */
if (properties || r_opptr) {
@@ -1138,8 +1197,9 @@ void uiItemEnumO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int
RNA_property_enum_set(&ptr, prop, value);
- if (!name)
+ if (!name) {
name = ui_menu_enumpropname(layout, &ptr, prop, value);
+ }
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
}
@@ -1204,9 +1264,11 @@ void uiItemsFullEnumO_items(
/* Check if there are more visible items for the next level. If not, we don't
* add a new level and add the remaining item instead of the 'more' button. */
- for (tmp = item + 1; tmp->identifier; tmp++)
- if (tmp->name)
+ for (tmp = item + 1; tmp->identifier; tmp++) {
+ if (tmp->name) {
break;
+ }
+ }
if (tmp->identifier) { /* only true if loop above found item and did early-exit */
ui_pie_menu_level_create(block, ot, propname, properties, item_array, totitem, context, flag);
@@ -1373,8 +1435,9 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char
RNA_property_enum_set(&ptr, prop, value);
/* same as uiItemEnumO */
- if (!name)
+ if (!name) {
name = ui_menu_enumpropname(layout, &ptr, prop, value);
+ }
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
}
@@ -1417,8 +1480,9 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char
RNA_property_enum_set(&ptr, prop, value);
/* same as uiItemEnumO */
- if (!name)
+ if (!name) {
name = ui_menu_enumpropname(layout, &ptr, prop, value);
+ }
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
}
@@ -1524,8 +1588,9 @@ static void ui_item_rna_size(
if (!w) {
if (type == PROP_ENUM && icon_only) {
w = ui_text_icon_width(layout, "", ICON_BLANK1, compact);
- if (index != RNA_ENUM_VALUE)
+ if (index != RNA_ENUM_VALUE) {
w += 0.6f * UI_UNIT_X;
+ }
}
else {
/* not compact for float/int buttons, looks too squashed */
@@ -1536,24 +1601,32 @@ static void ui_item_rna_size(
/* increase height for arrays */
if (index == RNA_NO_INDEX && len > 0) {
- if (!name[0] && icon == ICON_NONE)
+ if (!name[0] && icon == ICON_NONE) {
h = 0;
- if (layout->item.flag & UI_ITEM_PROP_SEP)
+ }
+ if (layout->item.flag & UI_ITEM_PROP_SEP) {
h = 0;
- if (ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER))
+ }
+ if (ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) {
h += 2 * UI_UNIT_Y;
- else if (subtype == PROP_MATRIX)
+ }
+ else if (subtype == PROP_MATRIX) {
h += ceilf(sqrtf(len)) * UI_UNIT_Y;
- else
+ }
+ else {
h += len * UI_UNIT_Y;
+ }
}
else if (ui_layout_variable_size(layout)) {
- if (type == PROP_BOOLEAN && name[0])
+ if (type == PROP_BOOLEAN && name[0]) {
w += UI_UNIT_X / 5;
- else if (type == PROP_ENUM && !icon_only)
+ }
+ else if (type == PROP_ENUM && !icon_only) {
w += UI_UNIT_X / 4;
- else if (type == PROP_FLOAT || type == PROP_INT)
+ }
+ else if (type == PROP_FLOAT || type == PROP_INT) {
w += UI_UNIT_X * 3;
+ }
}
*r_w = w;
@@ -1571,6 +1644,13 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
bool is_array;
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
+ /* By default 'use_prop_sep' uses a separate column for labels.
+ * This is an exception for check-boxes otherwise only the small checkbox region is clickable.
+ *
+ * Keep using 'use_prop_sep' instead of disabling it entirely because
+ * we need the ability to have decorators still. */
+ bool use_prop_sep_split_label = use_prop_sep;
+
#ifdef UI_PROP_DECORATE
struct {
bool use_prop_decorate;
@@ -1591,9 +1671,11 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
is_array = RNA_property_array_check(prop);
len = (is_array) ? RNA_property_array_length(ptr, prop) : 0;
+ icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
+
/* set name and icon */
if (!name) {
- if ((flag & UI_ITEM_R_ICON_ONLY) == 0) {
+ if (!icon_only) {
name = RNA_property_ui_name(prop);
}
else {
@@ -1601,8 +1683,9 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
}
}
- if (icon == ICON_NONE)
+ if (icon == ICON_NONE) {
icon = RNA_property_ui_icon(prop);
+ }
if (flag & UI_ITEM_R_ICON_ONLY) {
/* pass */
@@ -1628,6 +1711,14 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
}
}
+#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION
+ if (use_prop_sep) {
+ if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) {
+ use_prop_sep_split_label = false;
+ }
+ }
+#endif
+
/* menus and pie-menus don't show checkbox without this */
if ((layout->root->type == UI_LAYOUT_MENU) ||
/* use checkboxes only as a fallback in pie-menu's, when no icon is defined */
@@ -1666,7 +1757,6 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
slider = (flag & UI_ITEM_R_SLIDER) != 0;
toggle = (flag & UI_ITEM_R_TOGGLE) != 0;
expand = (flag & UI_ITEM_R_EXPAND) != 0;
- icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
no_bg = (flag & UI_ITEM_R_NO_BG) != 0;
compact = (flag & UI_ITEM_R_COMPACT) != 0;
@@ -1690,25 +1780,16 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
}
#endif /* UI_PROP_DECORATE */
- if (name[0] == '\0') {
+ if ((name[0] == '\0') || (use_prop_sep_split_label == false)) {
/* Ensure we get a column when text is not set. */
layout = uiLayoutColumn(layout_row ? layout_row : layout, true);
layout->space = 0;
}
else {
const PropertySubType subtype = RNA_property_subtype(prop);
- uiLayout *layout_split;
-#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION
- if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) {
- layout_split = uiLayoutRow(layout_row ? layout_row : layout, true);
- }
- else
-#endif /* UI_PROP_SEP_ICON_WIDTH_EXCEPTION */
- {
- layout_split = uiLayoutSplit(
- layout_row ? layout_row : layout,
- UI_ITEM_PROP_SEP_DIVIDE, true);
- }
+ uiLayout *layout_split = uiLayoutSplit(
+ layout_row ? layout_row : layout,
+ UI_ITEM_PROP_SEP_DIVIDE, true);
layout_split->space = 0;
uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
layout_sub->space = 0;
@@ -1770,12 +1851,6 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
layout = uiLayoutColumn(layout_split, true);
}
layout->space = 0;
-
-#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION
- if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) {
- w = UI_UNIT_X;
- }
-#endif /* UI_PROP_SEP_ICON_WIDTH_EXCEPTION */
}
#ifdef UI_PROP_DECORATE
@@ -1796,16 +1871,19 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
if (index == RNA_NO_INDEX && is_array) {
ui_item_array(
layout, block, name, icon, ptr, prop, len, 0, 0, w, h,
- expand, slider, toggle, icon_only, compact, !use_prop_sep);
+ expand, slider, toggle, icon_only, compact, !use_prop_sep_split_label);
}
/* enum item */
else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
- if (icon && name[0] && !icon_only)
+ if (icon && name[0] && !icon_only) {
uiDefIconTextButR_prop(block, UI_BTYPE_ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
- else if (icon)
+ }
+ else if (icon) {
uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
- else
+ }
+ else {
uiDefButR_prop(block, UI_BTYPE_ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
+ }
}
/* expanded enum */
else if (type == PROP_ENUM && expand) {
@@ -1816,21 +1894,40 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
ui_but_add_search(but, ptr, prop, NULL, NULL);
- if (layout->redalert)
+ if (layout->redalert) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
+ }
+
+ if (layout->activate_init) {
+ UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
+ }
}
/* single button */
else {
but = uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h);
- if (slider && but->type == UI_BTYPE_NUM)
+ if (slider && but->type == UI_BTYPE_NUM) {
but->type = UI_BTYPE_NUM_SLIDER;
+ }
- if (toggle && but->type == UI_BTYPE_CHECKBOX)
+ if (toggle && but->type == UI_BTYPE_CHECKBOX) {
but->type = UI_BTYPE_TOGGLE;
+ }
- if (layout->redalert)
+ if (layout->redalert) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
+ }
+
+ if (layout->activate_init) {
+ UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
+ }
+
+ if (use_prop_sep && (use_prop_sep_split_label == false)) {
+ /* When the button uses it's own text right align it. */
+ but->drawflag |= UI_BUT_TEXT_RIGHT;
+ but->drawflag &= ~UI_BUT_TEXT_LEFT;
+ }
+
}
/* Mark non-embossed textfields inside a listbox. */
@@ -1898,6 +1995,57 @@ void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag,
uiItemFullR(layout, ptr, prop, RNA_NO_INDEX, 0, flag, name, icon);
}
+/**
+ * Use a wrapper function since re-implementing all the logic in this function would be messy.
+ */
+void uiItemFullR_with_popover(
+ uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag, const char *name, int icon,
+ const char *panel_type)
+{
+ uiBlock *block = layout->root->block;
+ uiBut *but = block->buttons.last;
+ uiItemFullR(layout, ptr, prop, index, value, flag, name, icon);
+ but = but->next;
+ while (but) {
+ if (but->rnaprop == prop && but->type == UI_BTYPE_MENU) {
+ ui_but_rna_menu_convert_to_panel_type(but, panel_type);
+ break;
+ }
+ but = but->next;
+ }
+ if (but == NULL) {
+ const char *propname = RNA_property_identifier(prop);
+ ui_item_disabled(layout, panel_type);
+ RNA_warning(
+ "property could not use a popover: %s.%s (%s)",
+ RNA_struct_identifier(ptr->type), propname, panel_type);
+ }
+}
+
+void uiItemFullR_with_menu(
+ uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag, const char *name, int icon,
+ const char *menu_type)
+{
+ uiBlock *block = layout->root->block;
+ uiBut *but = block->buttons.last;
+ uiItemFullR(layout, ptr, prop, index, value, flag, name, icon);
+ but = but->next;
+ while (but) {
+ if (but->rnaprop == prop && but->type == UI_BTYPE_MENU) {
+ ui_but_rna_menu_convert_to_menu_type(but, menu_type);
+ break;
+ }
+ but = but->next;
+ }
+ if (but == NULL) {
+ const char *propname = RNA_property_identifier(prop);
+ ui_item_disabled(layout, menu_type);
+ RNA_warning(
+ "property could not use a menu: %s.%s (%s)",
+ RNA_struct_identifier(ptr->type), propname, menu_type);
+ }
+}
+
void uiItemEnumR_prop(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, PropertyRNA *prop, int value)
{
if (RNA_property_type(prop) != PROP_ENUM) {
@@ -2025,8 +2173,9 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
ui_but_tip_from_enum_item(bt, &item[i]);
}
- else
+ else {
uiItemS(column);
+ }
}
}
@@ -2042,24 +2191,24 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
/* Pointer RNA button with search */
-static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA **prop)
+static void search_id_collection(StructRNA *ptype, PointerRNA *r_ptr, PropertyRNA **r_prop)
{
StructRNA *srna;
/* look for collection property in Main */
/* Note: using global Main is OK-ish here, UI shall not access other Mains anyay... */
- RNA_main_pointer_create(G_MAIN, ptr);
+ RNA_main_pointer_create(G_MAIN, r_ptr);
- *prop = NULL;
+ *r_prop = NULL;
- RNA_STRUCT_BEGIN (ptr, iprop)
+ RNA_STRUCT_BEGIN (r_ptr, iprop)
{
/* if it's a collection and has same pointer type, we've got it */
if (RNA_property_type(iprop) == PROP_COLLECTION) {
- srna = RNA_property_pointer_type(ptr, iprop);
+ srna = RNA_property_pointer_type(r_ptr, iprop);
if (ptype == srna) {
- *prop = iprop;
+ *r_prop = iprop;
break;
}
}
@@ -2108,8 +2257,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN
UI_but_func_search_set(
but, ui_searchbox_create_generic, ui_rna_collection_search_cb,
- coll_search, NULL, NULL);
- but->free_search_arg = true;
+ coll_search, true, NULL, NULL);
}
else if (but->type == UI_BTYPE_SEARCH_MENU) {
/* In case we fail to find proper searchprop,
@@ -2146,15 +2294,18 @@ void uiItemPointerR_prop(
/* get icon & name */
if (icon == ICON_NONE) {
- if (type == PROP_POINTER)
+ if (type == PROP_POINTER) {
icontype = RNA_property_pointer_type(ptr, prop);
- else
+ }
+ else {
icontype = RNA_property_pointer_type(searchptr, searchprop);
+ }
icon = RNA_struct_ui_icon(icontype);
}
- if (!name)
+ if (!name) {
name = RNA_property_ui_name(prop);
+ }
if (use_prop_sep == false) {
name = ui_item_name_add_colon(name, namestr);
@@ -2196,7 +2347,7 @@ void uiItemPointerR(
}
/* menu item */
-static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
+void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
{
MenuType *mt = (MenuType *)arg_mt;
@@ -2225,10 +2376,12 @@ static uiBut *ui_item_menu(
UI_block_layout_set_current(block, layout);
- if (!name)
+ if (!name) {
name = "";
- if (layout->root->type == UI_LAYOUT_MENU && !icon)
+ }
+ if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
+ }
w = ui_text_icon_width(layout, name, icon, 1);
h = UI_UNIT_Y;
@@ -2290,8 +2443,9 @@ void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon)
name = CTX_IFACE_(mt->translation_context, mt->label);
}
- if (layout->root->type == UI_LAYOUT_MENU && !icon)
+ if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
+ }
ui_item_menu(
layout, name, icon, ui_item_menutype_func, mt, NULL,
@@ -2390,10 +2544,12 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
UI_block_layout_set_current(block, layout);
- if (!name)
+ if (!name) {
name = "";
- if (layout->root->type == UI_LAYOUT_MENU && !icon)
+ }
+ if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
+ }
w = ui_text_icon_width(layout, name, icon, 0);
@@ -2436,9 +2592,11 @@ void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon)
{
uiBut *but = uiItemL_(layout, name, icon);
- if (ptr && ptr->type)
- if (RNA_struct_is_ID(ptr->type))
+ if (ptr && ptr->type) {
+ if (RNA_struct_is_ID(ptr->type)) {
UI_but_drag_set_id(but, ptr->id.data);
+ }
+ }
}
@@ -2452,19 +2610,24 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
UI_block_layout_set_current(block, layout);
- if (!name)
+ if (!name) {
name = "";
- if (layout->root->type == UI_LAYOUT_MENU && !icon)
+ }
+ if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
+ }
w = ui_text_icon_width(layout, name, icon, 0);
- if (icon && name[0])
+ if (icon && name[0]) {
uiDefIconTextButI(block, UI_BTYPE_BUT, argval, icon, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, "");
- else if (icon)
+ }
+ else if (icon) {
uiDefIconButI(block, UI_BTYPE_BUT, argval, icon, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, "");
- else
+ }
+ else {
uiDefButI(block, UI_BTYPE_BUT, argval, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, "");
+ }
}
/* separator item */
@@ -2508,8 +2671,9 @@ void uiItemSpacer(uiLayout *layout)
/* level items */
void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg)
{
- if (!func)
+ if (!func) {
return;
+ }
ui_item_menu(layout, name, icon, func, arg, NULL, "", false);
}
@@ -2519,8 +2683,9 @@ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc
*/
void uiItemMenuFN(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *argN)
{
- if (!func)
+ if (!func) {
return;
+ }
/* Second 'argN' only ensures it gets freed. */
ui_item_menu(layout, name, icon, func, argN, argN, "", false);
@@ -2562,8 +2727,9 @@ void uiItemMenuEnumO_ptr(
name = RNA_struct_ui_name(ot->srna);
}
- if (layout->root->type == UI_LAYOUT_MENU && !icon)
+ if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
+ }
lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname));
@@ -2618,10 +2784,12 @@ void uiItemMenuEnumR_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA
{
MenuItemLevel *lvl;
- if (!name)
+ if (!name) {
name = RNA_property_ui_name(prop);
- if (layout->root->type == UI_LAYOUT_MENU && !icon)
+ }
+ if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
+ }
lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
lvl->rnapoin = *ptr;
@@ -2673,8 +2841,9 @@ static void ui_litem_estimate_row(uiLayout *litem)
litem->w += itemw;
litem->h = MAX2(itemh, litem->h);
- if (item->next)
+ if (item->next) {
litem->w += litem->space;
+ }
}
if (min_size_flag) {
@@ -2706,11 +2875,13 @@ static void ui_litem_layout_row(uiLayout *litem)
tot++;
}
- if (totw == 0)
+ if (totw == 0) {
return;
+ }
- if (w != 0)
+ if (w != 0) {
w -= (tot - 1) * litem->space;
+ }
fixedw = 0;
/* keep clamping items to fixed minimum size until all are done */
@@ -2722,16 +2893,19 @@ static void ui_litem_layout_row(uiLayout *litem)
extra_pixel = 0.0f;
for (item = litem->items.first; item; item = item->next) {
- if (item->flag & UI_ITEM_FIXED)
+ if (item->flag & UI_ITEM_FIXED) {
continue;
+ }
ui_item_size(item, &itemw, &itemh);
minw = ui_litem_min_width(itemw);
- if (w - lastw > 0)
+ if (w - lastw > 0) {
neww = ui_item_fit(itemw, x, totw, w - lastw, !item->next, litem->alignment, &extra_pixel);
- else
+ }
+ else {
neww = 0; /* no space left, all will need clamping to minimum size */
+ }
x += neww;
@@ -2793,20 +2967,23 @@ static void ui_litem_layout_row(uiLayout *litem)
/* align right/center */
offset = 0;
if (litem->alignment == UI_LAYOUT_ALIGN_RIGHT) {
- if (freew + fixedw > 0 && freew + fixedw < w)
+ if (freew + fixedw > 0 && freew + fixedw < w) {
offset = w - (fixedw + freew);
+ }
}
else if (litem->alignment == UI_LAYOUT_ALIGN_CENTER) {
- if (freew + fixedw > 0 && freew + fixedw < w)
+ if (freew + fixedw > 0 && freew + fixedw < w) {
offset = (w - (fixedw + freew)) / 2;
+ }
}
/* position item */
ui_item_position(item, x + offset, y - itemh, itemw, itemh);
x += itemw;
- if (item->next)
+ if (item->next) {
x += litem->space;
+ }
}
/* add extra pixel */
@@ -2816,8 +2993,9 @@ static void ui_litem_layout_row(uiLayout *litem)
last_free_item && last_item && last_item->flag & UI_ITEM_FIXED)
{
ui_item_move(last_free_item, 0, extra_pixel);
- for (item = last_free_item->next; item; item = item->next)
+ for (item = last_free_item->next; item; item = item->next) {
ui_item_move(item, extra_pixel, extra_pixel);
+ }
}
litem->w = x - litem->x;
@@ -2844,8 +3022,9 @@ static void ui_litem_estimate_column(uiLayout *litem, bool is_box)
litem->w = MAX2(litem->w, itemw);
litem->h += itemh;
- if (item->next && (!is_box || item != litem->items.first))
+ if (item->next && (!is_box || item != litem->items.first)) {
litem->h += litem->space;
+ }
}
if (min_size_flag) {
@@ -2867,8 +3046,9 @@ static void ui_litem_layout_column(uiLayout *litem, bool is_box)
y -= itemh;
ui_item_position(item, x, y, litem->w, itemh);
- if (item->next && (!is_box || item != litem->items.first))
+ if (item->next && (!is_box || item != litem->items.first)) {
y -= litem->space;
+ }
if (is_box) {
item->flag |= UI_ITEM_BOX_ITEM;
@@ -2900,8 +3080,9 @@ static RadialDirection ui_get_radialbut_vec(float vec[2], short itemnum)
static bool ui_item_is_radial_displayable(uiItem *item)
{
- if ((item->type == ITEM_BUTTON) && (((uiButtonItem *)item)->but->type == UI_BTYPE_LABEL))
+ if ((item->type == ITEM_BUTTON) && (((uiButtonItem *)item)->but->type == UI_BTYPE_LABEL)) {
return false;
+ }
return true;
}
@@ -2909,8 +3090,9 @@ static bool ui_item_is_radial_displayable(uiItem *item)
static bool ui_item_is_radial_drawable(uiButtonItem *bitem)
{
- if (ELEM(bitem->but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER))
+ if (ELEM(bitem->but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) {
return false;
+ }
return true;
}
@@ -2935,11 +3117,13 @@ static void ui_litem_layout_radial(uiLayout *litem)
int minx = x, miny = y, maxx = x, maxy = y;
/* first count total items */
- for (item = litem->items.first; item; item = item->next)
+ for (item = litem->items.first; item; item = item->next) {
totitems++;
+ }
- if (totitems < 5)
+ if (totitems < 5) {
litem->root->block->pie_data.flags |= UI_PIE_DEGREES_RANGE_LARGE;
+ }
for (item = litem->items.first; item; item = item->next) {
/* not all button types are drawn in a radial menu, do filtering here */
@@ -3010,12 +3194,15 @@ static void ui_litem_layout_root_radial(uiLayout *litem)
static void ui_litem_layout_root(uiLayout *litem)
{
- if (litem->root->type == UI_LAYOUT_HEADER)
+ if (litem->root->type == UI_LAYOUT_HEADER) {
ui_litem_layout_row(litem);
- else if (litem->root->type == UI_LAYOUT_PIEMENU)
+ }
+ else if (litem->root->type == UI_LAYOUT_PIEMENU) {
ui_litem_layout_root_radial(litem);
- else
+ }
+ else {
ui_litem_layout_column(litem, false);
+ }
}
/* box layout */
@@ -3041,16 +3228,24 @@ static void ui_litem_layout_box(uiLayout *litem)
litem->x += style->boxspace;
litem->y -= style->boxspace;
- if (w != 0) litem->w -= 2 * style->boxspace;
- if (h != 0) litem->h -= 2 * style->boxspace;
+ if (w != 0) {
+ litem->w -= 2 * style->boxspace;
+ }
+ if (h != 0) {
+ litem->h -= 2 * style->boxspace;
+ }
ui_litem_layout_column(litem, true);
litem->x -= style->boxspace;
litem->y -= style->boxspace;
- if (w != 0) litem->w += 2 * style->boxspace;
- if (h != 0) litem->h += 2 * style->boxspace;
+ if (w != 0) {
+ litem->w += 2 * style->boxspace;
+ }
+ if (h != 0) {
+ litem->h += 2 * style->boxspace;
+ }
/* roundbox around the sublayout */
but = box->roundbox;
@@ -3089,8 +3284,9 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
flow->totcol = max_ii(litem->root->emw / maxw, 1);
flow->totcol = min_ii(flow->totcol, totitem);
}
- else
+ else {
flow->totcol = flow->number;
+ }
/* compute sizes */
x = 0;
@@ -3424,7 +3620,10 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
for (gflow->tot_rows = (int)ceilf((float)gflow->tot_items / gflow->tot_columns);
(gflow->tot_columns - step) > 0 &&
(int)ceilf((float)gflow->tot_items / (gflow->tot_columns - step)) <= gflow->tot_rows;
- gflow->tot_columns -= step);
+ gflow->tot_columns -= step)
+ {
+ /* pass */
+ }
}
else {
/* Adjust number of rows to be multiple of given modulo. */
@@ -3435,7 +3634,10 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
for (gflow->tot_columns = (int)ceilf((float)gflow->tot_items / gflow->tot_rows);
(gflow->tot_rows - step) > 0 &&
(int)ceilf((float)gflow->tot_items / (gflow->tot_rows - step)) <= gflow->tot_columns;
- gflow->tot_rows -= step);
+ gflow->tot_rows -= step)
+ {
+ /* pass */
+ }
}
}
@@ -3593,10 +3795,12 @@ static void ui_litem_layout_absolute(uiLayout *litem)
totw -= minx;
toth -= miny;
- if (litem->w && totw > 0)
+ if (litem->w && totw > 0) {
scalex = (float)litem->w / (float)totw;
- if (litem->h && toth > 0)
+ }
+ if (litem->h && toth > 0) {
scaley = (float)litem->h / (float)toth;
+ }
x = litem->x;
y = litem->y - scaley * toth;
@@ -3641,8 +3845,9 @@ static void ui_litem_layout_split(uiLayout *litem)
const int tot = BLI_listbase_count(&litem->items);
int itemh, x, y, w, colw = 0;
- if (tot == 0)
+ if (tot == 0) {
return;
+ }
x = litem->x;
y = litem->y;
@@ -3823,8 +4028,9 @@ uiLayout *uiLayoutRadial(uiLayout *layout)
uiItem *item;
/* radial layouts are only valid for radial menus */
- if (layout->root->type != UI_LAYOUT_PIEMENU)
+ if (layout->root->type != UI_LAYOUT_PIEMENU) {
return ui_item_local_sublayout(layout, layout, 0);
+ }
/* only one radial wheel per root layout is allowed, so check and return that, if it exists */
for (item = layout->root->layout->items.first; item; item = item->next) {
@@ -3949,6 +4155,16 @@ void uiLayoutSetActive(uiLayout *layout, bool active)
layout->active = active;
}
+void uiLayoutSetActiveDefault(uiLayout *layout, bool active_default)
+{
+ layout->active_default = active_default;
+}
+
+void uiLayoutSetActivateInit(uiLayout *layout, bool activate_init)
+{
+ layout->activate_init = activate_init;
+}
+
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
{
layout->enabled = enabled;
@@ -4019,6 +4235,16 @@ bool uiLayoutGetActive(uiLayout *layout)
return layout->active;
}
+bool uiLayoutGetActiveDefault(uiLayout *layout)
+{
+ return layout->active_default;
+}
+
+bool uiLayoutGetActivateInit(uiLayout *layout)
+{
+ return layout->activate_init;
+}
+
bool uiLayoutGetEnabled(uiLayout *layout)
{
return layout->enabled;
@@ -4111,8 +4337,9 @@ static void ui_item_estimate(uiItem *item)
if (item->type != ITEM_BUTTON) {
uiLayout *litem = (uiLayout *)item;
- for (subitem = litem->items.first; subitem; subitem = subitem->next)
+ for (subitem = litem->items.first; subitem; subitem = subitem->next) {
ui_item_estimate(subitem);
+ }
if (BLI_listbase_is_empty(&litem->items)) {
litem->w = 0;
@@ -4120,8 +4347,9 @@ static void ui_item_estimate(uiItem *item)
return;
}
- if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f)
+ if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f) {
ui_item_scale(litem, litem->scale);
+ }
switch (litem->item.type) {
case ITEM_LAYOUT_COLUMN:
@@ -4211,8 +4439,9 @@ static void ui_item_flag(uiLayout *litem, int flag)
bitem = (uiButtonItem *)item;
bitem->but->flag |= flag;
}
- else
+ else {
ui_item_flag((uiLayout *)item, flag);
+ }
}
}
@@ -4223,15 +4452,19 @@ static void ui_item_layout(uiItem *item)
if (item->type != ITEM_BUTTON) {
uiLayout *litem = (uiLayout *)item;
- if (BLI_listbase_is_empty(&litem->items))
+ if (BLI_listbase_is_empty(&litem->items)) {
return;
+ }
- if (litem->align)
+ if (litem->align) {
ui_item_align(litem, ++litem->root->block->alignnr);
- if (!litem->active)
+ }
+ if (!litem->active) {
ui_item_flag(litem, UI_BUT_INACTIVE);
- if (!litem->enabled)
+ }
+ if (!litem->enabled) {
ui_item_flag(litem, UI_BUT_DISABLED);
+ }
switch (litem->item.type) {
case ITEM_LAYOUT_COLUMN:
@@ -4283,16 +4516,21 @@ static void ui_item_layout(uiItem *item)
}
}
-static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y)
+static void ui_layout_end(uiBlock *block, uiLayout *layout, int *r_x, int *r_y)
{
- if (layout->root->handlefunc)
+ if (layout->root->handlefunc) {
UI_block_func_handle_set(block, layout->root->handlefunc, layout->root->argv);
+ }
ui_item_estimate(&layout->item);
ui_item_layout(&layout->item);
- if (x) *x = layout->x;
- if (y) *y = layout->y;
+ if (r_x) {
+ *r_x = layout->x;
+ }
+ if (r_y) {
+ *r_y = layout->y;
+ }
}
static void ui_layout_free(uiLayout *layout)
@@ -4302,10 +4540,12 @@ static void ui_layout_free(uiLayout *layout)
for (item = layout->items.first; item; item = next) {
next = item->next;
- if (item->type == ITEM_BUTTON)
+ if (item->type == ITEM_BUTTON) {
MEM_freeN(item);
- else
+ }
+ else {
ui_layout_free((uiLayout *)item);
+ }
}
MEM_freeN(layout);
@@ -4351,8 +4591,9 @@ uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int s
layout->context = NULL;
layout->emboss = UI_EMBOSS_UNDEFINED;
- if (type == UI_LAYOUT_MENU || type == UI_LAYOUT_PIEMENU)
+ if (type == UI_LAYOUT_MENU || type == UI_LAYOUT_PIEMENU) {
layout->space = 0;
+ }
if (dir == UI_LAYOUT_HORIZONTAL) {
layout->h = size;
@@ -4432,14 +4673,18 @@ void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv)
layout->root->argv = argv;
}
-void UI_block_layout_resolve(uiBlock *block, int *x, int *y)
+void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
{
uiLayoutRoot *root;
BLI_assert(block->active);
- if (x) *x = 0;
- if (y) *y = 0;
+ if (r_x) {
+ *r_x = 0;
+ }
+ if (r_y) {
+ *r_y = 0;
+ }
block->curlayout = NULL;
@@ -4447,7 +4692,7 @@ void UI_block_layout_resolve(uiBlock *block, int *x, int *y)
ui_layout_add_padding_button(root);
/* NULL in advance so we don't interfere when adding button */
- ui_layout_end(block, root->layout, x, y);
+ ui_layout_end(block, root->layout, r_x, r_y);
ui_layout_free(root->layout);
}
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index d39fe514f99..e00ea2d16bd 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -70,7 +70,9 @@
#include "BKE_main.h"
#include "BLI_ghash.h"
-/* Copy Data Path Operator ------------------------ */
+/* -------------------------------------------------------------------- */
+/** \name Copy Data Path Operator
+ * \{ */
static bool copy_data_path_button_poll(bContext *C)
{
@@ -162,6 +164,12 @@ static bool copy_python_command_button_poll(bContext *C)
return 0;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Copy Python Command Operator
+ * \{ */
+
static int copy_python_command_button_exec(bContext *C, wmOperator *UNUSED(op))
{
uiBut *but = UI_context_active_but_get(C);
@@ -198,7 +206,11 @@ static void UI_OT_copy_python_command_button(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER;
}
-/* Reset to Default Values Button Operator ------------------------ */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Reset to Default Values Button Operator
+ * \{ */
static int operator_button_property_finish(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
{
@@ -245,8 +257,9 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
/* if there is a valid property that is editable... */
if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
- if (RNA_property_reset(&ptr, prop, (all) ? -1 : index))
+ if (RNA_property_reset(&ptr, prop, (all) ? -1 : index)) {
return operator_button_property_finish(C, &ptr, prop);
+ }
}
return OPERATOR_CANCELLED;
@@ -270,7 +283,11 @@ static void UI_OT_reset_default_button(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
}
-/* Assign Value as Default Button Operator ------------------------ */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Assign Value as Default Button Operator
+ * \{ */
static bool assign_default_button_poll(bContext *C)
{
@@ -300,8 +317,9 @@ static int assign_default_button_exec(bContext *C, wmOperator *UNUSED(op))
/* if there is a valid property that is editable... */
if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
- if (RNA_property_assign_default(&ptr, prop))
+ if (RNA_property_assign_default(&ptr, prop)) {
return operator_button_property_finish(C, &ptr, prop);
+ }
}
return OPERATOR_CANCELLED;
@@ -322,7 +340,11 @@ static void UI_OT_assign_default_button(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/* Unset Property Button Operator ------------------------ */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Unset Property Button Operator
+ * \{ */
static int unset_property_button_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -360,6 +382,11 @@ static void UI_OT_unset_property_button(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Define Override Type Operator
+ * \{ */
/* Note that we use different values for UI/UX than 'real' override operations, user does not care
* whether it's added or removed for the differential operation e.g. */
@@ -571,10 +598,11 @@ static void UI_OT_override_remove_button(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
}
+/** \} */
-
-
-/* Copy To Selected Operator ------------------------ */
+/* -------------------------------------------------------------------- */
+/** \name Copy To Selected Operator
+ * \{ */
bool UI_context_copy_to_selected_list(
bContext *C, PointerRNA *ptr, PropertyRNA *prop,
@@ -831,6 +859,7 @@ static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "all", true, "All", "Copy to selected all elements of the array");
}
+/** \} */
/* -------------------------------------------------------------------- */
/** \name Jump to Target Operator
@@ -949,7 +978,7 @@ static bool jump_to_target_button(bContext *C, bool poll)
return false;
}
-static bool jump_to_target_button_poll(bContext *C)
+bool ui_jump_to_target_button_poll(bContext *C)
{
return jump_to_target_button(C, true);
}
@@ -969,7 +998,7 @@ static void UI_OT_jump_to_target_button(wmOperatorType *ot)
ot->description = "Switch to the target object or bone";
/* callbacks */
- ot->poll = jump_to_target_button_poll;
+ ot->poll = ui_jump_to_target_button_poll;
ot->exec = jump_to_target_button_exec;
/* flags */
@@ -978,7 +1007,9 @@ static void UI_OT_jump_to_target_button(wmOperatorType *ot)
/** \} */
-/* Reports to Textblock Operator ------------------------ */
+/* -------------------------------------------------------------------- */
+/** \name Reports to Textblock Operator
+ * \{ */
/* FIXME: this is just a temporary operator so that we can see all the reports somewhere
* when there are too many to display...
@@ -1029,6 +1060,12 @@ static void UI_OT_reports_to_textblock(wmOperatorType *ot)
ot->exec = reports_to_text_exec;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Edit Python Source Operator
+ * \{ */
+
#ifdef WITH_PYTHON
/* ------------------------------------------------------------------------- */
@@ -1244,7 +1281,11 @@ static void UI_OT_editsource(wmOperatorType *ot)
ot->exec = editsource_exec;
}
-/* ------------------------------------------------------------------------- */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Edit Translation Operator
+ * \{ */
/**
* EditTranslation utility funcs and operator,
@@ -1259,8 +1300,9 @@ static void edittranslation_find_po_file(const char *root, const char *uilng, ch
BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng);
BLI_join_dirfile(path, maxlen, root, uilng);
BLI_path_append(path, maxlen, tstr);
- if (BLI_is_file(path))
+ if (BLI_is_file(path)) {
return;
+ }
/* Now try without the second iso code part (_ES in es_ES). */
{
@@ -1271,20 +1313,23 @@ static void edittranslation_find_po_file(const char *root, const char *uilng, ch
tc = strchr(uilng, '_');
if (tc) {
szt = tc - uilng;
- if (szt < sizeof(tstr)) /* Paranoid, should always be true! */
+ if (szt < sizeof(tstr)) { /* Paranoid, should always be true! */
BLI_strncpy(tstr, uilng, szt + 1); /* +1 for '\0' char! */
+ }
}
if (tstr[0]) {
/* Because of some codes like sr_SR@latin... */
tc = strchr(uilng, '@');
- if (tc)
+ if (tc) {
BLI_strncpy(tstr + szt, tc, sizeof(tstr) - szt);
+ }
BLI_join_dirfile(path, maxlen, root, tstr);
strcat(tstr, ".po");
BLI_path_append(path, maxlen, tstr);
- if (BLI_is_file(path))
+ if (BLI_is_file(path)) {
return;
+ }
}
}
@@ -1358,26 +1403,36 @@ static int edittranslation_exec(bContext *C, wmOperator *op)
ret = WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr);
/* Clean up */
- if (but_label.strinfo)
+ if (but_label.strinfo) {
MEM_freeN(but_label.strinfo);
- if (rna_label.strinfo)
+ }
+ if (rna_label.strinfo) {
MEM_freeN(rna_label.strinfo);
- if (enum_label.strinfo)
+ }
+ if (enum_label.strinfo) {
MEM_freeN(enum_label.strinfo);
- if (but_tip.strinfo)
+ }
+ if (but_tip.strinfo) {
MEM_freeN(but_tip.strinfo);
- if (rna_tip.strinfo)
+ }
+ if (rna_tip.strinfo) {
MEM_freeN(rna_tip.strinfo);
- if (enum_tip.strinfo)
+ }
+ if (enum_tip.strinfo) {
MEM_freeN(enum_tip.strinfo);
- if (rna_struct.strinfo)
+ }
+ if (rna_struct.strinfo) {
MEM_freeN(rna_struct.strinfo);
- if (rna_prop.strinfo)
+ }
+ if (rna_prop.strinfo) {
MEM_freeN(rna_prop.strinfo);
- if (rna_enum.strinfo)
+ }
+ if (rna_enum.strinfo) {
MEM_freeN(rna_enum.strinfo);
- if (rna_ctxt.strinfo)
+ }
+ if (rna_ctxt.strinfo) {
MEM_freeN(rna_ctxt.strinfo);
+ }
return ret;
}
@@ -1400,6 +1455,12 @@ static void UI_OT_edittranslation_init(wmOperatorType *ot)
#endif /* WITH_PYTHON */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Reload Translation Operator
+ * \{ */
+
static int reloadtranslation_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
{
BLT_lang_init();
@@ -1420,6 +1481,11 @@ static void UI_OT_reloadtranslation(wmOperatorType *ot)
ot->exec = reloadtranslation_exec;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Prese Button Operator
+ * \{ */
static ARegion *region_event_inside_for_screen(bContext *C, const int xy[2])
{
@@ -1480,6 +1546,12 @@ static void UI_OT_button_execute(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "skip_depressed", 0, "Skip Depressed", "");
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Drop Color Operator
+ * \{ */
+
bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip))
{
/* should only return true for regions that include buttons, for now
@@ -1488,8 +1560,9 @@ bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
- if (UI_but_active_drop_color(C))
+ if (UI_but_active_drop_color(C)) {
return 1;
+ }
if (sima && (sima->mode == SI_MODE_PAINT) &&
sima->image && (ar && ar->regiontype == RGN_TYPE_WINDOW))
@@ -1521,7 +1594,7 @@ static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
/* find button under mouse, check if it has RNA color property and
* if it does copy the data */
- but = ui_but_find_active_in_region(ar);
+ but = ui_region_find_active_but(ar);
if (but && but->type == UI_BTYPE_COLOR && but->rnaprop) {
const int color_len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
@@ -1533,14 +1606,16 @@ static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
}
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
- if (!gamma)
+ if (!gamma) {
IMB_colormanagement_scene_linear_to_srgb_v3(color);
+ }
RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color);
RNA_property_update(C, &but->rnapoin, but->rnaprop);
}
else if (RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
- if (gamma)
+ if (gamma) {
IMB_colormanagement_srgb_to_scene_linear_v3(color);
+ }
RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color);
RNA_property_update(C, &but->rnapoin, but->rnaprop);
}
@@ -1572,9 +1647,11 @@ static void UI_OT_drop_color(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "gamma", 0, "Gamma Corrected", "The source color is gamma corrected ");
}
+/** \} */
-/* ********************************************************* */
-/* Registration */
+/* -------------------------------------------------------------------- */
+/** \name Operator & Keymap Registration
+ * \{ */
void ED_operatortypes_ui(void)
{
@@ -1598,8 +1675,8 @@ void ED_operatortypes_ui(void)
/* external */
WM_operatortype_append(UI_OT_eyedropper_color);
- WM_operatortype_append(UI_OT_eyedropper_colorband);
- WM_operatortype_append(UI_OT_eyedropper_colorband_point);
+ WM_operatortype_append(UI_OT_eyedropper_colorramp);
+ WM_operatortype_append(UI_OT_eyedropper_colorramp_point);
WM_operatortype_append(UI_OT_eyedropper_id);
WM_operatortype_append(UI_OT_eyedropper_depth);
WM_operatortype_append(UI_OT_eyedropper_driver);
@@ -1615,3 +1692,5 @@ void ED_keymap_ui(wmKeyConfig *keyconf)
eyedropper_modal_keymap(keyconf);
eyedropper_colorband_modal_keymap(keyconf);
}
+
+/** \} */
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 1897d07d224..c34992ceb9c 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -134,16 +134,21 @@ typedef enum eSpaceButtons_Align {
static int panel_aligned(ScrArea *sa, ARegion *ar)
{
- if (sa->spacetype == SPACE_PROPERTIES && ar->regiontype == RGN_TYPE_WINDOW)
+ if (sa->spacetype == SPACE_PROPERTIES && ar->regiontype == RGN_TYPE_WINDOW) {
return BUT_VERTICAL;
- else if (sa->spacetype == SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW)
+ }
+ else if (sa->spacetype == SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) {
return BUT_VERTICAL;
- else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
+ }
+ else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) {
return BUT_VERTICAL;
- else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW)
+ }
+ else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) {
return BUT_VERTICAL;
- else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS, RGN_TYPE_HUD, RGN_TYPE_NAV_BAR, RGN_TYPE_EXECUTE))
+ }
+ else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS, RGN_TYPE_HUD, RGN_TYPE_NAV_BAR, RGN_TYPE_EXECUTE)) {
return BUT_VERTICAL;
+ }
return 0;
}
@@ -186,9 +191,9 @@ static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, b
return false;
}
-static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **pa_animate)
+static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **r_pa_animate)
{
- *pa_animate = NULL;
+ *r_pa_animate = NULL;
if (sa->spacetype == SPACE_PROPERTIES && ar->regiontype == RGN_TYPE_WINDOW) {
SpaceProperties *sbuts = sa->spacedata.first;
@@ -214,7 +219,7 @@ static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **pa_animate)
/* Detect panel marked for animation, if we're not already animating. */
if (pa_animation) {
if (!no_animation) {
- *pa_animate = pa_animation;
+ *r_pa_animate = pa_animation;
}
return true;
}
@@ -313,10 +318,12 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, ListBase *lb, uiBlock *block, Pa
BLI_strncpy(pa->panelname, idname, sizeof(pa->panelname));
if (pt->flag & PNL_DEFAULT_CLOSED) {
- if (align == BUT_VERTICAL)
+ if (align == BUT_VERTICAL) {
pa->flag |= PNL_CLOSEDY;
- else
+ }
+ else {
pa->flag |= PNL_CLOSEDX;
+ }
}
pa->ofsx = 0;
@@ -378,13 +385,16 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, ListBase *lb, uiBlock *block, Pa
if (newpanel) {
pa->sortorder = (palast) ? palast->sortorder + 1 : 0;
- for (panext = lb->first; panext; panext = panext->next)
- if (panext != pa && panext->sortorder >= pa->sortorder)
+ for (panext = lb->first; panext; panext = panext->next) {
+ if (panext != pa && panext->sortorder >= pa->sortorder) {
panext->sortorder++;
+ }
+ }
}
- if (palast)
+ if (palast) {
palast->runtime_flag &= ~PNL_LAST_ADDED;
+ }
/* assign to block */
block->panel = pa;
@@ -395,8 +405,12 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, ListBase *lb, uiBlock *block, Pa
*r_open = false;
- if (pa->paneltab) return pa;
- if (pa->flag & PNL_CLOSED) return pa;
+ if (pa->paneltab) {
+ return pa;
+ }
+ if (pa->flag & PNL_CLOSED) {
+ return pa;
+ }
*r_open = true;
@@ -429,15 +443,18 @@ void UI_panel_end(uiBlock *block, int width, int height)
/* check if we need to do an animation */
if (!ELEM(width, 0, pa->sizex) || !ELEM(height, 0, pa->sizey)) {
pa->runtime_flag |= PNL_ANIM_ALIGN;
- if (height != 0)
+ if (height != 0) {
pa->ofsy += pa->sizey - height;
+ }
}
/* update width/height if non-zero */
- if (width != 0)
+ if (width != 0) {
pa->sizex = width;
- if (height != 0)
+ }
+ if (height != 0) {
pa->sizey = height;
+ }
}
}
@@ -613,16 +630,16 @@ static void ui_draw_panel_dragwidget(uint pos, uint col, const rctf *rect)
}
/* For button layout next to label. */
-void UI_panel_label_offset(uiBlock *block, int *x, int *y)
+void UI_panel_label_offset(uiBlock *block, int *r_x, int *r_y)
{
Panel *panel = block->panel;
const bool is_subpanel = (panel->type && panel->type->parent);
- *x = UI_UNIT_X * 1.0f;
- *y = UI_UNIT_Y * 1.5f;
+ *r_x = UI_UNIT_X * 1.0f;
+ *r_y = UI_UNIT_Y * 1.5f;
if (is_subpanel) {
- *x += (0.7f * UI_UNIT_X);
+ *r_x += (0.7f * UI_UNIT_X);
}
}
@@ -639,10 +656,12 @@ static void ui_draw_aligned_panel_header(
uchar col_title[4];
/* + 0.001f to avoid flirting with float inaccuracy */
- if (panel->control & UI_PNL_CLOSE)
+ if (panel->control & UI_PNL_CLOSE) {
pnl_icons = (panel->labelofs + (2.0f * PNL_ICON)) / block->aspect + 0.001f;
- else
+ }
+ else {
pnl_icons = (panel->labelofs + (1.1f * PNL_ICON)) / block->aspect + 0.001f;
+ }
/* draw text label */
panel_title_color_get(show_background, col_title);
@@ -683,8 +702,12 @@ void ui_draw_aligned_panel(
* This may be changed in future. */
show_background);
- if (panel->paneltab) return;
- if (panel->type && (panel->type->flag & PNL_NO_HEADER)) return;
+ if (panel->paneltab) {
+ return;
+ }
+ if (panel->type && (panel->type->flag & PNL_NO_HEADER)) {
+ return;
+ }
/* calculate header rect */
/* + 0.001f to prevent flicker due to float inaccuracy */
@@ -787,8 +810,12 @@ void ui_draw_aligned_panel(
else {
/* in some occasions, draw a border */
if (panel->flag & PNL_SELECT) {
- if (panel->control & UI_PNL_SOLID) UI_draw_roundbox_corner_set(UI_CNR_ALL);
- else UI_draw_roundbox_corner_set(UI_CNR_NONE);
+ if (panel->control & UI_PNL_SOLID) {
+ UI_draw_roundbox_corner_set(UI_CNR_ALL);
+ }
+ else {
+ UI_draw_roundbox_corner_set(UI_CNR_NONE);
+ }
UI_GetThemeColorShade4fv(TH_BACK, -120, color);
UI_draw_roundbox_aa(false, 0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax + 1, 8, color);
@@ -806,8 +833,9 @@ void ui_draw_aligned_panel(
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
}
- if (panel->control & UI_PNL_SCALE)
+ if (panel->control & UI_PNL_SCALE) {
ui_draw_panel_scalewidget(pos, rect);
+ }
immUnbindProgram();
}
@@ -841,12 +869,15 @@ void ui_draw_aligned_panel(
rgb_uchar_to_float(tria_color, col_title);
tria_color[3] = 1.0f;
- if (is_closed_y)
+ if (is_closed_y) {
ui_draw_anti_tria_rect(&itemrect, 'h', tria_color);
- else if (is_closed_x)
+ }
+ else if (is_closed_x) {
ui_draw_anti_tria_rect(&itemrect, 'h', tria_color);
- else
+ }
+ else {
ui_draw_anti_tria_rect(&itemrect, 'v', tria_color);
+ }
}
}
@@ -854,16 +885,18 @@ void ui_draw_aligned_panel(
static int get_panel_header(const Panel *pa)
{
- if (pa->type && (pa->type->flag & PNL_NO_HEADER))
+ if (pa->type && (pa->type->flag & PNL_NO_HEADER)) {
return 0;
+ }
return PNL_HEADER;
}
static int get_panel_size_y(const Panel *pa)
{
- if (pa->type && (pa->type->flag & PNL_NO_HEADER))
+ if (pa->type && (pa->type->flag & PNL_NO_HEADER)) {
return pa->sizey;
+ }
return PNL_HEADER + pa->sizey;
}
@@ -872,8 +905,9 @@ static int get_panel_real_size_y(const Panel *pa)
{
int sizey = (pa->flag & PNL_CLOSED) ? 0 : pa->sizey;
- if (pa->type && (pa->type->flag & PNL_NO_HEADER))
+ if (pa->type && (pa->type->flag & PNL_NO_HEADER)) {
return sizey;
+ }
return PNL_HEADER + sizey;
}
@@ -887,17 +921,31 @@ int UI_panel_size_y(const Panel *pa)
* change sizey or location when closed */
static int get_panel_real_ofsy(Panel *pa)
{
- if (pa->flag & PNL_CLOSEDY) return pa->ofsy + pa->sizey;
- else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) return pa->ofsy + pa->sizey;
- else if (pa->paneltab) return pa->paneltab->ofsy;
- else return pa->ofsy;
+ if (pa->flag & PNL_CLOSEDY) {
+ return pa->ofsy + pa->sizey;
+ }
+ else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) {
+ return pa->ofsy + pa->sizey;
+ }
+ else if (pa->paneltab) {
+ return pa->paneltab->ofsy;
+ }
+ else {
+ return pa->ofsy;
+ }
}
static int get_panel_real_ofsx(Panel *pa)
{
- if (pa->flag & PNL_CLOSEDX) return pa->ofsx + get_panel_header(pa);
- else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) return pa->ofsx + get_panel_header(pa);
- else return pa->ofsx + pa->sizex;
+ if (pa->flag & PNL_CLOSEDX) {
+ return pa->ofsx + get_panel_header(pa);
+ }
+ else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) {
+ return pa->ofsx + get_panel_header(pa);
+ }
+ else {
+ return pa->ofsx + pa->sizex;
+ }
}
typedef struct PanelSort {
@@ -916,10 +964,18 @@ static int find_leftmost_panel(const void *a1, const void *a2)
{
const PanelSort *ps1 = a1, *ps2 = a2;
- if (ps1->pa->ofsx > ps2->pa->ofsx) return 1;
- else if (ps1->pa->ofsx < ps2->pa->ofsx) return -1;
- else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
- else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
+ if (ps1->pa->ofsx > ps2->pa->ofsx) {
+ return 1;
+ }
+ else if (ps1->pa->ofsx < ps2->pa->ofsx) {
+ return -1;
+ }
+ else if (ps1->pa->sortorder > ps2->pa->sortorder) {
+ return 1;
+ }
+ else if (ps1->pa->sortorder < ps2->pa->sortorder) {
+ return -1;
+ }
return 0;
}
@@ -934,13 +990,25 @@ static int find_highest_panel(const void *a1, const void *a2)
if (ps1->pa->type->flag & PNL_NO_HEADER && ps2->pa->type->flag & PNL_NO_HEADER) {
/* skip and check for ofs and sortorder below */
}
- else if (ps1->pa->type->flag & PNL_NO_HEADER) return -1;
- else if (ps2->pa->type->flag & PNL_NO_HEADER) return 1;
+ else if (ps1->pa->type->flag & PNL_NO_HEADER) {
+ return -1;
+ }
+ else if (ps2->pa->type->flag & PNL_NO_HEADER) {
+ return 1;
+ }
- if (ps1->pa->ofsy + ps1->pa->sizey < ps2->pa->ofsy + ps2->pa->sizey) return 1;
- else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) return -1;
- else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
- else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
+ if (ps1->pa->ofsy + ps1->pa->sizey < ps2->pa->ofsy + ps2->pa->sizey) {
+ return 1;
+ }
+ else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) {
+ return -1;
+ }
+ else if (ps1->pa->sortorder > ps2->pa->sortorder) {
+ return 1;
+ }
+ else if (ps1->pa->sortorder < ps2->pa->sortorder) {
+ return -1;
+ }
return 0;
}
@@ -949,8 +1017,12 @@ static int compare_panel(const void *a1, const void *a2)
{
const PanelSort *ps1 = a1, *ps2 = a2;
- if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
- else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
+ if (ps1->pa->sortorder > ps2->pa->sortorder) {
+ return 1;
+ }
+ else if (ps1->pa->sortorder < ps2->pa->sortorder) {
+ return -1;
+ }
return 0;
}
@@ -985,19 +1057,25 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
bool has_category_tabs = UI_panel_category_is_visible(ar);
/* count active, not tabbed panels */
- for (pa = ar->panels.first; pa; pa = pa->next)
- if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL)
+ for (pa = ar->panels.first; pa; pa = pa->next) {
+ if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) {
tot++;
+ }
+ }
- if (tot == 0) return 0;
+ if (tot == 0) {
+ return 0;
+ }
/* extra; change close direction? */
for (pa = ar->panels.first; pa; pa = pa->next) {
if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) {
- if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL))
+ if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) {
pa->flag ^= PNL_CLOSED;
- else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL))
+ }
+ else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) {
pa->flag ^= PNL_CLOSED;
+ }
}
}
@@ -1015,17 +1093,21 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
if (drag) {
/* while we are dragging, we sort on location and update sortorder */
- if (align == BUT_VERTICAL)
+ if (align == BUT_VERTICAL) {
qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel);
- else
+ }
+ else {
qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel);
+ }
- for (ps = panelsort, a = 0; a < tot; a++, ps++)
+ for (ps = panelsort, a = 0; a < tot; a++, ps++) {
ps->orig->sortorder = a;
+ }
}
- else
+ else {
/* otherwise use sortorder */
qsort(panelsort, tot, sizeof(PanelSort), compare_panel);
+ }
/* no smart other default start loc! this keeps switching f5/f6/etc compatible */
ps = panelsort;
@@ -1085,7 +1167,7 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
return done;
}
-static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
+static void ui_panels_size(ScrArea *sa, ARegion *ar, int *r_x, int *r_y)
{
Panel *pa;
int align = panel_aligned(sa, ar);
@@ -1111,13 +1193,15 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
}
}
- if (sizex == 0)
+ if (sizex == 0) {
sizex = UI_PANEL_WIDTH;
- if (sizey == 0)
+ }
+ if (sizey == 0) {
sizey = -UI_PANEL_WIDTH;
+ }
- *x = sizex;
- *y = sizey;
+ *r_x = sizex;
+ *r_y = sizey;
}
static void ui_do_animate(const bContext *C, Panel *panel)
@@ -1166,16 +1250,18 @@ void UI_panels_begin(const bContext *UNUSED(C), ARegion *ar)
}
/* only draws blocks with panels */
-void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y)
+void UI_panels_end(const bContext *C, ARegion *ar, int *r_x, int *r_y)
{
ScrArea *sa = CTX_wm_area(C);
uiBlock *block;
Panel *panot, *panew, *patest, *pa, *firstpa;
/* offset contents */
- for (block = ar->uiblocks.first; block; block = block->next)
- if (block->active && block->panel)
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ if (block->active && block->panel) {
ui_offset_panel_block(block);
+ }
+ }
/* consistency; are panels not made, whilst they have tabs */
for (panot = ar->panels.first; panot; panot = panot->next) {
@@ -1204,24 +1290,30 @@ void UI_panels_end(const bContext *C, ARegion *ar, int *x, int *y)
/* re-align, possibly with animation */
if (panels_need_realign(sa, ar, &pa)) {
- if (pa)
+ if (pa) {
panel_activate_state(C, pa, PANEL_STATE_ANIMATION);
- else
+ }
+ else {
uiAlignPanelStep(sa, ar, 1.0, false);
+ }
}
/* tag first panel */
firstpa = NULL;
- for (block = ar->uiblocks.first; block; block = block->next)
- if (block->active && block->panel)
- if (!firstpa || block->panel->sortorder < firstpa->sortorder)
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ if (block->active && block->panel) {
+ if (!firstpa || block->panel->sortorder < firstpa->sortorder) {
firstpa = block->panel;
+ }
+ }
+ }
- if (firstpa)
+ if (firstpa) {
firstpa->runtime_flag |= PNL_FIRST;
+ }
/* compute size taken up by panel */
- ui_panels_size(sa, ar, x, y);
+ ui_panels_size(sa, ar, r_x, r_y);
}
void UI_panels_draw(const bContext *C, ARegion *ar)
@@ -1280,16 +1372,28 @@ static void check_panel_overlap(ARegion *ar, Panel *panel)
if (pa->paneltab == NULL && (pa->runtime_flag & PNL_ACTIVE)) {
float safex = 0.2, safey = 0.2;
- if (pa->flag & PNL_CLOSEDX) safex = 0.05;
- else if (pa->flag & PNL_CLOSEDY) safey = 0.05;
- else if (panel->flag & PNL_CLOSEDX) safex = 0.05;
- else if (panel->flag & PNL_CLOSEDY) safey = 0.05;
+ if (pa->flag & PNL_CLOSEDX) {
+ safex = 0.05;
+ }
+ else if (pa->flag & PNL_CLOSEDY) {
+ safey = 0.05;
+ }
+ else if (panel->flag & PNL_CLOSEDX) {
+ safex = 0.05;
+ }
+ else if (panel->flag & PNL_CLOSEDY) {
+ safey = 0.05;
+ }
- if (pa->ofsx > panel->ofsx - safex * panel->sizex)
- if (pa->ofsx + pa->sizex < panel->ofsx + (1.0f + safex) * panel->sizex)
- if (pa->ofsy > panel->ofsy - safey * panel->sizey)
- if (pa->ofsy + pa->sizey < panel->ofsy + (1.0f + safey) * panel->sizey)
+ if (pa->ofsx > panel->ofsx - safex * panel->sizex) {
+ if (pa->ofsx + pa->sizex < panel->ofsx + (1.0f + safex) * panel->sizex) {
+ if (pa->ofsy > panel->ofsy - safey * panel->sizey) {
+ if (pa->ofsy + pa->sizey < panel->ofsy + (1.0f + safey) * panel->sizey) {
pa->flag |= PNL_OVERLAP;
+ }
+ }
+ }
+ }
}
}
}
@@ -1305,8 +1409,9 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
short align = panel_aligned(sa, ar), dx = 0, dy = 0;
/* first clip for window, no dragging outside */
- if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x))
+ if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) {
return;
+ }
dx = (event->x - data->startx) & ~(PNL_GRID - 1);
dy = (event->y - data->starty) & ~(PNL_GRID - 1);
@@ -1317,8 +1422,9 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
if (data->state == PANEL_STATE_DRAG_SCALE) {
panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX);
- if (data->startsizey - dy < UI_PANEL_MINY)
+ if (data->startsizey - dy < UI_PANEL_MINY) {
dy = -UI_PANEL_MINY + data->startsizey;
+ }
panel->sizey = data->startsizey - dy;
panel->ofsy = data->startofsy + dy;
@@ -1331,7 +1437,9 @@ static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
panel->ofsy = data->startofsy + dy;
check_panel_overlap(ar, panel);
- if (align) uiAlignPanelStep(sa, ar, 0.2, true);
+ if (align) {
+ uiAlignPanelStep(sa, ar, 0.2, true);
+ }
}
ED_region_tag_redraw(ar);
@@ -1526,21 +1634,29 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
/* XXX weak code, currently it assumes layout style for location of widgets */
/* check open/collapsed button */
- if (event == RETKEY)
+ if (event == RETKEY) {
button = 1;
- else if (event == AKEY)
+ }
+ else if (event == AKEY) {
button = 1;
+ }
else if (ELEM(event, 0, RETKEY, LEFTMOUSE) && shift) {
block->panel->flag ^= PNL_PIN;
button = 2;
}
else if (block->panel->flag & PNL_CLOSEDX) {
- if (my >= block->rect.ymax) button = 1;
+ if (my >= block->rect.ymax) {
+ button = 1;
+ }
}
else if (block->panel->control & UI_PNL_CLOSE) {
/* whole of header can be used to collapse panel (except top-right corner) */
- if (mx <= block->rect.xmax - 8 - PNL_ICON) button = 2;
- //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) button = 1;
+ if (mx <= block->rect.xmax - 8 - PNL_ICON) {
+ button = 2;
+ }
+ //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) {
+ // button = 1;
+ //}
}
else if (mx < rect_leftmost) {
button = 1;
@@ -1561,8 +1677,9 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
if (block->panel->flag & PNL_CLOSED) {
block->panel->flag &= ~PNL_CLOSED;
/* snap back up so full panel aligns with screen edge */
- if (block->panel->snap & PNL_SNAP_BOTTOM)
+ if (block->panel->snap & PNL_SNAP_BOTTOM) {
block->panel->ofsy = 0;
+ }
if (event == LEFTMOUSE) {
ui_panel_drag_collapse_handler_add(C, false);
@@ -1578,8 +1695,9 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
else {
/* snap down to bottom screen edge */
block->panel->flag |= PNL_CLOSEDY;
- if (block->panel->snap & PNL_SNAP_BOTTOM)
+ if (block->panel->snap & PNL_SNAP_BOTTOM) {
block->panel->ofsy = -block->panel->sizey;
+ }
if (event == LEFTMOUSE) {
ui_panel_drag_collapse_handler_add(C, true);
@@ -1588,8 +1706,12 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
for (pa = ar->panels.first; pa; pa = pa->next) {
if (pa->paneltab == block->panel) {
- if (block->panel->flag & PNL_CLOSED) pa->flag |= PNL_CLOSED;
- else pa->flag &= ~PNL_CLOSED;
+ if (block->panel->flag & PNL_CLOSED) {
+ pa->flag |= PNL_CLOSED;
+ }
+ else {
+ pa->flag &= ~PNL_CLOSED;
+ }
}
}
}
@@ -2129,8 +2251,9 @@ static int ui_handle_panel_category_cycling(const wmEvent *event, ARegion *ar, c
(event->mval[0] > ((PanelCategoryDyn *)ar->panels_category.first)->rect.xmin));
/* if mouse is inside non-tab region, ctrl key is required */
- if (is_mousewheel && !event->ctrl && !inside_tabregion)
+ if (is_mousewheel && !event->ctrl && !inside_tabregion) {
return WM_UI_HANDLER_CONTINUE;
+ }
if (active_but && ui_but_supports_cycling(active_but)) {
@@ -2238,11 +2361,13 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
if (event->type == AKEY && ((event->ctrl + event->oskey + event->shift + event->alt) == 0)) {
if (pa->flag & PNL_CLOSEDY) {
- if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my))
+ if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) {
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
+ }
}
- else
+ else {
ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift);
+ }
retval = WM_UI_HANDLER_BREAK;
continue;
@@ -2250,8 +2375,9 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
}
/* on active button, do not handle panels */
- if (ui_but_is_active(ar))
+ if (ui_region_find_active_but(ar) != NULL) {
continue;
+ }
if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) {
@@ -2304,11 +2430,13 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
/* if panel is closed, only zoom if mouse is over the header */
if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) {
- if (inside_header)
+ if (inside_header) {
zoom = 1;
+ }
}
- else
+ else {
zoom = 1;
+ }
if (zoom) {
ScrArea *sa = CTX_wm_area(C);
@@ -2316,8 +2444,12 @@ int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, cons
if (sa->spacetype != SPACE_PROPERTIES) {
if (!(pa->control & UI_PNL_SCALE)) {
- if (event->type == PADPLUSKEY) sl->blockscale += 0.1;
- else sl->blockscale -= 0.1;
+ if (event->type == PADPLUSKEY) {
+ sl->blockscale += 0.1;
+ }
+ else {
+ sl->blockscale -= 0.1;
+ }
CLAMP(sl->blockscale, 0.6, 1.0);
ED_region_tag_redraw(ar);
@@ -2348,28 +2480,35 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata)
ARegion *ar = CTX_wm_region(C);
int align = panel_aligned(sa, ar);
- if (align)
+ if (align) {
panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
- else
+ }
+ else {
panel_activate_state(C, panel, PANEL_STATE_EXIT);
+ }
}
else if (event->type == MOUSEMOVE) {
- if (data->state == PANEL_STATE_DRAG)
+ if (data->state == PANEL_STATE_DRAG) {
ui_do_drag(C, event, panel);
+ }
}
else if (event->type == TIMER && event->customdata == data->animtimer) {
- if (data->state == PANEL_STATE_ANIMATION)
+ if (data->state == PANEL_STATE_ANIMATION) {
ui_do_animate(C, panel);
- else if (data->state == PANEL_STATE_DRAG)
+ }
+ else if (data->state == PANEL_STATE_DRAG) {
ui_do_drag(C, event, panel);
+ }
}
data = panel->activedata;
- if (data && data->state == PANEL_STATE_ANIMATION)
+ if (data && data->state == PANEL_STATE_ANIMATION) {
return WM_UI_HANDLER_CONTINUE;
- else
+ }
+ else {
return WM_UI_HANDLER_BREAK;
+ }
}
static void ui_handler_remove_panel(bContext *C, void *userdata)
@@ -2385,8 +2524,9 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
wmWindow *win = CTX_wm_window(C);
ARegion *ar = CTX_wm_region(C);
- if (data && data->state == state)
+ if (data && data->state == state) {
return;
+ }
if (state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) {
if (data && data->state != PANEL_STATE_ANIMATION) {
@@ -2402,8 +2542,9 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
pa->flag &= ~PNL_SELECT;
}
- else
+ else {
pa->flag |= PNL_SELECT;
+ }
if (data && data->animtimer) {
WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer);
@@ -2424,8 +2565,9 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0);
}
- if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG))
+ if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) {
data->animtimer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL);
+ }
data->state = state;
data->startx = win->eventstate->x;
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index d4d5e3d3df6..1954e20ab8b 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -21,10 +21,15 @@
*/
#include "BLI_utildefines.h"
+#include "BLI_math.h"
+#include "BLI_rect.h"
#include "DNA_screen_types.h"
#include "UI_interface.h"
+#include "UI_view2d.h"
+
+#include "RNA_access.h"
#include "interface_intern.h"
@@ -32,9 +37,10 @@
#include "WM_types.h"
/* -------------------------------------------------------------------- */
-/** \name Button (uiBut)
+/** \name Button (#uiBut) State
* \{ */
+
bool ui_but_is_editable(const uiBut *but)
{
return !ELEM(
@@ -67,6 +73,49 @@ bool ui_but_is_toggle(const uiBut *but)
);
}
+/**
+ * Can we mouse over the button or is it hidden/disabled/layout.
+ * \note ctrl is kind of a hack currently,
+ * so that non-embossed UI_BTYPE_TEXT button behaves as a label when ctrl is not pressed.
+ */
+bool ui_but_is_interactive(const uiBut *but, const bool labeledit)
+{
+ /* note, UI_BTYPE_LABEL is included for highlights, this allows drags */
+ if ((but->type == UI_BTYPE_LABEL) && but->dragpoin == NULL) {
+ return false;
+ }
+ if (ELEM(but->type, UI_BTYPE_ROUNDBOX, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_LISTBOX)) {
+ return false;
+ }
+ if (but->flag & UI_HIDDEN) {
+ return false;
+ }
+ if (but->flag & UI_SCROLLED) {
+ return false;
+ }
+ if ((but->type == UI_BTYPE_TEXT) && (but->dt == UI_EMBOSS_NONE) && !labeledit) {
+ return false;
+ }
+ if ((but->type == UI_BTYPE_LISTROW) && labeledit) {
+ return false;
+ }
+
+ return true;
+}
+
+/* file selectors are exempt from utf-8 checks */
+bool ui_but_is_utf8(const uiBut *but)
+{
+ if (but->rnaprop) {
+ const int subtype = RNA_property_subtype(but->rnaprop);
+ return !(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME, PROP_BYTESTRING));
+ }
+ else {
+ return !(but->flag & UI_BUT_NO_UTF8);
+ }
+}
+
+
#ifdef USE_UI_POPOVER_ONCE
bool ui_but_is_popover_once_compat(const uiBut *but)
{
@@ -77,13 +126,23 @@ bool ui_but_is_popover_once_compat(const uiBut *but)
}
#endif
+bool ui_but_has_array_value(const uiBut *but)
+{
+ return (but->rnapoin.data && but->rnaprop &&
+ ELEM(RNA_property_subtype(but->rnaprop), PROP_COLOR, PROP_TRANSLATION, PROP_DIRECTION,
+ PROP_VELOCITY, PROP_ACCELERATION, PROP_MATRIX, PROP_EULER, PROP_QUATERNION, PROP_AXISANGLE,
+ PROP_XYZ, PROP_XYZ_LENGTH, PROP_COLOR_GAMMA, PROP_COORDS));
+}
+
+
+
bool UI_but_is_tool(const uiBut *but)
{
/* very evil! */
if (but->optype != NULL) {
static wmOperatorType *ot = NULL;
if (ot == NULL) {
- ot = WM_operatortype_find("WM_OT_tool_set_by_name", false);
+ ot = WM_operatortype_find("WM_OT_tool_set_by_id", false);
}
if (but->optype == ot) {
return true;
@@ -103,7 +162,253 @@ bool UI_but_has_tooltip_label(const uiBut *but)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Block (uiBlock)
+/** \name Button (#uiBut) Spatial
+ * \{ */
+
+void ui_but_pie_dir(RadialDirection dir, float vec[2])
+{
+ float angle;
+
+ BLI_assert(dir != UI_RADIAL_NONE);
+
+ angle = DEG2RADF((float)ui_radial_dir_to_angle[dir]);
+ vec[0] = cosf(angle);
+ vec[1] = sinf(angle);
+}
+
+static bool ui_but_isect_pie_seg(const uiBlock *block, const uiBut *but)
+{
+ const float angle_range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_4 : M_PI_4 / 2.0;
+ float vec[2];
+
+ if (block->pie_data.flags & UI_PIE_INVALID_DIR) {
+ return false;
+ }
+
+ ui_but_pie_dir(but->pie_dir, vec);
+
+ if (saacos(dot_v2v2(vec, block->pie_data.pie_dir)) < angle_range) {
+ return true;
+ }
+
+ return false;
+}
+
+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_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;
+
+ ui_window_to_block_fl(ar, block, &mx, &my);
+
+ if (but->pie_dir != UI_RADIAL_NONE) {
+ if (!ui_but_isect_pie_seg(block, but)) {
+ return false;
+ }
+ }
+ else if (!ui_but_contains_pt(but, mx, my)) {
+ return false;
+ }
+
+ return true;
+}
+
+bool ui_but_contains_point_px_icon(const uiBut *but, ARegion *ar, const wmEvent *event)
+{
+ rcti rect;
+ int x = event->x, y = event->y;
+
+ ui_window_to_block(ar, but->block, &x, &y);
+
+ BLI_rcti_rctf_copy(&rect, &but->rect);
+
+ if (but->imb || but->type == UI_BTYPE_COLOR) {
+ /* use button size itself */
+ }
+ else if (but->drawflag & UI_BUT_ICON_LEFT) {
+ rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect));
+ }
+ else {
+ int delta = BLI_rcti_size_x(&rect) - BLI_rcti_size_y(&rect);
+ rect.xmin += delta / 2;
+ rect.xmax -= delta / 2;
+ }
+
+ return BLI_rcti_isect_pt(&rect, x, y);
+}
+
+/* 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;
+
+// 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;
+ ui_window_to_block_fl(ar, block, &mx, &my);
+
+ for (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)) {
+ butover = but;
+ break;
+ }
+ }
+ else if (ui_but_contains_pt(but, mx, my)) {
+ 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_pt(&block->rect, mx, my)) {
+ break;
+ }
+ }
+ }
+
+ return butover;
+}
+
+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)
+{
+ uiBlock *block;
+ uiBut *but;
+ float mx, my;
+
+ if (!ui_region_contains_point_px(ar, x, y)) {
+ return NULL;
+ }
+
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ mx = x;
+ my = y;
+ ui_window_to_block_fl(ar, block, &mx, &my);
+
+ for (but = block->buttons.last; but; but = but->prev) {
+ if (but->type == UI_BTYPE_LISTBOX && ui_but_contains_pt(but, mx, my)) {
+ return but;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+uiBut *ui_list_find_mouse_over(ARegion *ar, const wmEvent *event)
+{
+ return ui_list_find_mouse_over_ex(ar, event->x, event->y);
+}
+
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/** \name Button (#uiBut) Relations
+ * \{ */
+
+uiBut *ui_but_prev(uiBut *but)
+{
+ while (but->prev) {
+ but = but->prev;
+ if (ui_but_is_editable(but)) {
+ return but;
+ }
+ }
+ return NULL;
+}
+
+uiBut *ui_but_next(uiBut *but)
+{
+ while (but->next) {
+ but = but->next;
+ if (ui_but_is_editable(but)) {
+ return but;
+ }
+ }
+ return NULL;
+}
+
+uiBut *ui_but_first(uiBlock *block)
+{
+ uiBut *but;
+
+ but = block->buttons.first;
+ while (but) {
+ if (ui_but_is_editable(but)) {
+ return but;
+ }
+ but = but->next;
+ }
+ return NULL;
+}
+
+uiBut *ui_but_last(uiBlock *block)
+{
+ uiBut *but;
+
+ but = block->buttons.last;
+ while (but) {
+ if (ui_but_is_editable(but)) {
+ return but;
+ }
+ but = but->prev;
+ }
+ return NULL;
+}
+
+bool ui_but_is_cursor_warp(const uiBut *but)
+{
+ if (U.uiflag & USER_CONTINUOUS_MOUSE) {
+ if (ELEM(but->type,
+ UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, UI_BTYPE_HSVCIRCLE,
+ UI_BTYPE_TRACK_PREVIEW, UI_BTYPE_HSVCUBE, UI_BTYPE_CURVE))
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool ui_but_contains_password(const uiBut *but)
+{
+ return but->rnaprop && (RNA_property_subtype(but->rnaprop) == PROP_PASSWORD);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Block (#uiBlock) State
* \{ */
bool ui_block_is_menu(const uiBlock *block)
@@ -143,3 +448,85 @@ bool UI_block_is_empty(const uiBlock *block)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Region (#ARegion) State
+ * \{ */
+
+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) {
+ if (but->active) {
+ return but;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+uiBut *ui_region_find_first_but_test_flag(ARegion *ar, int flag_include, int flag_exclude)
+{
+ for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
+ for (uiBut *but = block->buttons.first; but; but = but->next) {
+ if (((but->flag & flag_include) == flag_include) &&
+ ((but->flag & flag_exclude) == 0))
+ {
+ return but;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Region (#ARegion) State
+ * \{ */
+
+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;
+ }
+
+ /* also, check that with view2d, that the mouse is not over the scrollbars
+ * NOTE: care is needed here, since the mask rect may include the scrollbars
+ * even when they are not visible, so we need to make a copy of the mask to
+ * use to check
+ */
+ if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) {
+ const View2D *v2d = &ar->v2d;
+ int mx, my;
+
+ /* 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;
+ }
+ }
+
+ return true;
+}
+
+/** \} */
diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c
index f96210b46d4..52136cee9ea 100644
--- a/source/blender/editors/interface/interface_region_color_picker.c
+++ b/source/blender/editors/interface/interface_region_color_picker.c
@@ -178,8 +178,9 @@ static void ui_update_color_picker_buts_rgb(
/* this updates button strings,
* is hackish... but button pointers are on stack of caller function */
for (bt = block->buttons.first; bt; bt = bt->next) {
- if (bt->custom_data != cpicker)
+ if (bt->custom_data != cpicker) {
continue;
+ }
if (bt->rnaprop) {
ui_but_v3_set(bt, rgb);
@@ -201,9 +202,15 @@ static void ui_update_color_picker_buts_rgb(
IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex);
}
- if (rgb_hex[0] > 1.0f) rgb_hex[0] = modf(rgb_hex[0], &intpart);
- if (rgb_hex[1] > 1.0f) rgb_hex[1] = modf(rgb_hex[1], &intpart);
- if (rgb_hex[2] > 1.0f) rgb_hex[2] = modf(rgb_hex[2], &intpart);
+ if (rgb_hex[0] > 1.0f) {
+ rgb_hex[0] = modf(rgb_hex[0], &intpart);
+ }
+ if (rgb_hex[1] > 1.0f) {
+ rgb_hex[1] = modf(rgb_hex[1], &intpart);
+ }
+ if (rgb_hex[2] > 1.0f) {
+ rgb_hex[2] = modf(rgb_hex[2], &intpart);
+ }
rgb_float_to_uchar(rgb_hex_uchar, rgb_hex);
BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3_EX((uint), rgb_hex_uchar, ));
@@ -252,8 +259,9 @@ static void ui_colorpicker_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a
but, but->block, but->custom_data, rgb);
}
- if (popup)
+ if (popup) {
popup->menuretval = UI_RETURN_UPDATE;
+ }
}
static void ui_color_wheel_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
@@ -271,8 +279,9 @@ static void ui_color_wheel_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a
ui_update_color_picker_buts_rgb(but, but->block, cpicker, rgb);
- if (popup)
+ if (popup) {
popup->menuretval = UI_RETURN_UPDATE;
+ }
}
static void ui_colorpicker_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl)
@@ -292,8 +301,9 @@ static void ui_colorpicker_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexc
ui_update_color_picker_buts_rgb(but, but->block, cpicker, rgb);
- if (popup)
+ if (popup) {
popup->menuretval = UI_RETURN_UPDATE;
+ }
}
static void ui_popup_close_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
@@ -589,10 +599,12 @@ static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *blo
{
float add = 0.0f;
- if (event->type == WHEELUPMOUSE)
+ if (event->type == WHEELUPMOUSE) {
add = 0.05f;
- else if (event->type == WHEELDOWNMOUSE)
+ }
+ else if (event->type == WHEELDOWNMOUSE) {
add = -0.05f;
+ }
if (add != 0.0f) {
uiBut *but;
@@ -615,8 +627,9 @@ static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *blo
ui_but_v3_set(but, rgb);
ui_update_color_picker_buts_rgb(but, block, cpicker, rgb);
- if (popup)
+ if (popup) {
popup->menuretval = UI_RETURN_UPDATE;
+ }
return 1;
}
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index e874609f61e..f6a5c9611af 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -178,9 +178,19 @@ static void hud_region_layout(const bContext *C, ARegion *ar)
ED_region_panels_layout(C, ar);
if (ar->panels.first && (ar->sizey != size_y)) {
+ int winx_new = UI_DPI_FAC * (ar->sizex + 0.5f);
+ int winy_new = UI_DPI_FAC * (ar->sizey + 0.5f);
View2D *v2d = &ar->v2d;
- ar->winx = ar->sizex * UI_DPI_FAC;
- ar->winy = ar->sizey * UI_DPI_FAC;
+
+ if (ar->flag & RGN_FLAG_SIZE_CLAMP_X) {
+ CLAMP_MAX(winx_new, ar->winx);
+ }
+ if (ar->flag & RGN_FLAG_SIZE_CLAMP_Y) {
+ CLAMP_MAX(winy_new, ar->winy);
+ }
+
+ ar->winx = winx_new;
+ ar->winy = winy_new;
ar->winrct.xmax = (ar->winrct.xmin + ar->winx) - 1;
ar->winrct.ymax = (ar->winrct.ymin + ar->winy) - 1;
diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c
index 2631f38d73d..b2fcfc0b23b 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.c
+++ b/source/blender/editors/interface/interface_region_menu_pie.c
@@ -75,8 +75,9 @@ static uiBlock *ui_block_func_PIE(bContext *UNUSED(C), uiPopupBlockHandle *handl
/* in some cases we create the block before the region,
* so we set it delayed here if necessary */
- if (BLI_findindex(&handle->region->uiblocks, block) == -1)
+ if (BLI_findindex(&handle->region->uiblocks, block) == -1) {
UI_block_region_set(block, handle->region);
+ }
UI_block_layout_resolve(block, &width, &height);
@@ -85,8 +86,8 @@ static uiBlock *ui_block_func_PIE(bContext *UNUSED(C), uiPopupBlockHandle *handl
block->minbounds = minwidth;
block->bounds = 1;
- block->mx = 0;
- block->my = 0;
+ block->bounds_offset[0] = 0;
+ block->bounds_offset[1] = 0;
block->bounds_type = UI_BLOCK_BOUNDS_PIE_CENTER;
block->pie_data.pie_center_spawned[0] = pie->mx;
@@ -134,8 +135,9 @@ uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, co
event_type = EVENT_NONE;
pie->block_radial->pie_data.flags |= UI_PIE_CLICK_STYLE;
}
- else
+ else {
event_type = win->last_pie_event;
+ }
}
else {
event_type = event->type;
diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c
index 73847d6fc71..a20c4fe9379 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -272,7 +272,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
}
block->minbounds = minwidth;
- UI_block_bounds_set_menu(block, 1, offset[0], offset[1]);
+ UI_block_bounds_set_menu(block, 1, offset);
}
else {
/* for a header menu we set the direction automatic */
@@ -311,7 +311,7 @@ uiPopupBlockHandle *ui_popup_menu_create(
pup = MEM_callocN(sizeof(uiPopupMenu), __func__);
pup->block = UI_block_begin(C, NULL, __func__, UI_EMBOSS_PULLDOWN);
pup->block->flag |= UI_BLOCK_NUMSELECT; /* default menus to numselect */
- pup->layout = UI_block_layout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, MENU_PADDING, style);
+ pup->layout = UI_block_layout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, UI_MENU_PADDING, style);
pup->slideout = but ? ui_block_is_menu(but->block) : false;
pup->but = but;
uiLayoutSetOperatorContext(pup->layout, WM_OP_INVOKE_REGION_WIN);
@@ -377,7 +377,7 @@ uiPopupMenu *UI_popup_menu_begin_ex(bContext *C, const char *title, const char *
pup->block = UI_block_begin(C, NULL, block_name, UI_EMBOSS_PULLDOWN);
pup->block->flag |= UI_BLOCK_POPUP_MEMORY | UI_BLOCK_IS_FLIP;
pup->block->puphash = ui_popup_menu_hash(title);
- pup->layout = UI_block_layout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, MENU_PADDING, style);
+ pup->layout = UI_block_layout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, UI_MENU_PADDING, style);
/* note, this intentionally differs from the menu & submenu default because many operators
* use popups like this to select one of their options -
@@ -480,8 +480,9 @@ void UI_popup_menu_reports(bContext *C, ReportList *reports)
uiPopupMenu *pup = NULL;
uiLayout *layout;
- if (!CTX_wm_window(C))
+ if (!CTX_wm_window(C)) {
return;
+ }
for (report = reports->list.first; report; report = report->next) {
int icon;
@@ -567,6 +568,7 @@ void UI_popup_block_invoke_ex(bContext *C, uiBlockCreateFunc func, void *arg, co
handle->opcontext = opcontext;
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
+ UI_block_active_only_flagged_buttons(C, handle->region, handle->region->uiblocks.first);
WM_event_add_mousemove(C);
}
@@ -594,6 +596,7 @@ void UI_popup_block_ex(
// handle->opcontext = opcontext;
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
+ UI_block_active_only_flagged_buttons(C, handle->region, handle->region->uiblocks.first);
WM_event_add_mousemove(C);
}
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 4fd25c4c7e2..0b1d3f19919 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -48,6 +48,7 @@
#include "BLI_rect.h"
#include "BLI_utildefines.h"
+#include "BLI_math_vector.h"
#include "BKE_context.h"
#include "BKE_screen.h"
@@ -105,7 +106,7 @@ static void ui_popover_create_block(bContext *C, uiPopover *pup, int opcontext)
pup->layout = UI_block_layout(
pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0,
- pup->ui_size_x, 0, MENU_PADDING, style);
+ pup->ui_size_x, 0, UI_MENU_PADDING, style);
uiLayoutSetOperatorContext(pup->layout, opcontext);
@@ -152,8 +153,9 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
/* If menu slides out of other menu, override direction. */
bool slideout = ui_block_is_menu(pup->but->block);
- if (slideout)
+ if (slideout) {
UI_block_direction_set(block, UI_DIR_RIGHT);
+ }
/* Store the button location for positioning the popover arrow hint. */
if (!handle->refresh) {
@@ -161,12 +163,12 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
ui_block_to_window_fl(handle->ctx_region, pup->but->block, &center[0], &center[1]);
/* These variables aren't used for popovers,
* we could add new variables if there is a conflict. */
- handle->prev_mx = block->mx = (int)center[0];
- handle->prev_my = block->my = (int)center[1];
+ block->bounds_offset[0] = (int)center[0];
+ block->bounds_offset[1] = (int)center[1];
+ copy_v2_v2_int(handle->prev_bounds_offset, block->bounds_offset);
}
else {
- block->mx = handle->prev_mx;
- block->my = handle->prev_my;
+ copy_v2_v2_int(block->bounds_offset, handle->prev_bounds_offset);
}
if (!slideout) {
@@ -192,28 +194,39 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
}
else {
/* Not attached to a button. */
- int offset[2] = {0, 0};
+ int bounds_offset[2] = {0, 0};
UI_block_flag_enable(block, UI_BLOCK_LOOP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
UI_block_direction_set(block, block->direction);
block->minbounds = UI_MENU_WIDTH_MIN;
- bool use_place_under_active = !handle->refresh;
- if (use_place_under_active) {
+ if (!handle->refresh) {
uiBut *but = NULL;
+ uiBut *but_first = NULL;
for (but = block->buttons.first; but; but = but->next) {
+ if ((but_first == NULL) && ui_but_is_editable(but)) {
+ but_first = but;
+ }
if (but->flag & (UI_SELECT | UI_SELECT_DRAW)) {
break;
}
}
if (but) {
- offset[0] = -(but->rect.xmin + 0.8f * BLI_rctf_size_x(&but->rect));
- offset[1] = -(but->rect.ymin + 0.5f * BLI_rctf_size_y(&but->rect));
+ bounds_offset[0] = -(but->rect.xmin + 0.8f * BLI_rctf_size_x(&but->rect));
+ bounds_offset[1] = -BLI_rctf_cent_y(&but->rect);
+ }
+ else {
+ bounds_offset[0] = -(pup->ui_size_x / 2);
+ bounds_offset[1] = but_first ? -BLI_rctf_cent_y(&but_first->rect) : (UI_UNIT_Y / 2);
}
+ copy_v2_v2_int(handle->prev_bounds_offset, bounds_offset);
+ }
+ else {
+ copy_v2_v2_int(bounds_offset, handle->prev_bounds_offset);
}
- UI_block_bounds_set_popup(block, block_margin, offset[0], offset[1]);
+ UI_block_bounds_set_popup(block, block_margin, bounds_offset);
}
return block;
@@ -290,16 +303,24 @@ int UI_popover_panel_invoke(
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
}
+ uiBlock *block = NULL;
if (keep_open) {
- ui_popover_panel_create(C, NULL, NULL, ui_item_paneltype_func, pt);
+ uiPopupBlockHandle *handle = ui_popover_panel_create(C, NULL, NULL, ui_item_paneltype_func, pt);
+ uiPopover *pup = handle->popup_create_vars.arg;
+ block = pup->block;
+
}
else {
uiPopover *pup = UI_popover_begin(C, U.widget_unit * pt->ui_units_x);
layout = UI_popover_layout(pup);
UI_paneltype_draw(C, pt, layout);
UI_popover_end(C, pup, NULL);
+ block = pup->block;
}
+ if (block) {
+ UI_block_active_only_flagged_buttons(C, CTX_wm_region(C), block);
+ }
return OPERATOR_INTERFACE;
}
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 91020cea371..59223970af8 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -95,10 +95,12 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut
/* widget_roundbox_set has this correction too, keep in sync */
if (but->type != UI_BTYPE_PULLDOWN) {
- if (but->drawflag & UI_BUT_ALIGN_TOP)
+ if (but->drawflag & UI_BUT_ALIGN_TOP) {
butrct.ymax += U.pixelsize;
- if (but->drawflag & UI_BUT_ALIGN_LEFT)
+ }
+ if (but->drawflag & UI_BUT_ALIGN_LEFT) {
butrct.xmin -= U.pixelsize;
+ }
}
handle->prev_butrct = butrct;
@@ -148,44 +150,46 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut
const float max_size_y = max_ff(size_y, handle->max_size_y);
/* check if there's space at all */
- if (butrct.xmin - max_size_x + center_x > 0.0f) left = 1;
- if (butrct.xmax + max_size_x - center_x < win_x) right = 1;
- if (butrct.ymin - max_size_y + center_y > 0.0f) down = 1;
- if (butrct.ymax + max_size_y - center_y < win_y) top = 1;
+ if (butrct.xmin - max_size_x + center_x > 0.0f) { left = 1; }
+ if (butrct.xmax + max_size_x - center_x < win_x) { right = 1; }
+ if (butrct.ymin - max_size_y + center_y > 0.0f) { down = 1; }
+ if (butrct.ymax + max_size_y - center_y < win_y) { top = 1; }
if (top == 0 && down == 0) {
- if (butrct.ymin - max_size_y < win_y - butrct.ymax - max_size_y)
+ if (butrct.ymin - max_size_y < win_y - butrct.ymax - max_size_y) {
top = 1;
- else
+ }
+ else {
down = 1;
+ }
}
dir1 = (block->direction & UI_DIR_ALL);
/* Secondary directions. */
if (dir1 & (UI_DIR_UP | UI_DIR_DOWN)) {
- if (dir1 & UI_DIR_LEFT) dir2 = UI_DIR_LEFT;
- else if (dir1 & UI_DIR_RIGHT) dir2 = UI_DIR_RIGHT;
+ if (dir1 & UI_DIR_LEFT) { dir2 = UI_DIR_LEFT; }
+ else if (dir1 & UI_DIR_RIGHT) { dir2 = UI_DIR_RIGHT; }
dir1 &= (UI_DIR_UP | UI_DIR_DOWN);
}
- if ((dir2 == 0) && (dir1 == UI_DIR_LEFT || dir1 == UI_DIR_RIGHT)) dir2 = UI_DIR_DOWN;
- if ((dir2 == 0) && (dir1 == UI_DIR_UP || dir1 == UI_DIR_DOWN)) dir2 = UI_DIR_LEFT;
+ if ((dir2 == 0) && (dir1 == UI_DIR_LEFT || dir1 == UI_DIR_RIGHT)) { dir2 = UI_DIR_DOWN; }
+ if ((dir2 == 0) && (dir1 == UI_DIR_UP || dir1 == UI_DIR_DOWN)) { dir2 = UI_DIR_LEFT; }
/* no space at all? don't change */
if (left || right) {
- if (dir1 == UI_DIR_LEFT && left == 0) dir1 = UI_DIR_RIGHT;
- if (dir1 == UI_DIR_RIGHT && right == 0) dir1 = UI_DIR_LEFT;
+ if (dir1 == UI_DIR_LEFT && left == 0) { dir1 = UI_DIR_RIGHT; }
+ if (dir1 == UI_DIR_RIGHT && right == 0) { dir1 = UI_DIR_LEFT; }
/* this is aligning, not append! */
- if (dir2 == UI_DIR_LEFT && right == 0) dir2 = UI_DIR_RIGHT;
- if (dir2 == UI_DIR_RIGHT && left == 0) dir2 = UI_DIR_LEFT;
+ if (dir2 == UI_DIR_LEFT && right == 0) { dir2 = UI_DIR_RIGHT; }
+ if (dir2 == UI_DIR_RIGHT && left == 0) { dir2 = UI_DIR_LEFT; }
}
if (down || top) {
- if (dir1 == UI_DIR_UP && top == 0) dir1 = UI_DIR_DOWN;
- if (dir1 == UI_DIR_DOWN && down == 0) dir1 = UI_DIR_UP;
+ if (dir1 == UI_DIR_UP && top == 0) { dir1 = UI_DIR_DOWN; }
+ if (dir1 == UI_DIR_DOWN && down == 0) { dir1 = UI_DIR_UP; }
BLI_assert(dir2 != UI_DIR_UP);
-// if (dir2 == UI_DIR_UP && top == 0) dir2 = UI_DIR_DOWN;
- if (dir2 == UI_DIR_DOWN && down == 0) dir2 = UI_DIR_UP;
+// if (dir2 == UI_DIR_UP && top == 0) { dir2 = UI_DIR_DOWN; }
+ if (dir2 == UI_DIR_DOWN && down == 0) { dir2 = UI_DIR_UP; }
}
handle->prev_dir1 = dir1;
@@ -203,18 +207,18 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut
if (dir1 == UI_DIR_LEFT) {
offset_x = butrct.xmin - block->rect.xmax;
- if (dir2 == UI_DIR_UP) offset_y = butrct.ymin - block->rect.ymin - center_y - MENU_PADDING;
- else offset_y = butrct.ymax - block->rect.ymax + center_y + MENU_PADDING;
+ if (dir2 == UI_DIR_UP) { offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; }
+ else { offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; }
}
else if (dir1 == UI_DIR_RIGHT) {
offset_x = butrct.xmax - block->rect.xmin;
- if (dir2 == UI_DIR_UP) offset_y = butrct.ymin - block->rect.ymin - center_y - MENU_PADDING;
- else offset_y = butrct.ymax - block->rect.ymax + center_y + MENU_PADDING;
+ if (dir2 == UI_DIR_UP) { offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; }
+ else { offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; }
}
else if (dir1 == UI_DIR_UP) {
offset_y = butrct.ymax - block->rect.ymin;
- if (dir2 == UI_DIR_RIGHT) offset_x = butrct.xmax - block->rect.xmax + center_x;
- else offset_x = butrct.xmin - block->rect.xmin - center_x;
+ if (dir2 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmax + center_x; }
+ else { offset_x = butrct.xmin - block->rect.xmin - center_x; }
/* changed direction? */
if ((dir1 & block->direction) == 0) {
/* TODO: still do */
@@ -223,8 +227,8 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut
}
else if (dir1 == UI_DIR_DOWN) {
offset_y = butrct.ymin - block->rect.ymax;
- if (dir2 == UI_DIR_RIGHT) offset_x = butrct.xmax - block->rect.xmax + center_x;
- else offset_x = butrct.xmin - block->rect.xmin - center_x;
+ if (dir2 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmax + center_x; }
+ else { offset_x = butrct.xmin - block->rect.xmin - center_x; }
/* changed direction? */
if ((dir1 & block->direction) == 0) {
/* TODO: still do */
@@ -257,23 +261,43 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut
/* when you are outside parent button, safety there should be smaller */
/* parent button to left */
- if (midx < block->rect.xmin) block->safety.xmin = block->rect.xmin - 3;
- else block->safety.xmin = block->rect.xmin - 40;
+ if (midx < block->rect.xmin) {
+ block->safety.xmin = block->rect.xmin - 3;
+ }
+ else {
+ block->safety.xmin = block->rect.xmin - 40;
+ }
/* parent button to right */
- if (midx > block->rect.xmax) block->safety.xmax = block->rect.xmax + 3;
- else block->safety.xmax = block->rect.xmax + 40;
+ if (midx > block->rect.xmax) {
+ block->safety.xmax = block->rect.xmax + 3;
+ }
+ else {
+ block->safety.xmax = block->rect.xmax + 40;
+ }
/* parent button on bottom */
- if (midy < block->rect.ymin) block->safety.ymin = block->rect.ymin - 3;
- else block->safety.ymin = block->rect.ymin - 40;
+ if (midy < block->rect.ymin) {
+ block->safety.ymin = block->rect.ymin - 3;
+ }
+ else {
+ block->safety.ymin = block->rect.ymin - 40;
+ }
/* parent button on top */
- if (midy > block->rect.ymax) block->safety.ymax = block->rect.ymax + 3;
- else block->safety.ymax = block->rect.ymax + 40;
+ if (midy > block->rect.ymax) {
+ block->safety.ymax = block->rect.ymax + 3;
+ }
+ else {
+ block->safety.ymax = block->rect.ymax + 40;
+ }
/* exception for switched pulldowns... */
if (dir1 && (dir1 & block->direction) == 0) {
- if (dir2 == UI_DIR_RIGHT) block->safety.xmax = block->rect.xmax + 3;
- if (dir2 == UI_DIR_LEFT) block->safety.xmin = block->rect.xmin - 3;
+ if (dir2 == UI_DIR_RIGHT) {
+ block->safety.xmax = block->rect.xmax + 3;
+ }
+ if (dir2 == UI_DIR_LEFT) {
+ block->safety.xmin = block->rect.xmin - 3;
+ }
}
block->direction = dir1;
}
@@ -335,8 +359,9 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar)
{
uiBlock *block;
- for (block = ar->uiblocks.first; block; block = block->next)
+ for (block = ar->uiblocks.first; block; block = block->next) {
UI_block_draw(C, block);
+ }
}
/**
@@ -409,11 +434,13 @@ void ui_popup_block_scrolltest(uiBlock *block)
block->flag &= ~(UI_BLOCK_CLIPBOTTOM | UI_BLOCK_CLIPTOP);
- for (bt = block->buttons.first; bt; bt = bt->next)
+ for (bt = block->buttons.first; bt; bt = bt->next) {
bt->flag &= ~UI_SCROLLED;
+ }
- if (block->buttons.first == block->buttons.last)
+ if (block->buttons.first == block->buttons.last) {
return;
+ }
/* mark buttons that are outside boundary */
for (bt = block->buttons.first; bt; bt = bt->next) {
@@ -430,12 +457,14 @@ void ui_popup_block_scrolltest(uiBlock *block)
/* mark buttons overlapping arrows, if we have them */
for (bt = block->buttons.first; bt; bt = bt->next) {
if (block->flag & UI_BLOCK_CLIPBOTTOM) {
- if (bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW)
+ if (bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW) {
bt->flag |= UI_SCROLLED;
+ }
}
if (block->flag & UI_BLOCK_CLIPTOP) {
- if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW)
+ if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW) {
bt->flag |= UI_SCROLLED;
+ }
}
}
}
@@ -454,8 +483,9 @@ static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle)
WM_event_add_mousemove(C);
}
- if (handle->scrolltimer)
+ if (handle->scrolltimer) {
WM_event_remove_timer(CTX_wm_manager(C), win, handle->scrolltimer);
+ }
}
/**
@@ -485,10 +515,12 @@ uiBlock *ui_popup_block_refresh(
#endif
/* create ui block */
- if (create_func)
+ if (create_func) {
block = create_func(C, ar, arg);
- else
+ }
+ else {
block = handle_create_func(C, handle, arg);
+ }
/* callbacks _must_ leave this for us, otherwise we can't call UI_block_update_from_old */
BLI_assert(!block->endblock);
@@ -503,8 +535,9 @@ uiBlock *ui_popup_block_refresh(
MEM_freeN(handle);
handle = block->handle;
}
- else
+ else {
block->handle = handle;
+ }
ar->regiondata = handle;
@@ -550,13 +583,21 @@ uiBlock *ui_popup_block_refresh(
/* only try translation if area is large enough */
if (BLI_rctf_size_x(&block->rect) < winx - (2.0f * win_width)) {
- if (block->rect.xmin < win_width ) x_offset += win_width - block->rect.xmin;
- if (block->rect.xmax > winx - win_width) x_offset += winx - win_width - block->rect.xmax;
+ if (block->rect.xmin < win_width ) {
+ x_offset += win_width - block->rect.xmin;
+ }
+ if (block->rect.xmax > winx - win_width) {
+ x_offset += winx - win_width - block->rect.xmax;
+ }
}
if (BLI_rctf_size_y(&block->rect) < winy - (2.0f * win_width)) {
- if (block->rect.ymin < win_width ) y_offset += win_width - block->rect.ymin;
- if (block->rect.ymax > winy - win_width) y_offset += winy - win_width - block->rect.ymax;
+ if (block->rect.ymin < win_width ) {
+ y_offset += win_width - block->rect.ymin;
+ }
+ if (block->rect.ymax > winy - win_width) {
+ y_offset += winy - win_width - block->rect.ymax;
+ }
}
/* if we are offsetting set up initial data for timeout functionality */
@@ -566,8 +607,9 @@ uiBlock *ui_popup_block_refresh(
UI_block_translate(block, x_offset, y_offset);
- if (U.pie_initial_timeout > 0)
+ if (U.pie_initial_timeout > 0) {
block->pie_data.flags |= UI_PIE_INITIAL_DIRECTION;
+ }
}
ar->winrct.xmin = 0;
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index 65d5fdaba88..9aebf1183e0 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -108,8 +108,9 @@ bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int
/* hijack for finding active item */
if (items->active) {
- if (poin == items->active)
+ if (poin == items->active) {
items->offset_i = items->totitem;
+ }
items->totitem++;
return true;
}
@@ -125,12 +126,15 @@ bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int
return true;
}
- if (items->names)
+ if (items->names) {
BLI_strncpy(items->names[items->totitem], name, items->maxstrlen);
- if (items->pointers)
+ }
+ if (items->pointers) {
items->pointers[items->totitem] = poin;
- if (items->icons)
+ }
+ if (items->icons) {
items->icons[items->totitem] = iconid;
+ }
items->totitem++;
@@ -275,8 +279,9 @@ void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, const wmEvent *eve
uiSearchboxData *data = ar->regiondata;
int type = event->type, val = event->val;
- if (type == MOUSEPAN)
+ if (type == MOUSEPAN) {
ui_pan_to_scroll(event, &type, &val);
+ }
switch (type) {
case WHEELUPMOUSE:
@@ -354,8 +359,9 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset)
}
/* callback */
- if (but->search_func)
+ if (but->search_func) {
but->search_func(C, but->search_arg, but->editstr, &data->items);
+ }
/* handle case where editstr is equal to one of items */
if (reset && data->active == -1) {
@@ -369,8 +375,9 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset)
break;
}
}
- if (data->items.totitem == 1 && but->editstr[0])
+ if (data->items.totitem == 1 && but->editstr[0]) {
data->active = 0;
+ }
}
/* validate selected item */
@@ -404,7 +411,7 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *ar)
wmOrtho2_region_pixelspace(ar);
if (data->noback == false) {
- ui_draw_widget_back(UI_WTYPE_MENU_BACK, true, &data->bbox);
+ ui_draw_widget_menu_back(&data->bbox, true);
}
/* draw text */
@@ -521,8 +528,9 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but
/* special case, hardcoded feature, not draw backdrop when called from menus,
* assume for design that popup already added it */
- if (but->block->flag & UI_BLOCK_SEARCH_MENU)
+ if (but->block->flag & UI_BLOCK_SEARCH_MENU) {
data->noback = true;
+ }
if (but->a1 > 0 && but->a2 > 0) {
data->preview = true;
@@ -605,8 +613,9 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but
if (rect_i.ymin < 0) {
int newy1 = but->rect.ymax + ofsy;
- if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax)
+ if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
newy1 = UI_view2d_view_to_region_y(&butregion->v2d, newy1);
+ }
newy1 += butregion->winrct.ymin;
@@ -645,8 +654,9 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but
data->items.names = MEM_callocN(data->items.maxitem * sizeof(void *), "search names");
data->items.pointers = MEM_callocN(data->items.maxitem * sizeof(void *), "search pointers");
data->items.icons = MEM_callocN(data->items.maxitem * sizeof(int), "search icons");
- for (i = 0; i < data->items.maxitem; i++)
+ for (i = 0; i < data->items.maxitem; i++) {
data->items.names[i] = MEM_callocN(but->hardmax + 1, "search pointers");
+ }
return ar;
}
@@ -685,7 +695,7 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
wmOrtho2_region_pixelspace(ar);
if (data->noback == false) {
- ui_draw_widget_back(UI_WTYPE_MENU_BACK, true, &data->bbox);
+ ui_draw_widget_menu_back(&data->bbox, true);
}
/* draw text */
@@ -784,8 +794,9 @@ void ui_but_search_refresh(uiBut *but)
items->maxitem = 10;
items->maxstrlen = 256;
items->names = MEM_callocN(items->maxitem * sizeof(void *), "search names");
- for (x1 = 0; x1 < items->maxitem; x1++)
+ for (x1 = 0; x1 < items->maxitem; x1++) {
items->names[x1] = MEM_callocN(but->hardmax + 1, "search names");
+ }
but->search_func(but->block->evil_C, but->search_arg, but->drawstr, items);
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index 0da96cc09c6..4bde694b5da 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -364,7 +364,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
return NULL;
}
- if (!STREQ(but->optype->idname, "WM_OT_tool_set_by_name")) {
+ if (!STREQ(but->optype->idname, "WM_OT_tool_set_by_id")) {
return NULL;
}
@@ -373,9 +373,9 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
return NULL;
}
- char tool_name[MAX_NAME];
- RNA_string_get(but->opptr, "name", tool_name);
- BLI_assert(tool_name[0] != '\0');
+ char tool_id[MAX_NAME];
+ RNA_string_get(but->opptr, "name", tool_id);
+ BLI_assert(tool_id[0] != '\0');
/* We have a tool, now extract the info. */
uiTooltipData *data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData");
@@ -387,13 +387,43 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
/* Title (when icon-only). */
if (but->drawstr[0] == '\0') {
- uiTooltipField *field = text_field_add(
- data, &(uiTooltipFormat){
- .style = UI_TIP_STYLE_NORMAL,
- .color_id = UI_TIP_LC_MAIN,
- .is_pad = true,
- });
- field->text = BLI_strdup(tool_name);
+ const char *expr_imports[] = {"bpy", "bl_ui", NULL};
+ char expr[256];
+ SNPRINTF(
+ expr,
+ "bl_ui.space_toolsystem_common.item_from_id("
+ "bpy.context, "
+ "bpy.context.space_data.type, "
+ "'%s').label",
+ tool_id);
+ char *expr_result = NULL;
+ bool is_error = false;
+ if (BPY_execute_string_as_string(C, expr_imports, expr, true, &expr_result)) {
+ if (STREQ(expr_result, "")) {
+ MEM_freeN(expr_result);
+ expr_result = NULL;
+ }
+ }
+ else {
+ /* Note, this is an exceptional case, we could even remove it
+ * however there have been reports of tooltips failing, so keep it for now. */
+ expr_result = BLI_strdup("Internal error!");
+ is_error = true;
+ }
+
+ if (expr_result != NULL) {
+ uiTooltipField *field = text_field_add(
+ data, &(uiTooltipFormat){
+ .style = UI_TIP_STYLE_NORMAL,
+ .color_id = UI_TIP_LC_MAIN,
+ .is_pad = true,
+ });
+ field->text = expr_result;
+
+ if (UNLIKELY(is_error)) {
+ field->format.color_id = UI_TIP_LC_ALERT;
+ }
+ }
}
/* Tip. */
@@ -402,11 +432,11 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
char expr[256];
SNPRINTF(
expr,
- "bl_ui.space_toolsystem_common.description_from_name("
+ "bl_ui.space_toolsystem_common.description_from_id("
"bpy.context, "
"bpy.context.space_data.type, "
"'%s') + '.'",
- tool_name);
+ tool_id);
char *expr_result = NULL;
bool is_error = false;
@@ -461,7 +491,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
const char *tool_attr = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
if (tool_attr != NULL) {
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
- const int i = RNA_enum_from_name(items, tool_name);
+ const int i = RNA_enum_from_name(items, tool_id);
if (i != -1) {
wmOperatorType *ot = WM_operatortype_find("paint.brush_select", true);
PointerRNA op_props;
@@ -504,9 +534,9 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
wmKeyMap *keymap = (wmKeyMap *)expr_result;
for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (STREQ(kmi->idname, but->optype->idname)) {
- char tool_name_test[MAX_NAME];
- RNA_string_get(kmi->ptr, "name", tool_name_test);
- if (STREQ(tool_name, tool_name_test)) {
+ char tool_id_test[MAX_NAME];
+ RNA_string_get(kmi->ptr, "name", tool_id_test);
+ if (STREQ(tool_id, tool_id_test)) {
char buf[128];
WM_keymap_item_to_string(kmi, false, buf, sizeof(buf));
shortcut = BLI_sprintfN("%s, %s", shortcut_toolbar, buf);
@@ -543,12 +573,12 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
SNPRINTF(
expr,
"getattr("
- "bl_ui.space_toolsystem_common.keymap_from_name("
+ "bl_ui.space_toolsystem_common.keymap_from_id("
"bpy.context, "
"bpy.context.space_data.type, "
"'%s'), "
"'as_pointer', lambda: 0)()",
- tool_name);
+ tool_id);
intptr_t expr_result = 0;
if (BPY_execute_string_as_intptr(C, expr_imports, expr, true, &expr_result)) {
@@ -809,20 +839,27 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
}
/* Free strinfo's... */
- if (but_tip.strinfo)
+ if (but_tip.strinfo) {
MEM_freeN(but_tip.strinfo);
- if (enum_label.strinfo)
+ }
+ if (enum_label.strinfo) {
MEM_freeN(enum_label.strinfo);
- if (enum_tip.strinfo)
+ }
+ if (enum_tip.strinfo) {
MEM_freeN(enum_tip.strinfo);
- if (op_keymap.strinfo)
+ }
+ if (op_keymap.strinfo) {
MEM_freeN(op_keymap.strinfo);
- if (prop_keymap.strinfo)
+ }
+ if (prop_keymap.strinfo) {
MEM_freeN(prop_keymap.strinfo);
- if (rna_struct.strinfo)
+ }
+ if (rna_struct.strinfo) {
MEM_freeN(rna_struct.strinfo);
- if (rna_prop.strinfo)
+ }
+ if (rna_prop.strinfo) {
MEM_freeN(rna_prop.strinfo);
+ }
if (data->fields_len == 0) {
MEM_freeN(data);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 8e3e99940a6..933864c1cb4 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -58,8 +58,9 @@ void ui_region_temp_remove(bContext *C, bScreen *sc, ARegion *ar)
BLI_assert(ar->regiontype == RGN_TYPE_TEMPORARY);
BLI_assert(BLI_findindex(&sc->regionbase, ar) != -1);
- if (win)
+ if (win) {
wm_draw_region_clear(win, ar);
+ }
ED_region_exit(C, ar);
BKE_area_region_free(NULL, ar); /* NULL: no spacetype */
diff --git a/source/blender/editors/interface/interface_regions_intern.h b/source/blender/editors/interface/interface_regions_intern.h
index 0d24b310817..fb71cbd788b 100644
--- a/source/blender/editors/interface/interface_regions_intern.h
+++ b/source/blender/editors/interface/interface_regions_intern.h
@@ -23,8 +23,6 @@
#ifndef __INTERFACE_REGIONS_INTERN_H__
#define __INTERFACE_REGIONS_INTERN_H__
-#define MENU_PADDING (int)(0.2f * UI_UNIT_Y)
-
/* interface_region_menu_popup.c */
uint ui_popup_menu_hash(const char *str);
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 4aea1fad89f..eecd5885c74 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -182,17 +182,15 @@ void UI_fontstyle_draw_ex(
if (fs_params->align == UI_STYLE_TEXT_CENTER) {
xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len)));
- /* don't center text if it chops off the start of the text, 2 gives some margin */
- if (xofs < 2) {
- xofs = 2;
- }
}
else if (fs_params->align == UI_STYLE_TEXT_RIGHT) {
- xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len) - 0.1f * U.widget_unit;
+ xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len);
}
- /* clip is very strict, so we give it some space */
- BLF_clipping(fs->uifont_id, rect->xmin - 2, rect->ymin - 4, rect->xmax + 1, rect->ymax + 4);
+ yofs = MAX2(0, yofs);
+ xofs = MAX2(0, xofs);
+
+ BLF_clipping(fs->uifont_id, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);
BLF_color4ubv(fs->uifont_id, col);
@@ -259,16 +257,19 @@ void UI_fontstyle_draw_rotated(const uiFontStyle *fs, const rcti *rect, const ch
BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
}
- if (fs->kerning == 1)
+ if (fs->kerning == 1) {
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
+ }
BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_disable(fs->uifont_id, BLF_ROTATION);
BLF_disable(fs->uifont_id, BLF_CLIPPING);
- if (fs->shadow)
+ if (fs->shadow) {
BLF_disable(fs->uifont_id, BLF_SHADOW);
- if (fs->kerning == 1)
+ }
+ if (fs->kerning == 1) {
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
+ }
}
/**
@@ -279,16 +280,18 @@ void UI_fontstyle_draw_rotated(const uiFontStyle *fs, const rcti *rect, const ch
*/
void UI_fontstyle_draw_simple(const uiFontStyle *fs, float x, float y, const char *str, const uchar col[4])
{
- if (fs->kerning == 1)
+ if (fs->kerning == 1) {
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
+ }
UI_fontstyle_set(fs);
BLF_position(fs->uifont_id, x, y, 0.0f);
BLF_color4ubv(fs->uifont_id, col);
BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
- if (fs->kerning == 1)
+ if (fs->kerning == 1) {
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
+ }
}
/**
@@ -298,8 +301,9 @@ void UI_fontstyle_draw_simple_backdrop(
const uiFontStyle *fs, float x, float y, const char *str,
const float col_fg[4], const float col_bg[4])
{
- if (fs->kerning == 1)
+ if (fs->kerning == 1) {
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
+ }
UI_fontstyle_set(fs);
@@ -326,8 +330,9 @@ void UI_fontstyle_draw_simple_backdrop(
BLF_color4fv(fs->uifont_id, col_fg);
BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
- if (fs->kerning == 1)
+ if (fs->kerning == 1) {
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
+ }
}
@@ -375,14 +380,17 @@ int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str)
{
int width;
- if (fs->kerning == 1) /* for BLF_width */
+ if (fs->kerning == 1) {
+ /* for BLF_width */
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
+ }
UI_fontstyle_set(fs);
width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
- if (fs->kerning == 1)
+ if (fs->kerning == 1) {
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
+ }
return width;
}
@@ -406,8 +414,9 @@ void uiStyleInit(void)
uchar *monofont_ttf = (uchar *)datatoc_bmonofont_ttf;
/* recover from uninitialized dpi */
- if (U.dpi == 0)
+ if (U.dpi == 0) {
U.dpi = 72;
+ }
CLAMP(U.dpi, 48, 144);
for (font = U.uifonts.first; font; font = font->next) {
@@ -481,8 +490,9 @@ void uiStyleInit(void)
BLF_default_set(font->blf_id);
if (font->blf_id == -1) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: error, no fonts available\n", __func__);
+ }
}
else {
/* ? just for speed to initialize?
@@ -565,8 +575,9 @@ void uiStyleInit(void)
* \note This isn't good that the render font depends on the preferences,
* keep for now though, since without this there is no way to display many unicode chars.
*/
- if (blf_mono_font_render == -1)
+ if (blf_mono_font_render == -1) {
blf_mono_font_render = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size);
+ }
BLF_size(blf_mono_font_render, 12 * U.pixelsize, 72);
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 987a2e56948..0bb1497a74e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -27,6 +27,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_cachefile_types.h"
+#include "DNA_constraint_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
@@ -50,8 +51,10 @@
#include "BLF_api.h"
#include "BLT_translation.h"
+#include "BKE_action.h"
#include "BKE_colorband.h"
#include "BKE_colortools.h"
+#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_gpencil_modifier.h"
@@ -143,8 +146,9 @@ static void template_add_button_search_menu(
UI_but_drawflag_enable(but, UI_BUT_ICON_LEFT);
}
- if ((idfrom && idfrom->lib) || !editable)
+ if ((idfrom && idfrom->lib) || !editable) {
UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
if (use_big_size) {
uiLayoutRow(layout, true);
}
@@ -165,8 +169,9 @@ static void template_add_button_search_menu(
}
UI_but_drawflag_enable(but, UI_BUT_ICON_LEFT);
- if ((idfrom && idfrom->lib) || !editable)
+ if ((idfrom && idfrom->lib) || !editable) {
UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
}
}
@@ -216,7 +221,7 @@ static uiBlock *template_common_search_menu(
}
UI_but_func_search_set(
but, ui_searchbox_create_generic, search_func,
- search_arg, handle_func, active_item);
+ search_arg, false, handle_func, active_item);
UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
@@ -298,7 +303,7 @@ static bool id_search_add(
/* +1 is needed because BKE_id_ui_prefix used 3 letter prefix
* followed by ID_NAME-2 characters from id->name
*/
- char name_ui[MAX_ID_FULL_NAME];
+ char name_ui[MAX_ID_FULL_NAME_UI];
BKE_id_full_name_ui_prefix_get(name_ui, id);
int iconid = ui_id_icon_get(C, id, template_ui->preview);
@@ -451,8 +456,12 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
break;
case UI_ID_FAKE_USER:
if (id) {
- if (id->flag & LIB_FAKEUSER) id_us_plus(id);
- else id_us_min(id);
+ if (id->flag & LIB_FAKEUSER) {
+ id_us_plus(id);
+ }
+ else {
+ id_us_min(id);
+ }
}
else {
return;
@@ -495,15 +504,14 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
if (id) {
const bool do_scene_obj = (
(GS(id->name) == ID_OB) &&
- (template_ui->ptr.type == &RNA_SceneObjects));
+ (template_ui->ptr.type == &RNA_LayerObjects));
/* make copy */
if (do_scene_obj) {
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ED_object_single_user(bmain, scene, (struct Object *)id);
- DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
DEG_relations_tag_update(bmain);
}
else {
@@ -665,8 +673,9 @@ static void template_ID(
block = uiLayoutGetBlock(layout);
UI_block_align_begin(block);
- if (idptr.type)
+ if (idptr.type) {
type = idptr.type;
+ }
if (flag & UI_ID_BROWSE) {
template_add_button_search_menu(
@@ -686,7 +695,9 @@ static void template_ID(
block, UI_BTYPE_TEXT, 0, name, 0, 0, TEMPLATE_SEARCH_TEXTBUT_WIDTH, TEMPLATE_SEARCH_TEXTBUT_HEIGHT,
&idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type));
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_RENAME));
- if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT);
+ if (user_alert) {
+ UI_but_flag_enable(but, UI_BUT_REDALERT);
+ }
if (id->lib) {
if (id->tag & LIB_TAG_INDIRECT) {
@@ -788,8 +799,9 @@ static void template_ID(
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN));
}
- if ((idfrom && idfrom->lib) || !editable)
+ if ((idfrom && idfrom->lib) || !editable) {
UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
}
/* delete button */
@@ -925,10 +937,12 @@ static void ui_template_id(
template_ui->filter = 0;
}
- if (newop)
+ if (newop) {
flag |= UI_ID_ADD_NEW;
- if (openop)
+ }
+ if (openop) {
flag |= UI_ID_OPEN;
+ }
type = RNA_property_pointer_type(ptr, prop);
idcode = RNA_type_to_ID_code(type);
@@ -1054,8 +1068,9 @@ void uiTemplateAnyID(
/* Label - either use the provided text, or will become "ID-Block:" */
if (text) {
- if (text[0])
+ if (text[0]) {
uiItemL(row, text, ICON_NONE);
+ }
}
else {
uiItemL(row, IFACE_("ID-Block:"), ICON_NONE);
@@ -1349,9 +1364,11 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
static int modifier_can_delete(ModifierData *md)
{
/* fluid particle modifier can't be deleted here */
- if (md->type == eModifierType_ParticleSystem)
- if (((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID)
+ if (md->type == eModifierType_ParticleSystem) {
+ if (((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID) {
return 0;
+ }
+ }
return 1;
}
@@ -1597,10 +1614,12 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
vmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
for (i = 0; vmd; i++, vmd = vmd->next) {
- if (md == vmd)
+ if (md == vmd) {
return draw_modifier(layout, scene, ob, md, i, cageIndex, lastCageIndex);
- else if (vmd->mode & eModifierMode_Virtual)
+ }
+ else if (vmd->mode & eModifierMode_Virtual) {
i--;
+ }
}
return NULL;
@@ -1729,8 +1748,9 @@ uiLayout *uiTemplateGpencilModifier(uiLayout *layout, bContext *UNUSED(C), Point
/* find modifier and draw it */
vmd = ob->greasepencil_modifiers.first;
for (i = 0; vmd; i++, vmd = vmd->next) {
- if (md == vmd)
+ if (md == vmd) {
return gpencil_draw_modifier(layout, ob, md);
+ }
}
return NULL;
@@ -1848,8 +1868,9 @@ uiLayout *uiTemplateShaderFx(uiLayout *layout, bContext *UNUSED(C), PointerRNA *
/* find modifier and draw it */
vfx = ob->shader_fx.first;
for (i = 0; vfx; i++, vfx = vfx->next) {
- if (fx == vfx)
+ if (fx == vfx) {
return gpencil_draw_shaderfx(layout, ob, fx);
+ }
}
return NULL;
@@ -1920,47 +1941,6 @@ void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
/************************ Constraint Template *************************/
-#include "DNA_constraint_types.h"
-
-#include "BKE_action.h"
-#include "BKE_constraint.h"
-
-#define B_CONSTRAINT_TEST 5
-// #define B_CONSTRAINT_CHANGETARGET 6
-
-static void do_constraint_panels(bContext *C, void *ob_pt, int event)
-{
- Object *ob = (Object *)ob_pt;
-
- switch (event) {
- case B_CONSTRAINT_TEST:
- break; /* no handling */
-#if 0 /* UNUSED */
- case B_CONSTRAINT_CHANGETARGET:
- {
- Main *bmain = CTX_data_main(C);
- if (ob->pose)
- BKE_pose_tag_recalc(bmain, ob->pose); /* checks & sorts pose channels */
- DEG_relations_tag_update(bmain);
- break;
- }
-#endif
- default:
- break;
- }
-
- /* note: RNA updates now call this, commenting else it gets called twice.
- * if there are problems because of this, then rna needs changed update functions.
- *
- * object_test_constraints(ob);
- * if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); */
-
- if (ob->type == OB_ARMATURE) DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
- else DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
-
- WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
-}
-
static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v)
{
ED_object_constraint_set_active(ob_v, con_v);
@@ -1984,18 +1964,20 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
/* exception for 'Null' constraint - it doesn't have constraint typeinfo! */
BLI_strncpy(typestr, (con->type == CONSTRAINT_TYPE_NULL) ? IFACE_("Null") : IFACE_("Unknown"), sizeof(typestr));
}
- else
+ else {
BLI_strncpy(typestr, IFACE_(cti->name), sizeof(typestr));
+ }
/* determine whether constraint is proxy protected or not */
- if (BKE_constraints_proxylocked_owner(ob, pchan))
+ if (BKE_constraints_proxylocked_owner(ob, pchan)) {
proxy_protected = (con->flag & CONSTRAINT_PROXY_LOCAL) == 0;
- else
+ }
+ else {
proxy_protected = 0;
+ }
/* unless button has own callback, it adds this callback to button */
block = uiLayoutGetBlock(layout);
- UI_block_func_handle_set(block, do_constraint_panels, ob);
UI_block_func_set(block, constraint_active_func, ob, con);
RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr);
@@ -2015,17 +1997,19 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
UI_block_emboss_set(block, UI_EMBOSS);
/* name */
- uiDefBut(block, UI_BTYPE_LABEL, B_CONSTRAINT_TEST, typestr,
+ uiDefBut(block, UI_BTYPE_LABEL, 0, typestr,
xco + 0.5f * UI_UNIT_X, yco, 5 * UI_UNIT_X, 0.9f * UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "");
- if (con->flag & CONSTRAINT_DISABLE)
+ if (con->flag & CONSTRAINT_DISABLE) {
uiLayoutSetRedAlert(row, true);
+ }
if (proxy_protected == 0) {
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
}
- else
+ else {
uiItemL(row, con->name, ICON_NONE);
+ }
uiLayoutSetRedAlert(row, false);
@@ -2035,9 +2019,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
/* draw a ghost icon (for proxy) and also a lock beside it,
* to show that constraint is "proxy locked" */
- uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_GHOST_ENABLED, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
+ uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_GHOST_ENABLED, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
- uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
+ uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
UI_block_emboss_set(block, UI_EMBOSS);
@@ -2056,11 +2040,13 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
if (con->prev) {
prev_proxylock = (con->prev->flag & CONSTRAINT_PROXY_LOCAL) ? 0 : 1;
}
- else
+ else {
prev_proxylock = 0;
+ }
}
- else
+ else {
prev_proxylock = 0;
+ }
show_upbut = ((prev_proxylock == 0) && (con->prev));
show_downbut = (con->next) ? 1 : 0;
@@ -2076,11 +2062,13 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
/* up/down */
if (show_upbut || show_downbut) {
UI_block_align_begin(block);
- if (show_upbut)
+ if (show_upbut) {
uiItemO(row, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up");
+ }
- if (show_downbut)
+ if (show_downbut) {
uiItemO(row, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down");
+ }
UI_block_align_end(block);
}
@@ -2091,8 +2079,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
}
/* Set but-locks for protected settings (magic numbers are used here!) */
- if (proxy_protected)
+ if (proxy_protected) {
UI_block_lock_set(block, true, IFACE_("Cannot edit Proxy-Protected Constraint"));
+ }
/* Draw constraint data */
if ((con->flag & CONSTRAINT_EXPAND) == 0) {
@@ -2134,8 +2123,9 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
/* hrms, the temporal constraint should not draw! */
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = con->data;
- if (data->flag & CONSTRAINT_IK_TEMP)
+ if (data->flag & CONSTRAINT_IK_TEMP) {
return NULL;
+ }
}
return draw_constraint(layout, ob, con);
@@ -2187,20 +2177,26 @@ void uiTemplatePreview(
pparent = NULL;
if (id && (GS(id->name) == ID_TE)) {
- if (parent && (GS(parent->name) == ID_MA))
+ if (parent && (GS(parent->name) == ID_MA)) {
pr_texture = &((Material *)parent)->pr_texture;
- else if (parent && (GS(parent->name) == ID_WO))
+ }
+ else if (parent && (GS(parent->name) == ID_WO)) {
pr_texture = &((World *)parent)->pr_texture;
- else if (parent && (GS(parent->name) == ID_LA))
+ }
+ else if (parent && (GS(parent->name) == ID_LA)) {
pr_texture = &((Light *)parent)->pr_texture;
- else if (parent && (GS(parent->name) == ID_LS))
+ }
+ else if (parent && (GS(parent->name) == ID_LS)) {
pr_texture = &((FreestyleLineStyle *)parent)->pr_texture;
+ }
if (pr_texture) {
- if (*pr_texture == TEX_PR_OTHER)
+ if (*pr_texture == TEX_PR_OTHER) {
pid = parent;
- else if (*pr_texture == TEX_PR_BOTH)
+ }
+ else if (*pr_texture == TEX_PR_BOTH) {
pparent = parent;
+ }
}
}
@@ -2246,8 +2242,12 @@ void uiTemplatePreview(
/* add buttons */
if (pid && show_buttons) {
if (GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) {
- if (GS(pid->name) == ID_MA) ma = (Material *)pid;
- else ma = (Material *)pparent;
+ if (GS(pid->name) == ID_MA) {
+ ma = (Material *)pid;
+ }
+ else {
+ ma = (Material *)pparent;
+ }
/* Create RNA Pointer */
RNA_pointer_create(&ma->id, &RNA_Material, ma, &material_ptr);
@@ -2378,15 +2378,26 @@ static void colorband_tools_dofunc(bContext *C, void *coba_v, int event)
static uiBlock *colorband_tools_func(
bContext *C, ARegion *ar, void *coba_v)
{
+ uiStyle *style = UI_style_get_dpi();
ColorBand *coba = coba_v;
uiBlock *block;
short yco = 0, menuwidth = 10 * UI_UNIT_X;
- block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
+ block = UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN);
UI_block_func_butmenu_set(block, colorband_tools_dofunc, coba);
+ uiLayout *layout = UI_block_layout(
+ block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, UI_MENU_WIDTH_MIN, 0, UI_MENU_PADDING, style);
+ UI_block_layout_set_current(block, layout);
+ {
+ PointerRNA coba_ptr;
+ RNA_pointer_create(NULL, &RNA_ColorRamp, coba, &coba_ptr);
+ uiLayoutSetContextPointer(layout, "color_ramp", &coba_ptr);
+ }
+
+ /* We could move these to operators,
+ * although this isn't important unless we want to assign key shortcuts to them. */
{
- uiBut *but;
uiDefIconTextBut(
block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1,
IFACE_("Flip Color Ramp"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y,
@@ -2399,11 +2410,9 @@ static uiBlock *colorband_tools_func(
block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1,
IFACE_("Distribute Stops Evenly"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y,
NULL, 0.0, 0.0, 0, CB_FUNC_DISTRIBUTE_EVENLY, "");
- but = uiDefIconTextButO(
- block, UI_BTYPE_BUT_MENU, "UI_OT_eyedropper_colorband", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER,
- IFACE_("Eyedropper"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y,
- "");
- but->custom_data = coba;
+
+ uiItemO(layout, IFACE_("Eyedropper"), ICON_EYEDROPPER, "UI_OT_eyedropper_colorramp");
+
uiDefIconTextBut(
block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset Color Ramp"),
0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, CB_FUNC_RESET, "");
@@ -2421,8 +2430,12 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
float pos = 0.5f;
if (coba->tot > 1) {
- if (coba->cur > 0) pos = (coba->data[coba->cur - 1].pos + coba->data[coba->cur].pos) * 0.5f;
- else pos = (coba->data[coba->cur + 1].pos + coba->data[coba->cur].pos) * 0.5f;
+ if (coba->cur > 0) {
+ pos = (coba->data[coba->cur - 1].pos + coba->data[coba->cur].pos) * 0.5f;
+ }
+ else {
+ pos = (coba->data[coba->cur + 1].pos + coba->data[coba->cur].pos) * 0.5f;
+ }
}
if (BKE_colorband_element_add(coba, pos)) {
@@ -2560,12 +2573,14 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
ID *id;
rctf rect;
- if (!prop || RNA_property_type(prop) != PROP_POINTER)
+ if (!prop || RNA_property_type(prop) != PROP_POINTER) {
return;
+ }
cptr = RNA_property_pointer_get(ptr, prop);
- if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp))
+ if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp)) {
return;
+ }
cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
cb->ptr = *ptr;
@@ -2724,12 +2739,14 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
uiLayout *col;
Histogram *hist;
- if (!prop || RNA_property_type(prop) != PROP_POINTER)
+ if (!prop || RNA_property_type(prop) != PROP_POINTER) {
return;
+ }
cptr = RNA_property_pointer_get(ptr, prop);
- if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram))
+ if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram)) {
return;
+ }
hist = (Histogram *)cptr.data;
if (hist->height < UI_UNIT_Y) {
@@ -2759,12 +2776,14 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
uiLayout *col;
Scopes *scopes;
- if (!prop || RNA_property_type(prop) != PROP_POINTER)
+ if (!prop || RNA_property_type(prop) != PROP_POINTER) {
return;
+ }
cptr = RNA_property_pointer_get(ptr, prop);
- if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes))
+ if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
return;
+ }
scopes = (Scopes *)cptr.data;
col = uiLayoutColumn(layout, true);
@@ -2794,12 +2813,14 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
uiLayout *col;
Scopes *scopes;
- if (!prop || RNA_property_type(prop) != PROP_POINTER)
+ if (!prop || RNA_property_type(prop) != PROP_POINTER) {
return;
+ }
cptr = RNA_property_pointer_get(ptr, prop);
- if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes))
+ if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
return;
+ }
scopes = (Scopes *)cptr.data;
if (scopes->vecscope_height < UI_UNIT_Y) {
@@ -2849,28 +2870,36 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
if (BLI_rctf_size_x(&cumap->curr) < 20.0f * BLI_rctf_size_x(&cumap->clipr)) {
d = d1 = 0.15f * BLI_rctf_size_x(&cumap->curr);
- if (cumap->flag & CUMA_DO_CLIP)
- if (cumap->curr.xmin - d < cumap->clipr.xmin)
+ if (cumap->flag & CUMA_DO_CLIP) {
+ if (cumap->curr.xmin - d < cumap->clipr.xmin) {
d1 = cumap->curr.xmin - cumap->clipr.xmin;
+ }
+ }
cumap->curr.xmin -= d1;
d1 = d;
- if (cumap->flag & CUMA_DO_CLIP)
- if (cumap->curr.xmax + d > cumap->clipr.xmax)
+ if (cumap->flag & CUMA_DO_CLIP) {
+ if (cumap->curr.xmax + d > cumap->clipr.xmax) {
d1 = -cumap->curr.xmax + cumap->clipr.xmax;
+ }
+ }
cumap->curr.xmax += d1;
d = d1 = 0.15f * BLI_rctf_size_y(&cumap->curr);
- if (cumap->flag & CUMA_DO_CLIP)
- if (cumap->curr.ymin - d < cumap->clipr.ymin)
+ if (cumap->flag & CUMA_DO_CLIP) {
+ if (cumap->curr.ymin - d < cumap->clipr.ymin) {
d1 = cumap->curr.ymin - cumap->clipr.ymin;
+ }
+ }
cumap->curr.ymin -= d1;
d1 = d;
- if (cumap->flag & CUMA_DO_CLIP)
- if (cumap->curr.ymax + d > cumap->clipr.ymax)
+ if (cumap->flag & CUMA_DO_CLIP) {
+ if (cumap->curr.ymax + d > cumap->clipr.ymax) {
d1 = -cumap->curr.ymax + cumap->clipr.ymax;
+ }
+ }
cumap->curr.ymax += d1;
}
@@ -3058,8 +3087,9 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
int a;
cumap->preset = CURVE_PRESET_LINE;
- for (a = 0; a < CM_TOT; a++)
+ for (a = 0; a < CM_TOT; a++) {
curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
+ }
cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f;
cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
@@ -3154,11 +3184,13 @@ static void curvemap_buttons_layout(
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
}
}
- else
+ else {
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
+ }
- if (labeltype == 'h')
+ if (labeltype == 'h') {
bg = UI_GRAD_H;
+ }
/* operation buttons */
sub = uiLayoutRow(row, true);
@@ -3171,16 +3203,19 @@ static void curvemap_buttons_layout(
bt = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_ZOOM_OUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom out"));
UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, NULL);
- if (brush)
+ if (brush) {
bt = uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_DOWNARROW_HLT, 0, 0, dx, dx, TIP_("Tools"));
- else if (neg_slope)
+ }
+ else if (neg_slope) {
bt = uiDefIconBlockBut(
block, curvemap_tools_negslope_func, cumap, 0, ICON_DOWNARROW_HLT,
0, 0, dx, dx, TIP_("Tools"));
- else
+ }
+ else {
bt = uiDefIconBlockBut(
block, curvemap_tools_posslope_func, cumap, 0, ICON_DOWNARROW_HLT,
0, 0, dx, dx, TIP_("Tools"));
+ }
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
@@ -3265,8 +3300,9 @@ void uiTemplateCurveMapping(
}
cptr = RNA_property_pointer_get(ptr, prop);
- if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping))
+ if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping)) {
return;
+ }
cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
cb->ptr = *ptr;
@@ -3338,45 +3374,42 @@ void uiTemplateColorPicker(
but->custom_data = cpicker;
- if (lock) {
- but->flag |= UI_BUT_COLOR_LOCK;
- }
+ cpicker->use_color_lock = lock;
+ cpicker->use_color_cubic = cubic;
+ cpicker->use_luminosity_lock = lock_luminosity;
if (lock_luminosity) {
float color[4]; /* in case of alpha */
- but->flag |= UI_BUT_VEC_SIZE_LOCK;
RNA_property_float_get_array(ptr, prop, color);
but->a2 = len_v3(color);
+ cpicker->luminosity_lock_value = len_v3(color);
}
- if (cubic)
- but->flag |= UI_BUT_COLOR_CUBIC;
-
if (value_slider) {
switch (U.color_picker_type) {
case USER_CP_CIRCLE_HSL:
uiItemS(row);
but = uiDefButR_prop(
- block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop,
+ block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14 * UI_DPI_FAC, WHEEL_SIZE, ptr, prop,
-1, softmin, softmax, UI_GRAD_L_ALT, 0, "");
break;
case USER_CP_SQUARE_SV:
uiItemS(col);
but = uiDefButR_prop(
- block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop,
+ block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18 * UI_DPI_FAC, ptr, prop,
-1, softmin, softmax, UI_GRAD_SV + 3, 0, "");
break;
case USER_CP_SQUARE_HS:
uiItemS(col);
but = uiDefButR_prop(
- block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop,
+ block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18 * UI_DPI_FAC, ptr, prop,
-1, softmin, softmax, UI_GRAD_HS + 3, 0, "");
break;
case USER_CP_SQUARE_HV:
uiItemS(col);
but = uiDefButR_prop(
- block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop,
+ block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18 * UI_DPI_FAC, ptr, prop,
-1, softmin, softmax, UI_GRAD_HV + 3, 0, "");
break;
@@ -3385,7 +3418,7 @@ void uiTemplateColorPicker(
default:
uiItemS(row);
but = uiDefButR_prop(
- block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop,
+ block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14 * UI_DPI_FAC, WHEEL_SIZE, ptr, prop,
-1, softmin, softmax, UI_GRAD_V_ALT, 0, "");
break;
}
@@ -3411,8 +3444,9 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname,
}
cptr = RNA_property_pointer_get(ptr, prop);
- if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette))
+ if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette)) {
return;
+ }
block = uiLayoutGetBlock(layout);
@@ -3483,8 +3517,9 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
/* Normally clicking only selects one layer */
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, true);
for (i = 0; i < tot; ++i) {
- if (i != cur)
+ if (i != cur) {
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, i, false);
+ }
}
}
@@ -3529,8 +3564,9 @@ void uiTemplateLayers(
return;
}
- if (RNA_property_array_length(used_ptr, used_prop) < layers)
+ if (RNA_property_array_length(used_ptr, used_prop) < layers) {
used_prop = NULL;
+ }
}
/* layers are laid out going across rows, with the columns being divided into groups */
@@ -3551,10 +3587,12 @@ void uiTemplateLayers(
int icon = 0;
int butlay = 1 << layer;
- if (active_layer & butlay)
+ if (active_layer & butlay) {
icon = ICON_LAYER_ACTIVE;
- else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer))
+ }
+ else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer)) {
icon = ICON_LAYER_USED;
+ }
but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2);
UI_but_func_set(but, handle_layer_buttons, but, POINTER_FROM_INT(layer));
@@ -3748,13 +3786,16 @@ static void uilist_prepare(
const bool use_auto_size = (ui_list->list_grip < (rows - UI_LIST_AUTO_SIZE_THRESHOLD));
/* default rows */
- if (rows <= 0)
+ if (rows <= 0) {
rows = 5;
+ }
dyn_data->visual_height_min = rows;
- if (maxrows < rows)
+ if (maxrows < rows) {
maxrows = max_ii(rows, 5);
- if (columns <= 0)
+ }
+ if (columns <= 0) {
columns = 9;
+ }
if (columns > 1) {
dyn_data->height = (int)ceil((double)len / (double)columns);
@@ -4087,8 +4128,9 @@ void uiTemplateList(
sub = uiLayoutRow(overlap, false);
icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false);
- if (icon == ICON_DOT)
+ if (icon == ICON_DOT) {
icon = ICON_NONE;
+ }
draw_item(ui_list, C, sub, dataptr, itemptr, icon, active_dataptr, active_propname,
org_i, flt_flag);
@@ -4124,8 +4166,9 @@ void uiTemplateList(
int org_i = items_ptr[activei].org_idx;
icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false);
- if (icon == ICON_DOT)
+ if (icon == ICON_DOT) {
icon = ICON_NONE;
+ }
draw_item(ui_list, C, row, dataptr, itemptr, icon, active_dataptr, active_propname, org_i, 0);
}
/* if list is empty, add in dummy button */
@@ -4138,8 +4181,9 @@ void uiTemplateList(
but = uiDefIconTextButR_prop(
block, UI_BTYPE_NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y,
active_dataptr, activeprop, 0, 0, 0, 0, 0, "");
- if (dyn_data->items_shown == 0)
+ if (dyn_data->items_shown == 0) {
UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
break;
case UILST_LAYOUT_GRID:
box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
@@ -4158,8 +4202,9 @@ void uiTemplateList(
int flt_flag = items_ptr[i].flt_flag;
/* create button */
- if (!(i % columns))
+ if (!(i % columns)) {
subrow = uiLayoutRow(col, false);
+ }
subblock = uiLayoutGetBlock(subrow);
overlap = uiLayoutOverlap(subrow);
@@ -4266,8 +4311,9 @@ static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2)
{
wmOperatorType *ot = arg2;
- if (ot)
+ if (ot) {
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL);
+ }
}
static bool has_word_prefix(const char *haystack, const char *needle, size_t needle_len)
@@ -4300,8 +4346,9 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
const char *ot_ui_name = CTX_IFACE_(ot->translation_context, ot->name);
int index;
- if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0)
+ if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) {
continue;
+ }
/* match name against all search words */
for (index = 0; index < words_len; index++) {
@@ -4328,8 +4375,9 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
}
}
- if (false == UI_search_item_add(items, name, ot, 0))
+ if (false == UI_search_item_add(items, name, ot, 0)) {
break;
+ }
}
}
}
@@ -4339,7 +4387,7 @@ void UI_but_func_operator_search(uiBut *but)
{
UI_but_func_search_set(
but, ui_searchbox_create_operator, operator_search_cb,
- NULL, operator_call_cb, NULL);
+ NULL, false, operator_call_cb, NULL);
}
void uiTemplateOperatorSearch(uiLayout *layout)
@@ -4457,6 +4505,7 @@ eAutoPropButsReturn uiTemplateOperatorPropertyButs(
layout, &ptr,
op->type->poll_property ? ui_layout_operator_buts_poll_property : NULL,
op->type->poll_property ? &user_data : NULL,
+ op->type->prop,
label_align, (flag & UI_TEMPLATE_OP_PROPS_COMPACT));
if ((return_info & UI_PROP_BUTS_NONE_ADDED) && (flag & UI_TEMPLATE_OP_PROPS_SHOW_EMPTY)) {
@@ -4593,14 +4642,16 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
UI_block_func_handle_set(block, do_running_jobs, NULL);
if (sa->spacetype == SPACE_SEQ) {
- if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY))
+ if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) {
owner = sa;
+ }
handle_event = B_STOPSEQ;
icon = ICON_SEQUENCE;
}
else if (sa->spacetype == SPACE_CLIP) {
- if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY))
+ if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) {
owner = sa;
+ }
handle_event = B_STOPCLIP;
icon = ICON_TRACKER;
}
@@ -4709,9 +4760,10 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
}
}
- if (screen->animtimer)
+ if (screen->animtimer) {
uiDefIconTextBut(block, UI_BTYPE_BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y,
NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop animation playback"));
+ }
}
/************************* Reports for Last Operator Template **************************/
@@ -4730,11 +4782,15 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
int icon;
/* if the report display has timed out, don't show */
- if (!reports->reporttimer) return;
+ if (!reports->reporttimer) {
+ return;
+ }
rti = (ReportTimerInfo *)reports->reporttimer->customdata;
- if (!rti || rti->widthfac == 0.0f || !report) return;
+ if (!rti || rti->widthfac == 0.0f || !report) {
+ return;
+ }
ui_abs = uiLayoutAbsolute(layout, false);
block = uiLayoutGetBlock(ui_abs);
@@ -4764,11 +4820,13 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
*/
UI_block_emboss_set(block, UI_EMBOSS_NONE);
- if (reports->list.first != reports->list.last)
+ if (reports->list.first != reports->list.last) {
uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, UI_UNIT_X,
UI_UNIT_Y, TIP_("Click to see the remaining reports in text block: 'Recent Reports'"));
- else
+ }
+ else {
uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ }
UI_block_emboss_set(block, UI_EMBOSS);
@@ -4830,8 +4888,9 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title,
uiItemS(layout);
- if (title)
+ if (title) {
uiItemL(layout, title, ICON_NONE);
+ }
flow = uiLayoutColumnFlow(layout, 2, false);
@@ -4947,8 +5006,9 @@ void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), P
col = uiLayoutColumn(layout, false);
uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE);
- if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES)
+ if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) {
uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', true, false, false, false);
+ }
}
/********************************* Component Menu *************************************/
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 7400e922b30..65abac968e3 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -61,25 +61,25 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
{
- int arraylen = RNA_property_array_length(ptr, prop);
-
- if (arraylen && index == -1)
+ if (RNA_property_array_check(prop) && index == -1) {
return NULL;
+ }
- if (icon && name && name[0] == '\0')
+ if (icon && name && name[0] == '\0') {
but = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
- else if (icon)
+ }
+ else if (icon) {
but = uiDefIconTextButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
- else
+ }
+ else {
but = uiDefButR_prop(block, UI_BTYPE_CHECKBOX, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
+ }
break;
}
case PROP_INT:
case PROP_FLOAT:
{
- int arraylen = RNA_property_array_length(ptr, prop);
-
- if (arraylen && index == -1) {
+ if (RNA_property_array_check(prop) && index == -1) {
if (ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) {
but = uiDefButR_prop(block, UI_BTYPE_COLOR, 0, name, x1, y1, x2, y2, ptr, prop, -1, 0, 0, -1, -1, NULL);
}
@@ -87,10 +87,12 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
return NULL;
}
}
- else if (RNA_property_subtype(prop) == PROP_PERCENTAGE || RNA_property_subtype(prop) == PROP_FACTOR)
+ else if (RNA_property_subtype(prop) == PROP_PERCENTAGE || RNA_property_subtype(prop) == PROP_FACTOR) {
but = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
- else
+ }
+ else {
but = uiDefButR_prop(block, UI_BTYPE_NUM, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
+ }
if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) {
UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE);
@@ -98,20 +100,26 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
break;
}
case PROP_ENUM:
- if (icon && name && name[0] == '\0')
+ if (icon && name && name[0] == '\0') {
but = uiDefIconButR_prop(block, UI_BTYPE_MENU, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
- else if (icon)
+ }
+ else if (icon) {
but = uiDefIconTextButR_prop(block, UI_BTYPE_MENU, 0, icon, NULL, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
- else
+ }
+ else {
but = uiDefButR_prop(block, UI_BTYPE_MENU, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
+ }
break;
case PROP_STRING:
- if (icon && name && name[0] == '\0')
+ if (icon && name && name[0] == '\0') {
but = uiDefIconButR_prop(block, UI_BTYPE_TEXT, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
- else if (icon)
+ }
+ else if (icon) {
but = uiDefIconTextButR_prop(block, UI_BTYPE_TEXT, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
- else
+ }
+ else {
but = uiDefButR_prop(block, UI_BTYPE_TEXT, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
+ }
if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) {
/* TEXTEDIT_UPDATE is usually used for search buttons. For these we also want
@@ -125,8 +133,9 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
PointerRNA pptr = RNA_property_pointer_get(ptr, prop);
icon = RNA_struct_ui_icon(pptr.type ? pptr.type : RNA_property_pointer_type(ptr, prop));
}
- if (icon == ICON_DOT)
+ if (icon == ICON_DOT) {
icon = 0;
+ }
but = uiDefIconTextButR_prop(block, UI_BTYPE_SEARCH_MENU, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
break;
@@ -150,20 +159,22 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
/**
* \a check_prop callback filters functions to avoid drawing certain properties,
* in cases where PROP_HIDDEN flag can't be used for a property.
+ *
+ * \param prop_activate_init: Property to activate on initial popup (#UI_BUT_ACTIVATE_ON_INIT).
*/
eAutoPropButsReturn uiDefAutoButsRNA(
uiLayout *layout, PointerRNA *ptr,
bool (*check_prop)(PointerRNA *ptr, PropertyRNA *prop, void *user_data), void *user_data,
+ PropertyRNA *prop_activate_init,
const eButLabelAlign label_align, const bool compact)
{
eAutoPropButsReturn return_info = UI_PROP_BUTS_NONE_ADDED;
uiLayout *split, *col;
- int flag;
const char *name;
RNA_STRUCT_BEGIN (ptr, prop)
{
- flag = RNA_property_flag(prop);
+ const int flag = RNA_property_flag(prop);
if (flag & PROP_HIDDEN) {
continue;
@@ -173,11 +184,11 @@ eAutoPropButsReturn uiDefAutoButsRNA(
continue;
}
+ const PropertyType type = RNA_property_type(prop);
switch (label_align) {
case UI_BUT_LABEL_ALIGN_COLUMN:
case UI_BUT_LABEL_ALIGN_SPLIT_COLUMN:
{
- PropertyType type = RNA_property_type(prop);
const bool is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
name = RNA_property_ui_name(prop);
@@ -185,8 +196,9 @@ eAutoPropButsReturn uiDefAutoButsRNA(
if (label_align == UI_BUT_LABEL_ALIGN_COLUMN) {
col = uiLayoutColumn(layout, true);
- if (!is_boolean)
+ if (!is_boolean) {
uiItemL(col, name, ICON_NONE);
+ }
}
else {
BLI_assert(label_align == UI_BUT_LABEL_ALIGN_SPLIT_COLUMN);
@@ -212,8 +224,22 @@ eAutoPropButsReturn uiDefAutoButsRNA(
break;
}
+ /* Only buttons that can be edited as text. */
+ const bool use_activate_init = (
+ (prop == prop_activate_init) &&
+ (ELEM(type, PROP_STRING, PROP_INT, PROP_FLOAT)));
+
+ if (use_activate_init) {
+ uiLayoutSetActivateInit(col, true);
+ }
+
uiItemFullR(col, ptr, prop, -1, 0, compact ? UI_ITEM_R_COMPACT : 0, name, ICON_NONE);
return_info &= ~UI_PROP_BUTS_NONE_ADDED;
+
+ if (use_activate_init) {
+ uiLayoutSetActivateInit(col, false);
+ }
+
}
RNA_STRUCT_END;
@@ -235,10 +261,12 @@ static int sort_search_items_list(const void *a, const void *b)
const CollItemSearch *cis1 = a;
const CollItemSearch *cis2 = b;
- if (BLI_strcasecmp(cis1->name, cis2->name) > 0)
+ if (BLI_strcasecmp(cis1->name, cis2->name) > 0) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char *str, uiSearchItems *items)
@@ -254,14 +282,17 @@ void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char
RNA_PROP_BEGIN (&data->search_ptr, itemptr, data->search_prop)
{
- if (flag & PROP_ID_SELF_CHECK)
- if (itemptr.data == data->target_ptr.id.data)
+ if (flag & PROP_ID_SELF_CHECK) {
+ if (itemptr.data == data->target_ptr.id.data) {
continue;
+ }
+ }
/* use filter */
if (RNA_property_type(data->target_prop) == PROP_POINTER) {
- if (RNA_property_pointer_poll(&data->target_ptr, data->target_prop, &itemptr) == 0)
+ if (RNA_property_pointer_poll(&data->target_ptr, data->target_prop, &itemptr) == 0) {
continue;
+ }
}
name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */
@@ -310,8 +341,9 @@ int UI_icon_from_id(ID *id)
PointerRNA ptr;
short idcode;
- if (id == NULL)
+ if (id == NULL) {
return ICON_NONE;
+ }
idcode = GS(id->name);
@@ -319,10 +351,12 @@ int UI_icon_from_id(ID *id)
if (idcode == ID_OB) {
ob = (Object *)id;
- if (ob->type == OB_EMPTY)
+ if (ob->type == OB_EMPTY) {
return ICON_EMPTY_DATA;
- else
+ }
+ else {
return UI_icon_from_id(ob->data);
+ }
}
/* otherwise get it through RNA, creating the pointer
@@ -335,14 +369,18 @@ int UI_icon_from_id(ID *id)
/* see: report_type_str */
int UI_icon_from_report_type(int type)
{
- if (type & RPT_ERROR_ALL)
+ if (type & RPT_ERROR_ALL) {
return ICON_ERROR;
- else if (type & RPT_WARNING_ALL)
+ }
+ else if (type & RPT_WARNING_ALL) {
return ICON_ERROR;
- else if (type & RPT_INFO_ALL)
+ }
+ else if (type & RPT_INFO_ALL) {
return ICON_INFO;
- else
+ }
+ else {
return ICON_NONE;
+ }
}
/********************************** Misc **************************************/
@@ -586,8 +624,9 @@ void UI_butstore_update(uiBlock *block)
}
}
- if (LIKELY(block->butstore.first == NULL))
+ if (LIKELY(block->butstore.first == NULL)) {
return;
+ }
/* warning, loop-in-loop, in practice we only store <10 buttons at a time,
* so this isn't going to be a problem, if that changes old-new mapping can be cached first */
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 7e43ac8c850..6528faca265 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -61,6 +61,54 @@
/* icons are 80% of height of button (16 pixels inside 20 height) */
#define ICON_SIZE_FROM_BUTRECT(rect) (0.8f * BLI_rcti_size_y(rect))
+/* visual types for drawing */
+/* for time being separated from functional types */
+typedef enum {
+ /* default */
+ UI_WTYPE_REGULAR,
+
+ /* standard set */
+ UI_WTYPE_LABEL,
+ UI_WTYPE_TOGGLE,
+ UI_WTYPE_CHECKBOX,
+ UI_WTYPE_RADIO,
+ UI_WTYPE_NUMBER,
+ UI_WTYPE_SLIDER,
+ UI_WTYPE_EXEC,
+ UI_WTYPE_TOOLBAR_ITEM,
+ UI_WTYPE_TAB,
+ UI_WTYPE_TOOLTIP,
+
+ /* strings */
+ UI_WTYPE_NAME,
+ UI_WTYPE_NAME_LINK,
+ UI_WTYPE_POINTER_LINK,
+ UI_WTYPE_FILENAME,
+
+ /* menus */
+ UI_WTYPE_MENU_RADIO,
+ UI_WTYPE_MENU_ICON_RADIO,
+ UI_WTYPE_MENU_POINTER_LINK,
+ UI_WTYPE_MENU_NODE_LINK,
+
+ UI_WTYPE_PULLDOWN,
+ UI_WTYPE_MENU_ITEM,
+ UI_WTYPE_MENU_ITEM_RADIAL,
+ UI_WTYPE_MENU_BACK,
+
+ /* specials */
+ UI_WTYPE_ICON,
+ UI_WTYPE_ICON_LABEL,
+ UI_WTYPE_SWATCH,
+ UI_WTYPE_RGB_PICKER,
+ UI_WTYPE_UNITVEC,
+ UI_WTYPE_BOX,
+ UI_WTYPE_SCROLL,
+ UI_WTYPE_LISTITEM,
+ UI_WTYPE_PROGRESSBAR,
+} uiWidgetTypeEnum;
+
+
/* Button state argument shares bits with 'uiBut.flag'.
* reuse flags that aren't needed for drawing to avoid collision. */
enum {
@@ -69,11 +117,14 @@ enum {
UI_STATE_TEXT_INPUT = UI_BUT_UNDO,
UI_STATE_ACTIVE_LEFT = UI_BUT_VALUE_CLEAR,
UI_STATE_ACTIVE_RIGHT = UI_BUT_TEXTEDIT_UPDATE,
-
- UI_STATE_FLAGS_ALL = (UI_STATE_HOLD_ACTION |
- UI_STATE_TEXT_INPUT |
- UI_STATE_ACTIVE_LEFT |
- UI_STATE_ACTIVE_RIGHT),
+ UI_STATE_TEXT_BEFORE_WIDGET = UI_BUT_IMMEDIATE,
+
+ UI_STATE_FLAGS_ALL = (
+ UI_STATE_HOLD_ACTION |
+ UI_STATE_TEXT_INPUT |
+ UI_STATE_ACTIVE_LEFT |
+ UI_STATE_ACTIVE_RIGHT |
+ UI_STATE_TEXT_BEFORE_WIDGET),
};
/* Prevent accidental use. */
#define UI_BUT_UPDATE_DELAY ((void)0)
@@ -219,7 +270,7 @@ static const uint g_shape_preset_hold_action_face[2][3] = {{2, 0, 1}, {3, 5, 4}}
* In order to speed up UI drawing we create some batches that are then
* modified by specialized shaders to draw certain elements really fast.
* TODO: find a better place. Maybe it's own file?
- **/
+ */
/* offset in triavec[] in shader per type */
static const int tria_ofs[ROUNDBOX_TRIA_MAX] = {
@@ -388,16 +439,20 @@ GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased)
GPUBatch **batch = NULL;
if (filled) {
- if (antialiased)
+ if (antialiased) {
batch = &g_ui_batch_cache.roundbox_simple_aa;
- else
+ }
+ else {
batch = &g_ui_batch_cache.roundbox_simple;
+ }
}
else {
- if (antialiased)
+ if (antialiased) {
BLI_assert(0); /* Use GL_LINE_SMOOTH instead!!: */
- else
+ }
+ else {
batch = &g_ui_batch_cache.roundbox_simple_outline;
+ }
}
if (*batch == NULL) {
@@ -602,8 +657,9 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad,
rad += step;
- if (2.0f * rad > BLI_rcti_size_y(rect))
+ if (2.0f * rad > BLI_rcti_size_y(rect)) {
rad = 0.5f * BLI_rcti_size_y(rect);
+ }
minx = rect->xmin - step;
miny = rect->ymin - step;
@@ -695,11 +751,13 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, const rcti *re
BLI_rcti_size_x(rect) * hnum,
BLI_rcti_size_y(rect) * vnum);
- if (2.0f * rad > minsize)
+ if (2.0f * rad > minsize) {
rad = 0.5f * minsize;
+ }
- if (2.0f * (radi + 1.0f) > minsize)
+ if (2.0f * (radi + 1.0f) > minsize) {
radi = 0.5f * minsize - U.pixelsize;
+ }
wt->uniform_params.rad = rad;
wt->uniform_params.radi = radi;
@@ -935,8 +993,9 @@ static void widget_draw_vertex_buffer(uint pos, uint col, int mode,
{
immBegin(mode, totvert);
for (int i = 0; i < totvert; ++i) {
- if (quads_col)
+ if (quads_col) {
immAttr4ubv(col, quads_col[i]);
+ }
immVertex2fv(pos, quads_pos[i]);
}
immEnd();
@@ -1096,8 +1155,9 @@ void UI_widgetbase_draw_cache_flush(void)
{
float checker_params[3] = {UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 8.0f};
- if (g_widget_base_batch.count == 0)
+ if (g_widget_base_batch.count == 0) {
return;
+ }
GPUBatch *batch = g_widget_base_batch.batch;
if (g_widget_base_batch.count == 1) {
@@ -1256,8 +1316,9 @@ static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect)
{
int w, h, size;
- if (icon == ICON_NONE)
+ if (icon == ICON_NONE) {
return;
+ }
w = BLI_rcti_size_x(rect);
h = BLI_rcti_size_y(rect);
@@ -1295,16 +1356,24 @@ static void widget_draw_icon(
}
/* this icon doesn't need draw... */
- if (icon == ICON_BLANK1 && (but->flag & UI_BUT_ICON_SUBMENU) == 0) return;
+ if (icon == ICON_BLANK1 && (but->flag & UI_BUT_ICON_SUBMENU) == 0) {
+ return;
+ }
aspect = but->block->aspect / UI_DPI_FAC;
height = ICON_DEFAULT_HEIGHT / aspect;
/* calculate blend color */
if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_ROW, UI_BTYPE_TOGGLE_N, UI_BTYPE_LISTROW)) {
- if (but->flag & UI_SELECT) {}
- else if (but->flag & UI_ACTIVE) {}
- else alpha = 0.75f;
+ if (but->flag & UI_SELECT) {
+ /* pass */
+ }
+ else if (but->flag & UI_ACTIVE) {
+ /* pass */
+ }
+ else {
+ alpha = 0.75f;
+ }
}
else if ((but->type == UI_BTYPE_LABEL)) {
/* extra feature allows more alpha blending */
@@ -1325,12 +1394,15 @@ static void widget_draw_icon(
if (but->drawflag & UI_BUT_ICON_LEFT) {
/* special case - icon_only pie buttons */
- if (ui_block_is_pie_menu(but->block) && !ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && but->str && but->str[0] == '\0')
+ if (ui_block_is_pie_menu(but->block) && !ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && but->str && but->str[0] == '\0') {
xs = rect->xmin + 2.0f * ofs;
- else if (but->dt == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL)
+ }
+ else if (but->dt == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL) {
xs = rect->xmin + 2.0f * ofs;
- else
+ }
+ else {
xs = rect->xmin + 4.0f * ofs;
+ }
}
else {
xs = (rect->xmin + rect->xmax - height) / 2.0f;
@@ -1453,7 +1525,8 @@ float UI_text_clip_middle_ex(
/* need to set this first */
UI_fontstyle_set(fstyle);
- if (fstyle->kerning == 1) { /* for BLF_width */
+ if (fstyle->kerning == 1) {
+ /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
@@ -1602,15 +1675,19 @@ static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rct
/* need to set this first */
UI_fontstyle_set(fstyle);
- if (fstyle->kerning == 1) /* for BLF_width */
+ if (fstyle->kerning == 1) {
+ /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
/* define ofs dynamically */
- if (but->ofs > but->pos)
+ if (but->ofs > but->pos) {
but->ofs = but->pos;
+ }
- if (BLF_width(fstyle->uifont_id, but->editstr, INT_MAX) <= okwidth)
+ if (BLF_width(fstyle->uifont_id, but->editstr, INT_MAX) <= okwidth) {
but->ofs = 0;
+ }
but->strwidth = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, INT_MAX);
@@ -1630,17 +1707,21 @@ static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rct
else {
int bytes;
/* shift string to the left */
- if (width < 20 && but->ofs > 0)
+ if (width < 20 && but->ofs > 0) {
ui_text_clip_give_prev_off(but, but->editstr);
+ }
bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->editstr, but->editstr + len));
- if (bytes == -1)
+ if (bytes == -1) {
bytes = 1;
+ }
len -= bytes;
}
but->strwidth = BLF_width(fstyle->uifont_id, but->editstr + but->ofs, len - but->ofs);
- if (but->strwidth < 10) break;
+ if (but->strwidth < 10) {
+ break;
+ }
}
}
@@ -1665,8 +1746,10 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
/* need to set this first */
UI_fontstyle_set(fstyle);
- if (fstyle->kerning == 1) /* for BLF_width */
+ if (fstyle->kerning == 1) {
+ /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
but->ofs = 0;
@@ -1698,7 +1781,9 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
// BLI_assert(strlen(but->drawstr) == drawstr_len);
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
- if (but->strwidth < 10) break;
+ if (but->strwidth < 10) {
+ break;
+ }
}
@@ -1706,7 +1791,9 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
while ((but->strwidth > okwidth) && (but->ofs < 2)) {
ui_text_clip_give_next_off(but, but->drawstr);
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
- if (but->strwidth < 10) break;
+ if (but->strwidth < 10) {
+ break;
+ }
}
}
@@ -1722,8 +1809,9 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
but->drawstr[drawstr_len] = 0;
}
- if (fstyle->kerning == 1)
+ if (fstyle->kerning == 1) {
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
}
#ifdef WITH_INPUT_IME
@@ -1797,9 +1885,10 @@ static void widget_draw_text(const uiFontStyle *fstyle, const uiWidgetColors *wc
align = UI_STYLE_TEXT_CENTER;
}
- if (fstyle->kerning == 1) /* for BLF_width */
+ if (fstyle->kerning == 1) {
+ /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-
+ }
/* Special case: when we're entering text for multiple buttons,
* don't draw the text for any of the multi-editing buttons */
@@ -1923,8 +2012,9 @@ static void widget_draw_text(const uiFontStyle *fstyle, const uiWidgetColors *wc
#endif
}
- if (fstyle->kerning == 1)
+ if (fstyle->kerning == 1) {
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
+ }
#if 0
ui_rasterpos_safe(x, y, but->aspect);
@@ -1987,8 +2077,9 @@ static void widget_draw_text(const uiFontStyle *fstyle, const uiWidgetColors *wc
BLI_strncpy(fixedbuf, drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawlen));
str = strchr(fixedbuf, but->menu_key - 32); /* upper case */
- if (str == NULL)
+ if (str == NULL) {
str = strchr(fixedbuf, but->menu_key);
+ }
if (str) {
int ul_index = -1;
@@ -2124,11 +2215,13 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, const uiWidgetColor
/* pass (even if its a menu toolbar) */
}
else if (ui_block_is_pie_menu(but->block)) {
- if (but->dt == UI_EMBOSS_RADIAL)
+ if (but->dt == UI_EMBOSS_RADIAL) {
rect->xmin += 0.3f * U.widget_unit;
+ }
}
- else if (ui_block_is_menu(but->block))
+ else if (ui_block_is_menu(but->block)) {
rect->xmin += 0.2f * U.widget_unit;
+ }
widget_draw_icon(but, icon, alpha, rect, wcol->text);
if (show_menu_icon) {
@@ -2143,11 +2236,21 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, const uiWidgetColor
rect->xmin += icon_size + icon_padding;
}
- if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) {
- rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
+ int text_padding = (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
+ if (but->editstr) {
+ rect->xmin += text_padding;
+ }
+ else if (but->flag & UI_BUT_DRAG_MULTI) {
+ bool text_is_edited = ui_but_drag_multi_edit_get(but) != NULL;
+ if (text_is_edited) {
+ rect->xmin += text_padding;
+ }
+ }
+ else if (but->drawflag & UI_BUT_TEXT_LEFT) {
+ rect->xmin += text_padding;
}
- else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
- rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
+ else if (but->drawflag & UI_BUT_TEXT_RIGHT) {
+ rect->xmax -= text_padding;
}
/* Menu contains sub-menu items with triangle icon on their right. Shortcut
@@ -2263,33 +2366,44 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag)
if (state & UI_SELECT) {
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
- if (drawflag & UI_BUT_ANIMATED_CHANGED)
+ if (drawflag & UI_BUT_ANIMATED_CHANGED) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_changed_sel, wcol_state->blend);
- else if (state & UI_BUT_ANIMATED_KEY)
+ }
+ else if (state & UI_BUT_ANIMATED_KEY) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_key_sel, wcol_state->blend);
- else if (state & UI_BUT_ANIMATED)
+ }
+ else if (state & UI_BUT_ANIMATED) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_anim_sel, wcol_state->blend);
- else if (state & UI_BUT_DRIVEN)
+ }
+ else if (state & UI_BUT_DRIVEN) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_driven_sel, wcol_state->blend);
- else if (state & UI_BUT_OVERRIDEN)
+ }
+ else if (state & UI_BUT_OVERRIDEN) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_overridden_sel, wcol_state->blend);
+ }
copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
- if (state & UI_SELECT)
+ if (state & UI_SELECT) {
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
+ }
}
else {
- if (drawflag & UI_BUT_ANIMATED_CHANGED)
+ if (drawflag & UI_BUT_ANIMATED_CHANGED) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_changed, wcol_state->blend);
- else if (state & UI_BUT_ANIMATED_KEY)
+ }
+ else if (state & UI_BUT_ANIMATED_KEY) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_key, wcol_state->blend);
- else if (state & UI_BUT_ANIMATED)
+ }
+ else if (state & UI_BUT_ANIMATED) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_anim, wcol_state->blend);
- else if (state & UI_BUT_DRIVEN)
+ }
+ else if (state & UI_BUT_DRIVEN) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_driven, wcol_state->blend);
- else if (state & UI_BUT_OVERRIDEN)
+ }
+ else if (state & UI_BUT_OVERRIDEN) {
widget_state_blend(wt->wcol.inner, wcol_state->inner_overridden, wcol_state->blend);
+ }
if (state & UI_ACTIVE) { /* mouse over? */
widget_active_color(wt->wcol.inner);
@@ -2333,31 +2447,42 @@ static void widget_state_numslider(uiWidgetType *wt, int state, int drawflag)
/* TODO: maybe we should have separate settings for the blending colors used for this case? */
if (state & UI_SELECT) {
- if (drawflag & UI_BUT_ANIMATED_CHANGED)
+ if (drawflag & UI_BUT_ANIMATED_CHANGED) {
widget_state_blend(wt->wcol.item, wcol_state->inner_changed_sel, blend);
- else if (state & UI_BUT_ANIMATED_KEY)
+ }
+ else if (state & UI_BUT_ANIMATED_KEY) {
widget_state_blend(wt->wcol.item, wcol_state->inner_key_sel, blend);
- else if (state & UI_BUT_ANIMATED)
+ }
+ else if (state & UI_BUT_ANIMATED) {
widget_state_blend(wt->wcol.item, wcol_state->inner_anim_sel, blend);
- else if (state & UI_BUT_DRIVEN)
+ }
+ else if (state & UI_BUT_DRIVEN) {
widget_state_blend(wt->wcol.item, wcol_state->inner_driven_sel, blend);
- else if (state & UI_BUT_OVERRIDEN)
+ }
+ else if (state & UI_BUT_OVERRIDEN) {
widget_state_blend(wt->wcol.item, wcol_state->inner_overridden_sel, blend);
+ }
- if (state & UI_SELECT)
+ if (state & UI_SELECT) {
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
+ }
}
else {
- if (drawflag & UI_BUT_ANIMATED_CHANGED)
+ if (drawflag & UI_BUT_ANIMATED_CHANGED) {
widget_state_blend(wt->wcol.item, wcol_state->inner_changed, blend);
- else if (state & UI_BUT_ANIMATED_KEY)
+ }
+ else if (state & UI_BUT_ANIMATED_KEY) {
widget_state_blend(wt->wcol.item, wcol_state->inner_key, blend);
- else if (state & UI_BUT_ANIMATED)
+ }
+ else if (state & UI_BUT_ANIMATED) {
widget_state_blend(wt->wcol.item, wcol_state->inner_anim, blend);
- else if (state & UI_BUT_DRIVEN)
+ }
+ else if (state & UI_BUT_DRIVEN) {
widget_state_blend(wt->wcol.item, wcol_state->inner_driven, blend);
- else if (state & UI_BUT_OVERRIDEN)
+ }
+ else if (state & UI_BUT_OVERRIDEN) {
widget_state_blend(wt->wcol.item, wcol_state->inner_overridden, blend);
+ }
}
}
@@ -2370,10 +2495,12 @@ static void widget_state_option_menu(uiWidgetType *wt, int state, int drawflag)
widget_state(wt, state, drawflag);
/* if not selected we get theme from menu back */
- if (state & UI_SELECT)
+ if (state & UI_SELECT) {
copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel);
- else
+ }
+ else {
copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text);
+ }
}
@@ -2464,14 +2591,17 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
const float radout = UI_ThemeMenuShadowWidth();
/* disabled shadow */
- if (radout == 0.0f)
+ if (radout == 0.0f) {
return;
+ }
/* prevent tooltips to not show round shadow */
- if (radout > 0.2f * BLI_rcti_size_y(&rect1))
+ if (radout > 0.2f * BLI_rcti_size_y(&rect1)) {
rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1);
- else
+ }
+ else {
rect1.ymax -= radout;
+ }
/* inner part */
totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f);
@@ -2550,8 +2680,8 @@ static void ui_hsv_cursor(float x, float y)
}
void ui_hsvcircle_vals_from_pos(
- float *val_rad, float *val_dist, const rcti *rect,
- const float mx, const float my)
+ const rcti *rect, const float mx, const float my,
+ float *r_val_rad, float *r_val_dist)
{
/* duplication of code... well, simple is better now */
const float centx = BLI_rcti_cent_x_fl(rect);
@@ -2560,12 +2690,14 @@ void ui_hsvcircle_vals_from_pos(
const float m_delta[2] = {mx - centx, my - centy};
const float dist_sq = len_squared_v2(m_delta);
- *val_dist = (dist_sq < (radius * radius)) ? sqrtf(dist_sq) / radius : 1.0f;
- *val_rad = atan2f(m_delta[0], m_delta[1]) / (2.0f * (float)M_PI) + 0.5f;
+ *r_val_dist = (dist_sq < (radius * radius)) ? sqrtf(dist_sq) / radius : 1.0f;
+ *r_val_rad = atan2f(m_delta[0], m_delta[1]) / (2.0f * (float)M_PI) + 0.5f;
}
/* cursor in hsv circle, in float units -1 to 1, to map on radius */
-void ui_hsvcircle_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *xpos, float *ypos)
+void ui_hsvcircle_pos_from_vals(
+ const ColorPicker *cpicker, const rcti *rect, const float *hsv,
+ float *r_xpos, float *r_ypos)
{
/* duplication of code... well, simple is better now */
const float centx = BLI_rcti_cent_x_fl(rect);
@@ -2575,14 +2707,16 @@ void ui_hsvcircle_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float
ang = 2.0f * (float)M_PI * hsv[0] + (float)M_PI_2;
- if ((but->flag & UI_BUT_COLOR_CUBIC) && (U.color_picker_type == USER_CP_CIRCLE_HSV))
+ if (cpicker->use_color_cubic && (U.color_picker_type == USER_CP_CIRCLE_HSV)) {
radius_t = (1.0f - pow3f(1.0f - hsv[1]));
- else
+ }
+ else {
radius_t = hsv[1];
+ }
radius = clamp_f(radius_t, 0.0f, 1.0f) * radius;
- *xpos = centx + cosf(-ang) * radius;
- *ypos = centy + sinf(-ang) * radius;
+ *r_xpos = centx + cosf(-ang) * radius;
+ *r_ypos = centy + sinf(-ang) * radius;
}
static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const rcti *rect)
@@ -2612,11 +2746,13 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
/* exception: if 'lock' is set
* lock the value of the color wheel to 1.
* Useful for color correction tools where you're only interested in hue. */
- if (but->flag & UI_BUT_COLOR_LOCK) {
- if (U.color_picker_type == USER_CP_CIRCLE_HSV)
+ if (cpicker->use_color_lock) {
+ if (U.color_picker_type == USER_CP_CIRCLE_HSV) {
hsv[2] = 1.0f;
- else
+ }
+ else {
hsv[2] = 0.5f;
+ }
}
const float hsv_center[3] = {0.0f, 0.0f, hsv[2]};
@@ -2644,7 +2780,9 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
float hsv_ang[3];
float rgb_ang[3];
- ui_hsvcircle_vals_from_pos(hsv_ang, hsv_ang + 1, rect, centx + co * radius, centy + si * radius);
+ ui_hsvcircle_vals_from_pos(
+ rect, centx + co * radius, centy + si * radius,
+ hsv_ang, hsv_ang + 1);
hsv_ang[2] = hsv[2];
ui_color_picker_to_rgb_v(hsv_ang, rgb_ang);
@@ -2684,7 +2822,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
ui_rgb_to_color_picker_compat_v(rgb, hsv);
float xpos, ypos;
- ui_hsvcircle_pos_from_vals(but, rect, hsv, &xpos, &ypos);
+ ui_hsvcircle_pos_from_vals(cpicker, rect, hsv, &xpos, &ypos);
ui_hsv_cursor(xpos, ypos);
}
@@ -2841,7 +2979,9 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
immUnbindProgram();
}
-void ui_hsvcube_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp)
+void ui_hsvcube_pos_from_vals(
+ const uiBut *but, const rcti *rect, const float *hsv,
+ float *r_xp, float *r_yp)
{
float x = 0.0f, y = 0.0f;
@@ -2871,8 +3011,8 @@ void ui_hsvcube_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *x
}
/* cursor */
- *xp = rect->xmin + x * BLI_rcti_size_x(rect);
- *yp = rect->ymin + y * BLI_rcti_size_y(rect);
+ *r_xp = rect->xmin + x * BLI_rcti_size_x(rect);
+ *r_yp = rect->ymin + y * BLI_rcti_size_y(rect);
}
static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
@@ -2919,10 +3059,12 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
ui_but_v3_get(but, rgb);
ui_scene_linear_to_color_picker_space(but, rgb);
- if (but->a1 == UI_GRAD_L_ALT)
+ if (but->a1 == UI_GRAD_L_ALT) {
rgb_to_hsl_v(rgb, hsv);
- else
+ }
+ else {
rgb_to_hsv_v(rgb, hsv);
+ }
v = hsv[2];
/* map v from property range to [0,1] */
@@ -3011,8 +3153,9 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int
const float rad = wcol->roundness * BLI_rcti_size_y(rect);
const int handle_width = min_ii(BLI_rcti_size_x(rect) / 3, BLI_rcti_size_y(rect) * 0.7f);
- if (state & UI_SELECT)
+ if (state & UI_SELECT) {
SWAP(short, wcol->shadetop, wcol->shadedown);
+ }
widget_init(&wtb);
@@ -3131,16 +3274,19 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
/* determine horizontal/vertical */
horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
- if (horizontal)
+ if (horizontal) {
rad = wcol->roundness * BLI_rcti_size_y(rect);
- else
+ }
+ else {
rad = wcol->roundness * BLI_rcti_size_x(rect);
+ }
wtb.uniform_params.shade_dir = (horizontal) ? 1.0f : 0.0;
/* draw back part, colors swapped and shading inverted */
- if (horizontal)
+ if (horizontal) {
SWAP(short, wcol->shadetop, wcol->shadedown);
+ }
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
widgetbase_draw(&wtb, wcol);
@@ -3154,9 +3300,12 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
copy_v4_v4_char(wcol->inner, wcol->item);
- if (wcol->shadetop > wcol->shadedown)
+ if (wcol->shadetop > wcol->shadedown) {
wcol->shadetop += 20; /* XXX violates themes... */
- else wcol->shadedown += 20;
+ }
+ else {
+ wcol->shadedown += 20;
+ }
if (state & UI_SCROLL_PRESSED) {
wcol->inner[0] = wcol->inner[0] >= 250 ? 255 : wcol->inner[0] + 5;
@@ -3175,9 +3324,15 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
round_box_edges(&wtb, UI_CNR_ALL, slider, rad);
if (state & UI_SCROLL_ARROWS) {
- if (wcol->item[0] > 48) wcol->item[0] -= 48;
- if (wcol->item[1] > 48) wcol->item[1] -= 48;
- if (wcol->item[2] > 48) wcol->item[2] -= 48;
+ if (wcol->item[0] > 48) {
+ wcol->item[0] -= 48;
+ }
+ if (wcol->item[1] > 48) {
+ wcol->item[1] -= 48;
+ }
+ if (wcol->item[2] > 48) {
+ wcol->item[2] -= 48;
+ }
wcol->item[3] = 255;
if (horizontal) {
@@ -3251,10 +3406,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
}
}
- if (state & UI_SELECT)
+ if (state & UI_SELECT) {
state = UI_SCROLL_PRESSED;
- else
+ }
+ else {
state = 0;
+ }
UI_draw_widget_scroll(wcol, rect, &rect1, state);
}
@@ -3417,8 +3574,9 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
round_box_edges(&wtb, roundboxalign, rect, rad);
}
- if (!ui_but_is_color_gamma(but))
+ if (!ui_but_is_color_gamma(but)) {
ui_block_cm_to_display_space_v3(but->block, col);
+ }
rgba_float_to_uchar((uchar *)wcol->inner, col);
const bool show_alpha_checkers = (wcol->inner[3] < 255);
@@ -3493,8 +3651,9 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun
uiWidgetBase wtb;
float rad;
- if (state & UI_SELECT)
+ if (state & UI_SELECT) {
SWAP(short, wcol->shadetop, wcol->shadedown);
+ }
widget_init(&wtb);
@@ -3621,6 +3780,7 @@ static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta
static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
{
+ bool text_before_widget = (state & UI_STATE_TEXT_BEFORE_WIDGET);
uiWidgetBase wtb;
rcti recttemp = *rect;
float rad;
@@ -3629,7 +3789,12 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
widget_init(&wtb);
/* square */
- recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp);
+ if (text_before_widget) {
+ recttemp.xmin = recttemp.xmax - BLI_rcti_size_y(&recttemp);
+ }
+ else {
+ recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp);
+ }
/* smaller */
delta = 1 + BLI_rcti_size_y(&recttemp) / 8;
@@ -3649,7 +3814,13 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
widgetbase_draw(&wtb, wcol);
/* text space */
- rect->xmin += BLI_rcti_size_y(rect) * 0.7 + delta;
+ const float offset = BLI_rcti_size_y(rect) * 0.7 + delta;
+ if (text_before_widget) {
+ rect->xmax -= offset;
+ }
+ else {
+ rect->xmin += offset;
+ }
}
/* labels use Editor theme colors for text */
@@ -3665,10 +3836,12 @@ static void widget_state_label(uiWidgetType *wt, int state, int drawflag)
else {
/* call this for option button */
widget_state(wt, state, drawflag);
- if (state & UI_SELECT)
+ if (state & UI_SELECT) {
UI_GetThemeColor3ubv(TH_TEXT_HI, (uchar *)wt->wcol.text);
- else
+ }
+ else {
UI_GetThemeColor3ubv(TH_TEXT, (uchar *)wt->wcol.text);
+ }
}
if (state & UI_BUT_REDALERT) {
@@ -4030,10 +4203,12 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
if ((but->drawflag & UI_BUT_ALIGN) && but->type != UI_BTYPE_PULLDOWN) {
/* ui_popup_block_position has this correction too, keep in sync */
- if (but->drawflag & (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_STITCH_TOP))
+ if (but->drawflag & (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_STITCH_TOP)) {
rect->ymax += U.pixelsize;
- if (but->drawflag & (UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_STITCH_LEFT))
+ }
+ if (but->drawflag & (UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_STITCH_LEFT)) {
rect->xmin -= U.pixelsize;
+ }
switch (but->drawflag & UI_BUT_ALIGN) {
case UI_BUT_ALIGN_TOP:
@@ -4070,10 +4245,10 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
if (but->active && (but->type != UI_BTYPE_POPOVER)) {
int direction = ui_but_menu_direction(but);
- if (direction == UI_DIR_UP) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT);
- else if (direction == UI_DIR_DOWN) roundbox &= ~(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
- else if (direction == UI_DIR_LEFT) roundbox &= ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
- else if (direction == UI_DIR_RIGHT) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
+ if (direction == UI_DIR_UP) { roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT); }
+ else if (direction == UI_DIR_DOWN) { roundbox &= ~(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); }
+ else if (direction == UI_DIR_LEFT) { roundbox &= ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); }
+ else if (direction == UI_DIR_RIGHT) { roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); }
}
return roundbox;
@@ -4199,10 +4374,13 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case UI_BTYPE_CHECKBOX_N:
if (!(but->flag & UI_HAS_ICON)) {
wt = widget_type(UI_WTYPE_CHECKBOX);
- but->drawflag |= UI_BUT_TEXT_LEFT;
+ if ((but->drawflag & (UI_BUT_TEXT_LEFT | UI_BUT_TEXT_RIGHT)) == 0) {
+ but->drawflag |= UI_BUT_TEXT_LEFT;
+ }
}
- else
+ else {
wt = widget_type(UI_WTYPE_TOGGLE);
+ }
/* option buttons have strings outside, on menus use different colors */
if (but->block->theme_style == UI_BLOCK_THEME_STYLE_POPUP) {
@@ -4359,47 +4537,69 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
}
}
- if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
- if (but->dt != UI_EMBOSS_PULLDOWN)
+ if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
+ if (but->dt != UI_EMBOSS_PULLDOWN) {
disabled = true;
+ }
+ }
+
+ if (drawflag & UI_BUT_TEXT_RIGHT) {
+ state |= UI_STATE_TEXT_BEFORE_WIDGET;
+ }
- if (disabled)
+ if (disabled) {
ui_widget_color_disabled(wt);
+ }
wt->state(wt, state, drawflag);
- if (wt->custom)
+ if (wt->custom) {
wt->custom(but, &wt->wcol, rect, state, roundboxalign);
- else if (wt->draw)
+ }
+ else if (wt->draw) {
wt->draw(&wt->wcol, rect, state, roundboxalign);
+ }
- if (disabled)
+ if (disabled) {
GPU_blend(true);
+ }
+
+ bool show_semi_highlight = false;
#ifdef USE_UI_POPOVER_ONCE
if (but->block->flag & UI_BLOCK_POPOVER_ONCE) {
if ((state & UI_ACTIVE) && ui_but_is_popover_once_compat(but)) {
- uiWidgetType wt_back = *wt;
- uiWidgetType *wt_temp = widget_type(UI_WTYPE_MENU_ITEM);
- wt_temp->state(wt_temp, state, drawflag);
- copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
- wt->wcol.inner[3] = 128;
- wt->wcol.roundness = 0.5f;
- ui_draw_roundbox(
- &rect_orig,
- 0.25f * min_ff(BLI_rcti_size_x(&rect_orig), BLI_rcti_size_y(&rect_orig)),
- &wt_temp->wcol);
- *wt = wt_back;
+ show_semi_highlight = true;
}
}
#endif
+ if (but->flag & UI_BUT_ACTIVE_DEFAULT) {
+ show_semi_highlight = true;
+ }
+
+ if (show_semi_highlight) {
+ uiWidgetType wt_back = *wt;
+ uiWidgetType *wt_temp = widget_type(UI_WTYPE_MENU_ITEM);
+ wt_temp->state(wt_temp, state, drawflag);
+ copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
+ wt->wcol.inner[3] = 128;
+ wt->wcol.roundness = 0.5f;
+ ui_draw_roundbox(
+ &rect_orig,
+ 0.25f * min_ff(BLI_rcti_size_x(&rect_orig), BLI_rcti_size_y(&rect_orig)),
+ &wt_temp->wcol);
+ *wt = wt_back;
+ }
wt->text(fstyle, &wt->wcol, but, rect);
- if (disabled)
+ if (disabled) {
GPU_blend(false);
+ }
-// if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
-// if (but->dt != UI_EMBOSS_PULLDOWN)
+// if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
+// if (but->dt != UI_EMBOSS_PULLDOWN) {
// widget_disabled(&disablerect);
+// }
+// }
}
}
@@ -4430,10 +4630,12 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
wt->state(wt, 0, 0);
- if (block)
+ if (block) {
wt->draw(&wt->wcol, rect, block->flag, block->direction);
- else
+ }
+ else {
wt->draw(&wt->wcol, rect, 0, 0);
+ }
ui_draw_clip_tri(block, rect, wt);
}
@@ -4498,7 +4700,7 @@ void ui_draw_popover_back(ARegion *ar, uiStyle *UNUSED(style), uiBlock *block, r
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
if (block) {
- float mval_origin[2] = {block->mx, block->my};
+ float mval_origin[2] = {UNPACK2(block->bounds_offset)};
ui_window_to_block_fl(ar, block, &mval_origin[0], &mval_origin[1]);
ui_draw_popover_back_impl(wt->wcol_theme, rect, block->direction, U.widget_unit / block->aspect, mval_origin);
}
@@ -4619,11 +4821,7 @@ void ui_draw_pie_center(uiBlock *block)
float pie_confirm_radius = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm);
float pie_confirm_external = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm + 7.0f);
- const char col[4] = {btheme->tui.wcol_pie_menu.text_sel[0],
- btheme->tui.wcol_pie_menu.text_sel[1],
- btheme->tui.wcol_pie_menu.text_sel[2],
- 64};
-
+ const char col[4] = {UNPACK3(btheme->tui.wcol_pie_menu.text_sel), 64};
draw_disk_shaded(angle - range / 2.0f, range, pie_confirm_radius, pie_confirm_external, subd, col, NULL, false);
}
@@ -4641,7 +4839,7 @@ const uiWidgetColors *ui_tooltip_get_theme(void)
/**
* Generic drawing for background.
*/
-void ui_draw_widget_back_color(
+static void ui_draw_widget_back_color(
uiWidgetTypeEnum type, bool use_shadow, const rcti *rect,
const float color[4])
{
@@ -4661,9 +4859,14 @@ void ui_draw_widget_back_color(
}
wt->draw(&wt->wcol, &rect_copy, 0, UI_CNR_ALL);
}
-void ui_draw_widget_back(uiWidgetTypeEnum type, bool use_shadow, const rcti *rect)
+void ui_draw_widget_menu_back_color(const rcti *rect, bool use_shadow, const float color[4])
+{
+ ui_draw_widget_back_color(UI_WTYPE_MENU_BACK, use_shadow, rect, color);
+}
+
+void ui_draw_widget_menu_back(const rcti *rect, bool use_shadow)
{
- ui_draw_widget_back_color(type, use_shadow, rect, NULL);
+ ui_draw_widget_back_color(UI_WTYPE_MENU_BACK, use_shadow, rect, NULL);
}
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect)
@@ -4689,7 +4892,9 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, rcti *rect, const char *name,
/* text location offset */
rect->xmin += 0.25f * UI_UNIT_X;
- if (iconid) rect->xmin += UI_DPI_ICON_SIZE;
+ if (iconid) {
+ rect->xmin += UI_DPI_ICON_SIZE;
+ }
/* cut string in 2 parts? */
if (use_sep) {
@@ -4700,7 +4905,8 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, rcti *rect, const char *name,
/* need to set this first */
UI_fontstyle_set(fstyle);
- if (fstyle->kerning == 1) { /* for BLF_width */
+ if (fstyle->kerning == 1) {
+ /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
@@ -4781,8 +4987,9 @@ void ui_draw_preview_item(const uiFontStyle *fstyle, rcti *rect, const char *nam
trect.xmax = trect.xmin + font_dims[0] + U.widget_unit / 2;
trect.ymin += U.widget_unit / 2;
trect.ymax = trect.ymin + font_dims[1];
- if (trect.xmax > rect->xmax - PREVIEW_PAD)
+ if (trect.xmax > rect->xmax - PREVIEW_PAD) {
trect.xmax = rect->xmax - PREVIEW_PAD;
+ }
{
char drawstr[UI_MAX_DRAW_STR];
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 48b24da8f5c..72739b99e14 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -167,18 +167,24 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
switch (colorid) {
case TH_BACK:
- if (ELEM(theme_regionid, RGN_TYPE_WINDOW, RGN_TYPE_PREVIEW))
+ if (ELEM(theme_regionid, RGN_TYPE_WINDOW, RGN_TYPE_PREVIEW)) {
cp = ts->back;
- else if (theme_regionid == RGN_TYPE_CHANNELS)
+ }
+ else if (theme_regionid == RGN_TYPE_CHANNELS) {
cp = ts->list;
- else if (theme_regionid == RGN_TYPE_HEADER)
+ }
+ else if (theme_regionid == RGN_TYPE_HEADER) {
cp = ts->header;
- else if (theme_regionid == RGN_TYPE_NAV_BAR)
+ }
+ else if (theme_regionid == RGN_TYPE_NAV_BAR) {
cp = ts->navigation_bar;
- else if (theme_regionid == RGN_TYPE_EXECUTE)
+ }
+ else if (theme_regionid == RGN_TYPE_EXECUTE) {
cp = ts->execution_buts;
- else
+ }
+ else {
cp = ts->button;
+ }
copy_v4_v4_char(back, cp);
if (!ED_region_is_overlap(spacetype, theme_regionid)) {
@@ -195,34 +201,46 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
setting = ts->show_back_grad;
break;
case TH_TEXT:
- if (theme_regionid == RGN_TYPE_WINDOW)
+ if (theme_regionid == RGN_TYPE_WINDOW) {
cp = ts->text;
- else if (theme_regionid == RGN_TYPE_CHANNELS)
+ }
+ else if (theme_regionid == RGN_TYPE_CHANNELS) {
cp = ts->list_text;
- else if (theme_regionid == RGN_TYPE_HEADER)
+ }
+ else if (theme_regionid == RGN_TYPE_HEADER) {
cp = ts->header_text;
- else
+ }
+ else {
cp = ts->button_text;
+ }
break;
case TH_TEXT_HI:
- if (theme_regionid == RGN_TYPE_WINDOW)
+ if (theme_regionid == RGN_TYPE_WINDOW) {
cp = ts->text_hi;
- else if (theme_regionid == RGN_TYPE_CHANNELS)
+ }
+ else if (theme_regionid == RGN_TYPE_CHANNELS) {
cp = ts->list_text_hi;
- else if (theme_regionid == RGN_TYPE_HEADER)
+ }
+ else if (theme_regionid == RGN_TYPE_HEADER) {
cp = ts->header_text_hi;
- else
+ }
+ else {
cp = ts->button_text_hi;
+ }
break;
case TH_TITLE:
- if (theme_regionid == RGN_TYPE_WINDOW)
+ if (theme_regionid == RGN_TYPE_WINDOW) {
cp = ts->title;
- else if (theme_regionid == RGN_TYPE_CHANNELS)
+ }
+ else if (theme_regionid == RGN_TYPE_CHANNELS) {
cp = ts->list_title;
- else if (theme_regionid == RGN_TYPE_HEADER)
+ }
+ else if (theme_regionid == RGN_TYPE_HEADER) {
cp = ts->header_title;
- else
+ }
+ else {
cp = ts->button_title;
+ }
break;
case TH_HEADER:
@@ -1135,6 +1153,16 @@ void UI_GetThemeColor4ubv(int colorid, uchar col[4])
col[3] = cp[3];
}
+void UI_GetThemeColorType3fv(int colorid, int spacetype, float col[3])
+{
+ const uchar *cp;
+
+ cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
+ col[0] = ((float)cp[0]) / 255.0f;
+ col[1] = ((float)cp[1]) / 255.0f;
+ col[2] = ((float)cp[2]) / 255.0f;
+}
+
void UI_GetThemeColorType3ubv(int colorid, int spacetype, uchar col[3])
{
const uchar *cp;
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index bb49f024bc3..7d5a2e73113 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -103,10 +103,12 @@ BLI_INLINE void clamp_rctf_to_rcti(rcti *dst, const rctf *src)
*/
static int view2d_scroll_mapped(int scroll)
{
- if (scroll & V2D_SCROLL_HORIZONTAL_FULLR)
+ if (scroll & V2D_SCROLL_HORIZONTAL_FULLR) {
scroll &= ~(V2D_SCROLL_HORIZONTAL);
- if (scroll & V2D_SCROLL_VERTICAL_FULLR)
+ }
+ if (scroll & V2D_SCROLL_VERTICAL_FULLR) {
scroll &= ~(V2D_SCROLL_VERTICAL);
+ }
return scroll;
}
@@ -137,18 +139,22 @@ static void view2d_masks(View2D *v2d, bool check_scrollers, const rcti *mask_scr
/* check size if hiding flag is set: */
if (v2d->scroll & V2D_SCROLL_HORIZONTAL_HIDE) {
if (!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)) {
- if (BLI_rctf_size_x(&v2d->tot) > BLI_rctf_size_x(&v2d->cur))
+ if (BLI_rctf_size_x(&v2d->tot) > BLI_rctf_size_x(&v2d->cur)) {
v2d->scroll &= ~V2D_SCROLL_HORIZONTAL_FULLR;
- else
+ }
+ else {
v2d->scroll |= V2D_SCROLL_HORIZONTAL_FULLR;
+ }
}
}
if (v2d->scroll & V2D_SCROLL_VERTICAL_HIDE) {
if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)) {
- if (BLI_rctf_size_y(&v2d->tot) + 0.01f > BLI_rctf_size_y(&v2d->cur))
+ if (BLI_rctf_size_y(&v2d->tot) + 0.01f > BLI_rctf_size_y(&v2d->cur)) {
v2d->scroll &= ~V2D_SCROLL_VERTICAL_FULLR;
- else
+ }
+ else {
v2d->scroll |= V2D_SCROLL_VERTICAL_FULLR;
+ }
}
}
}
@@ -377,10 +383,12 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* set 'tot' rect before setting cur? */
/* XXX confusing stuff here still -
* I made this function not check scroller hide - that happens in totrect_set */
- if (tot_changed)
+ if (tot_changed) {
UI_view2d_totRect_set_resize(v2d, winx, winy, !do_init);
- else
+ }
+ else {
ui_view2d_curRect_validate_resize(v2d, !do_init, 0);
+ }
}
@@ -423,19 +431,29 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
curheight = height = BLI_rctf_size_y(cur);
/* if zoom is locked, size on the appropriate axis is reset to mask size */
- if (v2d->keepzoom & V2D_LOCKZOOM_X)
+ if (v2d->keepzoom & V2D_LOCKZOOM_X) {
width = winx;
- if (v2d->keepzoom & V2D_LOCKZOOM_Y)
+ }
+ if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
height = winy;
+ }
/* values used to divide, so make it safe
* NOTE: width and height must use FLT_MIN instead of 1, otherwise it is impossible to
* get enough resolution in Graph Editor for editing some curves
*/
- if (width < FLT_MIN) width = 1;
- if (height < FLT_MIN) height = 1;
- if (winx < 1) winx = 1;
- if (winy < 1) winy = 1;
+ if (width < FLT_MIN) {
+ width = 1;
+ }
+ if (height < FLT_MIN) {
+ height = 1;
+ }
+ if (winx < 1) {
+ winx = 1;
+ }
+ if (winy < 1) {
+ winy = 1;
+ }
/* V2D_LIMITZOOM indicates that zoom level should be preserved when the window size changes */
if (resize && (v2d->keepzoom & V2D_KEEPZOOM)) {
@@ -445,16 +463,18 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
zoom = winx / width;
oldzoom = v2d->oldwinx / curwidth;
- if (oldzoom != zoom)
+ if (oldzoom != zoom) {
width *= zoom / oldzoom;
+ }
}
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
zoom = winy / height;
oldzoom = v2d->oldwiny / curheight;
- if (oldzoom != zoom)
+ if (oldzoom != zoom) {
height *= zoom / oldzoom;
+ }
}
}
/* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits
@@ -499,8 +519,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
/* when a window edge changes, the aspect ratio can't be used to
* find which is the best new 'cur' rect. that's why it stores 'old'
*/
- if (winx != v2d->oldwinx) do_x = true;
- if (winy != v2d->oldwiny) do_y = true;
+ if (winx != v2d->oldwinx) {
+ do_x = true;
+ }
+ if (winy != v2d->oldwiny) {
+ do_y = true;
+ }
curRatio = height / width;
winRatio = winy / winx;
@@ -509,8 +533,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
if (do_x == do_y) {
if (do_x && do_y) {
/* here is 1,1 case, so all others must be 0,0 */
- if (fabsf(winx - v2d->oldwinx) > fabsf(winy - v2d->oldwiny)) do_y = false;
- else do_x = false;
+ if (fabsf(winx - v2d->oldwinx) > fabsf(winy - v2d->oldwiny)) {
+ do_y = false;
+ }
+ else {
+ do_x = false;
+ }
}
else if (winRatio > curRatio) {
do_x = false;
@@ -587,10 +615,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
cur->xmax += width - BLI_rctf_size_x(cur);
}
else if (v2d->keepofs & V2D_KEEPOFS_X) {
- if (v2d->align & V2D_ALIGN_NO_POS_X)
+ if (v2d->align & V2D_ALIGN_NO_POS_X) {
cur->xmin -= width - BLI_rctf_size_x(cur);
- else
+ }
+ else {
cur->xmax += width - BLI_rctf_size_x(cur);
+ }
}
else {
temp = BLI_rctf_cent_x(cur);
@@ -605,10 +635,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
cur->ymax += height - BLI_rctf_size_y(cur);
}
else if (v2d->keepofs & V2D_KEEPOFS_Y) {
- if (v2d->align & V2D_ALIGN_NO_POS_Y)
+ if (v2d->align & V2D_ALIGN_NO_POS_Y) {
cur->ymin -= height - BLI_rctf_size_y(cur);
- else
+ }
+ else {
cur->ymax += height - BLI_rctf_size_y(cur);
+ }
}
else {
temp = BLI_rctf_cent_y(cur);
@@ -631,8 +663,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
/* width */
if ((curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM))) {
/* if zoom doesn't have to be maintained, just clamp edges */
- if (cur->xmin < tot->xmin) cur->xmin = tot->xmin;
- if (cur->xmax > tot->xmax) cur->xmax = tot->xmax;
+ if (cur->xmin < tot->xmin) {
+ cur->xmin = tot->xmin;
+ }
+ if (cur->xmax > tot->xmax) {
+ cur->xmax = tot->xmax;
+ }
}
else if (v2d->keeptot == V2D_KEEPTOT_STRICT) {
/* This is an exception for the outliner (and later channel-lists, headers)
@@ -715,8 +751,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
/* height */
if ((curheight > totheight) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_Y | V2D_LIMITZOOM))) {
/* if zoom doesn't have to be maintained, just clamp edges */
- if (cur->ymin < tot->ymin) cur->ymin = tot->ymin;
- if (cur->ymax > tot->ymax) cur->ymax = tot->ymax;
+ if (cur->ymin < tot->ymin) {
+ cur->ymin = tot->ymin;
+ }
+ if (cur->ymax > tot->ymax) {
+ cur->ymax = tot->ymax;
+ }
}
else {
/* This here occurs when:
@@ -814,8 +854,9 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
ARegion *ar;
/* don't continue if no view syncing to be done */
- if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME | V2D_VIEWSYNC_AREA_VERTICAL)) == 0)
+ if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME | V2D_VIEWSYNC_AREA_VERTICAL)) == 0) {
return;
+ }
/* check if doing within area syncing (i.e. channels/vertical) */
if ((v2dcur->flag & V2D_VIEWSYNC_AREA_VERTICAL) && (area)) {
@@ -936,14 +977,17 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
/* hrumf! */
/* XXX: there are work arounds for this in the panel and file browse code. */
/* round to int, because this is called with width + V2D_SCROLL_WIDTH */
-// if (scroll & V2D_SCROLL_HORIZONTAL)
+// if (scroll & V2D_SCROLL_HORIZONTAL) {
// width -= (int)V2D_SCROLL_WIDTH;
-// if (scroll & V2D_SCROLL_VERTICAL)
+// }
+// if (scroll & V2D_SCROLL_VERTICAL) {
// height -= (int)V2D_SCROLL_HEIGHT;
+// }
if (ELEM(0, width, height)) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n", (void *)v2d, width, height); // XXX temp debug info
+ }
return;
}
@@ -1012,10 +1056,12 @@ bool UI_view2d_tab_set(View2D *v2d, int tab)
/* if tab changed, change offset */
if (tab != v2d->tab_cur && v2d->tab_offset) {
- if (tab < v2d->tab_num)
+ if (tab < v2d->tab_num) {
offset = &v2d->tab_offset[tab * 2];
- else
+ }
+ else {
offset = default_offset;
+ }
v2d->cur.xmax += offset[0] - v2d->cur.xmin;
v2d->cur.xmin = offset[0];
@@ -1069,9 +1115,9 @@ void UI_view2d_zoom_cache_reset(void)
/* View Matrix Setup */
/* mapping function to ensure 'cur' draws extended over the area where sliders are */
-static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
+static void view2d_map_cur_using_mask(View2D *v2d, rctf *r_curmasked)
{
- *curmasked = v2d->cur;
+ *r_curmasked = v2d->cur;
if (view2d_scroll_mapped(v2d->scroll)) {
float sizex = BLI_rcti_size_x(&v2d->mask);
@@ -1083,15 +1129,19 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1);
float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1);
- if (v2d->mask.xmin != 0)
- curmasked->xmin -= dx * (float)v2d->mask.xmin;
- if (v2d->mask.xmax + 1 != v2d->winx)
- curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1);
+ if (v2d->mask.xmin != 0) {
+ r_curmasked->xmin -= dx * (float)v2d->mask.xmin;
+ }
+ if (v2d->mask.xmax + 1 != v2d->winx) {
+ r_curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1);
+ }
- if (v2d->mask.ymin != 0)
- curmasked->ymin -= dy * (float)v2d->mask.ymin;
- if (v2d->mask.ymax + 1 != v2d->winy)
- curmasked->ymax += dy * (float)(v2d->winy - v2d->mask.ymax - 1);
+ if (v2d->mask.ymin != 0) {
+ r_curmasked->ymin -= dy * (float)v2d->mask.ymin;
+ }
+ if (v2d->mask.ymax + 1 != v2d->winy) {
+ r_curmasked->ymax += dy * (float)(v2d->winy - v2d->mask.ymax - 1);
+ }
}
}
}
@@ -1110,10 +1160,12 @@ void UI_view2d_view_ortho(View2D *v2d)
*/
/* XXX brecht: instead of zero at least use a tiny offset, otherwise
* pixel rounding is effectively random due to float inaccuracy */
- if (sizex > 0)
+ if (sizex > 0) {
xofs = eps * BLI_rctf_size_x(&v2d->cur) / sizex;
- if (sizey > 0)
+ }
+ if (sizey > 0) {
yofs = eps * BLI_rctf_size_y(&v2d->cur) / sizey;
+ }
/* apply mask-based adjustments to cur rect (due to scrollers),
* to eliminate scaling artifacts */
@@ -1157,10 +1209,12 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, const bool xaxis)
view2d_map_cur_using_mask(v2d, &curmasked);
/* only set matrix with 'cur' coordinates on relevant axes */
- if (xaxis)
+ if (xaxis) {
wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, -yofs, ar->winy - yofs);
- else
+ }
+ else {
wmOrtho2(-xofs, ar->winx - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs);
+ }
}
@@ -1190,22 +1244,28 @@ struct View2DGrid {
/* --------------- */
/* try to write step as a power of 10 */
-static void step_to_grid(float *step, int *power, int unit)
+static void step_to_grid(float *step, const int unit, int *r_power)
{
const float loga = (float)log10(*step);
float rem;
- *power = (int)(loga);
+ int power = (int)(loga);
- rem = loga - (*power);
+ rem = loga - power;
rem = (float)pow(10.0, rem);
if (loga < 0.0f) {
- if (rem < 0.2f) rem = 0.2f;
- else if (rem < 0.5f) rem = 0.5f;
- else rem = 1.0f;
+ if (rem < 0.2f) {
+ rem = 0.2f;
+ }
+ else if (rem < 0.5f) {
+ rem = 0.5f;
+ }
+ else {
+ rem = 1.0f;
+ }
- *step = rem * (float)pow(10.0, (*power));
+ *step = rem * (float)pow(10.0, power);
/* for frames, we want 1.0 frame intervals only */
if (unit == V2D_UNIT_FRAMES) {
@@ -1216,19 +1276,31 @@ static void step_to_grid(float *step, int *power, int unit)
}
/* prevents printing 1.0 2.0 3.0 etc */
- if (rem == 1.0f) (*power)++;
+ if (rem == 1.0f) {
+ power++;
+ }
}
else {
- if (rem < 2.0f) rem = 2.0f;
- else if (rem < 5.0f) rem = 5.0f;
- else rem = 10.0f;
+ if (rem < 2.0f) {
+ rem = 2.0f;
+ }
+ else if (rem < 5.0f) {
+ rem = 5.0f;
+ }
+ else {
+ rem = 10.0f;
+ }
- *step = rem * (float)pow(10.0, (*power));
+ *step = rem * (float)pow(10.0, power);
- (*power)++;
+ power++;
/* prevents printing 1.0, 2.0, 3.0, etc. */
- if (rem == 10.0f) (*power)++;
+ if (rem == 10.0f) {
+ power++;
+ }
}
+
+ *r_power = power;
}
/**
@@ -1254,8 +1326,9 @@ View2DGrid *UI_view2d_grid_calc(
float space, seconddiv;
/* check that there are at least some workable args */
- if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp))
+ if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp)) {
return NULL;
+ }
/* grid here is allocated... */
grid = MEM_callocN(sizeof(View2DGrid), "View2DGrid");
@@ -1276,7 +1349,7 @@ View2DGrid *UI_view2d_grid_calc(
const float pixels = (float)BLI_rcti_size_x(&v2d->mask);
if (pixels != 0.0f) {
grid->dx = (U.v2d_min_gridsize * UI_DPI_FAC * space) / (seconddiv * pixels);
- step_to_grid(&grid->dx, &grid->powerx, xunits);
+ step_to_grid(&grid->dx, xunits, &grid->powerx);
grid->dx *= seconddiv;
}
}
@@ -1295,7 +1368,7 @@ View2DGrid *UI_view2d_grid_calc(
const float pixels = (float)winy;
if (pixels != 0.0f) {
grid->dy = U.v2d_min_gridsize * UI_DPI_FAC * space / pixels;
- step_to_grid(&grid->dy, &grid->powery, yunits);
+ step_to_grid(&grid->dy, yunits, &grid->powery);
}
}
@@ -1308,17 +1381,23 @@ View2DGrid *UI_view2d_grid_calc(
/* calculate start position */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
grid->startx = seconddiv * (v2d->cur.xmin / seconddiv - (float)fmod(v2d->cur.xmin / seconddiv, grid->dx / seconddiv));
- if (v2d->cur.xmin < 0.0f) grid->startx -= grid->dx;
+ if (v2d->cur.xmin < 0.0f) {
+ grid->startx -= grid->dx;
+ }
}
- else
+ else {
grid->startx = v2d->cur.xmin;
+ }
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
grid->starty = (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy));
- if (v2d->cur.ymin < 0.0f) grid->starty -= grid->dy;
+ if (v2d->cur.ymin < 0.0f) {
+ grid->starty -= grid->dy;
+ }
}
- else
+ else {
grid->starty = v2d->cur.ymin;
+ }
return grid;
}
@@ -1328,13 +1407,14 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
{
float vec1[2], vec2[2];
int a, step;
- int vertical_minor_step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC),
- horizontal_major_step = (BLI_rcti_size_y(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC);
+ int vertical_minor_step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC);
+ int horizontal_major_step = (BLI_rcti_size_y(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC);
uchar grid_line_color[3];
/* check for grid first, as it may not exist */
- if (grid == NULL)
+ if (grid == NULL) {
return;
+ }
/* Count the needed vertices for the gridlines */
unsigned vertex_count = 0;
@@ -1348,18 +1428,22 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vertex_count += 2 * (horizontal_major_step + 1); /* major gridlines */
/* fine lines */
- if (flag & V2D_HORIZONTAL_FINELINES)
+ if (flag & V2D_HORIZONTAL_FINELINES) {
vertex_count += 2 * (horizontal_major_step + 1);
+ }
}
/* axes */
- if (flag & V2D_HORIZONTAL_AXIS)
+ if (flag & V2D_HORIZONTAL_AXIS) {
vertex_count += 2;
- if (flag & V2D_VERTICAL_AXIS)
+ }
+ if (flag & V2D_VERTICAL_AXIS) {
vertex_count += 2;
+ }
/* If there is nothing to render, exit early */
- if (vertex_count == 0)
+ if (vertex_count == 0) {
return;
+ }
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -1481,26 +1565,34 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step)
int count_x, count_y;
start_x = v2d->cur.xmin;
- if (start_x < 0.0)
+ if (start_x < 0.0) {
start_x += -(float)fmod(v2d->cur.xmin, step);
- else
+ }
+ else {
start_x += (step - (float)fmod(v2d->cur.xmin, step));
+ }
- if (start_x > v2d->cur.xmax)
+ if (start_x > v2d->cur.xmax) {
count_x = 0;
- else
+ }
+ else {
count_x = (v2d->cur.xmax - start_x) / step + 1;
+ }
start_y = v2d->cur.ymin;
- if (start_y < 0.0)
+ if (start_y < 0.0) {
start_y += -(float)fmod(v2d->cur.ymin, step);
- else
+ }
+ else {
start_y += (step - (float)fabs(fmod(v2d->cur.ymin, step)));
+ }
- if (start_y > v2d->cur.ymax)
+ if (start_y > v2d->cur.ymax) {
count_y = 0;
- else
+ }
+ else {
count_y = (v2d->cur.ymax - start_y) / step + 1;
+ }
if (count_x > 0 || count_y > 0) {
GPUVertFormat *format = immVertexFormat();
@@ -1542,8 +1634,9 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step)
void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_size, int totlevels)
{
/* Exit if there is nothing to draw */
- if (totlevels == 0)
+ if (totlevels == 0) {
return;
+ }
int offset = -10;
float lstep = step;
@@ -1567,13 +1660,15 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color);
int i = (int)(v2d->cur.xmin / lstep);
- if (v2d->cur.xmin > 0.0f)
+ if (v2d->cur.xmin > 0.0f) {
i++;
+ }
float start = i * lstep;
for (; start < v2d->cur.xmax; start += lstep, ++i) {
- if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
+ if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) {
continue;
+ }
immAttrSkip(color);
immVertex2f(pos, start, v2d->cur.ymin);
@@ -1582,13 +1677,15 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
}
i = (int)(v2d->cur.ymin / lstep);
- if (v2d->cur.ymin > 0.0f)
+ if (v2d->cur.ymin > 0.0f) {
i++;
+ }
start = i * lstep;
for (; start < v2d->cur.ymax; start += lstep, ++i) {
- if (i == 0 || (level < totlevels - 1 && i % level_size == 0))
+ if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) {
continue;
+ }
immAttrSkip(color);
immVertex2f(pos, v2d->cur.xmin, start);
@@ -1684,15 +1781,19 @@ View2DScrollers *UI_view2d_scrollers_calc(
/* width of sliders */
smaller = (int)(0.1f * U.widget_unit);
- if (scroll & V2D_SCROLL_BOTTOM)
+ if (scroll & V2D_SCROLL_BOTTOM) {
hor.ymin += smaller;
- else
+ }
+ else {
hor.ymax -= smaller;
+ }
- if (scroll & V2D_SCROLL_LEFT)
+ if (scroll & V2D_SCROLL_LEFT) {
vert.xmin += smaller;
- else
+ }
+ else {
vert.xmax -= smaller;
+ }
CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
@@ -1711,23 +1812,30 @@ View2DScrollers *UI_view2d_scrollers_calc(
/* scroller 'button' extents */
totsize = BLI_rctf_size_x(&v2d->tot);
scrollsize = (float)BLI_rcti_size_x(&hor);
- if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
+ if (totsize == 0.0f) {
+ totsize = 1.0f; /* avoid divide by zero */
+ }
fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize;
- if (fac1 <= 0.0f)
+ if (fac1 <= 0.0f) {
scrollers->hor_min = hor.xmin;
- else
+ }
+ else {
scrollers->hor_min = (int)(hor.xmin + (fac1 * scrollsize));
+ }
fac2 = (v2d->cur.xmax - v2d->tot.xmin) / totsize;
- if (fac2 >= 1.0f)
+ if (fac2 >= 1.0f) {
scrollers->hor_max = hor.xmax;
- else
+ }
+ else {
scrollers->hor_max = (int)(hor.xmin + (fac2 * scrollsize));
+ }
/* prevent inverted sliders */
- if (scrollers->hor_min > scrollers->hor_max)
+ if (scrollers->hor_min > scrollers->hor_max) {
scrollers->hor_min = scrollers->hor_max;
+ }
/* prevent sliders from being too small, and disappearing */
if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLLER_HANDLE_SIZE) {
scrollers->hor_max = scrollers->hor_min + V2D_SCROLLER_HANDLE_SIZE;
@@ -1743,23 +1851,30 @@ View2DScrollers *UI_view2d_scrollers_calc(
/* scroller 'button' extents */
totsize = BLI_rctf_size_y(&v2d->tot);
scrollsize = (float)BLI_rcti_size_y(&vert);
- if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
+ if (totsize == 0.0f) {
+ totsize = 1.0f; /* avoid divide by zero */
+ }
fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize;
- if (fac1 <= 0.0f)
+ if (fac1 <= 0.0f) {
scrollers->vert_min = vert.ymin;
- else
+ }
+ else {
scrollers->vert_min = (int)(vert.ymin + (fac1 * scrollsize));
+ }
fac2 = (v2d->cur.ymax - v2d->tot.ymin) / totsize;
- if (fac2 >= 1.0f)
+ if (fac2 >= 1.0f) {
scrollers->vert_max = vert.ymax;
- else
+ }
+ else {
scrollers->vert_max = (int)(vert.ymin + (fac2 * scrollsize));
+ }
/* prevent inverted sliders */
- if (scrollers->vert_min > scrollers->vert_max)
+ if (scrollers->vert_min > scrollers->vert_max) {
scrollers->vert_min = scrollers->vert_max;
+ }
/* prevent sliders from being too small, and disappearing */
if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLLER_HANDLE_SIZE) {
@@ -1821,10 +1936,12 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
len = strlen(timecode_str);
if (dir == 'h') {
/* seconds/timecode display has slightly longer strings... */
- if (unit == V2D_UNIT_SECONDS)
+ if (unit == V2D_UNIT_SECONDS) {
x -= 3 * len;
- else
+ }
+ else {
x -= 4 * len;
+ }
}
/* Add degree sympbol to end of string for vertical scrollbar? */
@@ -1916,8 +2033,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
dfac *= 2.0f;
}
}
- if (vs->xunits == V2D_UNIT_FRAMES)
+ if (vs->xunits == V2D_UNIT_FRAMES) {
grid->powerx = 1;
+ }
/* draw numbers in the appropriate range */
if (dfac > 0.0f) {
@@ -1928,8 +2046,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
for (; fac < hor.xmax - 0.5f * U.widget_unit; fac += dfac, val += grid->dx) {
/* make prints look nicer for scrollers */
- if (fac < hor.xmin + 0.5f * U.widget_unit)
+ if (fac < hor.xmin + 0.5f * U.widget_unit) {
continue;
+ }
switch (vs->xunits) {
case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/
@@ -2018,8 +2137,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* if vertical clamping (to whole numbers) is used (i.e. in Sequencer),
* apply correction */
- if (vs->yclamp == V2D_GRID_CLAMP)
+ if (vs->yclamp == V2D_GRID_CLAMP) {
fac += 0.5f * dfac;
+ }
/* draw vertical steps */
if (dfac > 0.0f) {
@@ -2029,8 +2149,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
for (; fac < vert.ymax - 10; fac += dfac, val += grid->dy) {
/* make prints look nicer for scrollers */
- if (fac < vert.ymin + 10)
+ if (fac < vert.ymin + 10) {
continue;
+ }
scroll_printstr(scene, (float)(vert.xmax) - 2.0f, fac, val, grid->powery, vs->yunits, 'v');
}
@@ -2115,11 +2236,11 @@ void UI_view2d_listview_cell_to_view(
* (like for Animation Editor channel lists, to make the first entry more visible), these will be
* the min-coordinates of the first item.
* \param viewx, viewy: 2D-coordinates (in 2D-view / 'tot' rect space) to get the cell for
- * \param column, row: the 'coordinates' of the relevant 'cell'
+ * \param r_column, r_row: the 'coordinates' of the relevant 'cell'
*/
void UI_view2d_listview_view_to_cell(
View2D *v2d, float columnwidth, float rowheight, float startx, float starty,
- float viewx, float viewy, int *column, int *row)
+ float viewx, float viewy, int *r_column, int *r_row)
{
/* adjust view coordinates to be all positive ints, corrected for the start offset */
const int x = (int)(floorf(fabsf(viewx) + 0.5f) - startx);
@@ -2127,23 +2248,31 @@ void UI_view2d_listview_view_to_cell(
/* sizes must not be negative */
if ((v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0))) {
- if (column) *column = 0;
- if (row) *row = 0;
+ if (r_column) {
+ *r_column = 0;
+ }
+ if (r_row) {
+ *r_row = 0;
+ }
return;
}
/* get column */
- if ((column) && (columnwidth > 0))
- *column = x / columnwidth;
- else if (column)
- *column = 0;
+ if ((r_column) && (columnwidth > 0)) {
+ *r_column = x / columnwidth;
+ }
+ else if (r_column) {
+ *r_column = 0;
+ }
/* get row */
- if ((row) && (rowheight > 0))
- *row = y / rowheight;
- else if (row)
- *row = 0;
+ if ((r_row) && (rowheight > 0)) {
+ *r_row = y / rowheight;
+ }
+ else if (r_row) {
+ *r_row = 0;
+ }
}
/**
@@ -2350,8 +2479,12 @@ View2D *UI_view2d_fromcontext(const bContext *C)
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- if (area == NULL) return NULL;
- if (region == NULL) return NULL;
+ if (area == NULL) {
+ return NULL;
+ }
+ if (region == NULL) {
+ return NULL;
+ }
return &(region->v2d);
}
@@ -2361,8 +2494,12 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
ScrArea *sa = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- if (sa == NULL) return NULL;
- if (region == NULL) return NULL;
+ if (sa == NULL) {
+ return NULL;
+ }
+ if (region == NULL) {
+ return NULL;
+ }
if (region->regiontype != RGN_TYPE_WINDOW) {
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
return ar ? &(ar->v2d) : NULL;
@@ -2377,31 +2514,43 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
* Is used to inverse correct drawing of icons, etc. that need to follow view
* but not be affected by scale
*
- * \param x, y: scale on each axis
+ * \param r_x, r_y: scale on each axis
*/
-void UI_view2d_scale_get(View2D *v2d, float *x, float *y)
+void UI_view2d_scale_get(View2D *v2d, float *r_x, float *r_y)
{
- if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur);
- if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur);
+ if (r_x) {
+ *r_x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur);
+ }
+ if (r_y) {
+ *r_y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur);
+ }
}
/**
* Same as ``UI_view2d_scale_get() - 1.0f / x, y``
*/
-void UI_view2d_scale_get_inverse(View2D *v2d, float *x, float *y)
+void UI_view2d_scale_get_inverse(View2D *v2d, float *r_x, float *r_y)
{
- if (x) *x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
- if (y) *y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
+ if (r_x) {
+ *r_x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
+ }
+ if (r_y) {
+ *r_y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
+ }
}
/**
* Simple functions for consistent center offset access.
* Used by node editor to shift view center for each individual node tree.
*/
-void UI_view2d_center_get(struct View2D *v2d, float *x, float *y)
+void UI_view2d_center_get(struct View2D *v2d, float *r_x, float *r_y)
{
/* get center */
- if (x) *x = BLI_rctf_cent_x(&v2d->cur);
- if (y) *y = BLI_rctf_cent_y(&v2d->cur);
+ if (r_x) {
+ *r_x = BLI_rctf_cent_x(&v2d->cur);
+ }
+ if (r_y) {
+ *r_y = BLI_rctf_cent_y(&v2d->cur);
+ }
}
void UI_view2d_center_set(struct View2D *v2d, float x, float y)
{
@@ -2452,7 +2601,7 @@ void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac)
* - 0 = not in scroller.
*/
char UI_view2d_mouse_in_scrollers_ex(
- const ARegion *ar, View2D *v2d, int x, int y,
+ const ARegion *ar, const View2D *v2d, int x, int y,
int *r_scroll)
{
int co[2];
@@ -2465,10 +2614,14 @@ char UI_view2d_mouse_in_scrollers_ex(
/* check if within scrollbars */
if (scroll & V2D_SCROLL_HORIZONTAL) {
- if (IN_2D_HORIZ_SCROLL(v2d, co)) return 'h';
+ if (IN_2D_HORIZ_SCROLL(v2d, co)) {
+ return 'h';
+ }
}
if (scroll & V2D_SCROLL_VERTICAL) {
- if (IN_2D_VERT_SCROLL(v2d, co)) return 'v';
+ if (IN_2D_VERT_SCROLL(v2d, co)) {
+ return 'v';
+ }
}
/* not found */
@@ -2476,7 +2629,7 @@ char UI_view2d_mouse_in_scrollers_ex(
}
char UI_view2d_mouse_in_scrollers(
- const ARegion *ar, View2D *v2d, int x, int y)
+ const ARegion *ar, const View2D *v2d, int x, int y)
{
int scroll_dummy = 0;
return UI_view2d_mouse_in_scrollers_ex(ar, v2d, x, y, &scroll_dummy);
@@ -2582,17 +2735,20 @@ void UI_view2d_text_cache_draw(ARegion *ar)
int xofs = 0, yofs;
yofs = ceil(0.5f * (BLI_rcti_size_y(&v2s->rect) - default_height));
- if (yofs < 1) yofs = 1;
+ if (yofs < 1) {
+ yofs = 1;
+ }
if (col_pack_prev != v2s->col.pack) {
BLF_color3ubv(font_id, v2s->col.ub);
col_pack_prev = v2s->col.pack;
}
- if (v2s->rect.xmin >= v2s->rect.xmax)
+ if (v2s->rect.xmin >= v2s->rect.xmax) {
BLF_draw_default(
(float)(v2s->mval[0] + xofs), (float)(v2s->mval[1] + yofs), 0.0,
v2s->str, BLF_DRAW_STR_DUMMY_MAX);
+ }
else {
BLF_enable(font_id, BLF_CLIPPING);
BLF_clipping(font_id, v2s->rect.xmin - 4, v2s->rect.ymin - 4, v2s->rect.xmax + 4, v2s->rect.ymax + 4);
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index e6cce1f0df9..790b92a357e 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -104,13 +104,15 @@ static int view_pan_init(bContext *C, wmOperator *op)
float winx, winy;
/* regions now have v2d-data by default, so check for region */
- if (ar == NULL)
+ if (ar == NULL) {
return 0;
+ }
/* check if panning is allowed at all */
v2d = &ar->v2d;
- if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y))
+ if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y)) {
return 0;
+ }
/* set custom-data for operator */
vpd = MEM_callocN(sizeof(v2dViewPanData), "v2dViewPanData");
@@ -138,13 +140,15 @@ static bool view_pan_poll(bContext *C)
View2D *v2d;
/* check if there's a region in context to work with */
- if (ar == NULL)
+ if (ar == NULL) {
return 0;
+ }
v2d = &ar->v2d;
/* check that 2d-view can pan */
- if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y))
+ if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y)) {
return 0;
+ }
/* view can pan */
return 1;
@@ -207,8 +211,9 @@ static void view_pan_exit(wmOperator *op)
/* for 'redo' only, with no user input */
static int view_pan_exec(bContext *C, wmOperator *op)
{
- if (!view_pan_init(C, op))
+ if (!view_pan_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
view_pan_apply(C, op);
view_pan_exit(op);
@@ -223,8 +228,9 @@ static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
View2D *v2d;
/* set up customdata */
- if (!view_pan_init(C, op))
+ if (!view_pan_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
vpd = op->customdata;
v2d = vpd->v2d;
@@ -246,12 +252,15 @@ static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RNA_int_set(op->ptr, "deltax", 0);
RNA_int_set(op->ptr, "deltay", 0);
- if (v2d->keepofs & V2D_LOCKOFS_X)
+ if (v2d->keepofs & V2D_LOCKOFS_X) {
WM_cursor_modal_set(window, BC_NS_SCROLLCURSOR);
- else if (v2d->keepofs & V2D_LOCKOFS_Y)
+ }
+ else if (v2d->keepofs & V2D_LOCKOFS_Y) {
WM_cursor_modal_set(window, BC_EW_SCROLLCURSOR);
- else
+ }
+ else {
WM_cursor_modal_set(window, BC_NSEW_SCROLLCURSOR);
+ }
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -347,8 +356,9 @@ static int view_scrollright_exec(bContext *C, wmOperator *op)
v2dViewPanData *vpd;
/* initialize default settings (and validate if ok to run) */
- if (!view_pan_init(C, op))
+ if (!view_pan_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
/* also, check if can pan in horizontal axis */
vpd = op->customdata;
@@ -391,8 +401,9 @@ static int view_scrollleft_exec(bContext *C, wmOperator *op)
v2dViewPanData *vpd;
/* initialize default settings (and validate if ok to run) */
- if (!view_pan_init(C, op))
+ if (!view_pan_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
/* also, check if can pan in horizontal axis */
vpd = op->customdata;
@@ -434,8 +445,9 @@ static int view_scrolldown_exec(bContext *C, wmOperator *op)
v2dViewPanData *vpd;
/* initialize default settings (and validate if ok to run) */
- if (!view_pan_init(C, op))
+ if (!view_pan_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
/* also, check if can pan in vertical axis */
vpd = op->customdata;
@@ -485,8 +497,9 @@ static int view_scrollup_exec(bContext *C, wmOperator *op)
v2dViewPanData *vpd;
/* initialize default settings (and validate if ok to run) */
- if (!view_pan_init(C, op))
+ if (!view_pan_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
/* also, check if can pan in vertical axis */
vpd = op->customdata;
@@ -577,8 +590,9 @@ static void view_zoom_axis_lock_defaults(bContext *C, bool r_do_zoom_xy[2])
if (sa && sa->spacetype == SPACE_SEQ) {
ARegion *ar = CTX_wm_region(C);
- if (ar && ar->regiontype == RGN_TYPE_WINDOW)
+ if (ar && ar->regiontype == RGN_TYPE_WINDOW) {
r_do_zoom_xy[1] = false;
+ }
}
}
@@ -590,13 +604,15 @@ static int view_zoomdrag_init(bContext *C, wmOperator *op)
View2D *v2d;
/* regions now have v2d-data by default, so check for region */
- if (ar == NULL)
+ if (ar == NULL) {
return 0;
+ }
v2d = &ar->v2d;
/* check that 2d-view is zoomable */
- if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y)) {
return 0;
+ }
/* set custom-data for operator */
vzd = MEM_callocN(sizeof(v2dViewZoomData), "v2dViewZoomData");
@@ -616,18 +632,21 @@ static bool view_zoom_poll(bContext *C)
View2D *v2d;
/* check if there's a region in context to work with */
- if (ar == NULL)
+ if (ar == NULL) {
return false;
+ }
/* Do not show that in 3DView context. */
- if (CTX_wm_region_view3d(C))
+ if (CTX_wm_region_view3d(C)) {
return false;
+ }
v2d = &ar->v2d;
/* check that 2d-view is zoomable */
- if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y)) {
return false;
+ }
/* view is zoomable */
return true;
@@ -662,10 +681,12 @@ static void view_zoomstep_apply_ex(
v2d->cur.xmax -= 2 * dx;
}
else if (v2d->keepofs & V2D_KEEPOFS_X) {
- if (v2d->align & V2D_ALIGN_NO_POS_X)
+ if (v2d->align & V2D_ALIGN_NO_POS_X) {
v2d->cur.xmin += 2 * dx;
- else
+ }
+ else {
v2d->cur.xmax -= 2 * dx;
+ }
}
else {
@@ -696,10 +717,12 @@ static void view_zoomstep_apply_ex(
v2d->cur.ymax -= 2 * dy;
}
else if (v2d->keepofs & V2D_KEEPOFS_Y) {
- if (v2d->align & V2D_ALIGN_NO_POS_Y)
+ if (v2d->align & V2D_ALIGN_NO_POS_Y) {
v2d->cur.ymin += 2 * dy;
- else
+ }
+ else {
v2d->cur.ymax -= 2 * dy;
+ }
}
else {
@@ -768,8 +791,9 @@ static int view_zoomin_exec(bContext *C, wmOperator *op)
bool do_zoom_xy[2];
/* check that there's an active region, as View2D data resides there */
- if (!view_zoom_poll(C))
+ if (!view_zoom_poll(C)) {
return OPERATOR_PASS_THROUGH;
+ }
view_zoom_axis_lock_defaults(C, do_zoom_xy);
@@ -790,8 +814,9 @@ static int view_zoomin_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
v2dViewZoomData *vzd;
- if (!view_zoomdrag_init(C, op))
+ if (!view_zoomdrag_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
vzd = op->customdata;
@@ -835,8 +860,9 @@ static int view_zoomout_exec(bContext *C, wmOperator *op)
bool do_zoom_xy[2];
/* check that there's an active region, as View2D data resides there */
- if (!view_zoom_poll(C))
+ if (!view_zoom_poll(C)) {
return OPERATOR_PASS_THROUGH;
+ }
view_zoom_axis_lock_defaults(C, do_zoom_xy);
@@ -856,8 +882,9 @@ static int view_zoomout_invoke(bContext *C, wmOperator *op, const wmEvent *event
{
v2dViewZoomData *vzd;
- if (!view_zoomdrag_init(C, op))
+ if (!view_zoomdrag_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
vzd = op->customdata;
@@ -995,8 +1022,9 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op)
if (op->customdata) {
v2dViewZoomData *vzd = op->customdata;
- if (vzd->timer)
+ if (vzd->timer) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vzd->timer);
+ }
MEM_freeN(op->customdata);
op->customdata = NULL;
@@ -1011,8 +1039,9 @@ static void view_zoomdrag_cancel(bContext *C, wmOperator *op)
/* for 'redo' only, with no user input */
static int view_zoomdrag_exec(bContext *C, wmOperator *op)
{
- if (!view_zoomdrag_init(C, op))
+ if (!view_zoomdrag_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
view_zoomdrag_apply(C, op);
view_zoomdrag_exit(C, op);
@@ -1027,8 +1056,9 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
View2D *v2d;
/* set up customdata */
- if (!view_zoomdrag_init(C, op))
+ if (!view_zoomdrag_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
vzd = op->customdata;
v2d = vzd->v2d;
@@ -1044,17 +1074,20 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
*/
fac = 0.01f * (event->prevx - event->x);
dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f;
- if (event->type == MOUSEPAN)
+ if (event->type == MOUSEPAN) {
fac = 0.01f * (event->prevy - event->y);
+ }
dy = fac * BLI_rctf_size_y(&v2d->cur) / 10.0f;
/* support trackpad zoom to always zoom entirely - the v2d code uses portrait or
* landscape exceptions */
if (v2d->keepzoom & V2D_KEEPASPECT) {
- if (fabsf(dx) > fabsf(dy))
+ if (fabsf(dx) > fabsf(dy)) {
dy = dx;
- else
+ }
+ else {
dx = dy;
+ }
}
RNA_float_set(op->ptr, "deltax", dx);
RNA_float_set(op->ptr, "deltay", dy);
@@ -1083,12 +1116,15 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even
&vzd->mx_2d, &vzd->my_2d);
}
- if (v2d->keepofs & V2D_LOCKOFS_X)
+ if (v2d->keepofs & V2D_LOCKOFS_X) {
WM_cursor_modal_set(window, BC_NS_SCROLLCURSOR);
- else if (v2d->keepofs & V2D_LOCKOFS_Y)
+ }
+ else if (v2d->keepofs & V2D_LOCKOFS_Y) {
WM_cursor_modal_set(window, BC_EW_SCROLLCURSOR);
- else
+ }
+ else {
WM_cursor_modal_set(window, BC_NSEW_SCROLLCURSOR);
+ }
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -1136,8 +1172,9 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
float fac, zoomfac = 0.01f;
/* some view2d's (graph) don't have min/max zoom, or extreme ones */
- if (v2d->maxzoom > 0.0f)
+ if (v2d->maxzoom > 0.0f) {
zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f);
+ }
/* x-axis transform */
fac = zoomfac * (event->x - vzd->lastx);
@@ -1152,10 +1189,12 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
/* support zoom to always zoom entirely - the v2d code uses portrait or
* landscape exceptions */
if (v2d->keepzoom & V2D_KEEPASPECT) {
- if (fabsf(dx) > fabsf(dy))
+ if (fabsf(dx) > fabsf(dy)) {
dy = dx;
- else
+ }
+ else {
dx = dy;
+ }
}
/* set transform amount, and add current deltas to stored total delta (for redo) */
@@ -1180,15 +1219,19 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
if (event->val == KM_RELEASE) {
/* for redo, store the overall deltas - need to respect zoom-locks here... */
- if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0)
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
RNA_float_set(op->ptr, "deltax", vzd->dx);
- else
+ }
+ else {
RNA_float_set(op->ptr, "deltax", 0);
+ }
- if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0)
+ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
RNA_float_set(op->ptr, "deltay", vzd->dy);
- else
+ }
+ else {
RNA_float_set(op->ptr, "deltay", 0);
+ }
/* free customdata */
view_zoomdrag_exit(C, op);
@@ -1363,8 +1406,9 @@ static int view2d_ndof_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool do_zoom_xy[2];
- if (U.ndof_flag & NDOF_ZOOM_INVERT)
+ if (U.ndof_flag & NDOF_ZOOM_INVERT) {
zoom_factor = -zoom_factor;
+ }
view_zoom_axis_lock_defaults(C, do_zoom_xy);
@@ -1440,12 +1484,16 @@ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
/* axis translation normalized to scale */
tfac = fabsf(cent_a[i] - cent_b[i]) / min_ff(size_a[i], size_b[i]);
fac_max = max_ff(fac_max, tfac);
- if (fac_max >= 1.0f) break;
+ if (fac_max >= 1.0f) {
+ break;
+ }
/* axis scale difference, x2 so doubling or half gives 1.0f */
tfac = (1.0f - (min_ff(size_a[i], size_b[i]) / max_ff(size_a[i], size_b[i]))) * 2.0f;
fac_max = max_ff(fac_max, tfac);
- if (fac_max >= 1.0f) break;
+ if (fac_max >= 1.0f) {
+ break;
+ }
}
return min_ff(fac_max, 1.0f);
}
@@ -1468,7 +1516,9 @@ void UI_view2d_smooth_view(
sms.new_cur = v2d->cur;
/* store the options we want to end with */
- if (cur) sms.new_cur = *cur;
+ if (cur) {
+ sms.new_cur = *cur;
+ }
if (cur) {
fac = smooth_view_rect_to_fac(&v2d->cur, cur);
@@ -1477,8 +1527,9 @@ void UI_view2d_smooth_view(
if (smooth_viewtx && fac > FLT_EPSILON) {
bool changed = false;
- if (BLI_rctf_compare(&sms.new_cur, &v2d->cur, FLT_EPSILON) == false)
+ if (BLI_rctf_compare(&sms.new_cur, &v2d->cur, FLT_EPSILON) == false) {
changed = true;
+ }
/* The new view is different from the old one
* so animate the view */
@@ -1491,11 +1542,13 @@ void UI_view2d_smooth_view(
sms.time_allowed *= (double)fac;
/* keep track of running timer! */
- if (v2d->sms == NULL)
+ if (v2d->sms == NULL) {
v2d->sms = MEM_mallocN(sizeof(struct SmoothView2DStore), "smoothview v2d");
+ }
*v2d->sms = sms;
- if (v2d->smooth_timer)
+ if (v2d->smooth_timer) {
WM_event_remove_timer(wm, win, v2d->smooth_timer);
+ }
/* TIMER1 is hardcoded in keymap */
/* max 30 frs/sec */
v2d->smooth_timer = WM_event_add_timer(wm, win, TIMER1, 1.0 / 100.0);
@@ -1523,13 +1576,16 @@ static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
float step;
/* escape if not our timer */
- if (v2d->smooth_timer == NULL || v2d->smooth_timer != event->customdata)
+ if (v2d->smooth_timer == NULL || v2d->smooth_timer != event->customdata) {
return OPERATOR_PASS_THROUGH;
+ }
- if (sms->time_allowed != 0.0)
+ if (sms->time_allowed != 0.0) {
step = (float)((v2d->smooth_timer->duration) / sms->time_allowed);
- else
+ }
+ else {
step = 1.0f;
+ }
/* end timer */
if (step >= 1.0f) {
@@ -1662,14 +1718,24 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
* - 'bubble' fills entire scroller
* - 'bubble' completely out of view on either side
*/
- if ((sh_min <= sc_min) && (sh_max >= sc_max)) in_view = 0;
+ if ((sh_min <= sc_min) && (sh_max >= sc_max)) {
+ in_view = 0;
+ }
if (sh_min == sh_max) {
- if (sh_min <= sc_min) in_view = 0;
- if (sh_max >= sc_max) in_view = 0;
+ if (sh_min <= sc_min) {
+ in_view = 0;
+ }
+ if (sh_max >= sc_max) {
+ in_view = 0;
+ }
}
else {
- if (sh_max <= sc_min) in_view = 0;
- if (sh_min >= sc_max) in_view = 0;
+ if (sh_max <= sc_min) {
+ in_view = 0;
+ }
+ if (sh_min >= sc_max) {
+ in_view = 0;
+ }
}
@@ -1685,16 +1751,21 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
out_min = mouse < (sh_min - V2D_SCROLLER_HANDLE_SIZE);
out_max = mouse > (sh_max + V2D_SCROLLER_HANDLE_SIZE);
- if (in_bar)
+ if (in_bar) {
return SCROLLHANDLE_BAR;
- else if (in_max)
+ }
+ else if (in_max) {
return SCROLLHANDLE_MAX;
- else if (in_min)
+ }
+ else if (in_min) {
return SCROLLHANDLE_MIN;
- else if (out_min)
+ }
+ else if (out_min) {
return SCROLLHANDLE_MIN_OUTSIDE;
- else if (out_max)
+ }
+ else if (out_max) {
return SCROLLHANDLE_MAX_OUTSIDE;
+ }
/* unlikely to happen, though we just cover it in case */
return SCROLLHANDLE_BAR;
@@ -1833,19 +1904,23 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
switch (vsm->zone) {
case SCROLLHANDLE_MIN:
/* only expand view on axis if zoom is allowed */
- if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X))
+ if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X)) {
v2d->cur.xmin -= temp;
- if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y))
+ }
+ if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y)) {
v2d->cur.ymin -= temp;
+ }
break;
case SCROLLHANDLE_MAX:
/* only expand view on axis if zoom is allowed */
- if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X))
+ if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X)) {
v2d->cur.xmax += temp;
- if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y))
+ }
+ if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y)) {
v2d->cur.ymax += temp;
+ }
break;
case SCROLLHANDLE_MIN_OUTSIDE:
@@ -1925,10 +2000,12 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e
if (event->val == KM_RELEASE) {
/* single-click was in empty space outside bubble, so scroll by 1 'page' */
if (ELEM(vsm->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) {
- if (vsm->zone == SCROLLHANDLE_MIN_OUTSIDE)
+ if (vsm->zone == SCROLLHANDLE_MIN_OUTSIDE) {
vsm->delta = -vsm->scrollbarwidth * 0.8f;
- else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE)
+ }
+ else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE) {
vsm->delta = vsm->scrollbarwidth * 0.8f;
+ }
scroller_activate_apply(C, op);
scroller_activate_exit(C, op);
@@ -2023,10 +2100,12 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
}
/* activate the scroller */
- if (vsm->scroller == 'h')
+ if (vsm->scroller == 'h') {
v2d->scroll_ui |= V2D_SCROLL_H_ACTIVE;
- else
+ }
+ else {
v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE;
+ }
/* still ok, so can add */
WM_event_add_modal_handler(C, op);
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index d73ddfac2f6..3829821ef2e 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -500,11 +500,13 @@ void WM_OT_collada_export(wmOperatorType *ot)
"Export also the curve handles (if available) (this does only work when the inverse parent matrix "
"is the unity matrix, otherwise you may end up with odd results)");
- RNA_def_boolean(func, "keep_keyframes", 0, "Keep Keyframes",
- "Use existing keyframes as additional sample points (this helps when you want to keep manual tweaks)");
+ RNA_def_boolean(
+ func, "keep_keyframes", 0, "Keep Keyframes",
+ "Use existing keyframes as additional sample points (this helps when you want to keep manual tweaks)");
- RNA_def_boolean(func, "keep_flat_curves", 0, "All keyed curves",
- "Export also curves which have only one key or are totally flat");
+ RNA_def_boolean(
+ func, "keep_flat_curves", 0, "All keyed curves",
+ "Export also curves which have only one key or are totally flat");
RNA_def_boolean(func, "active_uv_only", 0, "Only Selected UV Map",
"Export only the selected UV Map");
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index 2c7f084fe17..a92ed02c483 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -75,6 +75,29 @@ static void bpoint_select_set(BPoint *bp, bool select)
}
}
+bool ED_lattice_deselect_all_multi_ex(struct Base **bases, const uint bases_len)
+{
+ bool changed_multi = false;
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Base *base_iter = bases[base_index];
+ Object *ob_iter = base_iter->object;
+ changed_multi |= ED_lattice_flags_set(ob_iter, 0);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
+ }
+ return changed_multi;
+}
+
+bool ED_lattice_deselect_all_multi(struct bContext *C)
+{
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &bases_len);
+ bool changed_multi = ED_lattice_deselect_all_multi_ex(bases, bases_len);
+ MEM_freeN(bases);
+ return changed_multi;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -356,23 +379,32 @@ void LATTICE_OT_select_less(wmOperatorType *ot)
/** \name Select All Operator
* \{ */
-void ED_lattice_flags_set(Object *obedit, int flag)
+bool ED_lattice_flags_set(Object *obedit, int flag)
{
Lattice *lt = obedit->data;
BPoint *bp;
int a;
+ bool changed = false;
bp = lt->editlatt->latt->def;
a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
- lt->editlatt->latt->actbp = LT_ACTBP_NONE;
+
+ if (lt->editlatt->latt->actbp != LT_ACTBP_NONE) {
+ lt->editlatt->latt->actbp = LT_ACTBP_NONE;
+ changed = true;
+ }
while (a--) {
if (bp->hide == 0) {
- bp->f1 = flag;
+ if (bp->f1 != flag) {
+ bp->f1 = flag;
+ changed = true;
+ }
}
bp++;
}
+ return changed;
}
static int lattice_select_all_exec(bContext *C, wmOperator *op)
@@ -395,18 +427,20 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op)
}
}
+ bool changed_multi = false;
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
Lattice *lt;
BPoint *bp;
int a;
+ bool changed = false;
switch (action) {
case SEL_SELECT:
- ED_lattice_flags_set(obedit, 1);
+ changed = ED_lattice_flags_set(obedit, 1);
break;
case SEL_DESELECT:
- ED_lattice_flags_set(obedit, 0);
+ changed = ED_lattice_flags_set(obedit, 0);
break;
case SEL_INVERT:
lt = obedit->data;
@@ -417,18 +451,24 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op)
while (a--) {
if (bp->hide == 0) {
bp->f1 ^= SELECT;
+ changed = true;
}
bp++;
}
break;
}
- DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ if (changed) {
+ changed_multi = true;
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
}
MEM_freeN(objects);
-
- return OPERATOR_FINISHED;
+ if (changed_multi) {
+ return OPERATOR_FINISHED;
+ }
+ return OPERATOR_CANCELLED;
}
void LATTICE_OT_select_all(wmOperatorType *ot)
@@ -597,10 +637,10 @@ bool ED_lattice_select_pick(bContext *C, const int mval[2], bool extend, bool de
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
- ED_lattice_flags_set(ob, 0);
-
- DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+ if (ED_lattice_flags_set(ob, 0)) {
+ DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+ }
}
MEM_freeN(objects);
}
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 82f7cb49d12..0164fe4cc03 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -236,10 +236,10 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
if (point == masklay->act_point)
immUniformColor3f(1.0f, 1.0f, 1.0f);
else
- immUniformThemeColor(TH_HANDLE_VERTEX_SELECT);
+ immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX_SELECT, 0, 255);
}
else {
- immUniformThemeColor(TH_HANDLE_VERTEX);
+ immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX, 0, 255);
}
immBegin(GPU_PRIM_POINTS, 1);
@@ -306,10 +306,10 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
if (point == masklay->act_point)
immUniformColor3f(1.0f, 1.0f, 1.0f);
else
- immUniformThemeColor(TH_HANDLE_VERTEX_SELECT);
+ immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX_SELECT, 0, 255);
}
else
- immUniformThemeColor(TH_HANDLE_VERTEX);
+ immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX, 0, 255);
immBegin(GPU_PRIM_POINTS, 1);
immVertex2fv(pos, vert);
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 5afde1b3ba1..ef2e01e05fb 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -272,7 +272,7 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b
if (me == NULL || me->totpoly == 0) return;
if (mval) {
- if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
+ if (!ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
return;
}
}
@@ -282,14 +282,16 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b
paintface_flush_flags(C, ob, SELECT);
}
-void paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool flush_flags)
+bool paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool flush_flags)
{
Mesh *me;
MPoly *mpoly;
int a;
me = BKE_mesh_from_object(ob);
- if (me == NULL) return;
+ if (me == NULL) {
+ return false;
+ }
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@@ -305,28 +307,40 @@ void paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool fl
}
}
+ bool changed = false;
+
mpoly = me->mpoly;
a = me->totpoly;
while (a--) {
if ((mpoly->flag & ME_HIDE) == 0) {
switch (action) {
case SEL_SELECT:
- mpoly->flag |= ME_FACE_SEL;
+ if ((mpoly->flag & ME_FACE_SEL) == 0) {
+ mpoly->flag |= ME_FACE_SEL;
+ changed = true;
+ }
break;
case SEL_DESELECT:
- mpoly->flag &= ~ME_FACE_SEL;
+ if ((mpoly->flag & ME_FACE_SEL) != 0) {
+ mpoly->flag &= ~ME_FACE_SEL;
+ changed = true;
+ }
break;
case SEL_INVERT:
mpoly->flag ^= ME_FACE_SEL;
+ changed = true;
break;
}
}
mpoly++;
}
- if (flush_flags) {
- paintface_flush_flags(C, ob, SELECT);
+ if (changed) {
+ if (flush_flags) {
+ paintface_flush_flags(C, ob, SELECT);
+ }
}
+ return changed;
}
bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
@@ -368,29 +382,26 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], bool extend, bool deselect, bool toggle)
{
Mesh *me;
- MPoly *mpoly, *mpoly_sel;
- unsigned int a, index;
+ MPoly *mpoly_sel;
+ uint index;
/* Get the face under the cursor */
me = BKE_mesh_from_object(ob);
- if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE))
+ if (!ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
return false;
+ }
- if (index >= me->totpoly)
+ if (index >= me->totpoly) {
return false;
+ }
mpoly_sel = me->mpoly + index;
if (mpoly_sel->flag & ME_HIDE) return false;
/* clear flags */
- mpoly = me->mpoly;
- a = me->totpoly;
if (!extend && !deselect && !toggle) {
- while (a--) {
- mpoly->flag &= ~ME_FACE_SEL;
- mpoly++;
- }
+ paintface_deselect_all_visible(C, ob, SEL_DESELECT, false);
}
me->act_face = (int)index;
@@ -418,42 +429,33 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b
return true;
}
-int do_paintface_box_select(ViewContext *vc, rcti *rect, int sel_op)
+bool do_paintface_box_select(ViewContext *vc, const rcti *rect, int sel_op)
{
Object *ob = vc->obact;
Mesh *me;
MPoly *mpoly;
- struct ImBuf *ibuf;
- unsigned int *rt;
+ uint *rt;
char *selar;
int a, index;
- const int size[2] = {
- BLI_rcti_size_x(rect) + 1,
- BLI_rcti_size_y(rect) + 1};
me = BKE_mesh_from_object(ob);
-
- if ((me == NULL) || (me->totpoly == 0) || (size[0] * size[1] <= 0)) {
- return OPERATOR_CANCELLED;
+ if ((me == NULL) || (me->totpoly == 0) || BLI_rcti_is_empty(rect)) {
+ return false;
}
selar = MEM_callocN(me->totpoly + 1, "selar");
+ bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- paintface_deselect_all_visible(vc->C, vc->obact, SEL_DESELECT, false);
+ changed |= paintface_deselect_all_visible(vc->C, vc->obact, SEL_DESELECT, false);
}
- ED_view3d_backbuf_validate(vc);
+ uint buf_len;
+ uint *buf = ED_view3d_select_id_read_rect(vc, rect, &buf_len);
- ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect);
- rt = ibuf->rect;
- view3d_opengl_read_pixels(vc->ar, rect->xmin, rect->ymin, size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
- if (ENDIAN_ORDER == B_ENDIAN) {
- IMB_convert_rgba_to_abgr(ibuf);
- }
- GPU_select_to_index_array(ibuf->rect, size[0] * size[1]);
+ rt = buf;
- a = size[0] * size[1];
+ a = buf_len;
while (a--) {
if (*rt) {
index = *rt;
@@ -472,20 +474,22 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int sel_op)
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(mpoly->flag, sel_op_result, ME_FACE_SEL);
+ changed = true;
}
}
}
- IMB_freeImBuf(ibuf);
+ MEM_freeN(buf);
MEM_freeN(selar);
#ifdef __APPLE__
glReadBuffer(GL_BACK);
#endif
- paintface_flush_flags(vc->C, vc->obact, SELECT);
-
- return OPERATOR_FINISHED;
+ if (changed) {
+ paintface_flush_flags(vc->C, vc->obact, SELECT);
+ }
+ return changed;
}
@@ -544,14 +548,16 @@ void paintvert_tag_select_update(struct bContext *C, struct Object *ob)
/* note: if the caller passes false to flush_flags,
* then they will need to run paintvert_flush_flags(ob) themselves */
-void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
+bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
{
Mesh *me;
MVert *mvert;
int a;
me = BKE_mesh_from_object(ob);
- if (me == NULL) return;
+ if (me == NULL) {
+ return false;
+ }
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@@ -567,39 +573,50 @@ void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
}
}
+ bool changed = false;
mvert = me->mvert;
a = me->totvert;
while (a--) {
if ((mvert->flag & ME_HIDE) == 0) {
switch (action) {
case SEL_SELECT:
- mvert->flag |= SELECT;
+ if ((mvert->flag & SELECT) == 0) {
+ mvert->flag |= SELECT;
+ changed = true;
+ }
break;
case SEL_DESELECT:
- mvert->flag &= ~SELECT;
+ if ((mvert->flag & SELECT) != 0) {
+ mvert->flag &= ~SELECT;
+ changed = true;
+ }
break;
case SEL_INVERT:
mvert->flag ^= SELECT;
+ changed = true;
break;
}
}
mvert++;
}
- /* handle mselect */
- if (action == SEL_SELECT) {
- /* pass */
- }
- else if (ELEM(action, SEL_DESELECT, SEL_INVERT)) {
- BKE_mesh_mselect_clear(me);
- }
- else {
- BKE_mesh_mselect_validate(me);
- }
+ if (changed) {
+ /* handle mselect */
+ if (action == SEL_SELECT) {
+ /* pass */
+ }
+ else if (ELEM(action, SEL_DESELECT, SEL_INVERT)) {
+ BKE_mesh_mselect_clear(me);
+ }
+ else {
+ BKE_mesh_mselect_validate(me);
+ }
- if (flush_flags) {
- paintvert_flush_flags(ob);
+ if (flush_flags) {
+ paintvert_flush_flags(ob);
+ }
}
+ return changed;
}
void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags)
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 477a5b068ac..1059374dcc5 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -146,8 +146,9 @@ static void edbm_bevel_update_header(bContext *C, wmOperator *op)
BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%.1f%%", RNA_float_get(op->ptr, "offset_pct"));
}
else {
- bUnit_AsString2(offset_str, NUM_STR_REP_LEN, (double)RNA_float_get(op->ptr, "offset"), 3,
- B_UNIT_LENGTH, &sce->unit, true);
+ bUnit_AsString2(
+ offset_str, NUM_STR_REP_LEN, (double)RNA_float_get(op->ptr, "offset"), 3,
+ B_UNIT_LENGTH, &sce->unit, true);
}
prop = RNA_struct_find_property(op->ptr, "offset_type");
@@ -157,46 +158,47 @@ static void edbm_bevel_update_header(bContext *C, wmOperator *op)
prop = RNA_struct_find_property(op->ptr, "miter_inner");
RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &imiter_str);
- BLI_snprintf(header, sizeof(header),
- IFACE_("%s: confirm, "
- "%s: cancel, "
- "%s: mode (%s), "
- "%s: width (%s), "
- "%s: segments (%d), "
- "%s: profile (%.3f), "
- "%s: clamp overlap (%s), "
- "%s: vertex only (%s), "
- "%s: outer miter (%s), "
- "%s: inner miter (%s), "
- "%s: harden normals (%s), "
- "%s: mark seam (%s), "
- "%s: mark sharp (%s)"
- ),
- WM_MODALKEY(BEV_MODAL_CONFIRM),
- WM_MODALKEY(BEV_MODAL_CANCEL),
- WM_MODALKEY(BEV_MODAL_OFFSET_MODE_CHANGE),
- mode_str,
- WM_MODALKEY(BEV_MODAL_VALUE_OFFSET),
- offset_str,
- WM_MODALKEY(BEV_MODAL_VALUE_SEGMENTS),
- RNA_int_get(op->ptr, "segments"),
- WM_MODALKEY(BEV_MODAL_VALUE_PROFILE),
- RNA_float_get(op->ptr, "profile"),
- WM_MODALKEY(BEV_MODAL_CLAMP_OVERLAP_TOGGLE),
- WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")),
- WM_MODALKEY(BEV_MODAL_VERTEX_ONLY_TOGGLE),
- WM_bool_as_string(RNA_boolean_get(op->ptr, "vertex_only")),
- WM_MODALKEY(BEV_MODAL_OUTER_MITER_CHANGE),
- omiter_str,
- WM_MODALKEY(BEV_MODAL_INNER_MITER_CHANGE),
- imiter_str,
- WM_MODALKEY(BEV_MODAL_HARDEN_NORMALS_TOGGLE),
- WM_bool_as_string(RNA_boolean_get(op->ptr, "harden_normals")),
- WM_MODALKEY(BEV_MODAL_MARK_SEAM_TOGGLE),
- WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_seam")),
- WM_MODALKEY(BEV_MODAL_MARK_SHARP_TOGGLE),
- WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_sharp"))
- );
+ BLI_snprintf(
+ header, sizeof(header),
+ IFACE_("%s: confirm, "
+ "%s: cancel, "
+ "%s: mode (%s), "
+ "%s: width (%s), "
+ "%s: segments (%d), "
+ "%s: profile (%.3f), "
+ "%s: clamp overlap (%s), "
+ "%s: vertex only (%s), "
+ "%s: outer miter (%s), "
+ "%s: inner miter (%s), "
+ "%s: harden normals (%s), "
+ "%s: mark seam (%s), "
+ "%s: mark sharp (%s)"
+ ),
+ WM_MODALKEY(BEV_MODAL_CONFIRM),
+ WM_MODALKEY(BEV_MODAL_CANCEL),
+ WM_MODALKEY(BEV_MODAL_OFFSET_MODE_CHANGE),
+ mode_str,
+ WM_MODALKEY(BEV_MODAL_VALUE_OFFSET),
+ offset_str,
+ WM_MODALKEY(BEV_MODAL_VALUE_SEGMENTS),
+ RNA_int_get(op->ptr, "segments"),
+ WM_MODALKEY(BEV_MODAL_VALUE_PROFILE),
+ RNA_float_get(op->ptr, "profile"),
+ WM_MODALKEY(BEV_MODAL_CLAMP_OVERLAP_TOGGLE),
+ WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")),
+ WM_MODALKEY(BEV_MODAL_VERTEX_ONLY_TOGGLE),
+ WM_bool_as_string(RNA_boolean_get(op->ptr, "vertex_only")),
+ WM_MODALKEY(BEV_MODAL_OUTER_MITER_CHANGE),
+ omiter_str,
+ WM_MODALKEY(BEV_MODAL_INNER_MITER_CHANGE),
+ imiter_str,
+ WM_MODALKEY(BEV_MODAL_HARDEN_NORMALS_TOGGLE),
+ WM_bool_as_string(RNA_boolean_get(op->ptr, "harden_normals")),
+ WM_MODALKEY(BEV_MODAL_MARK_SEAM_TOGGLE),
+ WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_seam")),
+ WM_MODALKEY(BEV_MODAL_MARK_SHARP_TOGGLE),
+ WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_sharp"))
+ );
#undef WM_MODALKEY
@@ -209,12 +211,11 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
BevelData *opdata;
ViewLayer *view_layer = CTX_data_view_layer(C);
float pixels_per_inch;
- int i;
+ int i, otype;
if (is_modal) {
RNA_float_set(op->ptr, "offset", 0.0f);
RNA_float_set(op->ptr, "offset_pct", 0.0f);
- RNA_enum_set(op->ptr, "offset_type", BEVEL_AMT_OFFSET);
}
op->customdata = opdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator");
@@ -224,7 +225,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
{
uint ob_store_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
- view_layer, CTX_wm_view3d(C), &ob_store_len);
+ view_layer, CTX_wm_view3d(C), &ob_store_len);
opdata->ob_store = MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__);
for (uint ob_index = 0; ob_index < ob_store_len; ob_index++) {
Object *obedit = objects[ob_index];
@@ -241,7 +242,8 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
}
opdata->is_modal = is_modal;
- opdata->value_mode = OFFSET_VALUE;
+ otype = RNA_enum_get(op->ptr, "offset_type");
+ opdata->value_mode = (otype == BEVEL_AMT_PERCENT) ? OFFSET_VALUE_PERCENT : OFFSET_VALUE;
opdata->segments = (float) RNA_int_get(op->ptr, "segments");
pixels_per_inch = U.dpi * U.pixelsize;
@@ -272,8 +274,9 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
opdata->ob_store[ob_index].mesh_backup = EDBM_redo_state_store(opdata->ob_store[ob_index].em);
}
- opdata->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ED_region_draw_mouse_line_cb,
- opdata->mcenter, REGION_DRAW_POST_PIXEL);
+ opdata->draw_handle_pixel = ED_region_draw_cb_activate(
+ ar->type, ED_region_draw_mouse_line_cb,
+ opdata->mcenter, REGION_DRAW_POST_PIXEL);
G.moving = G_TRANSFORM_EDIT;
if (v3d) {
@@ -565,31 +568,31 @@ wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf)
{BEV_MODAL_CANCEL, "CANCEL", 0, "Cancel", "Cancel bevel"},
{BEV_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", "Confirm bevel"},
{BEV_MODAL_VALUE_OFFSET, "VALUE_OFFSET", 0, "Value is offset",
- "Value changes offset"},
+ "Value changes offset"},
{BEV_MODAL_VALUE_PROFILE, "VALUE_PROFILE", 0, "Value is profile",
- "Value changes profile"},
+ "Value changes profile"},
{BEV_MODAL_VALUE_SEGMENTS, "VALUE_SEGMENTS", 0, "Value is segments",
- "Value changes segments"},
+ "Value changes segments"},
{BEV_MODAL_SEGMENTS_UP, "SEGMENTS_UP", 0, "Increase segments",
- "Increase segments"},
+ "Increase segments"},
{BEV_MODAL_SEGMENTS_DOWN, "SEGMENTS_DOWN", 0, "Decrease segments",
- "Decrease segments"},
+ "Decrease segments"},
{BEV_MODAL_OFFSET_MODE_CHANGE, "OFFSET_MODE_CHANGE", 0, "Change offset mode",
- "Cycle through offset modes"},
+ "Cycle through offset modes"},
{BEV_MODAL_CLAMP_OVERLAP_TOGGLE, "CLAMP_OVERLAP_TOGGLE", 0, "Toggle clamp overlap",
- "Toggle clamp overlap flag"},
+ "Toggle clamp overlap flag"},
{BEV_MODAL_VERTEX_ONLY_TOGGLE, "VERTEX_ONLY_TOGGLE", 0, "Toggle vertex only",
- "Toggle vertex only flag"},
+ "Toggle vertex only flag"},
{BEV_MODAL_HARDEN_NORMALS_TOGGLE, "HARDEN_NORMALS_TOGGLE", 0, "Toggle harden normals",
- "Toggle harden normals flag"},
+ "Toggle harden normals flag"},
{BEV_MODAL_MARK_SEAM_TOGGLE, "MARK_SEAM_TOGGLE", 0, "Toggle mark seam",
- "Toggle mark seam flag"},
+ "Toggle mark seam flag"},
{BEV_MODAL_MARK_SHARP_TOGGLE, "MARK_SHARP_TOGGLE", 0, "Toggle mark sharp",
- "Toggle mark sharp flag"},
+ "Toggle mark sharp flag"},
{BEV_MODAL_OUTER_MITER_CHANGE, "OUTER_MITER_CHANGE", 0, "Change outer miter",
- "Cycle through outer miter kinds"},
+ "Cycle through outer miter kinds"},
{BEV_MODAL_INNER_MITER_CHANGE, "INNER_MITER_CHANGE", 0, "Change inner miter",
- "Cycle through inner miter kinds"},
+ "Cycle through inner miter kinds"},
{0, NULL, 0, NULL, NULL},
};
@@ -623,7 +626,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* Modal numinput active, try to handle numeric inputs first... */
if (etype != EVT_MODAL_MAP && eval == KM_PRESS && has_numinput &&
- handleNumInput(C, &opdata->num_input[opdata->value_mode], event))
+ handleNumInput(C, &opdata->num_input[opdata->value_mode], event))
{
edbm_bevel_numinput_set_value(op);
edbm_bevel_calc(op);
@@ -868,26 +871,34 @@ void MESH_OT_bevel(wmOperatorType *ot)
RNA_def_property_range(prop, 0.0, 100);
RNA_def_property_ui_text(prop, "Width Percent", "Bevel amount for percentage method");
RNA_def_int(ot->srna, "segments", 1, 1, SEGMENTS_HARD_MAX, "Segments", "Segments for curved edge", 1, 100);
- RNA_def_float(ot->srna, "profile", 0.5f, PROFILE_HARD_MIN, 1.0f, "Profile",
- "Controls profile shape (0.5 = round)", PROFILE_HARD_MIN, 1.0f);
+ RNA_def_float(
+ ot->srna, "profile", 0.5f, PROFILE_HARD_MIN, 1.0f, "Profile",
+ "Controls profile shape (0.5 = round)", PROFILE_HARD_MIN, 1.0f);
RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex Only", "Bevel only vertices");
- RNA_def_boolean(ot->srna, "clamp_overlap", false, "Clamp Overlap",
- "Do not allow beveled edges/vertices to overlap each other");
+ RNA_def_boolean(
+ ot->srna, "clamp_overlap", false, "Clamp Overlap",
+ "Do not allow beveled edges/vertices to overlap each other");
RNA_def_boolean(ot->srna, "loop_slide", true, "Loop Slide", "Prefer slide along edge to even widths");
RNA_def_boolean(ot->srna, "mark_seam", false, "Mark Seams", "Mark Seams along beveled edges");
RNA_def_boolean(ot->srna, "mark_sharp", false, "Mark Sharp", "Mark beveled edges as sharp");
- RNA_def_int(ot->srna, "material", -1, -1, INT_MAX, "Material",
- "Material for bevel faces (-1 means use adjacent faces)", -1, 100);
- RNA_def_boolean(ot->srna, "harden_normals", false, "Harden Normals",
- "Match normals of new faces to adjacent faces");
- RNA_def_enum(ot->srna, "face_strength_mode", face_strength_mode_items, BEVEL_FACE_STRENGTH_NONE,
- "Face Strength Mode", "Whether to set face strength, and which faces to set face strength on");
- RNA_def_enum(ot->srna, "miter_outer", miter_outer_items, BEVEL_MITER_SHARP,
- "Outer Miter", "Pattern to use for outside of miters");
- RNA_def_enum(ot->srna, "miter_inner", miter_inner_items, BEVEL_MITER_SHARP,
- "Inner Miter", "Pattern to use for inside of miters");
- RNA_def_float(ot->srna, "spread", 0.1f, 0.0f, 1e6f, "Spread",
- "Amount to spread arcs for arc inner miters", 0.0f, 100.0f);
+ RNA_def_int(
+ ot->srna, "material", -1, -1, INT_MAX, "Material",
+ "Material for bevel faces (-1 means use adjacent faces)", -1, 100);
+ RNA_def_boolean(
+ ot->srna, "harden_normals", false, "Harden Normals",
+ "Match normals of new faces to adjacent faces");
+ RNA_def_enum(
+ ot->srna, "face_strength_mode", face_strength_mode_items, BEVEL_FACE_STRENGTH_NONE,
+ "Face Strength Mode", "Whether to set face strength, and which faces to set face strength on");
+ RNA_def_enum(
+ ot->srna, "miter_outer", miter_outer_items, BEVEL_MITER_SHARP,
+ "Outer Miter", "Pattern to use for outside of miters");
+ RNA_def_enum(
+ ot->srna, "miter_inner", miter_inner_items, BEVEL_MITER_SHARP,
+ "Inner Miter", "Pattern to use for inside of miters");
+ RNA_def_float(
+ ot->srna, "spread", 0.1f, 0.0f, 1e6f, "Spread",
+ "Amount to spread arcs for arc inner miters", 0.0f, 100.0f);
prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index ab49a6ce203..f2ba227fd2e 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -307,9 +307,9 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op)
edbm_extrude_ex(obedit, em, BM_ALL_NOLOOP, BM_ELEM_SELECT, false, false, false);
BMO_op_callf(
- em->bm, BMO_FLAG_DEFAULTS,
- "translate vec=%v verts=%hv",
- dvec, BM_ELEM_SELECT);
+ em->bm, BMO_FLAG_DEFAULTS,
+ "translate vec=%v verts=%hv",
+ dvec, BM_ELEM_SELECT);
}
EDBM_mesh_normals_update(em);
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index c63f0db1f2b..3b48c4e29b0 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -383,12 +383,14 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
mdiff[0] = opdata->mcenter[0] - event->mval[0];
mdiff[1] = opdata->mcenter[1] - event->mval[1];
- if (opdata->modify_depth)
+ if (opdata->modify_depth) {
amount = opdata->old_depth +
((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size) / opdata->max_obj_scale;
- else
+ }
+ else {
amount = opdata->old_thickness -
((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size) / opdata->max_obj_scale;
+ }
/* Fake shift-transform... */
if (opdata->shift)
diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c
index 08486f28669..c500683a228 100644
--- a/source/blender/editors/mesh/editmesh_intersect.c
+++ b/source/blender/editors/mesh/editmesh_intersect.c
@@ -884,8 +884,8 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op))
float v_pivot_co[3];
float v_pivot_fac;
BMEdge *e_split = bm_face_split_edge_find(
- e, f, v_pivot, bm->ftable, bm->totface,
- v_pivot_co, &v_pivot_fac);
+ e, f, v_pivot, bm->ftable, bm->totface,
+ v_pivot_co, &v_pivot_fac);
if (e_split) {
/* for degenerate cases this vertex may be in one
@@ -918,9 +918,9 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op))
struct LinkBase *e_ls_base = BLI_ghashIterator_getValue(&gh_iter);
bm_face_split_by_edges_island_connect(
- bm, f,
- e_ls_base->list, e_ls_base->list_len,
- mem_arena_edgenet);
+ bm, f,
+ e_ls_base->list, e_ls_base->list_len,
+ mem_arena_edgenet);
BLI_memarena_clear(mem_arena_edgenet);
}
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 80d23f37e71..1855eeab944 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -213,32 +213,29 @@ bool EDBM_backbuf_border_init(
ViewContext *vc, short xmin,
short ymin, short xmax, short ymax)
{
- struct ImBuf *buf;
- unsigned int *dr;
- int a;
+ uint *buf, *dr, buf_len;
if (vc->obedit == NULL || !V3D_IS_ZBUF(vc->v3d)) {
return false;
}
- buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
+ buf = ED_view3d_select_id_read(vc, xmin, ymin, xmax, ymax, &buf_len);
if ((buf == NULL) || (bm_vertoffs == 0)) {
return false;
}
- dr = buf->rect;
+ dr = buf;
/* build selection lookup */
selbuf = edbm_backbuf_alloc(bm_vertoffs + 1);
- a = (xmax - xmin + 1) * (ymax - ymin + 1);
- while (a--) {
+ while (buf_len--) {
if (*dr > 0 && *dr <= bm_vertoffs) {
BLI_BITMAP_ENABLE(selbuf, *dr);
}
dr++;
}
- IMB_freeImBuf(buf);
+ MEM_freeN(buf);
return true;
}
@@ -286,9 +283,7 @@ static void edbm_mask_lasso_px_cb(int x, int x_end, int y, void *user_data)
*/
bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax)
{
- unsigned int *dr, *dr_mask, *dr_mask_arr;
- struct ImBuf *buf;
- int a;
+ uint *buf, *dr, *dr_mask, *dr_mask_arr, buf_len;
struct LassoMaskData lasso_mask_data;
/* method in use for face selecting too */
@@ -301,14 +296,14 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short
return false;
}
- buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
+ buf = ED_view3d_select_id_read(vc, xmin, ymin, xmax, ymax, &buf_len);
if ((buf == NULL) || (bm_vertoffs == 0)) {
return false;
}
- dr = buf->rect;
+ dr = buf;
- dr_mask = dr_mask_arr = MEM_callocN(sizeof(*dr_mask) * buf->x * buf->y, __func__);
+ dr_mask = dr_mask_arr = MEM_callocN(sizeof(*dr_mask) * buf_len, __func__);
lasso_mask_data.px = dr_mask;
lasso_mask_data.width = (xmax - xmin) + 1;
@@ -320,14 +315,13 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short
/* build selection lookup */
selbuf = edbm_backbuf_alloc(bm_vertoffs + 1);
- a = (xmax - xmin + 1) * (ymax - ymin + 1);
- while (a--) {
+ while (buf_len--) {
if (*dr > 0 && *dr <= bm_vertoffs && *dr_mask == true) {
BLI_BITMAP_ENABLE(selbuf, *dr);
}
dr++; dr_mask++;
}
- IMB_freeImBuf(buf);
+ MEM_freeN(buf);
MEM_freeN(dr_mask_arr);
return true;
@@ -338,8 +332,7 @@ bool EDBM_backbuf_circle_init(
ViewContext *vc,
short xs, short ys, short rads)
{
- struct ImBuf *buf;
- unsigned int *dr;
+ uint *buf, *dr;
short xmin, ymin, xmax, ymax, xc, yc;
int radsq;
@@ -355,12 +348,12 @@ bool EDBM_backbuf_circle_init(
xmin = xs - rads; xmax = xs + rads;
ymin = ys - rads; ymax = ys + rads;
- buf = ED_view3d_backbuf_read(vc, xmin, ymin, xmax, ymax);
+ buf = ED_view3d_select_id_read(vc, xmin, ymin, xmax, ymax, NULL);
if ((buf == NULL) || (bm_vertoffs == 0)) {
return false;
}
- dr = buf->rect;
+ dr = buf;
/* build selection lookup */
selbuf = edbm_backbuf_alloc(bm_vertoffs + 1);
@@ -375,7 +368,7 @@ bool EDBM_backbuf_circle_init(
}
}
- IMB_freeImBuf(buf);
+ MEM_freeN(buf);
return true;
}
@@ -472,26 +465,24 @@ BMVert *EDBM_vert_find_nearest_ex(
BMesh *bm = vc->em->bm;
if (V3D_IS_ZBUF(vc->v3d)) {
- const int dist_px = ED_view3d_backbuf_sample_size_clamp(vc->ar, *r_dist);
- float dist_test;
+ uint dist_px = (uint)ED_view3d_backbuf_sample_size_clamp(vc->ar, *r_dist);
unsigned int index;
BMVert *eve;
/* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
{
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_VERTEX);
- ED_view3d_backbuf_validate_with_select_mode(vc, select_mode);
+ ED_view3d_select_id_validate_with_select_mode(vc, select_mode);
- index = ED_view3d_backbuf_sample_rect(
- vc, vc->mval, dist_px, bm_wireoffs, 0xFFFFFF, &dist_test);
+ index = ED_view3d_select_id_read_nearest(vc, vc->mval, bm_wireoffs, 0xFFFFFF, &dist_px);
eve = index ? BM_vert_at_index_find_or_table(bm, index - 1) : NULL;
FAKE_SELECT_MODE_END(vc, fake_select_mode);
}
if (eve) {
- if (dist_test < *r_dist) {
- *r_dist = dist_test;
+ if (dist_px < *r_dist) {
+ *r_dist = dist_px;
return eve;
}
}
@@ -665,17 +656,16 @@ BMEdge *EDBM_edge_find_nearest_ex(
BMesh *bm = vc->em->bm;
if (V3D_IS_ZBUF(vc->v3d)) {
- const int dist_px = ED_view3d_backbuf_sample_size_clamp(vc->ar, *r_dist);
- float dist_test = 0.0f;
+ uint dist_px = (uint)ED_view3d_backbuf_sample_size_clamp(vc->ar, *r_dist);
unsigned int index;
BMEdge *eed;
/* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
{
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_EDGE);
- ED_view3d_backbuf_validate_with_select_mode(vc, select_mode);
+ ED_view3d_select_id_validate_with_select_mode(vc, select_mode);
- index = ED_view3d_backbuf_sample_rect(vc, vc->mval, dist_px, bm_solidoffs, bm_wireoffs, &dist_test);
+ index = ED_view3d_select_id_read_nearest(vc, vc->mval, bm_solidoffs, bm_wireoffs, &dist_px);
eed = index ? BM_edge_at_index_find_or_table(bm, index - 1) : NULL;
FAKE_SELECT_MODE_END(vc, fake_select_mode);
@@ -703,8 +693,8 @@ BMEdge *EDBM_edge_find_nearest_ex(
/* end exception */
if (eed) {
- if (dist_test < *r_dist) {
- *r_dist = dist_test;
+ if (dist_px < *r_dist) {
+ *r_dist = dist_px;
return eed;
}
}
@@ -842,9 +832,9 @@ BMFace *EDBM_face_find_nearest_ex(
{
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_FACE);
- ED_view3d_backbuf_validate_with_select_mode(vc, select_mode);
+ ED_view3d_select_id_validate_with_select_mode(vc, select_mode);
- index = ED_view3d_backbuf_sample(vc, vc->mval[0], vc->mval[1]);
+ index = ED_view3d_select_id_sample(vc, vc->mval[0], vc->mval[1]);
efa = index ? BM_face_at_index_find_or_table(bm, index - 1) : NULL;
FAKE_SELECT_MODE_END(vc, fake_select_mode);
@@ -974,7 +964,6 @@ static bool unified_findnearest(
Object *obedit = base_iter->object;
ED_view3d_viewcontext_init_object(vc, obedit);
BLI_assert(vc->em->selectmode == em->selectmode);
- ED_view3d_backbuf_validate(vc);
BMFace *efa_zbuf = NULL;
BMFace *efa_test = EDBM_face_find_nearest_ex(vc, &dist, dist_center_p, true, use_cycle, &efa_zbuf);
if (efa_test && dist_center_p) {
@@ -999,7 +988,6 @@ static bool unified_findnearest(
Base *base_iter = bases[base_index];
Object *obedit = base_iter->object;
ED_view3d_viewcontext_init_object(vc, obedit);
- ED_view3d_backbuf_validate(vc);
BMEdge *eed_zbuf = NULL;
BMEdge *eed_test = EDBM_edge_find_nearest_ex(vc, &dist, dist_center_p, true, use_cycle, &eed_zbuf);
if (eed_test && dist_center_p) {
@@ -1021,7 +1009,6 @@ static bool unified_findnearest(
Base *base_iter = bases[base_index];
Object *obedit = base_iter->object;
ED_view3d_viewcontext_init_object(vc, obedit);
- ED_view3d_backbuf_validate(vc);
BMVert *eve_test = EDBM_vert_find_nearest_ex(vc, &dist, true, use_cycle);
if (eve_test) {
hit.v.base_index = base_index;
@@ -2610,6 +2597,36 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */
}
}
+bool EDBM_mesh_deselect_all_multi_ex(struct Base **bases, const uint bases_len)
+{
+ bool changed_multi = false;
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Base *base_iter = bases[base_index];
+ Object *ob_iter = base_iter->object;
+ BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter);
+
+ if (em_iter->bm->totvertsel == 0) {
+ continue;
+ }
+
+ EDBM_flag_disable_all(em_iter, BM_ELEM_SELECT);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
+ changed_multi = true;
+ }
+ return changed_multi;
+}
+
+bool EDBM_mesh_deselect_all_multi(struct bContext *C)
+{
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &bases_len);
+ bool changed_multi = EDBM_mesh_deselect_all_multi_ex(bases, bases_len);
+ MEM_freeN(bases);
+ return changed_multi;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c
index c9dea33dc78..c9365e8d0fd 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -138,40 +138,16 @@ static bool face_data_value_set(BMFace *face, const int hflag, int *r_value)
}
/**
- * Note: This is not normal, but the face direction itself and always in
- * a positive quadrant (tries z, y then x).
- * Also, unlike edge_pos_direction_worldspace_get we don't normalize the direction.
- * In fact we scale the direction by the distance of the face center to the origin.
+ * World space normalized plane from a face.
*/
-static void face_pos_direction_worldspace_scaled_get(Object *ob, BMFace *face, float *r_dir)
+static void face_to_plane(const Object *ob, BMFace *face, float r_plane[4])
{
- float distance;
- float center[3];
-
- copy_v3_v3(r_dir, face->no);
- normalize_v3(r_dir);
-
- BM_face_calc_center_median(face, center);
- mul_m4_v3(ob->obmat, center);
-
- distance = dot_v3v3(r_dir, center);
- mul_v3_fl(r_dir, distance);
-
- /* Make sure we have a consistent direction regardless of the face orientation.
- * This spares us from storing dir and -dir in the tree. */
- if (fabs(r_dir[2]) < FLT_EPSILON) {
- if (fabs(r_dir[1]) < FLT_EPSILON) {
- if (r_dir[0] < 0.0f) {
- mul_v3_fl(r_dir, -1.0f);
- }
- }
- else if (r_dir[1] < 0.0f) {
- mul_v3_fl(r_dir, -1.0f);
- }
- }
- else if (r_dir[2] < 0.0f) {
- mul_v3_fl(r_dir, -1.0f);
- }
+ float normal[3], co[3];
+ copy_v3_v3(normal, face->no);
+ mul_transposed_mat3_m4_v3(ob->imat, normal);
+ normalize_v3(normal);
+ mul_v3_m4v3(co, ob->obmat, BM_FACE_FIRST_LOOP(face)->v->co);
+ plane_from_point_normal_v3(r_plane, co, normal);
}
/* TODO(dfelinto): `types` that should technically be compared in world space but are not:
@@ -203,7 +179,9 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- KDTree *tree = NULL;
+ KDTree_1d *tree_1d = NULL;
+ KDTree_3d *tree_3d = NULL;
+ KDTree_4d *tree_4d = NULL;
GSet *gset = NULL;
GSet **gset_array = NULL;
int face_data_value = SIMFACE_DATA_NONE;
@@ -211,9 +189,13 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
switch (type) {
case SIMFACE_AREA:
case SIMFACE_PERIMETER:
+ tree_1d = BLI_kdtree_1d_new(tot_faces_selected_all);
+ break;
case SIMFACE_NORMAL:
+ tree_3d = BLI_kdtree_3d_new(tot_faces_selected_all);
+ break;
case SIMFACE_COPLANAR:
- tree = BLI_kdtree_new(tot_faces_selected_all);
+ tree_4d = BLI_kdtree_4d_new(tot_faces_selected_all);
break;
case SIMFACE_SIDES:
case SIMFACE_MATERIAL:
@@ -289,15 +271,13 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
case SIMFACE_AREA:
{
float area = BM_face_calc_area_with_mat3(face, ob_m3);
- float dummy[3] = {area, 0.0f, 0.0f};
- BLI_kdtree_insert(tree, tree_index++, dummy);
+ BLI_kdtree_1d_insert(tree_1d, tree_index++, &area);
break;
}
case SIMFACE_PERIMETER:
{
float perimeter = BM_face_calc_perimeter_with_mat3(face, ob_m3);
- float dummy[3] = {perimeter, 0.0f, 0.0f};
- BLI_kdtree_insert(tree, tree_index++, dummy);
+ BLI_kdtree_1d_insert(tree_1d, tree_index++, &perimeter);
break;
}
case SIMFACE_NORMAL:
@@ -306,15 +286,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
copy_v3_v3(normal, face->no);
mul_transposed_mat3_m4_v3(ob->imat, normal);
normalize_v3(normal);
-
- BLI_kdtree_insert(tree, tree_index++, normal);
+ BLI_kdtree_3d_insert(tree_3d, tree_index++, normal);
break;
}
case SIMFACE_COPLANAR:
{
- float dir[3];
- face_pos_direction_worldspace_scaled_get(ob, face, dir);
- BLI_kdtree_insert(tree, tree_index++, dir);
+ float plane[4];
+ face_to_plane(ob, face, plane);
+ BLI_kdtree_4d_insert(tree_4d, tree_index++, plane);
break;
}
case SIMFACE_SMOOTH:
@@ -353,8 +332,17 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
BLI_assert((type != SIMFACE_FREESTYLE) || (face_data_value != SIMFACE_DATA_NONE));
- if (tree != NULL) {
- BLI_kdtree_balance(tree);
+ if (tree_1d != NULL) {
+ BLI_kdtree_1d_deduplicate(tree_1d);
+ BLI_kdtree_1d_balance(tree_1d);
+ }
+ if (tree_3d != NULL) {
+ BLI_kdtree_3d_deduplicate(tree_3d);
+ BLI_kdtree_3d_balance(tree_3d);
+ }
+ if (tree_4d != NULL) {
+ BLI_kdtree_4d_deduplicate(tree_4d);
+ BLI_kdtree_4d_balance(tree_4d);
}
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -438,7 +426,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
case SIMFACE_AREA:
{
float area = BM_face_calc_area_with_mat3(face, ob_m3);
- if (ED_select_similar_compare_float_tree(tree, area, thresh, compare)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, area, thresh, compare)) {
select = true;
}
break;
@@ -446,7 +434,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
case SIMFACE_PERIMETER:
{
float perimeter = BM_face_calc_perimeter_with_mat3(face, ob_m3);
- if (ED_select_similar_compare_float_tree(tree, perimeter, thresh, compare)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, perimeter, thresh, compare)) {
select = true;
}
break;
@@ -460,8 +448,8 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
/* We are treating the normals as coordinates, the "nearest" one will
* also be the one closest to the angle. */
- KDTreeNearest nearest;
- if (BLI_kdtree_find_nearest(tree, normal, &nearest) != -1) {
+ KDTreeNearest_3d nearest;
+ if (BLI_kdtree_3d_find_nearest(tree_3d, normal, &nearest) != -1) {
if (angle_normalized_v3v3(normal, nearest.co) <= thresh_radians) {
select = true;
}
@@ -470,19 +458,15 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
}
case SIMFACE_COPLANAR:
{
- float diff[3];
- float dir[3];
- face_pos_direction_worldspace_scaled_get(ob, face, dir);
-
- /* We are treating the direction as coordinates, the "nearest" one will
- * also be the one closest to the angle.
- * And since the direction is scaled by the face center distance to the origin,
- * the nearest point will also be the closest between the planes. */
- KDTreeNearest nearest;
- if (BLI_kdtree_find_nearest(tree, dir, &nearest) != -1) {
- sub_v3_v3v3(diff, dir, nearest.co);
- if (len_v3(diff) <= thresh) {
- if (angle_v3v3(dir, nearest.co) <= thresh_radians) {
+ float plane[4];
+ face_to_plane(ob, face, plane);
+
+ KDTreeNearest_4d nearest;
+ if (BLI_kdtree_4d_find_nearest(tree_4d, plane, &nearest) != -1) {
+ if (nearest.dist <= thresh) {
+ if ((fabsf(plane[3] - nearest.co[3]) <= thresh) &&
+ (angle_v3v3(plane, nearest.co) <= thresh_radians))
+ {
select = true;
}
}
@@ -568,7 +552,9 @@ face_select_all:
}
MEM_freeN(objects);
- BLI_kdtree_free(tree);
+ BLI_kdtree_1d_free(tree_1d);
+ BLI_kdtree_3d_free(tree_3d);
+ BLI_kdtree_4d_free(tree_4d);
if (gset != NULL) {
BLI_gset_free(gset, NULL);
}
@@ -609,7 +595,7 @@ static void edge_pos_direction_worldspace_get(Object *ob, BMEdge *edge, float *r
normalize_v3(r_dir);
/* Make sure we have a consistent direction that can be checked regardless of
- * the verts order of the edges. This spares us from storing dir and -dir in the tree. */
+ * the verts order of the edges. This spares us from storing dir and -dir in the tree_3d. */
if (fabs(r_dir[2]) < FLT_EPSILON) {
if (fabs(r_dir[1]) < FLT_EPSILON) {
if (r_dir[0] < 0.0f) {
@@ -688,7 +674,8 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- KDTree *tree = NULL;
+ KDTree_1d *tree_1d = NULL;
+ KDTree_3d *tree_3d = NULL;
GSet *gset = NULL;
int edge_data_value = SIMEDGE_DATA_NONE;
@@ -697,8 +684,10 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
case SIMEDGE_BEVEL:
case SIMEDGE_FACE_ANGLE:
case SIMEDGE_LENGTH:
+ tree_1d = BLI_kdtree_1d_new(tot_edges_selected_all);
+ break;
case SIMEDGE_DIR:
- tree = BLI_kdtree_new(tot_edges_selected_all);
+ tree_3d = BLI_kdtree_3d_new(tot_edges_selected_all);
break;
case SIMEDGE_FACE:
gset = BLI_gset_ptr_new("Select similar edge: face");
@@ -737,8 +726,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
case SIMEDGE_BEVEL:
{
if (!CustomData_has_layer(&bm->edata, custom_data_type)) {
- float dummy[3] = {0.0f, 0.0f, 0.0f};
- BLI_kdtree_insert(tree, tree_index++, dummy);
+ BLI_kdtree_1d_insert(tree_1d, tree_index++, (float[1]){0.0f});
continue;
}
break;
@@ -762,22 +750,20 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
{
float dir[3];
edge_pos_direction_worldspace_get(ob, edge, dir);
- BLI_kdtree_insert(tree, tree_index++, dir);
+ BLI_kdtree_3d_insert(tree_3d, tree_index++, dir);
break;
}
case SIMEDGE_LENGTH:
{
float length = edge_length_squared_worldspace_get(ob, edge);
- float dummy[3] = {length, 0.0f, 0.0f};
- BLI_kdtree_insert(tree, tree_index++, dummy);
+ BLI_kdtree_1d_insert(tree_1d, tree_index++, &length);
break;
}
case SIMEDGE_FACE_ANGLE:
{
if (BM_edge_face_count_at_most(edge, 2) == 2) {
float angle = BM_edge_calc_face_angle_with_imat3(edge, ob_m3_inv);
- float dummy[3] = {angle, 0.0f, 0.0f};
- BLI_kdtree_insert(tree, tree_index++, dummy);
+ BLI_kdtree_1d_insert(tree_1d, tree_index++, &angle);
}
break;
}
@@ -810,8 +796,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
case SIMEDGE_BEVEL:
{
const float *value = CustomData_bmesh_get(&bm->edata, edge->head.data, custom_data_type);
- float dummy[3] = {*value, 0.0f, 0.0f};
- BLI_kdtree_insert(tree, tree_index++, dummy);
+ BLI_kdtree_1d_insert(tree_1d, tree_index++, value);
break;
}
}
@@ -821,8 +806,13 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
BLI_assert((type != SIMEDGE_FREESTYLE) || (edge_data_value != SIMEDGE_DATA_NONE));
- if (tree != NULL) {
- BLI_kdtree_balance(tree);
+ if (tree_1d != NULL) {
+ BLI_kdtree_1d_deduplicate(tree_1d);
+ BLI_kdtree_1d_balance(tree_1d);
+ }
+ if (tree_3d != NULL) {
+ BLI_kdtree_3d_deduplicate(tree_3d);
+ BLI_kdtree_3d_balance(tree_3d);
}
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -849,7 +839,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
/* Proceed only if we have to select all the edges that have custom data value of 0.0f.
* In this case we will just select all the edges.
* Otherwise continue the for loop. */
- if (!ED_select_similar_compare_float_tree(tree, 0.0f, thresh, compare)) {
+ if (!ED_select_similar_compare_float_tree(tree_1d, 0.0f, thresh, compare)) {
continue;
}
}
@@ -890,8 +880,8 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
/* We are treating the direction as coordinates, the "nearest" one will
* also be the one closest to the intended direction. */
- KDTreeNearest nearest;
- if (BLI_kdtree_find_nearest(tree, dir, &nearest) != -1) {
+ KDTreeNearest_3d nearest;
+ if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
if (angle_normalized_v3v3(dir, nearest.co) <= thresh_radians) {
select = true;
}
@@ -901,7 +891,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
case SIMEDGE_LENGTH:
{
float length = edge_length_squared_worldspace_get(ob, edge);
- if (ED_select_similar_compare_float_tree(tree, length, thresh, compare)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, length, thresh, compare)) {
select = true;
}
break;
@@ -910,7 +900,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
{
if (BM_edge_face_count_at_most(edge, 2) == 2) {
float angle = BM_edge_calc_face_angle_with_imat3(edge, ob_m3_inv);
- if (ED_select_similar_compare_float_tree(tree, angle, thresh, SIM_CMP_EQ)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, angle, thresh, SIM_CMP_EQ)) {
select = true;
}
}
@@ -957,7 +947,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
}
const float *value = CustomData_bmesh_get(&bm->edata, edge->head.data, custom_data_type);
- if (ED_select_similar_compare_float_tree(tree, *value, thresh, compare)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, *value, thresh, compare)) {
select = true;
}
break;
@@ -1004,7 +994,8 @@ edge_select_all:
}
MEM_freeN(objects);
- BLI_kdtree_free(tree);
+ BLI_kdtree_1d_free(tree_1d);
+ BLI_kdtree_3d_free(tree_3d);
if (gset != NULL) {
BLI_gset_free(gset, NULL);
}
@@ -1043,12 +1034,12 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- KDTree *tree = NULL;
+ KDTree_3d *tree_3d = NULL;
GSet *gset = NULL;
switch (type) {
case SIMVERT_NORMAL:
- tree = BLI_kdtree_new(tot_verts_selected_all);
+ tree_3d = BLI_kdtree_3d_new(tot_verts_selected_all);
break;
case SIMVERT_EDGE:
case SIMVERT_FACE:
@@ -1098,7 +1089,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
mul_transposed_mat3_m4_v3(ob->imat, normal);
normalize_v3(normal);
- BLI_kdtree_insert(tree, normal_tree_index++, normal);
+ BLI_kdtree_3d_insert(tree_3d, normal_tree_index++, normal);
break;
}
case SIMVERT_VGROUP:
@@ -1139,8 +1130,9 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
}
/* Remove duplicated entries. */
- if (tree != NULL) {
- BLI_kdtree_balance(tree);
+ if (tree_3d != NULL) {
+ BLI_kdtree_3d_deduplicate(tree_3d);
+ BLI_kdtree_3d_balance(tree_3d);
}
/* Run .the BM operators. */
@@ -1221,8 +1213,8 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
/* We are treating the normals as coordinates, the "nearest" one will
* also be the one closest to the angle. */
- KDTreeNearest nearest;
- if (BLI_kdtree_find_nearest(tree, normal, &nearest) != -1) {
+ KDTreeNearest_3d nearest;
+ if (BLI_kdtree_3d_find_nearest(tree_3d, normal, &nearest) != -1) {
if (angle_normalized_v3v3(normal, nearest.co) <= thresh_radians) {
select = true;
}
@@ -1260,7 +1252,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
}
MEM_freeN(objects);
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree_3d);
if (gset != NULL) {
BLI_gset_free(gset, NULL);
}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 23814d4038b..736c79e6898 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -1748,8 +1748,8 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op)
EDBM_op_init(
em, &bmop, op,
- "duplicate geom=%hvef use_select_history=%b",
- BM_ELEM_SELECT, true);
+ "duplicate geom=%hvef use_select_history=%b use_edge_flip_from_face=%b",
+ BM_ELEM_SELECT, true, true);
BMO_op_exec(bm, &bmop);
@@ -2021,7 +2021,7 @@ static int edbm_hide_exec(bContext *C, wmOperator *op)
void MESH_OT_hide(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Hide Selection";
+ ot->name = "Hide Selected";
ot->idname = "MESH_OT_hide";
ot->description = "Hide (un)selected vertices, edges or faces";
@@ -7541,7 +7541,7 @@ static void edbm_point_normals_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call */
- uiDefAutoButsRNA(layout, &ptr, point_normals_draw_check_prop, NULL, '\0', false);
+ uiDefAutoButsRNA(layout, &ptr, point_normals_draw_check_prop, NULL, NULL, '\0', false);
}
void MESH_OT_point_normals(struct wmOperatorType *ot)
@@ -7936,7 +7936,7 @@ static void edbm_average_normals_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call */
- uiDefAutoButsRNA(layout, &ptr, average_normals_draw_check_prop, NULL, '\0', false);
+ uiDefAutoButsRNA(layout, &ptr, average_normals_draw_check_prop, NULL, NULL, '\0', false);
}
void MESH_OT_average_normals(struct wmOperatorType *ot)
@@ -8001,16 +8001,10 @@ static int edbm_normals_tools_exec(bContext *C, wmOperator *op)
switch (mode) {
case EDBM_CLNOR_TOOLS_COPY:
if (bm->totfacesel != 1 && lnors_ed_arr->totloop != 1 && bm->totvertsel != 1) {
- BKE_report(op->reports, RPT_ERROR, "Can only copy custom normal, vertex normal or face normal");
+ BKE_report(op->reports, RPT_ERROR, "Can only copy one custom normal, vertex normal or face normal");
BM_loop_normal_editdata_array_free(lnors_ed_arr);
return OPERATOR_CANCELLED;
}
- bool join = true;
- for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) {
- if (!compare_v3v3(lnors_ed_arr->lnor_editdata->nloc, lnor_ed->nloc, 1e-4f)) {
- join = false;
- }
- }
if (lnors_ed_arr->totloop == 1) {
copy_v3_v3(scene->toolsettings->normal_vector, lnors_ed_arr->lnor_editdata->nloc);
}
@@ -8023,8 +8017,18 @@ static int edbm_normals_tools_exec(bContext *C, wmOperator *op)
}
}
}
- else if (join) {
- copy_v3_v3(scene->toolsettings->normal_vector, lnors_ed_arr->lnor_editdata->nloc);
+ else {
+ /* 'Vertex' normal, i.e. common set of loop normals on the same vertex,
+ * only if they are all the same. */
+ bool are_same_lnors = true;
+ for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) {
+ if (!compare_v3v3(lnors_ed_arr->lnor_editdata->nloc, lnor_ed->nloc, 1e-4f)) {
+ are_same_lnors = false;
+ }
+ }
+ if (are_same_lnors) {
+ copy_v3_v3(scene->toolsettings->normal_vector, lnors_ed_arr->lnor_editdata->nloc);
+ }
}
break;
@@ -8124,7 +8128,7 @@ static void edbm_normals_tools_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call */
- uiDefAutoButsRNA(layout, &ptr, normals_tools_draw_check_prop, NULL, '\0', false);
+ uiDefAutoButsRNA(layout, &ptr, normals_tools_draw_check_prop, NULL, NULL, '\0', false);
}
void MESH_OT_normals_tools(struct wmOperatorType *ot)
@@ -8198,7 +8202,7 @@ static int edbm_set_normals_from_faces_exec(bContext *C, wmOperator *op)
if (!is_zero_v3(vnors[v_index])) {
short *clnors = BM_ELEM_CD_GET_VOID_P(l, cd_clnors_offset);
BKE_lnor_space_custom_normal_to_data(
- bm->lnor_spacearr->lspacearr[l_index], vnors[v_index], clnors);
+ bm->lnor_spacearr->lspacearr[l_index], vnors[v_index], clnors);
if (bm->lnor_spacearr->lspacearr[l_index]->flags & MLNOR_SPACE_IS_SINGLE) {
BLI_BITMAP_ENABLE(loop_set, l_index);
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index e22addd614e..5ea3fa784a5 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -509,7 +509,7 @@ static void *undomesh_from_editmesh(UndoMesh *um, BMEditMesh *em, Key *key)
NULL, em->bm, &um->me, (&(struct BMeshToMeshParams){
/* Undo code should not be manipulating 'G_MAIN->object' hooks/vertex-parent. */
.calc_object_remap = false,
- .cd_mask_extra = {.vmask=CD_MASK_SHAPE_KEYINDEX},
+ .cd_mask_extra = {.vmask = CD_MASK_SHAPE_KEYINDEX},
}));
um->selectmode = em->selectmode;
@@ -748,6 +748,9 @@ static void mesh_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bma
/* The first element is always active */
ED_undo_object_set_active_or_warn(CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
+ Scene *scene = CTX_data_scene(C);
+ scene->toolsettings->selectmode = us->elems[0].data.selectmode;
+
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
}
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index ed6ab38e5ab..3a4f9d461ec 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -1006,7 +1006,7 @@ void EDBM_verts_mirror_cache_begin_ex(
const float maxdist_sq = SQUARE(maxdist);
/* one or the other is used depending if topo is enabled */
- KDTree *tree = NULL;
+ KDTree_3d *tree = NULL;
MirrTopoStore_t mesh_topo_store = {NULL, -1, -1, -1};
BM_mesh_elem_table_ensure(bm, BM_VERT);
@@ -1032,14 +1032,14 @@ void EDBM_verts_mirror_cache_begin_ex(
ED_mesh_mirrtopo_init(me, NULL, &mesh_topo_store, true);
}
else {
- tree = BLI_kdtree_new(bm->totvert);
+ tree = BLI_kdtree_3d_new(bm->totvert);
BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
- BLI_kdtree_insert(tree, i, v->co);
+ BLI_kdtree_3d_insert(tree, i, v->co);
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
}
-#define VERT_INTPTR(_v, _i) r_index ? &r_index[_i] : BM_ELEM_CD_GET_VOID_P(_v, cd_vmirr_offset);
+#define VERT_INTPTR(_v, _i) (r_index ? &r_index[_i] : BM_ELEM_CD_GET_VOID_P(_v, cd_vmirr_offset))
BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
BLI_assert(BM_elem_index_get(v) == i);
@@ -1062,7 +1062,7 @@ void EDBM_verts_mirror_cache_begin_ex(
co[axis] *= -1.0f;
v_mirr = NULL;
- i_mirr = BLI_kdtree_find_nearest(tree, co, NULL);
+ i_mirr = BLI_kdtree_3d_find_nearest(tree, co, NULL);
if (i_mirr != -1) {
BMVert *v_test = BM_vert_at_index(bm, i_mirr);
if (len_squared_v3v3(co, v_test->co) < maxdist_sq) {
@@ -1090,7 +1090,7 @@ void EDBM_verts_mirror_cache_begin_ex(
ED_mesh_mirrtopo_free(&mesh_topo_store);
}
else {
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
}
}
diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c
index 3d49d874503..a1859bf70b0 100644
--- a/source/blender/editors/mesh/mesh_mirror.c
+++ b/source/blender/editors/mesh/mesh_mirror.c
@@ -51,8 +51,8 @@ int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, Mesh *me_eval, cons
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's');
if (MirrKdStore.tree) {
- KDTreeNearest nearest;
- const int i = BLI_kdtree_find_nearest(MirrKdStore.tree, co, &nearest);
+ KDTreeNearest_3d nearest;
+ const int i = BLI_kdtree_3d_find_nearest(MirrKdStore.tree, co, &nearest);
if (i != -1) {
if (nearest.dist < KD_THRESH) {
@@ -70,7 +70,7 @@ int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, Mesh *me_eval, cons
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_new(totvert);
+ MirrKdStore.tree = BLI_kdtree_3d_new(totvert);
if (use_em) {
BMVert *eve;
@@ -81,7 +81,7 @@ int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, Mesh *me_eval, cons
BM_mesh_elem_table_ensure(em->bm, BM_VERT);
BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) {
- BLI_kdtree_insert(MirrKdStore.tree, i, eve->co);
+ BLI_kdtree_3d_insert(MirrKdStore.tree, i, eve->co);
}
}
else {
@@ -89,15 +89,15 @@ int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, Mesh *me_eval, cons
int i;
for (i = 0; i < totvert; i++, mvert++) {
- BLI_kdtree_insert(MirrKdStore.tree, i, mvert->co);
+ BLI_kdtree_3d_insert(MirrKdStore.tree, i, mvert->co);
}
}
- BLI_kdtree_balance(MirrKdStore.tree);
+ BLI_kdtree_3d_balance(MirrKdStore.tree);
}
else if (mode == 'e') { /* end table */
if (MirrKdStore.tree) {
- BLI_kdtree_free(MirrKdStore.tree);
+ BLI_kdtree_3d_free(MirrKdStore.tree);
MirrKdStore.tree = NULL;
}
}
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 2b8535f868b..5339c83d158 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -1014,7 +1014,9 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
*
* \return boolean true == Found
*/
-bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size)
+bool ED_mesh_pick_face(
+ bContext *C, Object *ob, const int mval[2], uint dist_px,
+ uint *r_index)
{
ViewContext vc;
Mesh *me = ob->data;
@@ -1026,25 +1028,29 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int
ED_view3d_viewcontext_init(C, &vc);
- if (size) {
+ if (dist_px) {
/* sample rect to increase chances of selecting, so that when clicking
* on an edge in the backbuf, we can still select a face */
- float dummy_dist;
- *index = ED_view3d_backbuf_sample_rect(&vc, mval, size, 1, me->totpoly + 1, &dummy_dist);
+ ED_view3d_select_id_validate(&vc);
+
+ *r_index = ED_view3d_select_id_read_nearest(
+ &vc, mval, 1, me->totpoly + 1, &dist_px);
}
else {
/* sample only on the exact position */
- *index = ED_view3d_backbuf_sample(&vc, mval[0], mval[1]);
+ *r_index = ED_view3d_select_id_sample(&vc, mval[0], mval[1]);
}
- if ((*index) == 0 || (*index) > (unsigned int)me->totpoly)
+ if ((*r_index) == 0 || (*r_index) > (unsigned int)me->totpoly) {
return false;
+ }
- (*index)--;
+ (*r_index)--;
return true;
}
+
static void ed_mesh_pick_face_vert__mpoly_find(
/* context */
struct ARegion *ar, const float mval[2],
@@ -1073,7 +1079,9 @@ static void ed_mesh_pick_face_vert__mpoly_find(
* Use when the back buffer stores face index values. but we want a vert.
* This gets the face then finds the closest vertex to mval.
*/
-bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size)
+bool ED_mesh_pick_face_vert(
+ bContext *C, Object *ob, const int mval[2], uint dist_px,
+ uint *r_index)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
unsigned int poly_index;
@@ -1081,7 +1089,7 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
BLI_assert(me && GS(me->id.name) == ID_ME);
- if (ED_mesh_pick_face(C, ob, mval, &poly_index, size)) {
+ if (ED_mesh_pick_face(C, ob, mval, dist_px, &poly_index)) {
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
struct ARegion *ar = CTX_wm_region(C);
@@ -1131,7 +1139,7 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
}
}
- /* map 'dm -> me' index if possible */
+ /* map 'dm -> me' r_index if possible */
if (v_idx_best != ORIGINDEX_NONE) {
const int *index_mv_to_orig;
index_mv_to_orig = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX);
@@ -1141,7 +1149,7 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
}
if ((v_idx_best != ORIGINDEX_NONE) && (v_idx_best < me->totvert)) {
- *index = v_idx_best;
+ *r_index = v_idx_best;
return true;
}
}
@@ -1181,7 +1189,9 @@ static void ed_mesh_pick_vert__mapFunc(void *userData, int index, const float co
}
}
}
-bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size, bool use_zbuf)
+bool ED_mesh_pick_vert(
+ bContext *C, Object *ob, const int mval[2], uint dist_px, bool use_zbuf,
+ uint *r_index)
{
ViewContext vc;
Mesh *me = ob->data;
@@ -1194,22 +1204,25 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
ED_view3d_viewcontext_init(C, &vc);
if (use_zbuf) {
- if (size > 0) {
+ if (dist_px > 0) {
/* sample rect to increase chances of selecting, so that when clicking
* on an face in the backbuf, we can still select a vert */
- float dummy_dist;
- *index = ED_view3d_backbuf_sample_rect(&vc, mval, size, 1, me->totvert + 1, &dummy_dist);
+ ED_view3d_select_id_validate(&vc);
+
+ *r_index = ED_view3d_select_id_read_nearest(
+ &vc, mval, 1, me->totvert + 1, &dist_px);
}
else {
/* sample only on the exact position */
- *index = ED_view3d_backbuf_sample(&vc, mval[0], mval[1]);
+ *r_index = ED_view3d_select_id_sample(&vc, mval[0], mval[1]);
}
- if ((*index) == 0 || (*index) > (unsigned int)me->totvert)
+ if ((*r_index) == 0 || (*r_index) > (uint)me->totvert) {
return false;
+ }
- (*index)--;
+ (*r_index)--;
}
else {
Scene *scene_eval = DEG_get_evaluated_scene(vc.depsgraph);
@@ -1245,7 +1258,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
return false;
}
- *index = data.v_idx_best;
+ *r_index = data.v_idx_best;
}
return true;
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 2af78261b87..5ab6f9e0750 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -79,7 +79,9 @@ void ED_mball_editmball_make(Object *obedit)
ml = mb->elems.first;
while (ml) {
- if (ml->flag & SELECT) mb->lastelem = ml;
+ if (ml->flag & SELECT) {
+ mb->lastelem = ml;
+ }
ml = ml->next;
}
@@ -125,35 +127,35 @@ static int mball_select_all_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
ViewLayer *view_layer = CTX_data_view_layer(C);
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &bases_len);
if (action == SEL_TOGGLE) {
- action = BKE_mball_is_any_selected_multi(objects, objects_len) ?
+ action = BKE_mball_is_any_selected_multi(bases, bases_len) ?
SEL_DESELECT :
SEL_SELECT;
}
switch (action) {
case SEL_SELECT:
- BKE_mball_select_all_multi(objects, objects_len);
+ BKE_mball_select_all_multi_ex(bases, bases_len);
break;
case SEL_DESELECT:
- BKE_mball_deselect_all_multi(objects, objects_len);
+ BKE_mball_deselect_all_multi_ex(bases, bases_len);
break;
case SEL_INVERT:
- BKE_mball_select_swap_multi(objects, objects_len);
+ BKE_mball_select_swap_multi_ex(bases, bases_len);
break;
}
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
MetaBall *mb = (MetaBall *)obedit->data;
DEG_id_tag_update(&mb->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
}
- MEM_freeN(objects);
+ MEM_freeN(bases);
return OPERATOR_FINISHED;
}
@@ -194,7 +196,9 @@ static const EnumPropertyItem prop_similar_types[] = {
{0, NULL, 0, NULL, NULL},
};
-static void mball_select_similar_type_get(Object *obedit, MetaBall *mb, int type, KDTree *r_tree)
+static void mball_select_similar_type_get(
+ Object *obedit, MetaBall *mb, int type,
+ KDTree_1d *tree_1d, KDTree_3d *tree_3d)
{
float tree_entry[3] = {0.0f, 0.0f, 0.0f};
MetaElem *ml;
@@ -231,12 +235,20 @@ static void mball_select_similar_type_get(Object *obedit, MetaBall *mb, int typ
break;
}
}
- BLI_kdtree_insert(r_tree, tree_index++, tree_entry);
+ if (tree_1d) {
+ BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
+ }
+ else {
+ BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
+ }
}
}
}
-static bool mball_select_similar_type(Object *obedit, MetaBall *mb, int type, const KDTree *tree, const float thresh)
+static bool mball_select_similar_type(
+ Object *obedit, MetaBall *mb, int type,
+ const KDTree_1d *tree_1d, const KDTree_3d *tree_3d,
+ const float thresh)
{
MetaElem *ml;
bool changed = false;
@@ -254,7 +266,7 @@ static bool mball_select_similar_type(Object *obedit, MetaBall *mb, int type, co
mul_m3_v3(smat, radius_vec);
radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
- if (ED_select_similar_compare_float_tree(tree, radius, thresh, SIM_CMP_EQ)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, radius, thresh, SIM_CMP_EQ)) {
select = true;
}
break;
@@ -262,7 +274,7 @@ static bool mball_select_similar_type(Object *obedit, MetaBall *mb, int type, co
case SIMMBALL_STIFFNESS:
{
float s = ml->s;
- if (ED_select_similar_compare_float_tree(tree, s, thresh, SIM_CMP_EQ)) {
+ if (ED_select_similar_compare_float_tree(tree_1d, s, thresh, SIM_CMP_EQ)) {
select = true;
}
break;
@@ -277,8 +289,8 @@ static bool mball_select_similar_type(Object *obedit, MetaBall *mb, int type, co
float thresh_cos = cosf(thresh * (float)M_PI_2);
- KDTreeNearest nearest;
- if (BLI_kdtree_find_nearest(tree, dir, &nearest) != -1) {
+ KDTreeNearest_3d nearest;
+ if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
float orient = angle_normalized_v3v3(dir, nearest.co);
/* Map to 0-1 to compare orientation. */
float delta = thresh_cos - fabsf(cosf(orient));
@@ -305,21 +317,28 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
int tot_mball_selected_all = 0;
ViewLayer *view_layer = CTX_data_view_layer(C);
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &bases_len);
- tot_mball_selected_all = BKE_mball_select_count_multi(objects, objects_len);
+ tot_mball_selected_all = BKE_mball_select_count_multi(bases, bases_len);
short type_ref = 0;
- KDTree *tree = NULL;
+ KDTree_1d *tree_1d = NULL;
+ KDTree_3d *tree_3d = NULL;
- if (type != SIMMBALL_TYPE) {
- tree = BLI_kdtree_new(tot_mball_selected_all);
+ switch (type) {
+ case SIMMBALL_RADIUS:
+ case SIMMBALL_STIFFNESS:
+ tree_1d = BLI_kdtree_1d_new(tot_mball_selected_all);
+ break;
+ case SIMMBALL_ROTATION:
+ tree_3d = BLI_kdtree_3d_new(tot_mball_selected_all);
+ break;
}
/* Get type of selected MetaBall */
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
MetaBall *mb = (MetaBall *)obedit->data;
switch (type) {
@@ -337,7 +356,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
case SIMMBALL_RADIUS:
case SIMMBALL_STIFFNESS:
case SIMMBALL_ROTATION:
- mball_select_similar_type_get(obedit, mb, type, tree);
+ mball_select_similar_type_get(obedit, mb, type, tree_1d, tree_3d);
break;
default:
BLI_assert(0);
@@ -345,12 +364,17 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
}
}
- if (tree != NULL) {
- BLI_kdtree_balance(tree);
+ if (tree_1d != NULL) {
+ BLI_kdtree_1d_deduplicate(tree_1d);
+ BLI_kdtree_1d_balance(tree_1d);
+ }
+ if (tree_3d != NULL) {
+ BLI_kdtree_3d_deduplicate(tree_3d);
+ BLI_kdtree_3d_balance(tree_3d);
}
/* Select MetaBalls with desired type. */
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
MetaBall *mb = (MetaBall *)obedit->data;
bool changed = false;
@@ -370,7 +394,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
case SIMMBALL_RADIUS:
case SIMMBALL_STIFFNESS:
case SIMMBALL_ROTATION:
- changed = mball_select_similar_type(obedit, mb, type, tree, thresh);
+ changed = mball_select_similar_type(obedit, mb, type, tree_1d, tree_3d, thresh);
break;
default:
BLI_assert(0);
@@ -383,9 +407,12 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op)
}
}
- MEM_freeN(objects);
- if (tree != NULL) {
- BLI_kdtree_free(tree);
+ MEM_freeN(bases);
+ if (tree_1d != NULL) {
+ BLI_kdtree_1d_free(tree_1d);
+ }
+ if (tree_3d != NULL) {
+ BLI_kdtree_3d_free(tree_3d);
}
return OPERATOR_FINISHED;
}
@@ -550,7 +577,9 @@ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
while (ml) {
next = ml->next;
if (ml->flag & SELECT) {
- if (mb->lastelem == ml) mb->lastelem = NULL;
+ if (mb->lastelem == ml) {
+ mb->lastelem = NULL;
+ }
BLI_remlink(mb->editelems, ml);
MEM_freeN(ml);
}
@@ -594,8 +623,9 @@ static int hide_metaelems_exec(bContext *C, wmOperator *op)
if (ml) {
while (ml) {
- if ((ml->flag & SELECT) != invert)
+ if ((ml->flag & SELECT) != invert) {
ml->flag |= MB_HIDE;
+ }
ml = ml->next;
}
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb);
@@ -608,7 +638,7 @@ static int hide_metaelems_exec(bContext *C, wmOperator *op)
void MBALL_OT_hide_metaelems(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Hide";
+ ot->name = "Hide Selected";
ot->description = "Hide (un)selected metaelement(s)";
ot->idname = "MBALL_OT_hide_metaelems";
@@ -651,7 +681,7 @@ static int reveal_metaelems_exec(bContext *C, wmOperator *op)
void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Reveal";
+ ot->name = "Reveal Hidden";
ot->description = "Reveal all hidden metaelements";
ot->idname = "MBALL_OT_reveal_metaelems";
@@ -692,11 +722,15 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
/* does startelem exist? */
ml = mb->editelems->first;
while (ml) {
- if (ml == startelem) break;
+ if (ml == startelem) {
+ break;
+ }
ml = ml->next;
}
- if (ml == NULL) startelem = mb->editelems->first;
+ if (ml == NULL) {
+ startelem = mb->editelems->first;
+ }
if (hits > 0) {
int metaelem_id = 0;
@@ -733,10 +767,16 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
}
}
- if (ml_act) break;
+ if (ml_act) {
+ break;
+ }
ml = ml->next;
- if (ml == NULL) ml = mb->editelems->first;
- if (ml == startelem) break;
+ if (ml == NULL) {
+ ml = mb->editelems->first;
+ }
+ if (ml == startelem) {
+ break;
+ }
metaelem_id += 0x10000;
}
@@ -767,10 +807,12 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
ml_act->flag &= ~SELECT;
}
else if (toggle) {
- if (ml_act->flag & SELECT)
+ if (ml_act->flag & SELECT) {
ml_act->flag &= ~SELECT;
- else
+ }
+ else {
ml_act->flag |= SELECT;
+ }
}
else {
/* Deselect all existing metaelems */
@@ -796,3 +838,14 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese
return false;
}
+
+bool ED_mball_deselect_all_multi(bContext *C)
+{
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &bases_len);
+ bool changed_multi = BKE_mball_deselect_all_multi_ex(bases, bases_len);
+ MEM_freeN(bases);
+ return changed_multi;
+}
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 4a27e05815f..9269c25f54b 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -503,7 +503,7 @@ static int lightprobe_add_exec(bContext *C, wmOperator *op)
radius = RNA_float_get(op->ptr, "radius");
ob = ED_object_add_type(C, OB_LIGHTPROBE, get_lightprobe_defname(type), loc, rot, false, local_view_bits);
- BKE_object_obdata_size_init(ob, radius);
+ copy_v3_fl(ob->scale, radius);
probe = (LightProbe *)ob->data;
probe->type = type;
@@ -1879,8 +1879,8 @@ static int convert_exec(bContext *C, wmOperator *op)
* But at the very least, do not do that with linked IDs! */
if ((ID_IS_LINKED(ob) || (ob->data && ID_IS_LINKED(ob->data))) && !keep_original) {
keep_original = true;
- BKE_reportf(op->reports, RPT_INFO,
- "Converting some linked object/object data, enforcing 'Keep Original' option to True");
+ BKE_report(op->reports, RPT_INFO,
+ "Converting some linked object/object data, enforcing 'Keep Original' option to True");
}
DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY);
@@ -2215,7 +2215,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer
Object *obn;
if (ob->mode & OB_MODE_POSE) {
- ; /* nothing? */
+ /* nothing? */
}
else {
obn = ID_NEW_SET(ob, BKE_object_duplicate(bmain, ob, dupflag));
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 08bf08d0b62..e3e3f3d10ef 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -192,7 +192,7 @@ static bool write_internal_bake_pixels(
RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);
}
- is_float = (ibuf->flags & IB_rectfloat);
+ is_float = (ibuf->rect_float != NULL);
/* colormanagement conversions */
if (!is_noncolor) {
diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c
index 4aad3c14a62..e8552c823bf 100644
--- a/source/blender/editors/object/object_collection.c
+++ b/source/blender/editors/object/object_collection.c
@@ -59,6 +59,7 @@
static const EnumPropertyItem *collection_object_active_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
{
Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
Object *ob;
EnumPropertyItem *item = NULL, item_tmp = {0};
int totitem = 0;
@@ -76,7 +77,7 @@ static const EnumPropertyItem *collection_object_active_itemf(bContext *C, Point
/* if 2 or more collections, add option to add to all collections */
collection = NULL;
- while ((collection = BKE_collection_object_find(bmain, collection, ob)))
+ while ((collection = BKE_collection_object_find(bmain, scene, collection, ob)))
count++;
if (count >= 2) {
@@ -88,7 +89,7 @@ static const EnumPropertyItem *collection_object_active_itemf(bContext *C, Point
/* add collections */
collection = NULL;
- while ((collection = BKE_collection_object_find(bmain, collection, ob))) {
+ while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) {
item_tmp.identifier = item_tmp.name = collection->id.name + 2;
/* item_tmp.icon = ICON_ARMATURE_DATA; */
item_tmp.value = i;
@@ -104,11 +105,11 @@ static const EnumPropertyItem *collection_object_active_itemf(bContext *C, Point
}
/* get the collection back from the enum index, quite awkward and UI specific */
-static Collection *collection_object_active_find_index(Main *bmain, Object *ob, const int collection_object_index)
+static Collection *collection_object_active_find_index(Main *bmain, Scene *scene, Object *ob, const int collection_object_index)
{
Collection *collection = NULL;
int i = 0;
- while ((collection = BKE_collection_object_find(bmain, collection, ob))) {
+ while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) {
if (i == collection_object_index) {
break;
}
@@ -122,9 +123,9 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
int single_collection_index = RNA_enum_get(op->ptr, "collection");
- Collection *single_collection = collection_object_active_find_index(bmain, ob, single_collection_index);
- Collection *collection;
+ Collection *single_collection = collection_object_active_find_index(bmain, scene, ob, single_collection_index);
bool is_cycle = false;
bool updated = false;
@@ -132,7 +133,8 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
/* now add all selected objects to the collection(s) */
- for (collection = bmain->collections.first; collection; collection = collection->id.next) {
+ FOREACH_COLLECTION_BEGIN(bmain, scene, Collection *, collection)
+ {
if (single_collection && collection != single_collection)
continue;
if (!BKE_collection_has_object(collection, ob))
@@ -154,6 +156,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
+ FOREACH_COLLECTION_END;
if (is_cycle)
BKE_report(op->reports, RPT_WARNING, "Skipped some collections because of cycle detected");
@@ -194,20 +197,20 @@ void COLLECTION_OT_objects_add_active(wmOperatorType *ot)
static int objects_remove_active_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
int single_collection_index = RNA_enum_get(op->ptr, "collection");
- Collection *single_collection = collection_object_active_find_index(bmain, ob, single_collection_index);
- Collection *collection;
+ Collection *single_collection = collection_object_active_find_index(bmain, scene, ob, single_collection_index);
bool ok = false;
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 */
-
- for (collection = bmain->collections.first; collection; collection = collection->id.next) {
+ /* 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)
continue;
@@ -222,6 +225,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
}
}
+ FOREACH_COLLECTION_END;
if (!ok)
BKE_report(op->reports, RPT_ERROR, "Active object contains no collections");
@@ -259,10 +263,11 @@ void COLLECTION_OT_objects_remove_active(wmOperatorType *ot)
static int collection_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
- BKE_object_groups_clear(bmain, base->object);
+ BKE_object_groups_clear(bmain, scene, base->object);
}
CTX_DATA_END;
@@ -291,15 +296,16 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
int single_collection_index = RNA_enum_get(op->ptr, "collection");
- Collection *single_collection = collection_object_active_find_index(bmain, ob, single_collection_index);
- Collection *collection;
+ Collection *single_collection = collection_object_active_find_index(bmain, scene, ob, single_collection_index);
bool updated = false;
if (ob == NULL)
return OPERATOR_CANCELLED;
- for (collection = bmain->collections.first; collection; collection = collection->id.next) {
+ FOREACH_COLLECTION_BEGIN(bmain, scene, Collection *, collection)
+ {
if (single_collection && collection != single_collection)
continue;
if (!BKE_collection_has_object(collection, ob))
@@ -314,6 +320,7 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
+ FOREACH_COLLECTION_END;
if (!updated)
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index f095edc2d60..fe01764de1f 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1571,7 +1571,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op))
/* if we're not handling the object we're copying from, copy all constraints over */
if (obact != ob) {
BKE_constraints_copy(&ob->constraints, &obact->constraints, true);
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
}
}
CTX_DATA_END;
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 8ca0b9c3c91..52b60793585 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -88,19 +88,28 @@ static const EnumPropertyItem DT_layer_items[] = {
static const EnumPropertyItem *dt_layers_select_src_itemf(
bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
- EnumPropertyItem *item = NULL, tmp_item = {0};
- int totitem = 0;
- const int data_type = RNA_enum_get(ptr, "data_type");
-
if (!C) { /* needed for docs and i18n tools */
return rna_enum_dt_layers_select_src_items;
}
+ EnumPropertyItem *item = NULL, tmp_item = {0};
+ int totitem = 0;
+ const int data_type = RNA_enum_get(ptr, "data_type");
+
Depsgraph *depsgraph = CTX_data_depsgraph(C);
- RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ACTIVE_SRC);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer");
+ const bool reverse_transfer = prop != NULL && RNA_property_boolean_get(ptr, prop);
+ const int layers_select_dst = reverse_transfer ? RNA_enum_get(ptr, "layers_select_src") :
+ RNA_enum_get(ptr, "layers_select_dst");
+
+ if (!reverse_transfer || layers_select_dst == DT_LAYERS_ACTIVE_DST || layers_select_dst >= 0) {
+ RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ACTIVE_SRC);
+ }
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC);
+
+
if (data_type == DT_TYPE_MDEFORMVERT) {
Object *ob_src = CTX_data_active_object(C);
@@ -184,16 +193,19 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
static const EnumPropertyItem *dt_layers_select_dst_itemf(
bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
- EnumPropertyItem *item = NULL;
- int totitem = 0;
-
- const int layers_select_src = RNA_enum_get(ptr, "layers_select_src");
-
if (!C) { /* needed for docs and i18n tools */
return rna_enum_dt_layers_select_dst_items;
}
- if (layers_select_src == DT_LAYERS_ACTIVE_SRC || layers_select_src >= 0) {
+ EnumPropertyItem *item = NULL;
+ int totitem = 0;
+
+ PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer");
+ const bool reverse_transfer = prop != NULL && RNA_property_boolean_get(ptr, prop);
+ const int layers_select_src = reverse_transfer ? RNA_enum_get(ptr, "layers_select_dst") :
+ RNA_enum_get(ptr, "layers_select_src");
+
+ if (reverse_transfer || layers_select_src == DT_LAYERS_ACTIVE_SRC || layers_select_src >= 0) {
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_dst_items, DT_LAYERS_ACTIVE_DST);
}
RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_dst_items, DT_LAYERS_NAME_DST);
@@ -329,7 +341,7 @@ static bool data_transfer_exec_is_object_valid(
return true;
}
else if (!ID_IS_LINKED(me)) {
- /* Do not transfer apply operation more than once. */
+ /* Do not apply transfer operation more than once. */
/* XXX This is not nice regarding vgroups, which are half-Object data... :/ */
BKE_reportf(op->reports, RPT_WARNING,
"Skipping object '%s', data '%s' has already been processed with a previous object",
@@ -518,7 +530,7 @@ static bool data_transfer_poll_property(const bContext *UNUSED(C), wmOperator *o
return true;
}
-/* transfers weight from active to selected */
+/* Transfer mesh data from active to selected objects. */
void OBJECT_OT_data_transfer(wmOperatorType *ot)
{
PropertyRNA *prop;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 9048b786044..7950e79162d 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -77,6 +77,7 @@
#include "BKE_softbody.h"
#include "BKE_editmesh.h"
#include "BKE_report.h"
+#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "DEG_depsgraph.h"
@@ -162,7 +163,10 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
changed = true;
if (select) {
- ED_object_base_select(base, BA_SELECT);
+ /* We cannot call `ED_object_base_select` because
+ * base is not selectable while it is hidden. */
+ base->flag |= BASE_SELECTED;
+ BKE_scene_object_base_flag_sync_from_base(base);
}
}
}
@@ -735,6 +739,12 @@ static int posemode_exec(bContext *C, wmOperator *op)
{
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
Base *base = CTX_data_active_base(C);
+
+ /* If the base is NULL it means we have an active object, but the object itself is hidden. */
+ if (base == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+
Object *obact = base->object;
const int mode_flag = OB_MODE_POSE;
bool is_mode_set = (obact->mode & mode_flag) != 0;
@@ -1701,6 +1711,7 @@ void OBJECT_OT_move_to_collection(wmOperatorType *ot)
prop = RNA_def_string(ot->srna, "new_collection_name", NULL, MAX_NAME, "Name",
"Name of the newly added collection");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ ot->prop = prop;
}
void OBJECT_OT_link_to_collection(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index f65abb2f269..401260df406 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -442,7 +442,7 @@ static bool hook_op_edit_poll(bContext *C)
return 0;
}
-static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit)
+static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, Object *obedit)
{
Base *basedit;
Object *ob;
@@ -452,6 +452,10 @@ static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_la
basedit = BKE_view_layer_base_find(view_layer, obedit);
BLI_assert(view_layer->basact->object == ob);
+ if (v3d && v3d->localvd) {
+ view_layer->basact->local_view_bits |= v3d->local_view_uuid;
+ }
+
/* icky, BKE_object_add sets new base as active.
* so set it back to the original edit object */
view_layer->basact = basedit;
@@ -459,7 +463,16 @@ static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_la
return ob;
}
-static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit, Object *ob, int mode, ReportList *reports)
+static int add_hook_object(
+ const bContext *C,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer,
+ View3D *v3d,
+ Object *obedit,
+ Object *ob,
+ int mode,
+ ReportList *reports)
{
ModifierData *md = NULL;
HookModifierData *hmd = NULL;
@@ -477,7 +490,7 @@ static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLay
if (mode == OBJECT_ADDHOOK_NEWOB && !ob) {
- ob = add_hook_object_new(bmain, scene, view_layer, obedit);
+ ob = add_hook_object_new(bmain, scene, view_layer, v3d, obedit);
/* transform cent to global coords for loc */
mul_v3_m4v3(ob->loc, obedit->obmat, cent);
@@ -576,7 +589,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (add_hook_object(C, bmain, scene, view_layer, obedit, obsel, mode, op->reports)) {
+ if (add_hook_object(C, bmain, scene, view_layer, NULL, obedit, obsel, mode, op->reports)) {
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit);
return OPERATOR_FINISHED;
}
@@ -608,9 +621,10 @@ static int object_add_hook_newob_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
Object *obedit = CTX_data_edit_object(C);
- if (add_hook_object(C, bmain, scene, view_layer, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) {
+ if (add_hook_object(C, bmain, scene, view_layer, v3d, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) {
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index a55163b01d1..c3a562df037 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -283,8 +283,7 @@ static bool object_modifier_safe_to_delete(Main *bmain, Object *ob,
ModifierType type)
{
return (!object_has_modifier(ob, exclude, type) &&
- !ED_object_iter_other(bmain, ob, false,
- object_has_modifier_cb, &type));
+ !ED_object_iter_other(bmain, ob, false, object_has_modifier_cb, &type));
}
static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md,
@@ -542,6 +541,22 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports),
return 1;
}
+/* Gets mesh for the modifier which corresponds to an evaluated state. */
+static Mesh *modifier_apply_create_mesh_for_modifier(
+ Depsgraph *depsgraph,
+ Scene *UNUSED(scene),
+ Object *object,
+ ModifierData *md,
+ bool build_shapekey_layers)
+{
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
+ ModifierData *md_eval = modifiers_findByName(object_eval, md->name);
+ Mesh *mesh_applied = BKE_mesh_create_derived_for_modifier(
+ depsgraph, scene_eval, object_eval, md_eval, build_shapekey_layers);
+ return mesh_applied;
+}
+
static int modifier_apply_shape(
Main *bmain, ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md)
{
@@ -574,7 +589,7 @@ static int modifier_apply_shape(
return 0;
}
- mesh_applied = BKE_mesh_create_derived_for_modifier(depsgraph, scene, ob, md, 0);
+ mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md, false);
if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
return 0;
@@ -631,7 +646,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
}
}
else {
- mesh_applied = BKE_mesh_create_derived_for_modifier(depsgraph, scene, ob, md, 1);
+ mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md, true);
if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
return 0;
@@ -644,22 +659,23 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
}
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
- Curve *cu;
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+ Curve *curve = ob->data;
+ Curve *curve_eval = (Curve *)object_eval->data;
int numVerts;
float (*vertexCos)[3];
- ModifierEvalContext mectx = {depsgraph, ob, 0};
+ ModifierEvalContext mectx = {depsgraph, object_eval, 0};
if (ELEM(mti->type, eModifierTypeType_Constructive, eModifierTypeType_Nonconstructive)) {
BKE_report(reports, RPT_ERROR, "Transform curve to mesh in order to apply constructive modifiers");
return 0;
}
- cu = ob->data;
BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices");
- vertexCos = BKE_curve_nurbs_vertexCos_get(&cu->nurb, &numVerts);
+ vertexCos = BKE_curve_nurbs_vertexCos_get(&curve_eval->nurb, &numVerts);
mti->deformVerts(md, &mectx, NULL, vertexCos, numVerts);
- BK_curve_nurbs_vertexCos_apply(&cu->nurb, vertexCos);
+ BK_curve_nurbs_vertexCos_apply(&curve->nurb, vertexCos);
MEM_freeN(vertexCos);
@@ -1182,9 +1198,10 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op)
multiresModifier_del_levels(mmd, scene, ob, 1);
- ED_object_iter_other(CTX_data_main(C), ob, true,
- ED_object_multires_update_totlevels_cb,
- &mmd->totlvl);
+ ED_object_iter_other(
+ CTX_data_main(C), ob, true,
+ ED_object_multires_update_totlevels_cb,
+ &mmd->totlvl);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1227,9 +1244,10 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
multiresModifier_subdivide(mmd, scene, ob, 0, mmd->simple);
- ED_object_iter_other(CTX_data_main(C), ob, true,
- ED_object_multires_update_totlevels_cb,
- &mmd->totlvl);
+ ED_object_iter_other(
+ CTX_data_main(C), ob, true,
+ ED_object_multires_update_totlevels_cb,
+ &mmd->totlvl);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1404,8 +1422,8 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
WM_operator_properties_filesel(
- ot, FILE_TYPE_FOLDER | FILE_TYPE_BTX, FILE_SPECIAL, FILE_SAVE,
- WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
+ ot, FILE_TYPE_FOLDER | FILE_TYPE_BTX, FILE_SPECIAL, FILE_SAVE,
+ WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
edit_modifier_properties(ot);
}
@@ -1769,8 +1787,9 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature");
mvert_skin = CustomData_get_layer(&me->vdata, CD_MVERT_SKIN);
- BKE_mesh_vert_edge_map_create(&emap, &emap_mem,
- me->medge, me->totvert, me->totedge);
+ BKE_mesh_vert_edge_map_create(
+ &emap, &emap_mem,
+ me->medge, me->totvert, me->totedge);
edges_visited = BLI_BITMAP_NEW(me->totedge, "edge_visited");
@@ -2174,9 +2193,10 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- och = BKE_ocean_init_cache(omd->cachepath, modifier_path_relbase(bmain, ob),
- omd->bakestart, omd->bakeend, omd->wave_scale,
- omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
+ och = BKE_ocean_init_cache(
+ omd->cachepath, modifier_path_relbase(bmain, ob),
+ omd->bakestart, omd->bakeend, omd->wave_scale,
+ omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
och->time = MEM_mallocN(och->duration * sizeof(float), "foam bake time");
@@ -2213,8 +2233,9 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
scene->r.cfra = cfra;
/* setup job */
- wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation",
- WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN);
+ wm_job = WM_jobs_get(
+ CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation",
+ WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN);
oj = MEM_callocN(sizeof(OceanBakeJob), "ocean bake job");
oj->owner = ob;
oj->ocean = ocean;
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index dbd90628136..d069772a0ce 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -151,9 +151,12 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
EDBM_mesh_normals_update(em);
BKE_editmesh_tessface_calc(em);
- /* derivedMesh might be needed for solving parenting,
- * so re-create it here */
- makeDerivedMesh(depsgraph, scene, obedit, em, &CD_MASK_BAREMESH_ORIGINDEX, false);
+ /* Make sure the evaluated mesh is updates.
+ *
+ * Most reliable way is to update the tagged objects, which will ensure
+ * proper copy-on-write update, but also will make sure all dependent
+ * objects are also up to date. */
+ BKE_scene_graph_update_tagged(depsgraph, bmain);
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
@@ -628,14 +631,16 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
return 0;
else {
Curve *cu = par->data;
-
+ Curve *cu_eval = parent_eval->data;
if ((cu->flag & CU_PATH) == 0) {
cu->flag |= CU_PATH | CU_FOLLOW;
+ cu_eval->flag |= CU_PATH | CU_FOLLOW;
/* force creation of path data */
BKE_displist_make_curveTypes(depsgraph, scene, par, false, false, NULL);
}
else {
cu->flag |= CU_FOLLOW;
+ cu_eval->flag |= CU_FOLLOW;
}
/* if follow, add F-Curve for ctime (i.e. "eval_time") so that path-follow works */
@@ -835,14 +840,14 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
-static void parent_set_vert_find(KDTree *tree, Object *child, int vert_par[3], bool is_tri)
+static void parent_set_vert_find(KDTree_3d *tree, Object *child, int vert_par[3], bool is_tri)
{
const float *co_find = child->obmat[3];
if (is_tri) {
- KDTreeNearest nearest[3];
+ KDTreeNearest_3d nearest[3];
int tot;
- tot = BLI_kdtree_find_nearest_n(tree, co_find, nearest, 3);
+ tot = BLI_kdtree_3d_find_nearest_n(tree, co_find, nearest, 3);
BLI_assert(tot == 3);
UNUSED_VARS(tot);
@@ -853,7 +858,7 @@ static void parent_set_vert_find(KDTree *tree, Object *child, int vert_par[3], b
BLI_assert(min_iii(UNPACK3(vert_par)) >= 0);
}
else {
- vert_par[0] = BLI_kdtree_find_nearest(tree, co_find, NULL);
+ vert_par[0] = BLI_kdtree_3d_find_nearest(tree, co_find, NULL);
BLI_assert(vert_par[0] >= 0);
vert_par[1] = 0;
vert_par[2] = 0;
@@ -874,7 +879,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
const bool is_vert_par = ELEM(partype, PAR_VERTEX, PAR_VERTEX_TRI);
const bool is_tri = partype == PAR_VERTEX_TRI;
int tree_tot;
- struct KDTree *tree = NULL;
+ struct KDTree_3d *tree = NULL;
int vert_par[3] = {0, 0, 0};
const int *vert_par_p = is_vert_par ? vert_par : NULL;
@@ -906,7 +911,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
}
if (is_vert_par) {
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
}
if (!ok)
@@ -1356,9 +1361,13 @@ static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst
return true;
}
break;
+ case MAKE_LINKS_DUPLICOLLECTION:
+ if (ob_dst->type == OB_EMPTY) {
+ return true;
+ }
+ break;
case MAKE_LINKS_ANIMDATA:
case MAKE_LINKS_GROUP:
- case MAKE_LINKS_DUPLICOLLECTION:
return true;
case MAKE_LINKS_MODIFIERS:
if (!ELEM(OB_EMPTY, ob_src->type, ob_dst->type)) {
@@ -1392,7 +1401,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
/* avoid searching all collections in source object each time */
if (type == MAKE_LINKS_GROUP) {
- ob_collections = BKE_object_groups(bmain, ob_src);
+ ob_collections = BKE_object_groups(bmain, scene, ob_src);
}
CTX_DATA_BEGIN (C, Base *, base_dst, selected_editable_bases)
@@ -1441,7 +1450,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
LinkNode *collection_node;
/* first clear collections */
- BKE_object_groups_clear(bmain, ob_dst);
+ BKE_object_groups_clear(bmain, scene, ob_dst);
/* now add in the collections from the link nodes */
for (collection_node = ob_collections; collection_node; collection_node = collection_node->next) {
@@ -1593,7 +1602,7 @@ static void libblock_relink_collection(Collection *collection)
}
}
-static void single_object_users_collection(
+static Collection *single_object_users_collection(
Main *bmain, Scene *scene, Collection *collection,
const int flag, const bool copy_collections, const bool is_master_collection)
{
@@ -1614,9 +1623,26 @@ static void single_object_users_collection(
}
}
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
- single_object_users_collection(bmain, scene, child->collection, flag, copy_collections, false);
+ /* 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) {
+ child_next = child->next;
+ Collection *collection_child_new = single_object_users_collection(
+ bmain, scene, child->collection, flag, copy_collections, false);
+ if (is_master_collection && copy_collections && child->collection != collection_child_new) {
+ BKE_collection_child_add(bmain, collection, collection_child_new);
+ BLI_remlink(&collection->children, child);
+ MEM_freeN(child);
+ if (child == orig_child_last) {
+ break;
+ }
+ }
}
+
+ return collection;
}
/* Warning, sets ID->newid pointers of objects and collections, but does not clear them. */
@@ -1665,9 +1691,12 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
/* active camera */
ID_NEW_REMAP(scene->camera);
- if (v3d) ID_NEW_REMAP(v3d->camera);
+ if (v3d) {
+ ID_NEW_REMAP(v3d->camera);
+ }
- BKE_scene_collection_sync(scene);
+ /* Making single user may affect other scenes if they share with current one some collections in their ViewLayer. */
+ BKE_main_collection_sync(bmain);
}
/* not an especially efficient function, only added so the single user
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 2155956727e..919055aa668 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -86,13 +86,14 @@
/** \name Public Object Selection API
* \{ */
-/* simple API for object selection, rather than just using the flag
+/**
+ * simple API for object selection, rather than just using the flag
* this takes into account the 'restrict selection in 3d view' flag.
- * deselect works always, the restriction just prevents selection */
-
- /* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or
- * or a NC_SCENE|ND_OB_VISIBLE in case of visibility toggling */
-
+ * deselect works always, the restriction just prevents selection
+ *
+ * \note Caller must send a `NC_SCENE | ND_OB_SELECT` notifier
+ * (or a `NC_SCENE | ND_OB_VISIBLE` in case of visibility toggling).
+ */
void ED_object_base_select(Base *base, eObjectSelect_Mode mode)
{
if (mode == BA_INVERT) {
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index b2f314a66ec..112d453c44a 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -150,7 +150,7 @@ void PE_free_ptcache_edit(PTCacheEdit *edit)
}
if (edit->emitter_field) {
- BLI_kdtree_free(edit->emitter_field);
+ BLI_kdtree_3d_free(edit->emitter_field);
edit->emitter_field = 0;
}
@@ -405,7 +405,6 @@ typedef struct PEData {
const int *mval;
const rcti *rect;
float rad;
- float dist;
float dval;
int select;
eSelectOp sel_op;
@@ -432,6 +431,7 @@ static void PE_set_data(bContext *C, PEData *data)
{
memset(data, 0, sizeof(*data));
+ data->context = C;
data->bmain = CTX_data_main(C);
data->scene = CTX_data_scene(C);
data->view_layer = CTX_data_view_layer(C);
@@ -451,7 +451,7 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
/* needed or else the draw matrix can be incorrect */
view3d_operator_needs_opengl(C);
- ED_view3d_backbuf_validate(&data->vc);
+ ED_view3d_backbuf_depth_validate(&data->vc);
/* we may need to force an update here by setting the rv3d as dirty
* for now it seems ok, but take care!:
* rv3d->depths->dirty = 1; */
@@ -496,7 +496,7 @@ static void PE_free_random_generator(PEData *data)
/*************************** selection utilities *******************************/
-static bool key_test_depth(PEData *data, const float co[3], const int screen_co[2])
+static bool key_test_depth(const PEData *data, const float co[3], const int screen_co[2])
{
View3D *v3d = data->vc.v3d;
ViewDepths *vd = data->vc.rv3d->depths;
@@ -533,7 +533,7 @@ static bool key_test_depth(PEData *data, const float co[3], const int screen_co[
return 1;
}
-static bool key_inside_circle(PEData *data, float rad, const float co[3], float *distance)
+static bool key_inside_circle(const PEData *data, float rad, const float co[3], float *distance)
{
float dx, dy, dist;
int screen_co[2];
@@ -601,9 +601,35 @@ static bool point_is_selected(PTCacheEditPoint *point)
/*************************** iterators *******************************/
-typedef void (*ForPointFunc)(PEData *data, int point_index);
-typedef void (*ForKeyFunc)(PEData *data, int point_index, int key_index, bool is_inside);
-typedef void (*ForKeyMatFunc)(PEData *data, float mat[4][4], float imat[4][4], int point_index, int key_index, PTCacheEditKey *key);
+typedef void (*ForPointFunc)(
+ PEData *data,
+ int point_index);
+typedef void (*ForHitPointFunc)(
+ PEData *data,
+ int point_index,
+ float mouse_distance);
+
+typedef void (*ForKeyFunc)(
+ PEData *data,
+ int point_index,
+ int key_index,
+ bool is_inside);
+
+typedef void (*ForKeyMatFunc)(
+ PEData *data,
+ float mat[4][4],
+ float imat[4][4],
+ int point_index,
+ int key_index,
+ PTCacheEditKey *key);
+typedef void (*ForHitKeyMatFunc)(
+ PEData *data,
+ float mat[4][4],
+ float imat[4][4],
+ int point_index,
+ int key_index,
+ PTCacheEditKey *key,
+ float mouse_distance);
enum eParticleSelectFlag {
PSEL_NEAREST = (1 << 0),
@@ -672,7 +698,7 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, const enum ePartic
}
}
-static void foreach_mouse_hit_point(PEData *data, ForPointFunc func, int selected)
+static void foreach_mouse_hit_point(PEData *data, ForHitPointFunc func, int selected)
{
ParticleEditSettings *pset = PE_settings(data->scene);
PTCacheEdit *edit = data->edit;
@@ -688,17 +714,21 @@ static void foreach_mouse_hit_point(PEData *data, ForPointFunc func, int selecte
/* only do end keys */
key = point->keys + point->totkey - 1;
- if (selected == 0 || key->flag & PEK_SELECT)
- if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist))
- func(data, p);
+ if (selected == 0 || key->flag & PEK_SELECT) {
+ float mouse_distance;
+ if (key_inside_circle(data, data->rad, KEY_WCO, &mouse_distance)) {
+ func(data, p, mouse_distance);
+ }
+ }
}
}
else {
/* do all keys */
LOOP_VISIBLE_KEYS {
if (selected == 0 || key->flag & PEK_SELECT) {
- if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) {
- func(data, p);
+ float mouse_distance;
+ if (key_inside_circle(data, data->rad, KEY_WCO, &mouse_distance)) {
+ func(data, p, mouse_distance);
break;
}
}
@@ -711,7 +741,7 @@ typedef struct KeyIterData {
PEData *data;
PTCacheEdit *edit;
int selected;
- ForKeyMatFunc func;
+ ForHitKeyMatFunc func;
} KeyIterData;
static void foreach_mouse_hit_key_iter(
@@ -739,12 +769,13 @@ static void foreach_mouse_hit_key_iter(
PTCacheEditKey *key = point->keys + point->totkey - 1;
if (selected == 0 || key->flag & PEK_SELECT) {
- if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) {
+ float mouse_distance;
+ if (key_inside_circle(data, data->rad, KEY_WCO, &mouse_distance)) {
if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(data->ob, psmd_eval->mesh_final, psys->part->from, psys->particles + iter, mat);
invert_m4_m4(imat, mat);
}
- iter_data->func(data, mat, imat, iter, point->totkey - 1, key);
+ iter_data->func(data, mat, imat, iter, point->totkey - 1, key, mouse_distance);
}
}
}
@@ -755,19 +786,20 @@ static void foreach_mouse_hit_key_iter(
int k;
LOOP_VISIBLE_KEYS {
if (selected == 0 || key->flag & PEK_SELECT) {
- if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) {
+ float mouse_distance;
+ if (key_inside_circle(data, data->rad, KEY_WCO, &mouse_distance)) {
if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(data->ob, psmd_eval->mesh_final, psys->part->from, psys->particles + iter, mat);
invert_m4_m4(imat, mat);
}
- iter_data->func(data, mat, imat, iter, k, key);
+ iter_data->func(data, mat, imat, iter, k, key, mouse_distance);
}
}
}
}
}
-static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected)
+static void foreach_mouse_hit_key(PEData *data, ForHitKeyMatFunc func, int selected)
{
PTCacheEdit *edit = data->edit;
ParticleEditSettings *pset = PE_settings(data->scene);
@@ -852,8 +884,8 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
{
PTCacheEdit *edit;
ParticleSystemModifierData *psmd_eval;
- KDTree *tree;
- KDTreeNearest nearest;
+ KDTree_3d *tree;
+ KDTreeNearest_3d nearest;
HairKey *key;
PARTICLE_P;
float mat[4][4], co[3];
@@ -866,7 +898,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
if (!psmd_eval->mesh_final)
return;
- tree = BLI_kdtree_new(totpart);
+ tree = BLI_kdtree_3d_new(totpart);
/* insert particles into kd tree */
LOOP_PARTICLES {
@@ -874,10 +906,10 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
psys_mat_hair_to_orco(ob, psmd_eval->mesh_final, psys->part->from, pa, mat);
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
- BLI_kdtree_insert(tree, p, co);
+ BLI_kdtree_3d_insert(tree, p, co);
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
/* lookup particles and set in mirror cache */
if (!edit->mirror_cache)
@@ -890,7 +922,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
mul_m4_v3(mat, co);
co[0] = -co[0];
- index = BLI_kdtree_find_nearest(tree, co, &nearest);
+ 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))
@@ -908,7 +940,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
}
}
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
}
static void PE_mirror_particle(Object *ob, Mesh *mesh, ParticleSystem *psys, ParticleData *pa, ParticleData *mpa)
@@ -1076,7 +1108,7 @@ static void deflect_emitter_iter(
dist_1st *= dist * emitterdist;
}
else {
- index = BLI_kdtree_find_nearest(edit->emitter_field, key->co, NULL);
+ index = BLI_kdtree_3d_find_nearest(edit->emitter_field, key->co, NULL);
vec = edit->emitter_cosnos + index * 6;
nor = vec + 3;
@@ -1298,14 +1330,14 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part
if (edit->emitter_cosnos)
MEM_freeN(edit->emitter_cosnos);
- BLI_kdtree_free(edit->emitter_field);
+ BLI_kdtree_3d_free(edit->emitter_field);
totface = mesh->totface;
/*totvert=dm->getNumVerts(dm);*/ /*UNUSED*/
edit->emitter_cosnos = MEM_callocN(totface * 6 * sizeof(float), "emitter cosnos");
- edit->emitter_field = BLI_kdtree_new(totface);
+ edit->emitter_field = BLI_kdtree_3d_new(totface);
vec = edit->emitter_cosnos;
nor = vec + 3;
@@ -1339,10 +1371,10 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part
normalize_v3(nor);
- BLI_kdtree_insert(edit->emitter_field, i, vec);
+ BLI_kdtree_3d_insert(edit->emitter_field, i, vec);
}
- BLI_kdtree_balance(edit->emitter_field);
+ BLI_kdtree_3d_balance(edit->emitter_field);
}
static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob, int useflag)
@@ -1530,6 +1562,7 @@ static void select_key_op(PEData *data, int point_index, int key_index, bool is_
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(key->flag, sel_op_result, PEK_SELECT);
point->flag |= PEP_EDIT_RECALC;
+ data->is_changed = true;
}
}
@@ -1555,8 +1588,11 @@ static void extend_key_select(PEData *data, int point_index, int key_index, bool
PTCacheEditPoint *point = edit->points + point_index;
PTCacheEditKey *key = point->keys + key_index;
- key->flag |= PEK_SELECT;
- point->flag |= PEP_EDIT_RECALC;
+ if ((key->flag & PEK_SELECT) == 0) {
+ key->flag |= PEK_SELECT;
+ point->flag |= PEP_EDIT_RECALC;
+ data->is_changed = true;
+ }
}
static void deselect_key_select(PEData *data, int point_index, int key_index, bool UNUSED(is_inside))
@@ -1565,8 +1601,11 @@ static void deselect_key_select(PEData *data, int point_index, int key_index, bo
PTCacheEditPoint *point = edit->points + point_index;
PTCacheEditKey *key = point->keys + key_index;
- key->flag &= ~PEK_SELECT;
- point->flag |= PEP_EDIT_RECALC;
+ if ((key->flag & PEK_SELECT) != 0) {
+ key->flag &= ~PEK_SELECT;
+ point->flag |= PEP_EDIT_RECALC;
+ data->is_changed = true;
+ }
}
static void toggle_key_select(PEData *data, int point_index, int key_index, bool UNUSED(is_inside))
@@ -1577,36 +1616,43 @@ static void toggle_key_select(PEData *data, int point_index, int key_index, bool
key->flag ^= PEK_SELECT;
point->flag |= PEP_EDIT_RECALC;
+ data->is_changed = true;
}
/************************ de select all operator ************************/
-static void select_action_apply(PTCacheEditPoint *point, PTCacheEditKey *key, int action)
+static bool select_action_apply(PTCacheEditPoint *point, PTCacheEditKey *key, int action)
{
+ bool changed = false;
switch (action) {
case SEL_SELECT:
if ((key->flag & PEK_SELECT) == 0) {
key->flag |= PEK_SELECT;
point->flag |= PEP_EDIT_RECALC;
+ changed = true;
}
break;
case SEL_DESELECT:
if (key->flag & PEK_SELECT) {
key->flag &= ~PEK_SELECT;
point->flag |= PEP_EDIT_RECALC;
+ changed = true;
}
break;
case SEL_INVERT:
if ((key->flag & PEK_SELECT) == 0) {
key->flag |= PEK_SELECT;
point->flag |= PEP_EDIT_RECALC;
+ changed = true;
}
else {
key->flag &= ~PEK_SELECT;
point->flag |= PEP_EDIT_RECALC;
+ changed = true;
}
break;
}
+ return changed;
}
static int pe_select_all_exec(bContext *C, wmOperator *op)
@@ -1631,15 +1677,17 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
}
}
+ bool changed = false;
LOOP_VISIBLE_POINTS {
LOOP_VISIBLE_KEYS {
- select_action_apply(point, key, action);
+ changed |= select_action_apply(point, key, action);
}
}
- PE_update_selection(depsgraph, scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob);
-
+ if (changed) {
+ PE_update_selection(depsgraph, scene, ob, 1);
+ WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob);
+ }
return OPERATOR_FINISHED;
}
@@ -1662,7 +1710,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot)
/************************ pick select operator ************************/
-int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
+bool PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
{
PEData data;
Scene *scene = CTX_data_scene(C);
@@ -1670,8 +1718,9 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec
PTCacheEdit *edit = PE_get_current(scene, ob);
POINT_P; KEY_K;
- if (!PE_start_edit(edit))
- return OPERATOR_CANCELLED;
+ if (!PE_start_edit(edit)) {
+ return false;
+ }
if (!extend && !deselect && !toggle) {
LOOP_VISIBLE_POINTS {
@@ -1697,10 +1746,12 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec
for_mouse_hit_keys(&data, toggle_key_select, PSEL_NEAREST);
}
- PE_update_selection(data.depsgraph, scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
+ if (data.is_changed) {
+ PE_update_selection(data.depsgraph, scene, ob, 1);
+ WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
+ }
- return OPERATOR_FINISHED;
+ return true;
}
/************************ select root operator ************************/
@@ -1713,10 +1764,12 @@ static void select_root(PEData *data, int point_index)
if (point->flag & PEP_HIDE)
return;
- if (data->select_action != SEL_TOGGLE)
- select_action_apply(point, key, data->select_action);
- else if (key->flag & PEK_SELECT)
+ if (data->select_action != SEL_TOGGLE) {
+ data->is_changed = select_action_apply(point, key, data->select_action);
+ }
+ else if (key->flag & PEK_SELECT) {
data->select_toggle_action = SEL_DESELECT;
+ }
}
static int select_roots_exec(bContext *C, wmOperator *op)
@@ -1738,9 +1791,10 @@ static int select_roots_exec(bContext *C, wmOperator *op)
data.select_action = action;
foreach_point(&data, select_root);
- PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
-
+ if (data.is_changed) {
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
+ WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
+ }
return OPERATOR_FINISHED;
}
@@ -1778,10 +1832,12 @@ static void select_tip(PEData *data, int point_index)
if (point->flag & PEP_HIDE)
return;
- if (data->select_action != SEL_TOGGLE)
- select_action_apply(point, key, data->select_action);
- else if (key->flag & PEK_SELECT)
+ if (data->select_action != SEL_TOGGLE) {
+ data->is_changed = select_action_apply(point, key, data->select_action);
+ }
+ else if (key->flag & PEK_SELECT) {
data->select_toggle_action = SEL_DESELECT;
+ }
}
static int select_tips_exec(bContext *C, wmOperator *op)
@@ -1803,10 +1859,13 @@ static int select_tips_exec(bContext *C, wmOperator *op)
data.select_action = action;
foreach_point(&data, select_tip);
- PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
+ if (data.is_changed) {
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
+ WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
+ }
+ return OPERATOR_CANCELLED;
}
void PARTICLE_OT_select_tips(wmOperatorType *ot)
@@ -1867,7 +1926,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
LOOP_VISIBLE_POINTS {
int flag = ((BLI_rng_get_float(rng) < randfac) == select) ? SEL_SELECT : SEL_DESELECT;
LOOP_KEYS {
- select_action_apply(point, key, flag);
+ data.is_changed |= select_action_apply(point, key, flag);
}
}
break;
@@ -1875,7 +1934,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
LOOP_VISIBLE_POINTS {
LOOP_VISIBLE_KEYS {
int flag = ((BLI_rng_get_float(rng) < randfac) == select) ? SEL_SELECT : SEL_DESELECT;
- select_action_apply(point, key, flag);
+ data.is_changed |= select_action_apply(point, key, flag);
}
}
break;
@@ -1883,9 +1942,10 @@ static int select_random_exec(bContext *C, wmOperator *op)
BLI_rng_free(rng);
- PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
- WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
-
+ if (data.is_changed) {
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
+ WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, data.ob);
+ }
return OPERATOR_FINISHED;
}
@@ -1960,42 +2020,58 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot)
}
/************************ box select operator ************************/
-void PE_deselect_all_visible(PTCacheEdit *edit)
+bool PE_deselect_all_visible_ex(PTCacheEdit *edit)
{
+ bool changed = false;
POINT_P; KEY_K;
LOOP_VISIBLE_POINTS {
LOOP_SELECTED_KEYS {
- key->flag &= ~PEK_SELECT;
- point->flag |= PEP_EDIT_RECALC;
+ if ((key->flag & PEK_SELECT) != 0) {
+ key->flag &= ~PEK_SELECT;
+ point->flag |= PEP_EDIT_RECALC;
+ changed = true;
+ }
}
}
+ return changed;
}
-int PE_box_select(bContext *C, const rcti *rect, const int sel_op)
+bool PE_deselect_all_visible(bContext *C)
{
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
- PEData data;
+ if (!PE_start_edit(edit)) {
+ return false;
+ }
+ return PE_deselect_all_visible_ex(edit);
+}
- if (!PE_start_edit(edit))
- return OPERATOR_CANCELLED;
+bool PE_box_select(bContext *C, const rcti *rect, const int sel_op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ PTCacheEdit *edit = PE_get_current(scene, ob);
+ PEData data;
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- PE_deselect_all_visible(edit);
+ if (!PE_start_edit(edit)) {
+ return false;
}
PE_set_view3d_data(C, &data);
data.rect = rect;
data.sel_op = sel_op;
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ data.is_changed = PE_deselect_all_visible_ex(edit);
+ }
for_mouse_hit_keys(&data, select_key_op, PSEL_ALL_KEYS);
-
- PE_update_selection(data.depsgraph, scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob);
-
- return OPERATOR_FINISHED;
+ if (data.is_changed) {
+ PE_update_selection(data.depsgraph, scene, ob, 1);
+ WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob);
+ }
+ return data.is_changed;
}
/************************ circle select operator ************************/
@@ -2012,11 +2088,6 @@ bool PE_circle_select(bContext *C, const int sel_op, const int mval[2], float ra
return false;
}
- bool changed = false;
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- PE_deselect_all_visible(edit);
- changed = true;
- }
const bool select = (sel_op != SEL_OP_SUB);
PE_set_view3d_data(C, &data);
@@ -2024,14 +2095,15 @@ bool PE_circle_select(bContext *C, const int sel_op, const int mval[2], float ra
data.rad = rad;
data.select = select;
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ data.is_changed = PE_deselect_all_visible_ex(edit);
+ }
for_mouse_hit_keys(&data, select_key, 0);
- changed |= data.is_changed;
-
- if (changed) {
+ if (data.is_changed) {
PE_update_selection(data.depsgraph, scene, ob, 1);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob);
}
- return changed;
+ return data.is_changed;
}
/************************ lasso select operator ************************/
@@ -2056,13 +2128,13 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
if (!PE_start_edit(edit))
return OPERATOR_CANCELLED;
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- PE_deselect_all_visible(edit);
- }
-
/* only for depths */
PE_set_view3d_data(C, &data);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ data.is_changed |= PE_deselect_all_visible_ex(edit);
+ }
+
LOOP_VISIBLE_POINTS {
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);
@@ -2080,6 +2152,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(key->flag, sel_op_result, PEK_SELECT);
point->flag |= PEP_EDIT_RECALC;
+ data.is_changed = true;
}
}
}
@@ -2097,15 +2170,18 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(key->flag, sel_op_result, PEK_SELECT);
point->flag |= PEP_EDIT_RECALC;
+ data.is_changed = true;
}
}
}
}
- PE_update_selection(data.depsgraph, scene, ob, 1);
- WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob);
-
- return OPERATOR_FINISHED;
+ if (data.is_changed) {
+ PE_update_selection(data.depsgraph, scene, ob, 1);
+ WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_SELECTED, ob);
+ return OPERATOR_FINISHED;
+ }
+ return OPERATOR_CANCELLED;
}
/*************************** hide operator **************************/
@@ -2235,9 +2311,10 @@ static void select_less_keys(PEData *data, int point_index)
}
LOOP_KEYS {
- if (key->flag & PEK_TAG) {
+ if ((key->flag & PEK_TAG) && (key->flag & PEK_SELECT)) {
key->flag &= ~(PEK_TAG | PEK_SELECT);
point->flag |= PEP_EDIT_RECALC; /* redraw selection only */
+ data->is_changed = true;
}
}
}
@@ -2296,10 +2373,11 @@ static void select_more_keys(PEData *data, int point_index)
}
LOOP_KEYS {
- if (key->flag & PEK_TAG) {
+ if ((key->flag & PEK_TAG) && (key->flag & PEK_SELECT) == 0) {
key->flag &= ~PEK_TAG;
key->flag |= PEK_SELECT;
point->flag |= PEP_EDIT_RECALC; /* redraw selection only */
+ data->is_changed = true;
}
}
}
@@ -2742,7 +2820,9 @@ static int subdivide_exec(bContext *C, wmOperator *UNUSED(op))
foreach_point(&data, subdivide_particle);
recalc_lengths(data.edit);
+ PE_update_selection(data.depsgraph, data.scene, data.ob, 1);
PE_update_object(data.depsgraph, data.scene, data.ob, 1);
+ DEG_id_tag_update(&data.ob->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, data.ob);
return OPERATOR_FINISHED;
@@ -2772,8 +2852,8 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
PTCacheEdit *edit = PE_get_current(scene, ob);
ParticleSystem *psys = edit->psys;
ParticleSystemModifierData *psmd_eval;
- KDTree *tree;
- KDTreeNearest nearest[10];
+ KDTree_3d *tree;
+ KDTreeNearest_3d nearest[10];
POINT_P;
float mat[4][4], co[3], threshold = RNA_float_get(op->ptr, "threshold");
int n, totn, removed, totremoved;
@@ -2788,17 +2868,17 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
do {
removed = 0;
- tree = BLI_kdtree_new(psys->totpart);
+ tree = BLI_kdtree_3d_new(psys->totpart);
/* insert particles into kd tree */
LOOP_SELECTED_POINTS {
psys_mat_hair_to_object(ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
copy_v3_v3(co, point->keys->co);
mul_m4_v3(mat, co);
- BLI_kdtree_insert(tree, p, co);
+ BLI_kdtree_3d_insert(tree, p, co);
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
/* tag particles to be removed */
LOOP_SELECTED_POINTS {
@@ -2806,7 +2886,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
copy_v3_v3(co, point->keys->co);
mul_m4_v3(mat, co);
- totn = BLI_kdtree_find_nearest_n(tree, co, nearest, 10);
+ totn = BLI_kdtree_3d_find_nearest_n(tree, co, nearest, 10);
for (n = 0; n < totn; n++) {
/* this needs a custom threshold still */
@@ -2819,7 +2899,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
}
}
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
/* remove tagged particles - don't do mirror here! */
remove_tagged_particles(ob, psys, 0);
@@ -3206,14 +3286,21 @@ void PARTICLE_OT_mirror(wmOperatorType *ot)
/************************* brush edit callbacks ********************/
-static void brush_comb(PEData *data, float UNUSED(mat[4][4]), float imat[4][4], int point_index, int key_index, PTCacheEditKey *key)
+static void brush_comb(
+ PEData *data,
+ float UNUSED(mat[4][4]),
+ float imat[4][4],
+ int point_index,
+ int key_index,
+ PTCacheEditKey *key,
+ float mouse_distance)
{
ParticleEditSettings *pset = PE_settings(data->scene);
float cvec[3], fac;
if (pset->flag & PE_LOCK_FIRST && key_index == 0) return;
- fac = (float)pow((double)(1.0f - data->dist / data->rad), (double)data->combfac);
+ fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->combfac);
copy_v3_v3(cvec, data->dvec);
mul_mat3_m4_v3(imat, cvec);
@@ -3326,7 +3413,7 @@ static void brush_cut(PEData *data, int pa_index)
}
}
-static void brush_length(PEData *data, int point_index)
+static void brush_length(PEData *data, int point_index, float UNUSED(mouse_distance))
{
PTCacheEdit *edit = data->edit;
PTCacheEditPoint *point = edit->points + point_index;
@@ -3348,7 +3435,7 @@ static void brush_length(PEData *data, int point_index)
point->flag |= PEP_EDIT_RECALC;
}
-static void brush_puff(PEData *data, int point_index)
+static void brush_puff(PEData *data, int point_index, float mouse_distance)
{
PTCacheEdit *edit = data->edit;
ParticleSystem *psys = edit->psys;
@@ -3393,7 +3480,7 @@ static void brush_puff(PEData *data, int point_index)
* ob->imat is set before calling */
mul_v3_m4v3(kco, data->ob->imat, co);
- point_index = BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL);
+ point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, NULL);
if (point_index == -1) return;
copy_v3_v3(co_root, co);
@@ -3407,7 +3494,7 @@ static void brush_puff(PEData *data, int point_index)
normalize_v3(onor_prev);
}
- fac = (float)pow((double)(1.0f - data->dist / data->rad), (double)data->pufffac);
+ fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->pufffac);
fac *= 0.025f;
if (data->invert)
fac = -fac;
@@ -3480,7 +3567,7 @@ static void brush_puff(PEData *data, int point_index)
* ob->imat is set before calling */
mul_v3_m4v3(kco, data->ob->imat, oco);
- point_index = BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL);
+ point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, NULL);
if (point_index != -1) {
copy_v3_v3(onor, &edit->emitter_cosnos[point_index * 6 + 3]);
mul_mat3_m4_v3(data->ob->obmat, onor); /* normal into worldspace */
@@ -3511,7 +3598,14 @@ static void brush_puff(PEData *data, int point_index)
}
-static void BKE_brush_weight_get(PEData *data, float UNUSED(mat[4][4]), float UNUSED(imat[4][4]), int point_index, int key_index, PTCacheEditKey *UNUSED(key))
+static void BKE_brush_weight_get(
+ PEData *data,
+ float UNUSED(mat[4][4]),
+ float UNUSED(imat[4][4]),
+ int point_index,
+ int key_index,
+ PTCacheEditKey *UNUSED(key),
+ float UNUSED(mouse_distance))
{
/* roots have full weight always */
if (key_index) {
@@ -3525,7 +3619,14 @@ static void BKE_brush_weight_get(PEData *data, float UNUSED(mat[4][4]), float UN
}
}
-static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4][4]), int UNUSED(point_index), int key_index, PTCacheEditKey *key)
+static void brush_smooth_get(
+ PEData *data,
+ float mat[4][4],
+ float UNUSED(imat[4][4]),
+ int UNUSED(point_index),
+ int key_index,
+ PTCacheEditKey *key,
+ float UNUSED(mouse_distance))
{
if (key_index) {
float dvec[3];
@@ -3537,7 +3638,14 @@ static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4]
}
}
-static void brush_smooth_do(PEData *data, float UNUSED(mat[4][4]), float imat[4][4], int point_index, int key_index, PTCacheEditKey *key)
+static void brush_smooth_do(
+ PEData *data,
+ float UNUSED(mat[4][4]),
+ float imat[4][4],
+ int point_index,
+ int key_index,
+ PTCacheEditKey *key,
+ float UNUSED(mouse_distance))
{
float vec[3], dvec[3];
@@ -3904,7 +4012,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
if (n) {
int newtotpart = totpart + n;
float hairmat[4][4], cur_co[3];
- KDTree *tree = 0;
+ KDTree_3d *tree = 0;
ParticleData *pa, *new_pars = MEM_callocN(newtotpart * sizeof(ParticleData), "ParticleData new");
PTCacheEditPoint *point, *new_points = MEM_callocN(newtotpart * sizeof(PTCacheEditPoint), "PTCacheEditPoint array new");
PTCacheEditKey *key;
@@ -3928,14 +4036,14 @@ static int brush_add(const bContext *C, PEData *data, short number)
/* create tree for interpolation */
if (pset->flag & PE_INTERPOLATE_ADDED && psys->totpart) {
- tree = BLI_kdtree_new(psys->totpart);
+ tree = BLI_kdtree_3d_new(psys->totpart);
for (i = 0, pa = psys->particles; i < totpart; i++, pa++) {
psys_particle_on_dm(psmd_eval->mesh_final, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, cur_co, 0, 0, 0, 0);
- BLI_kdtree_insert(tree, i, cur_co);
+ BLI_kdtree_3d_insert(tree, i, cur_co);
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
}
edit->totpoint = psys->totpart = newtotpart;
@@ -3971,12 +4079,12 @@ static int brush_add(const bContext *C, PEData *data, short number)
ParticleData *ppa;
HairKey *thkey;
ParticleKey key3[3];
- KDTreeNearest ptn[3];
+ KDTreeNearest_3d ptn[3];
int w, maxw;
float maxd, totw = 0.0, weight[3];
psys_particle_on_dm(psmd_eval->mesh_final, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co1, 0, 0, 0, 0);
- maxw = BLI_kdtree_find_nearest_n(tree, co1, ptn, 3);
+ maxw = BLI_kdtree_3d_find_nearest_n(tree, co1, ptn, 3);
maxd = ptn[maxw - 1].dist;
@@ -4047,7 +4155,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
if (tree)
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
}
MEM_freeN(add_pars);
@@ -4320,7 +4428,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
if (edit->psys) {
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
- DEG_id_tag_update(&ob->id, ID_RECALC_SELECT);
+ DEG_id_tag_update(&ob->id, ID_RECALC_PSYS_REDO);
}
else {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -4477,8 +4585,8 @@ static bool shape_cut_test_point(PEData *data, ParticleCacheKey *key)
userdata.num_hits = 0;
BLI_bvhtree_ray_cast_all(
- shape_bvh->tree, key->co, dir, 0.0f, BVH_RAYCAST_DIST_MAX,
- point_inside_bvh_cb, &userdata);
+ shape_bvh->tree, key->co, dir, 0.0f, BVH_RAYCAST_DIST_MAX,
+ point_inside_bvh_cb, &userdata);
/* for any point inside a watertight mesh the number of hits is uneven */
return (userdata.num_hits % 2) == 1;
@@ -4589,7 +4697,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
if (edit->psys) {
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
BKE_particle_batch_cache_dirty_tag(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
- DEG_id_tag_update(&ob->id, ID_RECALC_SELECT);
+ DEG_id_tag_update(&ob->id, ID_RECALC_PSYS_REDO);
}
else {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index ac304f1aeec..2287659ef03 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -52,6 +52,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -580,7 +581,10 @@ static void disconnect_hair(
Depsgraph *depsgraph, Scene *scene,
Object *ob, ParticleSystem *psys)
{
- ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+ ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
+ ParticleSystemModifierData *psmd_eval =
+ psys_get_modifier(object_eval, psys_eval);
ParticleEditSettings *pset = PE_settings(scene);
ParticleData *pa;
PTCacheEdit *edit;
@@ -605,7 +609,8 @@ static void disconnect_hair(
point++;
}
- psys_mat_hair_to_global(ob, psmd->mesh_final, psys->part->from, pa, hairmat);
+ psys_mat_hair_to_global(
+ ob, psmd_eval->mesh_final, psys->part->from, pa, hairmat);
for (k = 0, key = pa->hair; k < pa->totkey; k++, key++) {
mul_m4_v3(hairmat, key->co);
@@ -678,7 +683,10 @@ static bool remap_hair_emitter(
Object *target_ob, ParticleSystem *target_psys, PTCacheEdit *target_edit,
float from_mat[4][4], float to_mat[4][4], bool from_global, bool to_global)
{
- ParticleSystemModifierData *target_psmd = psys_get_modifier(target_ob, target_psys);
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+ ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
+ ParticleSystemModifierData *target_psmd =
+ psys_get_modifier(object_eval, psys_eval);
ParticleData *pa, *tpa;
PTCacheEditPoint *edit_point;
PTCacheEditKey *ekey;
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index feadc88e1d7..3fdc34bd9c9 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -156,10 +156,10 @@ static bool screen_opengl_is_multiview(OGLRender *oglrender)
RegionView3D *rv3d = oglrender->rv3d;
RenderData *rd = &oglrender->scene->r;
- if ((rd == NULL) || ((!oglrender->is_sequencer) && ((rv3d == NULL) || (v3d == NULL))))
+ if ((rd == NULL) || ((v3d != NULL) && (rv3d == NULL)))
return false;
- return (rd->scemode & R_MULTIVIEW) && ((oglrender->is_sequencer) || (rv3d->persp == RV3D_CAMOB && v3d->camera));
+ return (rd->scemode & R_MULTIVIEW) && ((v3d == NULL) || (rv3d->persp == RV3D_CAMOB && v3d->camera));
}
static void screen_opengl_views_setup(OGLRender *oglrender)
@@ -203,8 +203,9 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
}
}
else {
- if (!oglrender->is_sequencer)
+ if (v3d) {
RE_SetOverrideCamera(oglrender->re, V3D_CAMERA_SCENE(oglrender->scene, v3d));
+ }
/* remove all the views that are not needed */
rv = rr->views.last;
@@ -265,7 +266,6 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
Scene *scene = oglrender->scene;
ARegion *ar = oglrender->ar;
View3D *v3d = oglrender->v3d;
@@ -326,8 +326,8 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
GPU_matrix_translate_2f(sizex / 2, sizey / 2);
G.f |= G_FLAG_RENDER_VIEWPORT;
- ED_gpencil_draw_ex(
- view_layer, rv3d, scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);
+ ED_annotation_draw_ex(
+ scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);
G.f &= ~G_FLAG_RENDER_VIEWPORT;
gp_rect = MEM_mallocN(sizex * sizey * sizeof(unsigned char) * 4, "offscreen rect");
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 9599a7bdbee..0b0acbffec9 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -61,6 +61,7 @@
#include "BKE_idprop.h"
#include "BKE_image.h"
#include "BKE_icons.h"
+#include "BKE_library.h"
#include "BKE_light.h"
#include "BKE_layer.h"
#include "BKE_main.h"
@@ -923,7 +924,7 @@ static void shader_preview_free(void *customdata)
/* get rid of copied ID */
properties = IDP_GetProperties(sp->id_copy, false);
if (properties) {
- IDP_FreeProperty(properties);
+ IDP_FreeProperty_ex(properties, false);
MEM_freeN(properties);
}
switch (GS(sp->id_copy->name)) {
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index d1bed15872d..9bf9b15cd07 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -43,6 +43,7 @@
#include "BLT_translation.h"
#include "BKE_animsys.h"
+#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_editmesh.h"
@@ -287,18 +288,46 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
static int material_slot_de_select(bContext *C, bool select)
{
bool changed_multi = false;
+ Object *obact = CTX_data_active_object(C);
+ const Material *mat_active = obact ? give_current_material(obact, obact->actcol) : NULL;
uint objects_len = 0;
Object **objects = object_array_for_shading(C, &objects_len);
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
+ short mat_nr_active = -1;
+
+ if (ob->totcol == 0) {
+ continue;
+ }
+ if (obact && (mat_active == give_current_material(ob, obact->actcol))) {
+ /* Avoid searching since there may be multiple slots with the same material.
+ * For the active object or duplicates: match the material slot index first. */
+ mat_nr_active = obact->actcol - 1;
+ }
+ else {
+ /* Find the first matching material.
+ * Note: there may be multiple but thats not a common use case. */
+ for (short i = 0; i < ob->totcol; i++) {
+ const Material *mat = give_current_material(ob, i + 1);
+ if (mat_active == mat) {
+ mat_nr_active = i;
+ break;
+ }
+ }
+ if (mat_nr_active == -1) {
+ continue;
+ }
+ }
+
+
bool changed = false;
if (ob->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(ob);
if (em) {
- changed = EDBM_deselect_by_material(em, ob->actcol - 1, select);
+ changed = EDBM_deselect_by_material(em, mat_nr_active, select);
}
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
@@ -310,7 +339,7 @@ static int material_slot_de_select(bContext *C, bool select)
if (nurbs) {
for (nu = nurbs->first; nu; nu = nu->next) {
- if (nu->mat_nr == ob->actcol - 1) {
+ if (nu->mat_nr == mat_nr_active) {
if (nu->bezt) {
a = nu->pntsu;
bezt = nu->bezt;
@@ -812,7 +841,7 @@ static int light_cache_bake_exec(bContext *C, wmOperator *op)
G.is_break = false;
/* TODO abort if selected engine is not eevee. */
- void *rj = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, false);
+ void *rj = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, false, scene->r.cfra);
light_cache_bake_tag_cache(scene, op);
@@ -837,7 +866,7 @@ static int light_cache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *U
Scene *scene = CTX_data_scene(C);
int delay = RNA_int_get(op->ptr, "delay");
- wmJob *wm_job = EEVEE_lightbake_job_create(wm, win, bmain, view_layer, scene, delay);
+ wmJob *wm_job = EEVEE_lightbake_job_create(wm, win, bmain, view_layer, scene, delay, scene->r.cfra);
if (!wm_job) {
return OPERATOR_CANCELLED;
@@ -864,10 +893,12 @@ static int light_cache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *U
void SCENE_OT_light_cache_bake(wmOperatorType *ot)
{
static const EnumPropertyItem light_cache_subset_items[] = {
- {LIGHTCACHE_SUBSET_ALL, "ALL", 0, "All LightProbes", "Bake both irradiance grids and reflection cubemaps"},
- {LIGHTCACHE_SUBSET_DIRTY, "DIRTY", 0, "Dirty Only", "Only bake lightprobes that are marked as dirty"},
- {LIGHTCACHE_SUBSET_CUBE, "CUBEMAPS", 0, "Cubemaps Only", "Try to only bake reflection cubemaps if irradiance "
- "grids are up to date"},
+ {LIGHTCACHE_SUBSET_ALL, "ALL", 0, "All LightProbes",
+ "Bake both irradiance grids and reflection cubemaps"},
+ {LIGHTCACHE_SUBSET_DIRTY, "DIRTY", 0, "Dirty Only",
+ "Only bake lightprobes that are marked as dirty"},
+ {LIGHTCACHE_SUBSET_CUBE, "CUBEMAPS", 0, "Cubemaps Only",
+ "Try to only bake reflection cubemaps if irradiance grids are up to date"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index d99c9847ed6..bbd73b581f4 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -199,6 +199,13 @@ void ED_render_engine_changed(Main *bmain)
}
}
+void ED_render_view_layer_changed(Main *bmain, bScreen *sc)
+{
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ ED_render_engine_area_exit(bmain, sa);
+ }
+}
+
/***************************** Updates ***********************************
* ED_render_id_flush_update gets called from DEG_id_tag_update, to do *
* editor level updates when the ID changes. when these ID blocks are in *
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index 3ad5ba5722a..ec0a851de97 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -70,10 +70,7 @@ Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod me
scene_new = BKE_scene_copy(bmain, scene_old, method);
/* these can't be handled in blenkernel currently, so do them here */
- if (method == SCE_COPY_LINK_DATA) {
- ED_object_single_users(bmain, scene_new, false, true);
- }
- else if (method == SCE_COPY_FULL) {
+ if (method == SCE_COPY_FULL) {
ED_editors_flush_edits(bmain, false);
ED_object_single_users(bmain, scene_new, true, true);
}
@@ -205,11 +202,14 @@ static int scene_new_exec(bContext *C, wmOperator *op)
static void SCENE_OT_new(wmOperatorType *ot)
{
static EnumPropertyItem type_items[] = {
- {SCE_COPY_NEW, "NEW", 0, "New", "Add new scene"},
- {SCE_COPY_EMPTY, "EMPTY", 0, "Copy Settings", "Make a copy without any objects"},
- {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene"},
- {SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene"},
- {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene"},
+ {SCE_COPY_NEW, "NEW", 0, "New",
+ "Add a new, empty scene with default settings"},
+ {SCE_COPY_EMPTY, "EMPTY", 0, "Copy Settings",
+ "Add a new, empty scene, and copy settings from the current scene"},
+ {SCE_COPY_LINK_COLLECTION, "LINK_COPY", 0, "Linked Copy",
+ "Link in the collections from the current scene (shallow copy)"},
+ {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy",
+ "Make a full copy of the current scene"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 27b97776503..886f2781312 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -535,12 +535,23 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
if (sa) {
const bScreen *screen = WM_window_get_active_screen(win);
- /* Only draw region emboss for top-bar and quad-view. */
+ /* Only region emboss for top-bar */
if ((screen->state != SCREENFULL) && ED_area_is_global(sa)) {
region_draw_emboss(ar, &ar->winrct, (REGION_EMBOSS_LEFT | REGION_EMBOSS_RIGHT));
}
else if ((ar->regiontype == RGN_TYPE_WINDOW) && (ar->alignment == RGN_ALIGN_QSPLIT)) {
- region_draw_emboss(ar, &ar->winrct, REGION_EMBOSS_ALL);
+
+ /* draw separating lines between the quad views */
+
+ float color[4] = { 0.0f, 0.0f, 0.0f, 0.8f };
+ UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor4fv(color);
+ GPU_line_width(1.0f);
+ imm_draw_box_wire_2d(pos, 0, 0, ar->winrct.xmax - ar->winrct.xmin + 1, ar->winrct.ymax - ar->winrct.ymin + 1);
+ immUnbindProgram();
}
}
@@ -750,6 +761,10 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
return;
}
+ if (screen->temp) {
+ return;
+ }
+
float coords[4][4] = {
/* Bottom-left. */
{sa->totrct.xmin - U.pixelsize,
@@ -981,17 +996,7 @@ static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *ar, c
const bool is_fullscreen = screen->state == SCREENFULL;
/* edge code (t b l r) is along which area edge azone will be drawn */
-
- if (ar->regiontype == RGN_TYPE_HEADER && ar->winy + 6 > sa->winy) {
- /* The logic for this is: when the header takes up the full area,
- * disallow hiding it to view the main window.
- *
- * Without this, you can drag down the file selectors header and hide it
- * by accident very easily (highly annoying!), the value 6 is arbitrary
- * but accounts for small common rounding problems when scaling the UI,
- * must be minimum '4' */
- }
- else 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)
region_azone_edge_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen);
@@ -1145,7 +1150,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, rct
ar->overlap = ED_region_is_overlap(sa->spacetype, ar->regiontype);
/* clear state flags first */
- ar->flag &= ~RGN_FLAG_TOO_SMALL;
+ ar->flag &= ~(RGN_FLAG_TOO_SMALL | RGN_FLAG_SIZE_CLAMP_X | RGN_FLAG_SIZE_CLAMP_Y);
/* user errors */
if ((ar->next == NULL) && !ELEM(alignment, RGN_ALIGN_QSPLIT, RGN_ALIGN_FLOAT)) {
alignment = RGN_ALIGN_NONE;
@@ -1196,6 +1201,13 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, rct
BLI_rcti_isect(&ar->winrct, &overlap_remainder_margin, &ar->winrct);
+ if (BLI_rcti_size_x(&ar->winrct) != prefsizex - 1) {
+ ar->flag |= RGN_FLAG_SIZE_CLAMP_X;
+ }
+ if (BLI_rcti_size_y(&ar->winrct) != prefsizey - 1) {
+ ar->flag |= RGN_FLAG_SIZE_CLAMP_Y;
+ }
+
/* We need to use a test that wont have been previously clamped. */
rcti winrct_test = {
.xmin = ar->winrct.xmin,
@@ -1937,7 +1949,7 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
/* no change */
return;
}
- sa->flag &= ~AREA_FLAG_STACKED_FULLSCREEN;
+ sa->flag &= ~(AREA_FLAG_STACKED_FULLSCREEN | AREA_FLAG_TEMP_TYPE);
ED_area_tag_redraw(sa);
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index c96b7f04284..230d6179871 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -48,21 +48,6 @@
/* ******************************************** */
-void setlinestyle(int nr)
-{
- if (nr == 0) {
- GPU_line_stipple(false);
- }
- else {
-
- GPU_line_stipple(true);
- if (U.pixelsize > 1.0f)
- glLineStipple(nr, 0xCCCC);
- else
- glLineStipple(nr, 0xAAAA);
- }
-}
-
/* Invert line handling */
#define GL_TOGGLE(mode, onoff) (((onoff) ? glEnable : glDisable)(mode))
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 31b1be2d8b3..b16d7f68976 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -76,7 +76,7 @@ const char *screen_context_dir[] = {
"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",
+ "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",
@@ -477,6 +477,13 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
return 1;
}
+ else if (CTX_data_equals(member, "pose_object")) {
+ Object *obpose = BKE_object_pose_armature_get(obact);
+ if (obpose) {
+ CTX_data_id_pointer_set(result, &obpose->id);
+ }
+ return 1;
+ }
else if (CTX_data_equals(member, "sequences")) {
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed) {
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index 84eb723a43d..6a0332731b4 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -27,6 +27,7 @@
#include "GPU_matrix.h"
#include "GPU_state.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rect.h"
@@ -370,6 +371,10 @@ void ED_screen_draw_edges(wmWindow *win)
return;
}
+ if (screen->temp && BLI_listbase_is_single(&screen->areabase)) {
+ return;
+ }
+
const int winsize_x = WM_window_pixels_x(win);
const int winsize_y = WM_window_pixels_y(win);
float col[4], corner_scale, edge_thickness;
@@ -407,6 +412,7 @@ void ED_screen_draw_edges(wmWindow *win)
edge_thickness = corner_scale * 0.21f;
GPU_blend(true);
+ GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPUBatch *batch = batch_screen_edges_get(&verts_per_corner);
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_AREA_EDGES);
@@ -479,6 +485,8 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
/* splitpoint */
GPU_blend(true);
+ GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
immUniformColor4ub(255, 255, 255, 100);
immBegin(GPU_PRIM_LINES, 2);
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 7556a44da1a..cd5b557f986 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -794,10 +794,15 @@ static void screen_global_area_refresh(
}
}
+static int screen_global_header_size(void)
+{
+ return (int)ceilf(ED_area_headersize() / UI_DPI_FAC);
+}
+
static void screen_global_topbar_area_refresh(wmWindow *win, bScreen *screen)
{
- const short size_min = HEADERY;
- const short size_max = 2.25 * HEADERY;
+ 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;
rcti rect;
@@ -810,7 +815,7 @@ static void screen_global_topbar_area_refresh(wmWindow *win, bScreen *screen)
static void screen_global_statusbar_area_refresh(wmWindow *win, bScreen *screen)
{
const short size_min = 1;
- const short size_max = 0.8f * HEADERY;
+ const short size_max = 0.8f * screen_global_header_size();
const short size = (screen->flag & SCREEN_COLLAPSE_STATUSBAR) ? size_min : size_max;
rcti rect;
@@ -1083,7 +1088,8 @@ void ED_screen_restore_temp_type(bContext *C, ScrArea *sa)
if (sa->flag & AREA_FLAG_TEMP_TYPE) {
ED_area_prevspace(C, sa);
- sa->flag &= ~AREA_FLAG_TEMP_TYPE;
+ /* Flag should be cleared now. */
+ BLI_assert((sa->flag & AREA_FLAG_TEMP_TYPE) == 0);
}
if (sa->full) {
@@ -1154,6 +1160,9 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
sc = sa->full; /* the old screen to restore */
oldscreen = WM_window_get_active_screen(win); /* the one disappearing */
+ BLI_assert(BKE_workspace_layout_screen_get(layout_old) != sc);
+ BLI_assert(BKE_workspace_layout_screen_get(layout_old)->state != SCREENNORMAL);
+
sc->state = SCREENNORMAL;
sc->flag = oldscreen->flag;
@@ -1535,6 +1544,24 @@ Scene *ED_screen_scene_find_with_window(const bScreen *screen, const wmWindowMan
return NULL;
}
+ScrArea *ED_screen_area_find_with_spacedata(const bScreen *screen, const SpaceLink *sl, const bool only_visible)
+{
+ if (only_visible) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ if (sa->spacedata.first == sl) {
+ return sa;
+ }
+ }
+ }
+ else {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ if (BLI_findindex(&sa->spacedata, sl) != -1) {
+ return sa;
+ }
+ }
+ }
+ return NULL;
+}
Scene *ED_screen_scene_find(const bScreen *screen, const wmWindowManager *wm)
{
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index bb56d127b31..ed96621a906 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2278,48 +2278,57 @@ typedef struct RegionMoveData {
} RegionMoveData;
-
static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
{
ARegion *ar;
int dist;
- if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) {
- dist = BLI_rcti_size_x(&sa->totrct);
- }
- else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
- dist = BLI_rcti_size_y(&sa->totrct);
- }
+ /* regions in regions. */
+ if (scalear->alignment & RGN_SPLIT_PREV) {
+ const int align = scalear->alignment & RGN_ALIGN_ENUM_MASK;
- /* subtractwidth of regions on opposite side
- * prevents dragging regions into other opposite regions */
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar == scalear)
- continue;
+ if (ELEM(align, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
+ ar = scalear->prev;
+ dist = ar->winy + scalear->winy - U.pixelsize;
+ }
+ else if (ELEM(align, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
+ ar = scalear->prev;
+ dist = ar->winx + scalear->winx - U.pixelsize;
+ }
+ }
+ else {
+ if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) {
+ dist = BLI_rcti_size_x(&sa->totrct);
+ }
+ else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
+ dist = BLI_rcti_size_y(&sa->totrct);
+ }
- if (scalear->alignment == RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_BOTTOM)
- dist -= ar->winy;
- else if (scalear->alignment == RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_TOP)
- dist -= ar->winy;
- else if (scalear->alignment == RGN_ALIGN_LEFT && ar->alignment == RGN_ALIGN_RIGHT)
- dist -= ar->winx;
- else if (scalear->alignment == RGN_ALIGN_RIGHT && ar->alignment == RGN_ALIGN_LEFT)
- dist -= ar->winx;
+ /* subtractwidth of regions on opposite side
+ * prevents dragging regions into other opposite regions */
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar == scalear)
+ continue;
- /* case of regions in regions, like operator properties panel */
- /* these can sit on top of other regions such as headers, so account for this */
- else if (edge == AE_BOTTOM_TO_TOPLEFT && scalear->alignment & RGN_ALIGN_TOP &&
- ar->alignment == RGN_ALIGN_TOP && ar->regiontype == RGN_TYPE_HEADER)
- {
- dist -= ar->winy;
- }
- else if (edge == AE_TOP_TO_BOTTOMRIGHT && scalear->alignment & RGN_ALIGN_BOTTOM &&
- ar->alignment == RGN_ALIGN_BOTTOM && ar->regiontype == RGN_TYPE_HEADER)
- {
- dist -= ar->winy;
+ if (scalear->alignment == RGN_ALIGN_LEFT && ar->alignment == RGN_ALIGN_RIGHT) {
+ dist -= ar->winx;
+ }
+ else if (scalear->alignment == RGN_ALIGN_RIGHT && ar->alignment == RGN_ALIGN_LEFT) {
+ dist -= ar->winx;
+ }
+ else if (scalear->alignment == RGN_ALIGN_TOP &&
+ (ar->alignment == RGN_ALIGN_BOTTOM || ar->regiontype == RGN_TYPE_HEADER))
+ {
+ dist -= ar->winy;
+ }
+ else if (scalear->alignment == RGN_ALIGN_BOTTOM &&
+ (ar->alignment == RGN_ALIGN_TOP || ar->regiontype == RGN_TYPE_HEADER)) {
+ dist -= ar->winy;
+ }
}
}
+ dist /= UI_DPI_FAC;
return dist;
}
@@ -2337,7 +2346,6 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
if (az->ar) {
RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData");
- int maxsize;
op->customdata = rmd;
@@ -2363,13 +2371,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
rmd->origval = rmd->ar->sizey;
}
- /* limit headers to standard height for now */
- if (rmd->ar->regiontype == RGN_TYPE_HEADER)
- maxsize = ED_area_headersize();
- else
- maxsize = 1000;
-
- CLAMP(rmd->maxsize, 0, maxsize);
+ CLAMP(rmd->maxsize, 0, 1000);
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -2380,24 +2382,6 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
return OPERATOR_FINISHED;
}
-static int region_scale_get_maxsize(RegionMoveData *rmd)
-{
- int maxsize = 0;
-
- if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
- return (int) ( (rmd->sa->winx / UI_DPI_FAC) - UI_UNIT_X);
- }
-
- if (rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) {
- /* this calculation seems overly verbose
- * can someone explain why this method is necessary? - campbell */
- const bool top_header = ED_area_header_alignment(rmd->sa) == RGN_ALIGN_TOP;
- maxsize = rmd->maxsize - ((top_header) ? UI_UNIT_Y * 2 : UI_UNIT_Y) - (UI_UNIT_Y / 4);
- }
-
- return maxsize;
-}
-
static void region_scale_validate_size(RegionMoveData *rmd)
{
if ((rmd->ar->flag & RGN_FLAG_HIDDEN) == 0) {
@@ -2409,7 +2393,7 @@ static void region_scale_validate_size(RegionMoveData *rmd)
else
size = &rmd->ar->sizey;
- maxsize = region_scale_get_maxsize(rmd);
+ maxsize = rmd->maxsize - (UI_UNIT_Y / UI_DPI_FAC);
if (*size > maxsize && maxsize > 0)
*size = maxsize;
@@ -2469,7 +2453,6 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
else {
- int maxsize = region_scale_get_maxsize(rmd);
delta = event->y - rmd->origy;
if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) delta = -delta;
@@ -2494,9 +2477,6 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
region_scale_toggle_hidden(C, rmd);
}
- else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) {
- rmd->ar->sizey = maxsize;
- }
else if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
region_scale_toggle_hidden(C, rmd);
}
@@ -2511,8 +2491,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
case LEFTMOUSE:
if (event->val == KM_RELEASE) {
-
- if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) {
+ if (len_manhattan_v2v2_int(&event->x, &rmd->origx) <= WM_EVENT_CURSOR_MOTION_THRESHOLD) {
if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
region_scale_toggle_hidden(C, rmd);
}
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index e49b42574a8..2e634cccedb 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -260,7 +260,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
+ uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
}
static bool screenshot_poll(bContext *C)
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index b442f718aa1..63d25cb96c4 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -203,6 +203,9 @@ WorkSpace *ED_workspace_duplicate(
ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old);
WorkSpace *workspace_new = ED_workspace_add(bmain, workspace_old->id.name + 2);
+ workspace_new->flags = workspace_old->flags;
+ BLI_duplicatelist(&workspace_new->owner_ids, &workspace_old->owner_ids);
+
/* TODO(campbell): tools */
for (WorkSpaceLayout *layout_old = layouts_old->first; layout_old; layout_old = layout_old->next) {
@@ -221,20 +224,31 @@ WorkSpace *ED_workspace_duplicate(
bool ED_workspace_delete(
WorkSpace *workspace, Main *bmain, bContext *C, wmWindowManager *wm)
{
- ID *workspace_id = (ID *)workspace;
-
if (BLI_listbase_is_single(&bmain->workspaces)) {
return false;
}
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- WorkSpace *prev = workspace_id->prev;
- WorkSpace *next = workspace_id->next;
+ ListBase ordered;
+ BKE_id_ordered_list(&ordered, &bmain->workspaces);
+ WorkSpace *prev = NULL, *next = NULL;
+ for (LinkData *link = ordered.first; link; link = link->next) {
+ if (link->data == workspace) {
+ prev = link->prev ? link->prev->data : NULL;
+ next = link->next ? link->next->data : NULL;
+ break;
+ }
+ }
+ BLI_freelistN(&ordered);
+ BLI_assert((prev != NULL) || (next != NULL));
- ED_workspace_change((prev != NULL) ? prev : next, C, wm, win);
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ WorkSpace *workspace_active = WM_window_get_active_workspace(win);
+ if (workspace_active == workspace) {
+ ED_workspace_change((prev != NULL) ? prev : next, C, wm, win);
+ }
}
- BKE_id_free(bmain, workspace_id);
+ BKE_id_free(bmain, &workspace->id);
return true;
}
@@ -301,6 +315,7 @@ static int workspace_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
WorkSpace *workspace = workspace_context_get(C);
WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_DELETE, workspace);
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
return OPERATOR_FINISHED;
}
@@ -518,7 +533,8 @@ static int workspace_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
BLI_freelistN(&templates);
uiItemS(layout);
- uiItemO(layout, "Duplicate Current", ICON_DUPLICATE, "WORKSPACE_OT_duplicate");
+ uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Duplicate Current"), ICON_DUPLICATE,
+ "WORKSPACE_OT_duplicate");
UI_popup_menu_end(C, pup);
diff --git a/source/blender/editors/sculpt_paint/paint_curve_undo.c b/source/blender/editors/sculpt_paint/paint_curve_undo.c
index fb2f4b49f19..1eaed8eabb8 100644
--- a/source/blender/editors/sculpt_paint/paint_curve_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_curve_undo.c
@@ -84,6 +84,9 @@ typedef struct PaintCurveUndoStep {
static bool paintcurve_undosys_poll(bContext *C)
{
+ if (C == NULL || !paint_curve_poll(C)) {
+ return false;
+ }
Paint *p = BKE_paint_get_active_from_context(C);
return (p->brush && p->brush->paint_curve);
}
@@ -96,6 +99,9 @@ static void paintcurve_undosys_step_encode_init(struct bContext *C, UndoStep *us
static bool paintcurve_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p)
{
+ if (C == NULL || !paint_curve_poll(C)) {
+ return false;
+ }
Paint *p = BKE_paint_get_active_from_context(C);
PaintCurve *pc = p ? (p->brush ? p->brush->paint_curve : NULL) : NULL;
if (pc == NULL) {
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 4749d2a3308..5e3d01d7f6a 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -585,8 +585,12 @@ static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke)
else {
if (pop->mode == PAINT_MODE_2D) {
float color[3];
-
- srgb_to_linearrgb_v3_v3(color, BKE_brush_color_get(scene, brush));
+ if (paint_stroke_inverted(stroke)) {
+ srgb_to_linearrgb_v3_v3(color, BKE_brush_secondary_color_get(scene, brush));
+ }
+ else {
+ srgb_to_linearrgb_v3_v3(color, BKE_brush_color_get(scene, brush));
+ }
paint_2d_bucket_fill(C, color, brush, pop->prevmouse, pop->custom_paint);
}
else {
@@ -1122,7 +1126,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
if (!sima->pin) {
Object *obedit = CTX_data_edit_object(C);
- ED_space_image_set(bmain, sima, obedit, ima);
+ ED_space_image_set(bmain, sima, obedit, ima, true);
}
}
}
@@ -1196,7 +1200,7 @@ static bool brush_colors_flip_poll(bContext *C)
{
if (image_paint_poll(C)) {
Brush *br = image_paint_brush(C);
- if (br->imagepaint_tool == PAINT_TOOL_DRAW)
+ if (ELEM(br->imagepaint_tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL))
return true;
}
else {
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 990017d3a20..cad75efbf56 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -1415,7 +1415,7 @@ static void paint_2d_fill_add_pixel_byte(
rgba_uchar_to_float(color_f, color_b);
straight_to_premul_v4(color_f);
- if (compare_len_squared_v4v4(color_f, color, threshold_sq)) {
+ if (len_squared_v4v4(color_f, color) <= threshold_sq) {
BLI_stack_push(stack, &coordinate);
}
BLI_BITMAP_SET(touched, coordinate, true);
@@ -1434,7 +1434,7 @@ static void paint_2d_fill_add_pixel_float(
coordinate = ((size_t)y_px) * ibuf->x + x_px;
if (!BLI_BITMAP_TEST(touched, coordinate)) {
- if (compare_len_squared_v4v4(ibuf->rect_float + 4 * coordinate, color, threshold_sq)) {
+ if (len_squared_v4v4(ibuf->rect_float + 4 * coordinate, color) <= threshold_sq) {
BLI_stack_push(stack, &coordinate);
}
BLI_BITMAP_SET(touched, coordinate, true);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index f8a2259d4a5..1691b70a271 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -158,6 +158,8 @@ BLI_INLINE unsigned char f_to_char(const float val)
#define PROJ_FACE_SEAM_INIT1 (1 << 9)
#define PROJ_FACE_SEAM_INIT2 (1 << 10)
+#define PROJ_FACE_DEGENERATE (1 << 12)
+
/* face winding */
#define PROJ_FACE_WINDING_INIT 1
#define PROJ_FACE_WINDING_CW 2
@@ -381,10 +383,10 @@ typedef struct ProjPaintState {
*/
#define PROJ_PAINT_STATE_SHARED_MEMCPY(ps_dst, ps_src) \
- MEMCPY_STRUCT_OFS(ps_dst, ps_src, is_shared_user)
+ MEMCPY_STRUCT_AFTER(ps_dst, ps_src, is_shared_user)
#define PROJ_PAINT_STATE_SHARED_CLEAR(ps) \
- MEMSET_STRUCT_OFS(ps, 0, is_shared_user)
+ MEMSET_STRUCT_AFTER(ps, 0, is_shared_user)
bool is_shared_user;
@@ -1324,7 +1326,7 @@ static void uv_image_outset(
len_fact = UNLIKELY(len_fact < FLT_EPSILON) ? FLT_MAX : (1.0f / len_fact);
/* Clamp the length factor, see: T62236. */
- len_fact = MIN2(len_fact, 5.0f);
+ len_fact = MIN2(len_fact, 10.0f);
mul_v2_fl(no, ps->seam_bleed_px * len_fact);
@@ -2984,7 +2986,7 @@ static void project_paint_face_init(
#ifndef PROJ_DEBUG_NOSEAMBLEED
- if (ps->seam_bleed_px > 0.0f) {
+ if (ps->seam_bleed_px > 0.0f && !(ps->faceSeamFlags[tri_index] & PROJ_FACE_DEGENERATE)) {
int face_seam_flag;
if (threaded) {
@@ -3759,11 +3761,23 @@ static void project_paint_bleed_add_face_user(
/* add face user if we have bleed enabled, set the UV seam flags later */
/* annoying but we need to add all faces even ones we never use elsewhere */
if (ps->seam_bleed_px > 0.0f) {
- const int lt_vtri[3] = { PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt) };
- void *tri_index_p = POINTER_FROM_INT(tri_index);
- BLI_linklist_prepend_arena(&ps->vertFaces[lt_vtri[0]], tri_index_p, arena);
- BLI_linklist_prepend_arena(&ps->vertFaces[lt_vtri[1]], tri_index_p, arena);
- BLI_linklist_prepend_arena(&ps->vertFaces[lt_vtri[2]], tri_index_p, arena);
+ const float *lt_tri_uv[3] = { PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt) };
+
+ /* Check for degenerate triangles. Degenerate faces cause trouble with bleed computations.
+ * Ideally this would be checked later, not to add to the cost of computing non-degenerate
+ * triangles, but that would allow other triangles to still find adjacent seams on degenerate
+ * triangles, potentially causing incorrect results. */
+ if (area_tri_v2(UNPACK3(lt_tri_uv)) > FLT_EPSILON) {
+ const int lt_vtri[3] = { PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt) };
+ void *tri_index_p = POINTER_FROM_INT(tri_index);
+
+ BLI_linklist_prepend_arena(&ps->vertFaces[lt_vtri[0]], tri_index_p, arena);
+ BLI_linklist_prepend_arena(&ps->vertFaces[lt_vtri[1]], tri_index_p, arena);
+ BLI_linklist_prepend_arena(&ps->vertFaces[lt_vtri[2]], tri_index_p, arena);
+ }
+ else {
+ ps->faceSeamFlags[tri_index] |= PROJ_FACE_DEGENERATE;
+ }
}
}
#endif
@@ -4061,10 +4075,7 @@ static void project_paint_prepare_all_faces(
for (tri_index = 0, lt = ps->mlooptri_eval; tri_index < ps->totlooptri_eval; tri_index++, lt++) {
bool is_face_sel;
-
-#ifndef PROJ_DEBUG_NOSEAMBLEED
- project_paint_bleed_add_face_user(ps, arena, lt, tri_index);
-#endif
+ bool skip_tri = false;
is_face_sel = project_paint_check_face_sel(ps, face_lookup, lt);
@@ -4084,14 +4095,15 @@ static void project_paint_prepare_all_faces(
/* don't allow using the same inage for painting and stencilling */
if (slot->ima == ps->stencil_ima) {
- /* While this shouldn't be used, face-winding reads all polys.
+ /* Delay continuing the loop until after loop_uvs and bleed faces are initialized.
+ * While this shouldn't be used, face-winding reads all polys.
* It's less trouble to set all faces to valid UV's,
* avoiding NULL checks all over. */
- ps->poly_to_loop_uv[lt->poly] = mloopuv_base;
- continue;
+ skip_tri = true;
+ }
+ else {
+ tpage = slot->ima;
}
-
- tpage = slot->ima;
}
}
else {
@@ -4100,7 +4112,11 @@ static void project_paint_prepare_all_faces(
ps->poly_to_loop_uv[lt->poly] = mloopuv_base;
- if (project_paint_clone_face_skip(ps, layer_clone, slot, tri_index)) {
+#ifndef PROJ_DEBUG_NOSEAMBLEED
+ project_paint_bleed_add_face_user(ps, arena, lt, tri_index);
+#endif
+
+ if (skip_tri || project_paint_clone_face_skip(ps, layer_clone, slot, tri_index)) {
continue;
}
@@ -5367,7 +5383,7 @@ static void paint_proj_stroke_ps(
ps->blend = IMB_BLEND_ERASE_ALPHA;
/* handle gradient and inverted stroke color here */
- if (ps->tool == PAINT_TOOL_DRAW) {
+ if (ELEM(ps->tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL)) {
paint_brush_color_get(scene, brush, false, ps->mode == BRUSH_STROKE_INVERT, distance, pressure, ps->paint_color, NULL);
if (ps->use_colormanagement) {
srgb_to_linearrgb_v3_v3(ps->paint_color_linear, ps->paint_color);
@@ -5376,15 +5392,6 @@ static void paint_proj_stroke_ps(
copy_v3_v3(ps->paint_color_linear, ps->paint_color);
}
}
- else if (ps->tool == PAINT_TOOL_FILL) {
- copy_v3_v3(ps->paint_color, BKE_brush_color_get(scene, brush));
- if (ps->use_colormanagement) {
- srgb_to_linearrgb_v3_v3(ps->paint_color_linear, ps->paint_color);
- }
- else {
- copy_v3_v3(ps->paint_color_linear, ps->paint_color);
- }
- }
else if (ps->tool == PAINT_TOOL_MASK) {
ps->stencil_value = brush->weight;
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 8363145ee07..5b86fc02979 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -81,6 +81,7 @@ int paint_stroke_modal(struct bContext *C, struct wmOperator *op, const struct w
int paint_stroke_exec(struct bContext *C, struct wmOperator *op);
void paint_stroke_cancel(struct bContext *C, struct wmOperator *op);
bool paint_stroke_flipped(struct PaintStroke *stroke);
+bool paint_stroke_inverted(struct PaintStroke *stroke);
struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
void *paint_stroke_mode_data(struct PaintStroke *stroke);
float paint_stroke_distance_get(struct PaintStroke *stroke);
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 2f9706db636..b88ae861229 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -249,7 +249,7 @@ static void mask_box_select_task_cb(
} BKE_pbvh_vertex_iter_end;
}
-int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select)
+bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Sculpt *sd = vc->scene->toolsettings->sculpt;
@@ -321,7 +321,7 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
- return OPERATOR_FINISHED;
+ return true;
}
typedef struct LassoMaskData {
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 12e98bc5d33..e26b30fbf45 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -815,8 +815,11 @@ static void BRUSH_OT_stencil_control(wmOperatorType *ot)
/* flags */
ot->flag = 0;
- RNA_def_enum(ot->srna, "mode", stencil_control_items, STENCIL_TRANSLATE, "Tool", "");
- RNA_def_enum(ot->srna, "texmode", stencil_texture_items, STENCIL_PRIMARY, "Tool", "");
+ PropertyRNA *prop;
+ prop = RNA_def_enum(ot->srna, "mode", stencil_control_items, STENCIL_TRANSLATE, "Tool", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ prop = RNA_def_enum(ot->srna, "texmode", stencil_texture_items, STENCIL_PRIMARY, "Tool", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 2af6a4db3ee..d66224034eb 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -808,9 +808,9 @@ static void stroke_done(struct bContext *C, struct wmOperator *op)
if (stroke->timer) {
WM_event_remove_timer(
- CTX_wm_manager(C),
- CTX_wm_window(C),
- stroke->timer);
+ CTX_wm_manager(C),
+ CTX_wm_window(C),
+ stroke->timer);
}
if (stroke->rng) {
@@ -1365,6 +1365,11 @@ bool paint_stroke_flipped(struct PaintStroke *stroke)
return stroke->pen_flip;
}
+bool paint_stroke_inverted(struct PaintStroke *stroke)
+{
+ return stroke->stroke_mode == BRUSH_STROKE_INVERT;
+}
+
float paint_stroke_distance_get(struct PaintStroke *stroke)
{
return stroke->stroke_distance;
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index b8c067d61e7..35401c470cc 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -362,7 +362,7 @@ static int imapaint_pick_face(
return 0;
/* sample only on the exact position */
- *r_index = ED_view3d_backbuf_sample(vc, mval[0], mval[1]);
+ *r_index = ED_view3d_select_id_sample(vc, mval[0], mval[1]);
if ((*r_index) == 0 || (*r_index) > (unsigned int)totpoly) {
return 0;
@@ -460,8 +460,10 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
bool use_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL);
if (ob) {
+ CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
+ cddata_masks.pmask |= CD_MASK_ORIGINDEX;
Mesh *me = (Mesh *)ob->data;
- Mesh *me_eval = ob_eval->runtime.mesh_eval;
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob_eval, &cddata_masks);
ViewContext vc;
const int mval[2] = {x, y};
@@ -648,9 +650,11 @@ void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
static int face_select_all_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
- paintface_deselect_all_visible(C, ob, RNA_enum_get(op->ptr, "action"), true);
- ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_FINISHED;
+ if (paintface_deselect_all_visible(C, ob, RNA_enum_get(op->ptr, "action"), true)) {
+ ED_region_tag_redraw(CTX_wm_region(C));
+ return OPERATOR_FINISHED;
+ }
+ return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index f1ada42100d..ca12854aa7d 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -175,7 +175,7 @@ static MDeformVert *defweight_prev_init(MDeformVert *dvert_prev, MDeformVert *dv
}
/* check if we can do partial updates and have them draw realtime
- * (without rebuilding the 'derivedFinal') */
+ * (without evaluating modifiers) */
static bool vertex_paint_use_fast_update_check(Object *ob)
{
Mesh *me_eval = ob->runtime.mesh_eval;
@@ -890,7 +890,7 @@ static void do_weight_paint_vertex_multi(
}
oldw = BKE_defvert_multipaint_collective_weight(
- dv_prev, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, wpi->do_auto_normalize);
+ dv_prev, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, wpi->do_auto_normalize);
}
else {
oldw = curw;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index aa3f424f816..a371d8ec93c 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -188,15 +188,15 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);
if (use_vert_sel) {
- if (ED_mesh_pick_vert(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, true)) {
+ if (ED_mesh_pick_vert(C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_VERT_DIST, true, &index)) {
v_idx_best = index;
}
}
else {
- if (ED_mesh_pick_face_vert(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
+ if (ED_mesh_pick_face_vert(C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
v_idx_best = index;
}
- else if (ED_mesh_pick_face(C, vc.obact, event->mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
+ else if (ED_mesh_pick_face(C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
/* this relies on knowning the internal worksings of ED_mesh_pick_face_vert() */
BKE_report(op->reports, RPT_WARNING, "The modifier used does not support deformed locations");
}
@@ -312,13 +312,13 @@ static const EnumPropertyItem *weight_paint_sample_enum_itemf(
ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);
if (use_vert_sel) {
- if (ED_mesh_pick_vert(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, true)) {
+ if (ED_mesh_pick_vert(C, vc.obact, mval, ED_MESH_PICK_DEFAULT_VERT_DIST, true, &index)) {
MDeformVert *dvert = &me->dvert[index];
found |= weight_paint_sample_enum_itemf__helper(dvert, defbase_tot, groups);
}
}
else {
- if (ED_mesh_pick_face(C, vc.obact, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) {
+ if (ED_mesh_pick_face(C, vc.obact, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
const MPoly *mp = &me->mpoly[index];
uint fidx = mp->totloop - 1;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 69b768c4318..24edd9bec86 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1859,8 +1859,8 @@ static void do_topology_rake_bmesh_task_cb_ex(
float tmp[3];
mul_v3_v3fl(
- tmp, ss->cache->sculpt_normal_symm,
- dot_v3v3(ss->cache->sculpt_normal_symm, direction));
+ tmp, ss->cache->sculpt_normal_symm,
+ dot_v3v3(ss->cache->sculpt_normal_symm, direction));
sub_v3_v3(direction, tmp);
/* Cancel if there's no grab data. */
@@ -1880,8 +1880,8 @@ static void do_topology_rake_bmesh_task_cb_ex(
{
if (sculpt_brush_test_sq_fn(&test, vd.co)) {
const float fade = bstrength * tex_strength(
- ss, brush, vd.co, sqrtf(test.dist),
- vd.no, vd.fno, *vd.mask, tls->thread_id) * ss->cache->pressure;
+ ss, brush, vd.co, sqrtf(test.dist),
+ vd.no, vd.fno, *vd.mask, tls->thread_id) * ss->cache->pressure;
float avg[3], val[3];
@@ -5056,21 +5056,43 @@ void sculpt_update_object_bounding_box(Object *ob)
static void sculpt_flush_update(bContext *C)
{
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = CTX_data_active_object(C);
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
SculptSession *ss = ob->sculpt;
ARegion *ar = CTX_wm_region(C);
+ bScreen *screen = CTX_wm_screen(C);
MultiresModifierData *mmd = ss->multires;
if (mmd != NULL) {
/* NOTE: SubdivCCG is living in the evaluated object. */
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
multires_mark_as_modified(ob_eval, MULTIRES_COORDS_MODIFIED);
}
DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
- if (ss->kb || ss->modifiers_active) {
+ bool use_shaded_mode = false;
+ if (mmd || (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH)) {
+ /* Multres or dyntopo are drawn directly by EEVEE,
+ * no need for hacks in this case. */
+ }
+ else {
+ /* We search if an area of the current window is in lookdev/rendered
+ * display mode. In this case, for changes to show up, we need to
+ * tag for ID_RECALC_GEOMETRY. */
+ 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;
+ if (v3d->shading.type > OB_SOLID) {
+ use_shaded_mode = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (ss->kb || ss->modifiers_active || use_shaded_mode) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
ED_region_tag_redraw(ar);
}
@@ -5101,9 +5123,6 @@ static void sculpt_flush_update(bContext *C)
ED_region_tag_redraw_partial(ar, &r);
}
}
-
- /* 2.8x - avoid full mesh update! */
- BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_SCULPT_COORDS);
}
/* Returns whether the mouse/stylus is over the mesh (1)
@@ -5404,7 +5423,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
static void sculpt_dynamic_topology_triangulate(BMesh *bm)
{
if (bm->totloop != bm->totface * 3) {
- BM_mesh_triangulate(bm, MOD_TRIANGULATE_QUAD_BEAUTY, MOD_TRIANGULATE_NGON_EARCLIP, false, NULL, NULL, NULL);
+ BM_mesh_triangulate(bm, MOD_TRIANGULATE_QUAD_BEAUTY, MOD_TRIANGULATE_NGON_EARCLIP, 4, false, NULL, NULL, NULL);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 8c934b6a16a..9c76292aaa7 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -194,7 +194,7 @@ static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode)
/* pbvh uses it's own mvert array, so coords should be */
/* propagated to pbvh here */
- BKE_pbvh_apply_vertCos(ss->pbvh, vertCos, unode->totvert);
+ BKE_pbvh_apply_vertCos(ss->pbvh, vertCos, ss->kb->totelem);
MEM_freeN(vertCos);
}
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 8c6970eba77..2a64d87fcba 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -627,7 +627,7 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* main draw call */
- uiDefAutoButsRNA(layout, &ptr, sound_mixdown_draw_check_prop, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
+ uiDefAutoButsRNA(layout, &ptr, sound_mixdown_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
}
#endif // WITH_AUDASPACE
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 68d4e4f8ef0..997b18f2013 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -128,7 +128,9 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
{
/* draw all channels using standard channel-drawing API */
- ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index);
+ rctf channel_rect;
+ BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, yminc, ymaxc);
+ ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index);
}
/* adjust y-position for next one */
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 152442f8671..0579e20bb5a 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -93,8 +93,9 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type)
for (a = 0; a < path->len; a++) {
ptr = &path->ptr[a];
- if (RNA_struct_is_a(ptr->type, type))
+ if (RNA_struct_is_a(ptr->type, type)) {
return ptr;
+ }
}
return NULL;
@@ -221,16 +222,36 @@ static int buttons_context_path_data(ButsContextPath *path, int type)
PointerRNA *ptr = &path->ptr[path->len - 1];
/* if we already have a data, we're done */
- if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) return 1;
- else if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) return 1;
+ if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) {
+ return 1;
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) {
+ return 1;
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) {
+ return 1;
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) {
+ return 1;
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) {
+ return 1;
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) {
+ return 1;
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) {
+ return 1;
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) {
+ return 1;
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) {
+ return 1;
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) {
+ return 1;
+ }
/* try to get an object in the path, no pinning supported here */
else if (buttons_context_path_object(path)) {
ob = path->ptr[path->len - 1].data;
@@ -254,8 +275,9 @@ static int buttons_context_path_modifier(ButsContextPath *path)
if (buttons_context_path_object(path)) {
ob = path->ptr[path->len - 1].data;
- if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_GPENCIL))
+ if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_GPENCIL)) {
return 1;
+ }
}
return 0;
@@ -268,8 +290,9 @@ static int buttons_context_path_shaderfx(ButsContextPath *path)
if (buttons_context_path_object(path)) {
ob = path->ptr[path->len - 1].data;
- if (ob && ELEM(ob->type, OB_GPENCIL))
+ if (ob && ELEM(ob->type, OB_GPENCIL)) {
return 1;
+ }
}
return 0;
@@ -429,27 +452,34 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path
PointerRNA *ptr = &path->ptr[path->len - 1];
ID *id;
- if (!ct)
+ if (!ct) {
return 0;
+ }
/* if we already have a (pinned) texture, we're done */
- if (RNA_struct_is_a(ptr->type, &RNA_Texture))
+ if (RNA_struct_is_a(ptr->type, &RNA_Texture)) {
return 1;
+ }
- if (!ct->user)
+ if (!ct->user) {
return 0;
+ }
id = ct->user->id;
if (id) {
- if (GS(id->name) == ID_BR)
+ if (GS(id->name) == ID_BR) {
buttons_context_path_brush(C, path);
- else if (GS(id->name) == ID_PA)
+ }
+ else if (GS(id->name) == ID_PA) {
buttons_context_path_particle(path);
- else if (GS(id->name) == ID_OB)
+ }
+ else if (GS(id->name) == ID_OB) {
buttons_context_path_object(path);
- else if (GS(id->name) == ID_LS)
+ }
+ else if (GS(id->name) == ID_LS) {
buttons_context_path_linestyle(path, CTX_wm_window(C));
+ }
}
if (ct->texture) {
@@ -568,8 +598,9 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
break;
case BCONTEXT_BONE:
found = buttons_context_path_bone(path);
- if (!found)
+ if (!found) {
found = buttons_context_path_data(path, OB_ARMATURE);
+ }
break;
case BCONTEXT_BONE_CONSTRAINT:
found = buttons_context_path_pose_bone(path);
@@ -588,10 +619,12 @@ static int buttons_shading_context(const bContext *C, int mainb)
ViewLayer *view_layer = WM_window_get_active_view_layer(window);
Object *ob = OBACT(view_layer);
- if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE))
+ if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) {
return 1;
- if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA))
+ }
+ if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA)) {
return 1;
+ }
return 0;
}
@@ -602,12 +635,15 @@ static int buttons_shading_new_context(const bContext *C, int flag)
ViewLayer *view_layer = WM_window_get_active_view_layer(window);
Object *ob = OBACT(view_layer);
- if (flag & (1 << BCONTEXT_MATERIAL))
+ if (flag & (1 << BCONTEXT_MATERIAL)) {
return BCONTEXT_MATERIAL;
- else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA)))
+ }
+ else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA))) {
return BCONTEXT_DATA;
- else if (flag & (1 << BCONTEXT_WORLD))
+ }
+ else if (flag & (1 << BCONTEXT_WORLD)) {
return BCONTEXT_WORLD;
+ }
return BCONTEXT_RENDER;
}
@@ -618,8 +654,9 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
PointerRNA *ptr;
int a, pflag = 0, flag = 0;
- if (!sbuts->path)
+ if (!sbuts->path) {
sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
+ }
path = sbuts->path;
@@ -639,10 +676,12 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
ptr = &path->ptr[path->len - 1];
if (ptr->type) {
- if (RNA_struct_is_a(ptr->type, &RNA_Light))
+ if (RNA_struct_is_a(ptr->type, &RNA_Light)) {
sbuts->dataicon = ICON_OUTLINER_DATA_LIGHT;
- else
+ }
+ else {
sbuts->dataicon = RNA_struct_ui_icon(ptr->type);
+ }
}
else {
sbuts->dataicon = ICON_EMPTY_DATA;
@@ -678,16 +717,20 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
buttons_context_path(C, path, sbuts->mainb, pflag);
if (!(flag & (1 << sbuts->mainb))) {
- if (flag & (1 << BCONTEXT_OBJECT))
+ if (flag & (1 << BCONTEXT_OBJECT)) {
sbuts->mainb = BCONTEXT_OBJECT;
- else
+ }
+ else {
sbuts->mainb = BCONTEXT_SCENE;
+ }
}
- if (buttons_shading_context(C, sbuts->mainb))
+ if (buttons_shading_context(C, sbuts->mainb)) {
sbuts->flag |= SB_SHADING_CONTEXT;
- else
+ }
+ else {
sbuts->flag &= ~SB_SHADING_CONTEXT;
+ }
sbuts->pathflag = flag;
}
@@ -708,17 +751,20 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
SpaceProperties *sbuts = CTX_wm_space_properties(C);
ButsContextPath *path = sbuts ? sbuts->path : NULL;
- if (!path)
+ if (!path) {
return 0;
+ }
/* here we handle context, getting data from precomputed path */
if (CTX_data_dir(member)) {
/* in case of new shading system we skip texture_slot, complex python
* UI script logic depends on checking if this is available */
- if (sbuts->texuser)
+ if (sbuts->texuser) {
CTX_data_dir_set(result, buttons_context_dir + 1);
- else
+ }
+ else {
CTX_data_dir_set(result, buttons_context_dir);
+ }
return 1;
}
else if (CTX_data_equals(member, "scene")) {
@@ -792,7 +838,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) {
/* a valid actcol isn't ensured [#27526] */
int matnr = ob->actcol - 1;
- if (matnr < 0) matnr = 0;
+ if (matnr < 0) {
+ matnr = 0;
+ }
CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, &ob->mat[matnr]);
}
}
@@ -802,8 +850,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
else if (CTX_data_equals(member, "texture_user")) {
ButsContextTexture *ct = sbuts->texuser;
- if (!ct)
+ if (!ct) {
return -1;
+ }
if (ct->user && ct->user->ptr.data) {
ButsTextureUser *user = ct->user;
@@ -815,8 +864,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
else if (CTX_data_equals(member, "texture_user_property")) {
ButsContextTexture *ct = sbuts->texuser;
- if (!ct)
+ if (!ct) {
return -1;
+ }
if (ct->user && ct->user->ptr.data) {
ButsTextureUser *user = ct->user;
@@ -845,8 +895,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) {
ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
- if (part)
+ if (part) {
CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]);
+ }
}
else if (ct) {
return 0; /* new shading system */
@@ -854,8 +905,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) {
FreestyleLineStyle *ls = ptr->data;
- if (ls)
+ if (ls) {
CTX_data_pointer_set(result, &ls->id, &RNA_LineStyleTextureSlot, ls->mtex[(int)ls->texact]);
+ }
}
return 1;
@@ -877,10 +929,12 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
return 1;
}
else if (CTX_data_equals(member, "particle_system_editable")) {
- if (PE_poll((bContext *)C))
+ if (PE_poll((bContext *)C)) {
set_pointer_type(path, result, &RNA_ParticleSystem);
- else
+ }
+ else {
CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL);
+ }
return 1;
}
else if (CTX_data_equals(member, "particle_settings")) {
@@ -993,8 +1047,9 @@ static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
if (sbuts->flag & SB_PIN_CONTEXT) {
sbuts->pinid = buttons_context_id_path(C);
}
- else
+ else {
sbuts->pinid = NULL;
+ }
ED_area_tag_redraw(CTX_wm_area(C));
}
@@ -1011,8 +1066,9 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
int a, icon;
bool first = true;
- if (!path)
+ if (!path) {
return;
+ }
row = uiLayoutRow(layout, true);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
@@ -1044,8 +1100,9 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
if (name) {
uiItemLDrag(row, ptr, name, icon);
- if (name != namebuf)
+ if (name != namebuf) {
MEM_freeN(name);
+ }
}
else {
uiItemL(row, "", icon);
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 7cec9c09767..3ae88f9cc78 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -99,8 +99,9 @@ static int file_browse_exec(bContext *C, wmOperator *op)
char *str, path[FILE_MAX];
const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath";
- if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL)
+ if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) {
return OPERATOR_CANCELLED;
+ }
str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0);
@@ -127,7 +128,9 @@ static int file_browse_exec(bContext *C, wmOperator *op)
}
else {
char * const lslash = (char *)BLI_last_slash(str);
- if (lslash) lslash[1] = '\0';
+ if (lslash) {
+ lslash[1] = '\0';
+ }
}
}
@@ -176,8 +179,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
UI_context_active_but_prop_get_filebrowser(C, &ptr, &prop, &is_undo);
- if (!prop)
+ if (!prop) {
return OPERATOR_CANCELLED;
+ }
str = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL);
@@ -189,8 +193,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (event->alt) {
char *lslash = (char *)BLI_last_slash(str);
- if (lslash)
+ if (lslash) {
*lslash = '\0';
+ }
}
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index bcf536e9d97..7c1355b6b3c 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -156,8 +156,9 @@ static void buttons_texture_modifier_gpencil_foreach(void *userData, Object *ob,
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr);
prop = RNA_struct_find_property(&ptr, propname);
- buttons_texture_user_property_add(users, &ob->id, ptr, prop,
- N_("Grease Pencil Modifiers"), RNA_struct_ui_icon(ptr.type), md->name);
+ buttons_texture_user_property_add(
+ users, &ob->id, ptr, prop,
+ N_("Grease Pencil Modifiers"), RNA_struct_ui_icon(ptr.type), md->name);
}
static void buttons_texture_users_from_context(ListBase *users, const bContext *C, SpaceProperties *sbuts)
@@ -171,14 +172,18 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
/* get data from context */
if (pinid) {
- if (GS(pinid->name) == ID_SCE)
+ if (GS(pinid->name) == ID_SCE) {
scene = (Scene *)pinid;
- else if (GS(pinid->name) == ID_OB)
+ }
+ else if (GS(pinid->name) == ID_OB) {
ob = (Object *)pinid;
- else if (GS(pinid->name) == ID_BR)
+ }
+ else if (GS(pinid->name) == ID_BR) {
brush = (Brush *)pinid;
- else if (GS(pinid->name) == ID_LS)
+ }
+ else if (GS(pinid->name) == ID_LS) {
linestyle = (FreestyleLineStyle *)pinid;
+ }
}
if (!scene) {
@@ -200,8 +205,9 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
/* fill users */
BLI_listbase_clear(users);
- if (linestyle && !limited_mode)
+ if (linestyle && !limited_mode) {
buttons_texture_users_find_nodetree(users, &linestyle->id, linestyle->nodetree, N_("Line Style"));
+ }
if (ob) {
ParticleSystem *psys = psys_get_current(ob);
@@ -289,8 +295,9 @@ void buttons_texture_context_compute(const bContext *C, SpaceProperties *sbuts)
}
else {
/* set one user as active based on active index */
- if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1))
+ if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1)) {
ct->index = 0;
+ }
ct->user = BLI_findlink(&ct->users, ct->index);
ct->texture = NULL;
@@ -334,8 +341,9 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg)
PointerRNA texptr;
Tex *tex;
- if (!ct)
+ if (!ct) {
return;
+ }
/* set user as active */
if (user->node) {
@@ -354,13 +362,16 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg)
ParticleSettings *part = user->ptr.id.data;
int a;
- for (a = 0; a < MAX_MTEX; a++)
- if (user->ptr.data == part->mtex[a])
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (user->ptr.data == part->mtex[a]) {
part->texact = a;
+ }
+ }
}
- if (sbuts && tex)
+ if (sbuts && tex) {
sbuts->preview = 1;
+ }
}
ct->user = user;
@@ -392,13 +403,16 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS
PointerRNA texptr = RNA_property_pointer_get(&user->ptr, user->prop);
Tex *tex = texptr.data;
- if (tex)
+ if (tex) {
BLI_snprintf(name, UI_MAX_NAME_STR, " %s - %s", user->name, tex->id.name + 2);
- else
+ }
+ else {
BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name);
+ }
}
- else
+ else {
BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name);
+ }
but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -422,8 +436,9 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C)
ButsTextureUser *user;
char name[UI_MAX_NAME_STR];
- if (!ct)
+ if (!ct) {
return;
+ }
/* get current user */
user = ct->user;
@@ -459,12 +474,15 @@ static void template_texture_show(bContext *C, void *data_p, void *prop_p)
ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL;
ButsTextureUser *user;
- if (!ct)
+ if (!ct) {
return;
+ }
- for (user = ct->users.first; user; user = user->next)
- if (user->ptr.data == data_p && user->prop == prop_p)
+ for (user = ct->users.first; user; user = user->next) {
+ if (user->ptr.data == data_p && user->prop == prop_p) {
break;
+ }
+ }
if (user) {
/* select texture */
@@ -488,13 +506,16 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope
ButsTextureUser *user;
/* only show button in other tabs in properties editor */
- if (!ct || sbuts->mainb == BCONTEXT_TEXTURE)
+ if (!ct || sbuts->mainb == BCONTEXT_TEXTURE) {
return;
+ }
/* find corresponding texture user */
- for (user = ct->users.first; user; user = user->next)
- if (user->ptr.data == ptr->data && user->prop == prop)
+ for (user = ct->users.first; user; user = user->next) {
+ if (user->ptr.data == ptr->data && user->prop == prop) {
break;
+ }
+ }
/* draw button */
if (user) {
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index acba11ddec7..3bf2d632a12 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -97,8 +97,9 @@ static void buttons_free(SpaceLink *sl)
{
SpaceProperties *sbuts = (SpaceProperties *) sl;
- if (sbuts->path)
+ if (sbuts->path) {
MEM_freeN(sbuts->path);
+ }
if (sbuts->texuser) {
ButsContextTexture *ct = sbuts->texuser;
@@ -201,7 +202,7 @@ static void buttons_main_region_layout_properties(const bContext *C, SpaceProper
static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
{
const WorkSpace *workspace = CTX_wm_workspace(C);
- const int mode = CTX_data_mode_enum(C);
+ const enum eContextObjectMode mode = CTX_data_mode_enum(C);
const char *contexts_base[5] = {NULL};
contexts_base[0] = ".active_tool";
@@ -260,6 +261,8 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
case CTX_MODE_WEIGHT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_weight");
break;
+ default:
+ break;
}
}
else if (workspace->tools_space_type == SPACE_IMAGE) {
@@ -295,6 +298,8 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
case CTX_MODE_EDIT_GPENCIL:
ARRAY_SET_ITEMS(contexts, ".greasepencil_edit");
break;
+ default:
+ break;
}
int i = 0;
@@ -447,8 +452,9 @@ static void buttons_area_redraw(ScrArea *sa, short buttons)
SpaceProperties *sbuts = sa->spacedata.first;
/* if the area's current button set is equal to the one to redraw */
- if (sbuts->mainb == buttons)
+ if (sbuts->mainb == buttons) {
ED_area_tag_redraw(sa);
+ }
}
/* reused! */
@@ -506,10 +512,12 @@ static void buttons_area_listener(
buttons_area_redraw(sa, BCONTEXT_DATA);
break;
case ND_MODIFIER:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_area_tag_redraw(sa);
- else
+ }
+ else {
buttons_area_redraw(sa, BCONTEXT_MODIFIER);
+ }
buttons_area_redraw(sa, BCONTEXT_PHYSICS);
break;
case ND_CONSTRAINT:
@@ -517,8 +525,9 @@ static void buttons_area_listener(
buttons_area_redraw(sa, BCONTEXT_BONE_CONSTRAINT);
break;
case ND_PARTICLE:
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
buttons_area_redraw(sa, BCONTEXT_PARTICLE);
+ }
sbuts->preview = 1;
break;
case ND_DRAW:
@@ -585,26 +594,30 @@ static void buttons_area_listener(
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_PROPERTIES)
+ if (wmn->data == ND_SPACE_PROPERTIES) {
ED_area_tag_redraw(sa);
+ }
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_area_tag_redraw(sa);
+ }
break;
case NC_ANIMATION:
switch (wmn->data) {
case ND_KEYFRAME:
- if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED))
+ if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) {
ED_area_tag_redraw(sa);
+ }
break;
}
break;
case NC_GPENCIL:
switch (wmn->data) {
case ND_DATA:
- if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED))
+ if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) {
ED_area_tag_redraw(sa);
+ }
break;
}
break;
@@ -612,8 +625,9 @@ static void buttons_area_listener(
if (wmn->action == NA_SELECTED) {
ED_area_tag_redraw(sa);
/* new active node, update texture preview */
- if (sbuts->mainb == BCONTEXT_TEXTURE)
+ if (sbuts->mainb == BCONTEXT_TEXTURE) {
sbuts->preview = 1;
+ }
}
break;
/* Listener for preview render, when doing an global undo. */
@@ -631,8 +645,9 @@ static void buttons_area_listener(
#endif
}
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_area_tag_redraw(sa);
+ }
}
static void buttons_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 54830c14b85..7c400f8a417 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -1879,12 +1879,12 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
}
}
- ED_gpencil_draw_2dimage(C);
+ ED_annotation_draw_2dimage(C);
GPU_matrix_pop();
}
}
else {
- ED_gpencil_draw_view2d(C, 0);
+ ED_annotation_draw_view2d(C, 0);
}
}
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index b7e4133e073..042fb366224 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -132,8 +132,9 @@ static void console_cursor_wrap_offset(const char *str, int width, int *row, int
*column = 0;
}
- if (end && str >= end)
+ if (end && str >= end) {
break;
+ }
*column += col;
}
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index 46d22df2609..d4489337847 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -87,10 +87,13 @@ static void console_scrollback_limit(SpaceConsole *sc)
{
int tot;
- if (U.scrollback < 32) U.scrollback = 256; // XXX - save in user defaults
+ if (U.scrollback < 32) {
+ U.scrollback = 256; // XXX - save in user defaults
+ }
- for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--)
+ for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) {
console_scrollback_free(sc, sc->scrollback.first);
+ }
}
static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore)
@@ -98,11 +101,13 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons
ConsoleLine *cl;
for (cl = sc->history.last; cl; cl = cl->prev) {
- if (cl == cl_ignore)
+ if (cl == cl_ignore) {
continue;
+ }
- if (STREQ(str, cl->line))
+ if (STREQ(str, cl->line)) {
return cl;
+ }
}
return NULL;
@@ -113,9 +118,15 @@ static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
{
int cursor_new;
- if (cursor < 0) cursor_new = 0;
- else if (cursor > cl->len) cursor_new = cl->len;
- else cursor_new = cursor;
+ if (cursor < 0) {
+ cursor_new = 0;
+ }
+ else if (cursor > cl->len) {
+ cursor_new = cl->len;
+ }
+ else {
+ cursor_new = cursor;
+ }
if (cursor_new == cl->cursor) {
return false;
@@ -184,8 +195,12 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, bool own)
{
ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
- if (own) ci->line = str;
- else ci->line = BLI_strdup(str);
+ if (own) {
+ ci->line = str;
+ }
+ else {
+ ci->line = BLI_strdup(str);
+ }
ci->len = ci->len_alloc = strlen(str);
@@ -207,8 +222,9 @@ ConsoleLine *console_history_verify(const bContext *C)
{
SpaceConsole *sc = CTX_wm_space_console(C);
ConsoleLine *ci = sc->history.last;
- if (ci == NULL)
+ if (ci == NULL) {
ci = console_history_add(sc, NULL);
+ }
return ci;
}
@@ -242,8 +258,9 @@ static int console_line_insert(ConsoleLine *ci, char *str)
len--;
}
- if (len == 0)
+ if (len == 0) {
return 0;
+ }
console_line_verify_length(ci, len + ci->len);
@@ -480,8 +497,9 @@ static int console_indent_exec(bContext *C, wmOperator *UNUSED(op))
int len;
for (spaces = 0; spaces < ci->len; spaces++) {
- if (ci->line[spaces] != ' ')
+ if (ci->line[spaces] != ' ') {
break;
+ }
}
len = TAB_LENGTH - spaces % TAB_LENGTH;
@@ -524,16 +542,19 @@ static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op))
int len;
for (spaces = 0; spaces < ci->len; spaces++) {
- if (ci->line[spaces] != ' ')
+ if (ci->line[spaces] != ' ') {
break;
+ }
}
- if (spaces == 0)
+ if (spaces == 0) {
return OPERATOR_CANCELLED;
+ }
len = spaces % TAB_LENGTH;
- if (len == 0)
+ if (len == 0) {
len = TAB_LENGTH;
+ }
console_line_verify_length(ci, ci->len - len);
@@ -701,13 +722,15 @@ static int console_clear_exec(bContext *C, wmOperator *op)
/*ConsoleLine *ci = */ console_history_verify(C);
if (scrollback) { /* last item in mistory */
- while (sc->scrollback.first)
+ while (sc->scrollback.first) {
console_scrollback_free(sc, sc->scrollback.first);
+ }
}
if (history) {
- while (sc->history.first)
+ while (sc->history.first) {
console_history_free(sc, sc->history.first);
+ }
console_history_verify(C);
}
@@ -751,8 +774,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
if (ci->prev) {
ConsoleLine *ci_prev = (ConsoleLine *)ci->prev;
- if (STREQ(ci->line, ci_prev->line))
+ if (STREQ(ci->line, ci_prev->line)) {
console_history_free(sc, ci_prev);
+ }
}
if (reverse) { /* last item in history */
@@ -768,8 +792,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
{ /* add a duplicate of the new arg and remove all other instances */
ConsoleLine *cl;
- while ((cl = console_history_find(sc, ci->line, ci)))
+ while ((cl = console_history_find(sc, ci->line, ci))) {
console_history_free(sc, cl);
+ }
console_history_add(sc, (ConsoleLine *)sc->history.last);
}
@@ -818,8 +843,9 @@ static int console_history_append_exec(bContext *C, wmOperator *op)
if (rem_dupes) {
ConsoleLine *cl;
- while ((cl = console_history_find(sc, ci->line, ci)))
+ while ((cl = console_history_find(sc, ci->line, ci))) {
console_history_free(sc, cl);
+ }
if (STREQ(str, ci->line)) {
MEM_freeN(str);
@@ -928,8 +954,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
ConsoleLine cl_dummy = {NULL};
- if (sc->sel_start == sc->sel_end)
+ if (sc->sel_start == sc->sel_end) {
return OPERATOR_CANCELLED;
+ }
console_scrollback_prompt_begin(sc, &cl_dummy);
@@ -952,8 +979,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
int sta = max_ii(sel[0], 0);
int end = min_ii(sel[1], cl->len);
- if (BLI_dynstr_get_len(buf_dyn))
+ if (BLI_dynstr_get_len(buf_dyn)) {
BLI_dynstr_append(buf_dyn, "\n");
+ }
BLI_dynstr_nappend(buf_dyn, cl->line + sta, end - sta);
}
@@ -998,8 +1026,9 @@ static int console_paste_exec(bContext *C, wmOperator *UNUSED(op))
char *buf_str = WM_clipboard_text_get(false, &buf_len);
char *buf_step, *buf_next;
- if (buf_str == NULL)
+ if (buf_str == NULL) {
return OPERATOR_CANCELLED;
+ }
buf_step = buf_str;
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 65f1fe36fec..5d4623e6fe6 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -88,11 +88,13 @@ static void console_free(SpaceLink *sl)
{
SpaceConsole *sc = (SpaceConsole *) sl;
- while (sc->scrollback.first)
+ while (sc->scrollback.first) {
console_scrollback_free(sc, sc->scrollback.first);
+ }
- while (sc->history.first)
+ while (sc->history.first) {
console_history_free(sc, sc->history.first);
+ }
}
@@ -208,8 +210,9 @@ static void console_main_region_draw(const bContext *C, ARegion *ar)
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
- if (BLI_listbase_is_empty(&sc->scrollback))
+ if (BLI_listbase_is_empty(&sc->scrollback)) {
WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL);
+ }
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 8156e62a427..c0aa03abece 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -241,8 +241,12 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
str_exec = params->title; /* params->title is already translated! */
}
- uiDefButO(block, UI_BTYPE_BUT, "FILE_OT_execute", WM_OP_EXEC_REGION_WIN, str_exec,
- max_x - loadbutton, line1_y, loadbutton, btn_h, "");
+ but = uiDefButO(
+ block, UI_BTYPE_BUT, "FILE_OT_execute", WM_OP_EXEC_REGION_WIN, str_exec,
+ max_x - loadbutton, line1_y, loadbutton, btn_h, "");
+ /* Just a display hint. */
+ UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT);
+
uiDefButO(block, UI_BTYPE_BUT, "FILE_OT_cancel", WM_OP_EXEC_REGION_WIN, IFACE_("Cancel"),
max_x - loadbutton, line2_y, loadbutton, btn_h, "");
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index eec30adff10..623442b753a 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -787,7 +787,7 @@ void filelist_init_icons(void)
#ifdef WITH_HEADLESS
bbuf = NULL;
#else
- bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, NULL, "<splash>");
+ bbuf = IMB_ibImageFromMemory((const uchar *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, NULL, "<splash>");
#endif
if (bbuf) {
for (y = 0; y < SPECIAL_IMG_ROWS; y++) {
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 535ec6e8da9..52f45a66c0d 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -1254,7 +1254,9 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
{
/* draw all channels using standard channel-drawing API */
- ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index);
+ rctf channel_rect;
+ BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax - V2D_SCROLL_WIDTH, yminc, ymaxc);
+ ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index);
}
/* adjust y-position for next one */
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index b77c08736dc..47b3f9995c5 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -69,8 +69,9 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
size_t ofs = 0;
str[0] = 0;
- if (ima == NULL)
+ if (ima == NULL) {
return;
+ }
if (ibuf == NULL) {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Can't Load Image"), len - ofs);
@@ -78,9 +79,10 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
else {
if (ima->source == IMA_SRC_MOVIE) {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Movie"), len - ofs);
- if (BKE_image_has_anim(ima))
+ if (BKE_image_has_anim(ima)) {
ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_(" %d frs"),
IMB_anim_get_duration(((ImageAnim *)ima->anims.first)->anim, IMB_TC_RECORD_RUN));
+ }
}
else {
ofs += BLI_strncpy_rlen(str, IFACE_("Image"), len - ofs);
@@ -92,26 +94,33 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf,
if (ibuf->channels != 4) {
ofs += BLI_snprintf(str + ofs, len - 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"), len - ofs);
- else
+ }
+ else {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB float"), len - 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"), len - ofs);
- else
+ }
+ else {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB byte"), len - ofs);
+ }
}
- if (ibuf->zbuf || ibuf->zbuf_float)
+ if (ibuf->zbuf || ibuf->zbuf_float) {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" + Z"), len - ofs);
+ }
if (ima->source == IMA_SRC_SEQUENCE) {
const char *file = BLI_last_slash(ibuf->name);
- if (file == NULL)
+ if (file == NULL) {
file = ibuf->name;
- else
+ }
+ else {
file++;
+ }
ofs += BLI_snprintf(str + ofs, len - ofs, ", %s", file);
}
}
@@ -129,11 +138,15 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
{
bNode *node;
- if (ntree)
- for (node = ntree->nodes.first; node; node = node->next)
- if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
- if (node->flag & NODE_DO_OUTPUT)
+ if (ntree) {
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
+ if (node->flag & NODE_DO_OUTPUT) {
return node->storage;
+ }
+ }
+ }
+ }
return NULL;
}
@@ -543,8 +556,9 @@ static bool ui_imageuser_layer_menu_step(bContext *C, int direction, void *rnd_p
else if (direction == 1) {
int tot = BLI_listbase_count(&rr->layers);
- if (RE_HasCombinedLayer(rr))
+ if (RE_HasCombinedLayer(rr)) {
tot++; /* fake compo/sequencer layer */
+ }
if (iuser->layer < tot - 1) {
iuser->layer++;
@@ -835,8 +849,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
void *lock;
- if (!ptr->data)
+ if (!ptr->data) {
return;
+ }
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -921,10 +936,12 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
if (ima->source != IMA_SRC_GENERATED) {
row = uiLayoutRow(layout, true);
- if (BKE_image_has_packedfile(ima))
+ if (BKE_image_has_packedfile(ima)) {
uiItemO(row, "", ICON_PACKAGE, "image.unpack");
- else
+ }
+ else {
uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
+ }
row = uiLayoutRow(row, true);
uiLayoutSetEnabled(row, BKE_image_has_packedfile(ima) == false);
@@ -1200,8 +1217,9 @@ void uiTemplateImageFormatViews(uiLayout *layout, PointerRNA *imfptr, PointerRNA
{
ImageFormatData *imf = imfptr->data;
- if (ptr == NULL)
+ if (ptr == NULL) {
return;
+ }
uiItemR(layout, ptr, "use_multiview", 0, NULL, ICON_NONE);
@@ -1247,8 +1265,9 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
char str[MAX_IMAGE_INFO_LEN];
void *lock;
- if (!ima || !iuser)
+ if (!ima || !iuser) {
return;
+ }
ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
@@ -1297,8 +1316,9 @@ 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)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
@@ -1321,8 +1341,9 @@ 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)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 885a9c18346..ca0f9bd013f 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -282,15 +282,19 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
float rgba[4];
copy_v3_v3(rgba, linearcol);
- if (channels == 3)
+ if (channels == 3) {
rgba[3] = 1.0f;
- else
+ }
+ else {
rgba[3] = linearcol[3];
+ }
- if (use_default_view)
+ if (use_default_view) {
IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, NULL, &scene->display_settings);
- else
+ }
+ else {
IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, &scene->view_settings, &scene->display_settings);
+ }
SNPRINTF(str, " | CM R:%-.4f G:%-.4f B:%-.4f", rgba[0], rgba[1], rgba[2]);
BLF_position(blf_mono_font, dx, dy, 0);
@@ -325,10 +329,12 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
}
if (color_manage) {
- if (use_default_view)
+ if (use_default_view) {
IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, NULL, &scene->display_settings);
- else
+ }
+ else {
IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, &scene->view_settings, &scene->display_settings);
+ }
}
else {
copy_v4_v4(finalcol, col);
@@ -471,10 +477,12 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec
rectf = MEM_mallocN(rectx * recty * sizeof(float), "temp");
for (a = rectx * recty - 1; a >= 0; a--) {
- if (rect_float[a] > clip_end)
+ if (rect_float[a] > clip_end) {
rectf[a] = 0.0f;
- else if (rect_float[a] < bias)
+ }
+ else if (rect_float[a] < bias) {
rectf[a] = 1.0f;
+ }
else {
rectf[a] = 1.0f - (rect_float[a] - bias) * scale;
rectf[a] *= rectf[a];
@@ -498,12 +506,15 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
/* this part is generic image display */
if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) {
- if (ibuf->zbuf)
+ if (ibuf->zbuf) {
sima_draw_zbuf_pixels(x, y, ibuf->x, ibuf->y, ibuf->zbuf, zoomx, zoomy);
- else if (ibuf->zbuf_float)
+ }
+ else if (ibuf->zbuf_float) {
sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->zbuf_float, zoomx, zoomy);
- else if (ibuf->channels == 1)
+ }
+ else if (ibuf->channels == 1) {
sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float, zoomx, zoomy);
+ }
}
else {
int clip_max_x, clip_max_y;
@@ -531,14 +542,18 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
ColorManagedViewSettings *view_settings;
ColorManagedDisplaySettings *display_settings;
- if (sima->flag & SI_SHOW_R)
+ if (sima->flag & SI_SHOW_R) {
shuffle[0] = 1.0f;
- else if (sima->flag & SI_SHOW_G)
+ }
+ else if (sima->flag & SI_SHOW_G) {
shuffle[1] = 1.0f;
- else if (sima->flag & SI_SHOW_B)
+ }
+ else if (sima->flag & SI_SHOW_B) {
shuffle[2] = 1.0f;
- else if (sima->flag & SI_SHOW_ALPHA)
+ }
+ else if (sima->flag & SI_SHOW_ALPHA) {
shuffle[3] = 1.0f;
+ }
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, shuffle);
@@ -554,8 +569,9 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
IMB_display_buffer_release(cache_handle);
}
- if (sima->flag & SI_USE_ALPHA)
+ if (sima->flag & SI_USE_ALPHA) {
GPU_blend(false);
+ }
}
}
@@ -573,8 +589,9 @@ static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, AReg
draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy);
/* only draw until running out of time */
- if ((PIL_check_seconds_timer() - time_current) > 0.25)
+ if ((PIL_check_seconds_timer() - time_current) > 0.25) {
return;
+ }
}
}
}
@@ -587,14 +604,14 @@ void draw_image_grease_pencil(bContext *C, bool onlyv2d)
/* draw in View2D space? */
if (onlyv2d) {
/* draw grease-pencil ('image' strokes) */
- ED_gpencil_draw_2dimage(C);
+ ED_annotation_draw_2dimage(C);
}
else {
/* assume that UI_view2d_restore(C) has been called... */
//SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
/* draw grease-pencil ('screen' strokes) */
- ED_gpencil_draw_view2d(C, 0);
+ ED_annotation_draw_view2d(C, 0);
}
}
@@ -715,11 +732,13 @@ void draw_image_main(const bContext *C, ARegion *ar)
}
if (show_stereo3d) {
- if (show_multilayer)
+ if (show_multilayer) {
/* update multiindex and pass for the current eye */
BKE_image_multilayer_index(ima->rr, &sima->iuser);
- else
+ }
+ else {
BKE_image_multiview_index(ima, &sima->iuser);
+ }
}
ibuf = ED_space_image_acquire_buffer(sima, &lock);
@@ -729,10 +748,12 @@ void draw_image_main(const bContext *C, ARegion *ar)
ED_region_grid_draw(ar, zoomx, zoomy);
}
else {
- if (sima->flag & SI_DRAW_TILE)
+ if (sima->flag & SI_DRAW_TILE) {
draw_image_buffer_repeated(C, sima, ar, scene, ibuf, zoomx, zoomy);
- else
+ }
+ else {
draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
+ }
if (sima->flag & SI_DRAW_METADATA) {
int x, y;
@@ -748,16 +769,18 @@ void draw_image_main(const bContext *C, ARegion *ar)
ED_space_image_release_buffer(sima, ibuf, lock);
/* paint helpers */
- if (show_paint)
+ if (show_paint) {
draw_image_paint_helpers(C, ar, scene, zoomx, zoomy);
+ }
if (show_viewer) {
BLI_thread_unlock(LOCK_DRAW_IMAGE);
}
/* render info */
- if (ima && show_render)
+ if (ima && show_render) {
draw_render_info(C, sima->iuser.scene, ima, ar, zoomx, zoomy);
+ }
}
bool ED_space_image_show_cache(SpaceImage *sima)
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index 9a6f7431d17..c838c6a87fe 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -57,9 +57,13 @@ Image *ED_space_image(SpaceImage *sima)
return sima->image;
}
-/* called to assign images to UV faces */
-void ED_space_image_set(Main *bmain, SpaceImage *sima, Object *obedit, Image *ima)
+void ED_space_image_set(Main *bmain, SpaceImage *sima, Object *obedit, Image *ima, bool automatic)
{
+ /* Automatically pin image when manually assigned, otherwise it follows object. */
+ if (!automatic && sima->image != ima && sima->mode == SI_MODE_UV) {
+ sima->pin = true;
+ }
+
/* change the space ima after because uvedit_face_visible_test uses the space ima
* to check if the face is displayed in UV-localview */
sima->image = ima;
@@ -70,17 +74,51 @@ void ED_space_image_set(Main *bmain, SpaceImage *sima, Object *obedit, Image *im
}
}
- if (sima->image)
+ if (sima->image) {
BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
+ }
id_us_ensure_real((ID *)sima->image);
- if (obedit)
+ if (obedit) {
WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data);
+ }
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL);
}
+void ED_space_image_auto_set(const bContext *C, SpaceImage *sima)
+{
+ if (sima->mode != SI_MODE_UV || sima->pin) {
+ return;
+ }
+
+ /* Track image assigned to active face in edit mode. */
+ Object *ob = CTX_data_active_object(C);
+ if (!(ob && (ob->mode & OB_MODE_EDIT) && ED_space_image_show_uvedit(sima, ob))) {
+ return;
+ }
+
+ BMEditMesh *em = BKE_editmesh_from_object(ob);
+ BMesh *bm = em->bm;
+ BMFace *efa = BM_mesh_active_face_get(bm, true, false);
+ if (efa == NULL) {
+ return;
+ }
+
+ Image *ima = NULL;
+ ED_object_get_active_image(ob, efa->mat_nr + 1, &ima, NULL, NULL, NULL);
+
+ if (ima != sima->image) {
+ sima->image = ima;
+
+ if (sima->image) {
+ Main *bmain = CTX_data_main(C);
+ BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
+ }
+ }
+}
+
Mask *ED_space_image_get_mask(SpaceImage *sima)
{
return sima->mask_info.mask;
@@ -111,22 +149,25 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **r_lock)
ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, r_lock);
if (ibuf) {
- if (ibuf->rect || ibuf->rect_float)
+ if (ibuf->rect || ibuf->rect_float) {
return ibuf;
+ }
BKE_image_release_ibuf(sima->image, ibuf, *r_lock);
*r_lock = NULL;
}
}
- else
+ else {
*r_lock = NULL;
+ }
return NULL;
}
void ED_space_image_release_buffer(SpaceImage *sima, ImBuf *ibuf, void *lock)
{
- if (sima && sima->image)
+ if (sima && sima->image) {
BKE_image_release_ibuf(sima->image, ibuf, lock);
+ }
}
bool ED_space_image_has_buffer(SpaceImage *sima)
@@ -299,7 +340,9 @@ bool ED_image_slot_cycle(struct Image *image, int direction)
int num_slots = BLI_listbase_count(&image->renderslots);
for (i = 1; i < num_slots; i++) {
slot = (cur + ((direction == -1) ? -i : i)) % num_slots;
- if (slot < 0) slot += num_slots;
+ if (slot < 0) {
+ slot += num_slots;
+ }
RenderSlot *render_slot = BKE_image_get_renderslot(image, slot);
if ((render_slot && render_slot->render) || slot == image->last_render_slot) {
@@ -321,10 +364,12 @@ void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *s
Object *ob = CTX_data_active_object(C);
/* scope update can be expensive, don't update during paint modes */
- if (sima->mode == SI_MODE_PAINT)
+ if (sima->mode == SI_MODE_PAINT) {
return;
- if (ob && ((ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0))
+ }
+ if (ob && ((ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) {
return;
+ }
/* We also don't update scopes of render result during render. */
if (G.is_rendering) {
@@ -346,8 +391,9 @@ bool ED_space_image_show_render(SpaceImage *sima)
bool ED_space_image_show_paint(SpaceImage *sima)
{
- if (ED_space_image_show_render(sima))
+ if (ED_space_image_show_render(sima)) {
return false;
+ }
return (sima->mode == SI_MODE_PAINT);
}
@@ -406,8 +452,9 @@ bool ED_space_image_paint_curve(const bContext *C)
if (sima && sima->mode == SI_MODE_PAINT) {
Brush *br = CTX_data_tool_settings(C)->imapaint.paint.brush;
- if (br && (br->flag & BRUSH_CURVE))
+ if (br && (br->flag & BRUSH_CURVE)) {
return true;
+ }
}
return false;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 064a4d2ce11..831be935fa4 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -117,12 +117,15 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, const float
width *= sima->zoom;
height *= sima->zoom;
- if ((width < 4) && (height < 4) && sima->zoom < oldzoom)
+ if ((width < 4) && (height < 4) && sima->zoom < oldzoom) {
sima->zoom = oldzoom;
- else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom)
+ }
+ else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom) {
sima->zoom = oldzoom;
- else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom)
+ }
+ else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom) {
sima->zoom = oldzoom;
+ }
}
if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) {
@@ -489,8 +492,9 @@ static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
ED_region_tag_redraw(CTX_wm_region(C));
}
- if (vpd->timer)
+ if (vpd->timer) {
WM_event_remove_timer(CTX_wm_manager(C), vpd->timer->win, vpd->timer);
+ }
WM_cursor_modal_restore(CTX_wm_window(C));
MEM_freeN(op->customdata);
@@ -534,8 +538,9 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
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);
@@ -582,8 +587,9 @@ static void image_zoom_apply(ViewZoomData *vpd, wmOperator *op, const int x, con
/* for now do the same things for scale and dolly */
float delta = x - vpd->origx + y - vpd->origy;
- if (zoom_invert)
+ if (zoom_invert) {
delta *= -1.0f;
+ }
factor = 1.0f + delta / 300.0f;
}
@@ -662,8 +668,9 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
static int image_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 {
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
@@ -747,8 +754,9 @@ static int image_view_all_exec(bContext *C, wmOperator *op)
/* find the zoom value that will fit the image in the image space */
sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL);
}
- else
+ else {
sima_zoom_set(sima, ar, 1.0f, NULL);
+ }
}
sima->xof = sima->yof = 0.0f;
@@ -1138,8 +1146,12 @@ static int image_cmp_frame(const void *a, const void *b)
const ImageFrame *frame_a = a;
const ImageFrame *frame_b = b;
- if (frame_a->framenr < frame_b->framenr) return -1;
- if (frame_a->framenr > frame_b->framenr) return 1;
+ if (frame_a->framenr < frame_b->framenr) {
+ return -1;
+ }
+ if (frame_a->framenr > frame_b->framenr) {
+ return 1;
+ }
return 0;
}
@@ -1181,7 +1193,9 @@ static Image *image_open_single(
ima = BKE_image_load_exists_ex(bmain, filepath, &exists);
if (!ima) {
- if (op->customdata) MEM_freeN(op->customdata);
+ if (op->customdata) {
+ MEM_freeN(op->customdata);
+ }
BKE_reportf(op->reports, RPT_ERROR, "Cannot read '%s': %s",
filepath, errno ? strerror(errno) : TIP_("unsupported image format"));
return NULL;
@@ -1232,8 +1246,9 @@ static int image_open_exec(bContext *C, wmOperator *op)
const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
const bool use_multiview = RNA_boolean_get(op->ptr, "use_multiview");
- if (!op->customdata)
+ if (!op->customdata) {
image_open_init(C, op);
+ }
RNA_string_get(op->ptr, "filepath", filepath);
@@ -1300,7 +1315,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
}
else if (sa && sa->spacetype == SPACE_IMAGE) {
SpaceImage *sima = sa->spacedata.first;
- ED_space_image_set(bmain, sima, obedit, ima);
+ ED_space_image_set(bmain, sima, obedit, ima, false);
iuser = &sima->iuser;
}
else {
@@ -1361,8 +1376,9 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
if (ima == NULL) {
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
- if (tex && tex->type == TEX_IMAGE)
+ if (tex && tex->type == TEX_IMAGE) {
ima = tex->ima;
+ }
}
if (ima == NULL) {
@@ -1385,11 +1401,13 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
}
}
- if (ima)
+ if (ima) {
path = ima->name;
+ }
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return image_open_exec(C, op);
+ }
image_open_init(C, op);
@@ -1422,14 +1440,15 @@ static void image_open_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
+ uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
/* multiview template */
- if (RNA_boolean_get(op->ptr, "show_multiview"))
+ if (RNA_boolean_get(op->ptr, "show_multiview")) {
uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
+ }
}
/* called by other space types too */
@@ -1481,12 +1500,14 @@ static int image_match_len_exec(bContext *C, wmOperator *UNUSED(op))
}
- if (!ima || !iuser || !BKE_image_has_anim(ima))
+ if (!ima || !iuser || !BKE_image_has_anim(ima)) {
return OPERATOR_CANCELLED;
+ }
struct anim *anim = ((ImageAnim *)ima->anims.first)->anim;
- if (!anim)
+ if (!anim) {
return OPERATOR_CANCELLED;
+ }
iuser->frames = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN);
BKE_image_user_frame_calc(iuser, scene->r.cfra);
@@ -1517,8 +1538,9 @@ static int image_replace_exec(bContext *C, wmOperator *op)
SpaceImage *sima = CTX_wm_space_image(C);
char str[FILE_MAX];
- if (!sima->image)
+ if (!sima->image) {
return OPERATOR_CANCELLED;
+ }
RNA_string_get(op->ptr, "filepath", str);
@@ -1530,10 +1552,12 @@ static int image_replace_exec(bContext *C, wmOperator *op)
BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE);
}
- if (BLI_path_extension_check_array(str, imb_ext_movie))
+ if (BLI_path_extension_check_array(str, imb_ext_movie)) {
sima->image->source = IMA_SRC_MOVIE;
- else
+ }
+ else {
sima->image->source = IMA_SRC_FILE;
+ }
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -1549,14 +1573,17 @@ static int image_replace_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
{
SpaceImage *sima = CTX_wm_space_image(C);
- if (!sima->image)
+ if (!sima->image) {
return OPERATOR_CANCELLED;
+ }
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return image_replace_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", BLI_path_is_rel(sima->image->name));
+ }
image_filesel(C, op, sima->image->name);
@@ -1604,18 +1631,18 @@ static char imtype_best_depth(ImBuf *ibuf, const char imtype)
const char depth_ok = BKE_imtype_valid_depths(imtype);
if (ibuf->rect_float) {
- if (depth_ok & R_IMF_CHAN_DEPTH_32) return R_IMF_CHAN_DEPTH_32;
- if (depth_ok & R_IMF_CHAN_DEPTH_24) return R_IMF_CHAN_DEPTH_24;
- if (depth_ok & R_IMF_CHAN_DEPTH_16) return R_IMF_CHAN_DEPTH_16;
- if (depth_ok & R_IMF_CHAN_DEPTH_12) return R_IMF_CHAN_DEPTH_12;
+ if (depth_ok & R_IMF_CHAN_DEPTH_32) { return R_IMF_CHAN_DEPTH_32; }
+ if (depth_ok & R_IMF_CHAN_DEPTH_24) { return R_IMF_CHAN_DEPTH_24; }
+ if (depth_ok & R_IMF_CHAN_DEPTH_16) { return R_IMF_CHAN_DEPTH_16; }
+ if (depth_ok & R_IMF_CHAN_DEPTH_12) { return R_IMF_CHAN_DEPTH_12; }
return R_IMF_CHAN_DEPTH_8;
}
else {
- if (depth_ok & R_IMF_CHAN_DEPTH_8) return R_IMF_CHAN_DEPTH_8;
- if (depth_ok & R_IMF_CHAN_DEPTH_12) return R_IMF_CHAN_DEPTH_12;
- if (depth_ok & R_IMF_CHAN_DEPTH_16) return R_IMF_CHAN_DEPTH_16;
- if (depth_ok & R_IMF_CHAN_DEPTH_24) return R_IMF_CHAN_DEPTH_24;
- if (depth_ok & R_IMF_CHAN_DEPTH_32) return R_IMF_CHAN_DEPTH_32;
+ if (depth_ok & R_IMF_CHAN_DEPTH_8) { return R_IMF_CHAN_DEPTH_8; }
+ if (depth_ok & R_IMF_CHAN_DEPTH_12) { return R_IMF_CHAN_DEPTH_12; }
+ if (depth_ok & R_IMF_CHAN_DEPTH_16) { return R_IMF_CHAN_DEPTH_16; }
+ if (depth_ok & R_IMF_CHAN_DEPTH_24) { return R_IMF_CHAN_DEPTH_24; }
+ if (depth_ok & R_IMF_CHAN_DEPTH_32) { return R_IMF_CHAN_DEPTH_32; }
return R_IMF_CHAN_DEPTH_8; /* fallback, should not get here */
}
}
@@ -1753,14 +1780,18 @@ static void save_image_post(
/* 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))
+ if (ibuf->rect && !(ibuf->mall & IB_rect)) {
imb_freerectImBuf(ibuf);
- if (ibuf->rect_float && !(ibuf->mall & IB_rectfloat))
+ }
+ if (ibuf->rect_float && !(ibuf->mall & IB_rectfloat)) {
imb_freerectfloatImBuf(ibuf);
- if (ibuf->zbuf && !(ibuf->mall & IB_zbuf))
+ }
+ if (ibuf->zbuf && !(ibuf->mall & IB_zbuf)) {
IMB_freezbufImBuf(ibuf);
- if (ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat))
+ }
+ 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;
@@ -1932,10 +1963,12 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
iuser.view = i;
iuser.flag &= ~IMA_SHOW_STEREO;
- if (rr)
+ if (rr) {
BKE_image_multilayer_index(rr, &iuser);
- else
+ }
+ else {
BKE_image_multiview_index(ima, &iuser);
+ }
ibuf = BKE_image_acquire_ibuf(sima->image, &iuser, &lock);
ibuf->planes = planes;
@@ -2087,13 +2120,15 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
PropertyRNA *prop;
const bool save_as_render = ((ima->source == IMA_SRC_VIEWER) || (ima->flag & IMA_VIEW_AS_RENDER));
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return image_save_as_exec(C, op);
+ }
save_image_options_defaults(&simopts);
- if (save_image_options_init(bmain, &simopts, sima, scene, true, save_as_render) == 0)
+ if (save_image_options_init(bmain, &simopts, sima, scene, true, save_as_render) == 0) {
return OPERATOR_CANCELLED;
+ }
save_image_options_to_op(&simopts, op);
/* enable save_copy by default for render results */
@@ -2147,11 +2182,12 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
+ uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
/* multiview template */
- if (is_multiview)
+ if (is_multiview) {
uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
+ }
}
static bool image_save_as_poll(bContext *C)
@@ -2209,8 +2245,9 @@ static int image_save_exec(bContext *C, wmOperator *op)
SaveImageOptions simopts;
save_image_options_defaults(&simopts);
- if (save_image_options_init(bmain, &simopts, sima, scene, false, false) == 0)
+ if (save_image_options_init(bmain, &simopts, sima, scene, false, false) == 0) {
return OPERATOR_CANCELLED;
+ }
save_image_options_from_op(bmain, &simopts, op);
if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) {
@@ -2253,8 +2290,9 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
char di[FILE_MAX];
struct MovieCacheIter *iter;
- if (sima->image == NULL)
+ if (sima->image == NULL) {
return OPERATOR_CANCELLED;
+ }
if (sima->image->source != IMA_SRC_SEQUENCE) {
BKE_report(op->reports, RPT_ERROR, "Can only save sequence on image sequences");
@@ -2341,8 +2379,9 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
Image *ima = CTX_data_edit_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
- if (!ima)
+ if (!ima) {
return OPERATOR_CANCELLED;
+ }
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -2437,8 +2476,9 @@ static int image_new_exec(bContext *C, wmOperator *op)
alpha = RNA_boolean_get(op->ptr, "alpha");
stereo3d = RNA_boolean_get(op->ptr, "use_stereo_3d");
- if (!alpha)
+ if (!alpha) {
color[3] = 1.0f;
+ }
ima = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color, stereo3d);
@@ -2461,7 +2501,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
RNA_property_update(C, &data->pprop.ptr, data->pprop.prop);
}
else if (sima) {
- ED_space_image_set(bmain, sima, obedit, ima);
+ ED_space_image_set(bmain, sima, obedit, ima, false);
}
BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
@@ -2619,10 +2659,10 @@ static int image_invert_exec(bContext *C, wmOperator *op)
float *fp = (float *) ibuf->rect_float;
for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, fp += 4) {
- if (r) fp[0] = 1.0f - fp[0];
- if (g) fp[1] = 1.0f - fp[1];
- if (b) fp[2] = 1.0f - fp[2];
- if (a) fp[3] = 1.0f - fp[3];
+ if (r) { fp[0] = 1.0f - fp[0]; }
+ if (g) { fp[1] = 1.0f - fp[1]; }
+ if (b) { fp[2] = 1.0f - fp[2]; }
+ if (a) { fp[3] = 1.0f - fp[3]; }
}
if (ibuf->rect) {
@@ -2633,10 +2673,10 @@ static int image_invert_exec(bContext *C, wmOperator *op)
char *cp = (char *) ibuf->rect;
for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, cp += 4) {
- if (r) cp[0] = 255 - cp[0];
- if (g) cp[1] = 255 - cp[1];
- if (b) cp[2] = 255 - cp[2];
- if (a) cp[3] = 255 - cp[3];
+ if (r) { cp[0] = 255 - cp[0]; }
+ if (g) { cp[1] = 255 - cp[1]; }
+ if (b) { cp[2] = 255 - cp[2]; }
+ if (a) { cp[3] = 255 - cp[3]; }
}
}
else {
@@ -2646,8 +2686,9 @@ static int image_invert_exec(bContext *C, wmOperator *op)
ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
- if (ibuf->mipmap[0])
+ if (ibuf->mipmap[0]) {
ibuf->userflags |= IB_MIPMAP_INVALID;
+ }
if (support_undo) {
ED_image_undo_push_end();
@@ -2697,10 +2738,12 @@ 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)
+ if (!ima) {
return 0;
- if (!as_png && BKE_image_has_packedfile(ima))
+ }
+ 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");
@@ -2717,18 +2760,21 @@ static int image_pack_exec(bContext *C, wmOperator *op)
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))
+ 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 (as_png) {
BKE_image_memorypack(ima);
- else
+ }
+ else {
BKE_image_packfiles(op->reports, ima, ID_BLEND_PATH(bmain, &ima->id));
+ }
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
@@ -2745,8 +2791,9 @@ static int image_pack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
uiLayout *layout;
const bool as_png = RNA_boolean_get(op->ptr, "as_png");
- if (!image_pack_test(C, op))
+ if (!image_pack_test(C, op)) {
return OPERATOR_CANCELLED;
+ }
ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
@@ -2797,19 +2844,23 @@ static int image_unpack_exec(bContext *C, wmOperator *op)
char imaname[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "id", imaname);
ima = BLI_findstring(&CTX_data_main(C)->images, imaname, offsetof(ID, name) + 2);
- if (!ima) ima = CTX_data_edit_image(C);
+ if (!ima) {
+ ima = CTX_data_edit_image(C);
+ }
}
- if (!ima || !BKE_image_has_packedfile(ima))
+ if (!ima || !BKE_image_has_packedfile(ima)) {
return OPERATOR_CANCELLED;
+ }
if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
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");
+ }
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -2825,19 +2876,22 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
{
Image *ima = CTX_data_edit_image(C);
- if (RNA_struct_property_is_set(op->ptr, "id"))
+ if (RNA_struct_property_is_set(op->ptr, "id")) {
return image_unpack_exec(C, op);
+ }
- if (!ima || !BKE_image_has_packedfile(ima))
+ if (!ima || !BKE_image_has_packedfile(ima)) {
return OPERATOR_CANCELLED;
+ }
if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
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, "IMAGE_OT_unpack", ima->id.name + 2, ima->name, "textures", BKE_image_has_packedfile(ima) ? ((ImagePackedFile *)ima->packedfiles.first)->packedfile : NULL);
@@ -3209,8 +3263,9 @@ static int image_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
}
- if (!ED_space_image_has_buffer(sima))
+ if (!ED_space_image_has_buffer(sima)) {
return OPERATOR_CANCELLED;
+ }
info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
@@ -3329,8 +3384,9 @@ static int image_sample_line_invoke(bContext *C, wmOperator *op, const wmEvent *
Histogram *hist = &sima->sample_line_hist;
hist->flag &= ~HISTO_FLAG_SAMPLELINE;
- if (!ED_space_image_has_buffer(sima))
+ if (!ED_space_image_has_buffer(sima)) {
return OPERATOR_CANCELLED;
+ }
return WM_gesture_straightline_invoke(C, op, event);
}
@@ -3559,8 +3615,9 @@ static int image_cycle_render_slot_exec(bContext *C, wmOperator *op)
/* no undo push for browsing existing */
RenderSlot *slot = BKE_image_get_renderslot(ima, ima->render_slot);
- if ((slot && slot->render) || ima->render_slot == ima->last_render_slot)
+ if ((slot && slot->render) || ima->render_slot == ima->last_render_slot) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -3678,8 +3735,9 @@ void IMAGE_OT_remove_render_slot(wmOperatorType *ot)
static bool change_frame_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return space_image_main_region_poll(C);
}
@@ -3761,8 +3819,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;
}
@@ -3800,7 +3859,7 @@ static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
ima = BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result");
if (sima->image == NULL) {
- ED_space_image_set(bmain, sima, NULL, ima);
+ ED_space_image_set(bmain, sima, NULL, ima, false);
}
RE_ReadRenderResult(scene, scene);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 6ae4eb9767b..d5eb0b485a1 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -91,8 +91,9 @@ static void image_scopes_tag_refresh(ScrArea *sa)
/* only while histogram is visible */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_TOOL_PROPS && ar->flag & RGN_FLAG_HIDDEN)
+ if (ar->regiontype == RGN_TYPE_TOOL_PROPS && ar->flag & RGN_FLAG_HIDDEN) {
return;
+ }
}
sima->scopes.ok = 0;
@@ -100,15 +101,19 @@ static void image_scopes_tag_refresh(ScrArea *sa)
static void image_user_refresh_scene(const bContext *C, SpaceImage *sima)
{
+ /* Update scene image user for acquiring render results. */
+ sima->iuser.scene = CTX_data_scene(C);
+
if (sima->image && sima->image->type == IMA_TYPE_R_RESULT) {
- /* for render result, try to use the currently rendering scene */
+ /* While rendering, prefer scene that is being rendered. */
Scene *render_scene = ED_render_job_get_current_scene(C);
if (render_scene) {
sima->iuser.scene = render_scene;
- return;
}
}
- sima->iuser.scene = CTX_data_scene(C);
+
+ /* Auto switch image to show in UV editor when selection changes. */
+ ED_space_image_auto_set(C, sima);
}
/* ******************** manage regions ********************* */
@@ -118,13 +123,17 @@ ARegion *image_has_buttons_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) return 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) return NULL;
+ if (ar == NULL) {
+ return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "buttons for image");
@@ -142,13 +151,17 @@ ARegion *image_has_tools_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
- if (ar) return ar;
+ 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;
+ if (ar == NULL) {
+ return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "scopes for image");
@@ -367,15 +380,17 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U
ED_area_tag_redraw(sa);
break;
case ND_MODE:
- if (wmn->subtype == NS_EDITMODE_MESH)
+ if (wmn->subtype == NS_EDITMODE_MESH) {
ED_area_tag_refresh(sa);
+ }
ED_area_tag_redraw(sa);
break;
case ND_RENDER_RESULT:
case ND_RENDER_OPTIONS:
case ND_COMPO_RESULT:
- if (ED_space_image_show_render(sima))
+ if (ED_space_image_show_render(sima)) {
image_scopes_tag_refresh(sa);
+ }
ED_area_tag_redraw(sa);
break;
}
@@ -528,8 +543,9 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar)
float w = width;
float h = height;
- if (ima)
+ if (ima) {
h *= ima->aspy / ima->aspx;
+ }
int winx = BLI_rcti_size_x(&ar->winrct) + 1;
int winy = BLI_rcti_size_y(&ar->winrct) + 1;
@@ -699,8 +715,9 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
ED_space_image_get_size(sima, &width, &height);
ED_space_image_get_aspect(sima, &aspx, &aspy);
- if (show_viewer)
+ if (show_viewer) {
BLI_thread_unlock(LOCK_DRAW_IMAGE);
+ }
ED_mask_draw_region(mask, ar,
sima->mask_info.draw_flag,
@@ -740,26 +757,31 @@ static void image_main_region_listener(
/* context changes */
switch (wmn->category) {
case NC_GEOM:
- if (ELEM(wmn->data, ND_DATA, ND_SELECT))
+ if (ELEM(wmn->data, ND_DATA, ND_SELECT)) {
WM_gizmomap_tag_refresh(ar->gizmo_map);
+ }
break;
case NC_GPENCIL:
- if (ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+ if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
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;
case NC_IMAGE:
- if (wmn->action == NA_PAINTING)
+ if (wmn->action == NA_PAINTING) {
ED_region_tag_redraw(ar);
+ }
WM_gizmomap_tag_refresh(ar->gizmo_map);
break;
case NC_MATERIAL:
if (wmn->data == ND_SHADING_LINKS) {
SpaceImage *sima = sa->spacedata.first;
- if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE))
+ if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE)) {
ED_region_tag_redraw(ar);
+ }
}
break;
case NC_SCREEN:
@@ -799,10 +821,12 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar)
if (!sima->scopes.ok) {
BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings);
}
- if (sima->image->flag & IMA_VIEW_AS_RENDER)
+ if (sima->image->flag & IMA_VIEW_AS_RENDER) {
ED_space_image_scopes_update(C, sima, ibuf, true);
- else
+ }
+ else {
ED_space_image_scopes_update(C, sima, ibuf, false);
+ }
}
}
ED_space_image_release_buffer(sima, ibuf, lock);
@@ -832,15 +856,17 @@ static void image_buttons_region_listener(
}
break;
case NC_IMAGE:
- if (wmn->action != NA_PAINTING)
+ if (wmn->action != NA_PAINTING) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_NODE:
ED_region_tag_redraw(ar);
break;
case NC_GPENCIL:
- if (ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+ if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -871,13 +897,15 @@ static void image_tools_region_listener(
/* context changes */
switch (wmn->category) {
case NC_GPENCIL:
- if (wmn->data == ND_DATA || ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+ if (wmn->data == ND_DATA || ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_BRUSH:
/* NA_SELECTED is used on brush changes */
- if (ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+ if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCENE:
switch (wmn->data) {
@@ -889,8 +917,9 @@ static void image_tools_region_listener(
}
break;
case NC_IMAGE:
- if (wmn->action != NA_PAINTING)
+ if (wmn->action != NA_PAINTING) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_NODE:
ED_region_tag_redraw(ar);
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 538c41f730a..0abad05cc76 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -219,7 +219,9 @@ static int unpack_all_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
int method = RNA_enum_get(op->ptr, "method");
- if (method != PF_KEEP) unpackAll(bmain, op->reports, method); /* XXX PF_ASK can't work here */
+ if (method != PF_KEEP) {
+ unpackAll(bmain, op->reports, method); /* XXX PF_ASK can't work here */
+ }
G.fileflags &= ~G_FILE_AUTOPACK;
return OPERATOR_FINISHED;
@@ -241,10 +243,12 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
return OPERATOR_CANCELLED;
}
- if (count == 1)
+ if (count == 1) {
BLI_strncpy(title, IFACE_("Unpack 1 File"), sizeof(title));
- else
+ }
+ else {
BLI_snprintf(title, sizeof(title), IFACE_("Unpack %d Files"), count);
+ }
pup = UI_popup_menu_begin(C, title, ICON_NONE);
layout = UI_popup_menu_layout(pup);
@@ -303,8 +307,9 @@ static int unpack_item_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (method != PF_KEEP)
+ if (method != PF_KEEP) {
BKE_unpack_id(bmain, id, op->reports, method); /* XXX PF_ASK can't work here */
+ }
G.fileflags &= ~G_FILE_AUTOPACK;
@@ -493,19 +498,19 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
*/
#define INFO_TIMEOUT 5.0f
-#define INFO_COLOR_TIMEOUT 3.0f
#define ERROR_TIMEOUT 10.0f
-#define ERROR_COLOR_TIMEOUT 6.0f
+#define FLASH_TIMEOUT 1.0f
#define COLLAPSE_TIMEOUT 0.25f
+#define BRIGHTEN_AMOUNT 0.1f
static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
wmWindowManager *wm = CTX_wm_manager(C);
ReportList *reports = CTX_wm_reports(C);
Report *report;
ReportTimerInfo *rti;
- float progress = 0.0, color_progress = 0.0;
- float neutral_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- float timeout = 0.0, color_timeout = 0.0;
+ float target_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ float progress = 0.0, flash_progress = 0.0;
+ float timeout = 0.0, flash_timeout = FLASH_TIMEOUT;
int send_note = 0;
/* escape if not our timer */
@@ -520,7 +525,6 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
rti = (ReportTimerInfo *)reports->reporttimer->customdata;
timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT;
- color_timeout = (report->type & RPT_ERROR_ALL) ? ERROR_COLOR_TIMEOUT : INFO_COLOR_TIMEOUT;
/* clear the report display after timeout */
if ((float)reports->reporttimer->duration > timeout) {
@@ -532,36 +536,39 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
}
+ /* set target color based on report type */
+ if (report->type & RPT_ERROR_ALL) {
+ UI_GetThemeColorType3fv(TH_INFO_ERROR, SPACE_INFO, target_col);
+ }
+ else if (report->type & RPT_WARNING_ALL) {
+ UI_GetThemeColorType3fv(TH_INFO_WARNING, SPACE_INFO, target_col);
+ }
+ else if (report->type & RPT_INFO_ALL) {
+ UI_GetThemeColorType3fv(TH_INFO_INFO, SPACE_INFO, target_col);
+ }
+ target_col[3] = 0.65f;
+
if (rti->widthfac == 0.0f) {
- /* initialize colors based on report type */
- if (report->type & RPT_ERROR_ALL) {
- rti->col[0] = 1.0f;
- rti->col[1] = 0.2f;
- rti->col[2] = 0.0f;
- }
- else if (report->type & RPT_WARNING_ALL) {
- rti->col[0] = 1.0f;
- rti->col[1] = 1.0f;
- rti->col[2] = 0.0f;
- }
- else if (report->type & RPT_INFO_ALL) {
- rti->col[0] = 0.3f;
- rti->col[1] = 0.45f;
- rti->col[2] = 0.7f;
- }
- rti->col[3] = 0.65f;
+ /* initialize color to a brighter shade of the target color */
+ rti->col[0] = target_col[0] + BRIGHTEN_AMOUNT;
+ rti->col[1] = target_col[1] + BRIGHTEN_AMOUNT;
+ rti->col[2] = target_col[2] + BRIGHTEN_AMOUNT;
+ rti->col[3] = 1.0f;
+
+ CLAMP3(rti->col, 0.0, 1.0);
+
rti->widthfac = 1.0f;
}
progress = powf((float)reports->reporttimer->duration / timeout, 2.0f);
- color_progress = powf((float)reports->reporttimer->duration / color_timeout, 2.0);
+ flash_progress = powf((float)reports->reporttimer->duration / flash_timeout, 2.0);
/* save us from too many draws */
- if (color_progress <= 1.0f) {
+ if (flash_progress <= 1.0f) {
send_note = 1;
- /* fade colors out sharply according to progress through fade-out duration */
- interp_v4_v4v4(rti->col, rti->col, neutral_col, color_progress);
+ /* flash report briefly according to progress through fade-out duration */
+ interp_v4_v4v4(rti->col, rti->col, target_col, flash_progress);
}
/* collapse report at end of timeout */
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index 73c36f64cb5..a8f5d9b9b76 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -111,8 +111,9 @@ static int select_report_pick_exec(bContext *C, wmOperator *op)
int report_index = RNA_int_get(op->ptr, "report_index");
Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index);
- if (!report)
+ if (!report) {
return OPERATOR_CANCELLED;
+ }
report->flag ^= SELECT; /* toggle */
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index e788af1507e..054e9cd0026 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -128,7 +128,9 @@ static void stats_object(Object *ob, SceneStats *stats)
const bool is_selected = (ob->base_flag & BASE_SELECTED) != 0;
stats->totobj++;
- if (is_selected) stats->totobjsel++;
+ if (is_selected) {
+ stats->totobjsel++;
+ }
switch (ob->type) {
case OB_MESH:
@@ -158,8 +160,9 @@ static void stats_object(Object *ob, SceneStats *stats)
{
int totv = 0, totf = 0, tottri = 0;
- if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first)
+ if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first) {
BKE_displist_count(&ob->runtime.curve_cache->disp, &totv, &totf, &tottri);
+ }
stats->totvert += totv;
stats->totface += totf;
@@ -214,15 +217,20 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
stats->totbone++;
- if ((ebo->flag & BONE_CONNECTED) && ebo->parent)
+ if ((ebo->flag & BONE_CONNECTED) && ebo->parent) {
stats->totvert--;
+ }
- if (ebo->flag & BONE_TIPSEL)
+ if (ebo->flag & BONE_TIPSEL) {
stats->totvertsel++;
- if (ebo->flag & BONE_ROOTSEL)
+ }
+ if (ebo->flag & BONE_ROOTSEL) {
stats->totvertsel++;
+ }
- if (ebo->flag & BONE_SELECTED) stats->totbonesel++;
+ if (ebo->flag & BONE_SELECTED) {
+ stats->totbonesel++;
+ }
/* if this is a connected child and it's parent is being moved, remove our root */
if ((ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL) &&
@@ -249,9 +257,15 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
a = nu->pntsu;
while (a--) {
stats->totvert += 3;
- if (bezt->f1 & SELECT) stats->totvertsel++;
- if (bezt->f2 & SELECT) stats->totvertsel++;
- if (bezt->f3 & SELECT) stats->totvertsel++;
+ if (bezt->f1 & SELECT) {
+ stats->totvertsel++;
+ }
+ if (bezt->f2 & SELECT) {
+ stats->totvertsel++;
+ }
+ if (bezt->f3 & SELECT) {
+ stats->totvertsel++;
+ }
bezt++;
}
}
@@ -260,7 +274,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
a = nu->pntsu * nu->pntsv;
while (a--) {
stats->totvert++;
- if (bp->f1 & SELECT) stats->totvertsel++;
+ if (bp->f1 & SELECT) {
+ stats->totvertsel++;
+ }
bp++;
}
}
@@ -273,7 +289,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
for (ml = mball->editelems->first; ml; ml = ml->next) {
stats->totvert++;
- if (ml->flag & SELECT) stats->totvertsel++;
+ if (ml->flag & SELECT) {
+ stats->totvertsel++;
+ }
}
}
else if (obedit->type == OB_LATTICE) {
@@ -288,7 +306,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw;
while (a--) {
stats->totvert++;
- if (bp->f1 & SELECT) stats->totvertsel++;
+ if (bp->f1 & SELECT) {
+ stats->totvertsel++;
+ }
bp++;
}
}
@@ -302,9 +322,11 @@ static void stats_object_pose(Object *ob, SceneStats *stats)
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
stats->totbone++;
- if (pchan->bone && (pchan->bone->flag & BONE_SELECTED))
- if (pchan->bone->layer & arm->layer)
+ if (pchan->bone && (pchan->bone->flag & BONE_SELECTED)) {
+ if (pchan->bone->layer & arm->layer) {
stats->totbonesel++;
+ }
+ }
}
}
}
@@ -448,8 +470,9 @@ static void stats_string(ViewLayer *view_layer)
}
if (obedit) {
- if (BKE_keyblock_from_object(obedit))
+ if (BKE_keyblock_from_object(obedit)) {
ofs += BLI_strncpy_rlen(s + ofs, IFACE_("(Key) "), MAX_INFO_LEN - ofs);
+ }
if (obedit->type == OB_MESH) {
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs,
@@ -475,9 +498,9 @@ static void stats_string(ViewLayer *view_layer)
}
else if ((ob) && (ob->type == OB_GPENCIL)) {
ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs,
- IFACE_("Layers:%s | Frames:%s | Strokes:%s | Points:%s | Objects:%s/%s"),
- stats_fmt.totgplayer, stats_fmt.totgpframe, stats_fmt.totgpstroke,
- stats_fmt.totgppoint, stats_fmt.totobjsel, stats_fmt.totobj);
+ IFACE_("Layers:%s | Frames:%s | Strokes:%s | Points:%s | Objects:%s/%s"),
+ stats_fmt.totgplayer, stats_fmt.totgpframe, stats_fmt.totgpstroke,
+ stats_fmt.totgppoint, stats_fmt.totobjsel, stats_fmt.totobj);
ofs += BLI_strncpy_rlen(s + ofs, memstr, MAX_INFO_LEN - ofs);
ofs += BLI_strncpy_rlen(s + ofs, gpumemstr, MAX_INFO_LEN - ofs);
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 754941a12c0..997a40839ac 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -151,8 +151,9 @@ static void info_main_region_draw(const bContext *C, ARegion *ar)
GPU_clear(GPU_COLOR_BIT);
/* quick way to avoid drawing if not bug enough */
- if (ar->winy < 16)
+ if (ar->winy < 16) {
return;
+ }
info_textview_update_rect(C, ar);
@@ -241,20 +242,24 @@ static void info_header_listener(
}
break;
case NC_WM:
- if (wmn->data == ND_JOB)
+ if (wmn->data == ND_JOB) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCENE:
- if (wmn->data == ND_RENDER_RESULT)
+ if (wmn->data == ND_RENDER_RESULT) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_INFO)
+ if (wmn->data == ND_SPACE_INFO) {
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;
}
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index a335d6d0bfb..7585cda5e19 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -291,11 +291,13 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous
xy[0] = x_orig; xy[1] = y_orig;
- if (mval[1] != INT_MAX)
+ if (mval[1] != INT_MAX) {
mval[1] += (tvc->ymin + CONSOLE_DRAW_MARGIN);
+ }
- if (pos_pick)
+ if (pos_pick) {
*pos_pick = 0;
+ }
/* constants for the sequencer context */
cdc.font_id = font_id;
@@ -306,8 +308,9 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous
/* note, scroll bar must be already subtracted () */
cdc.console_width = (tvc->winx - (CONSOLE_DRAW_MARGIN * 2)) / cdc.cwidth;
/* avoid divide by zero on small windows */
- if (cdc.console_width < 1)
+ if (cdc.console_width < 1) {
cdc.console_width = 1;
+ }
cdc.winx = tvc->winx - CONSOLE_DRAW_MARGIN;
cdc.ymin = tvc->ymin;
cdc.ymax = tvc->ymax;
@@ -341,8 +344,9 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous
y_prev = xy[1];
- if (draw)
+ if (draw) {
color_flag = tvc->line_color(tvc, fg, bg);
+ }
tvc->line_get(tvc, &ext_line, &ext_len);
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index c73fd768075..48eb2bdb82b 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -843,7 +843,9 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
{
/* draw all channels using standard channel-drawing API */
- ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index);
+ rctf channel_rect;
+ BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, yminc, ymaxc);
+ ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index);
}
/* adjust y-position for next one */
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 60dcdaebb08..be26f67b936 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -115,8 +115,9 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA
col = uiLayoutColumn(layout, false);
row = uiLayoutRow(col, true);
uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE);
- if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE))
+ if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE)) {
uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA);
+ }
uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
}
@@ -257,20 +258,24 @@ static int node_resize_area_default(bNode *node, int x, int y)
rctf totr = node->totr;
/* right part of node */
totr.xmin = node->totr.xmax - 20.0f;
- if (BLI_rctf_isect_pt(&totr, x, y))
+ if (BLI_rctf_isect_pt(&totr, x, y)) {
return NODE_RESIZE_RIGHT;
- else
+ }
+ else {
return 0;
+ }
}
else {
const float size = NODE_RESIZE_MARGIN;
rctf totr = node->totr;
int dir = 0;
- if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
+ if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_RIGHT;
- if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
+ }
+ if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_LEFT;
+ }
return dir;
}
}
@@ -306,8 +311,9 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
bbinit = (data->flag & NODE_FRAME_SHRINK);
/* fit bounding box to all children */
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
- if (tnode->parent != node)
+ if (tnode->parent != node) {
continue;
+ }
/* add margin to node rect */
noderect = tnode->totr;
@@ -322,8 +328,9 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
rect = noderect;
data->flag &= ~NODE_FRAME_RESIZEABLE;
}
- else
+ else {
BLI_rctf_union(&rect, &noderect);
+ }
}
/* now adjust the frame size from view-space bounding box */
@@ -445,18 +452,21 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
if (node->flag & NODE_CUSTOM_COLOR) {
rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], alpha);
}
- else
+ else {
UI_GetThemeColor4fv(TH_NODE_FRAME, color);
+ }
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
/* outline active and selected emphasis */
if (node->flag & SELECT) {
- if (node->flag & NODE_ACTIVE)
+ if (node->flag & NODE_ACTIVE) {
UI_GetThemeColorShadeAlpha4fv(TH_ACTIVE, 0, -40, color);
- else
+ }
+ else {
UI_GetThemeColorShadeAlpha4fv(TH_SELECT, 0, -40, color);
+ }
UI_draw_roundbox_aa(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
}
@@ -479,17 +489,22 @@ static int node_resize_area_frame(bNode *node, int x, int y)
int dir = 0;
/* shrinking frame size is determined by child nodes */
- if (!(data->flag & NODE_FRAME_RESIZEABLE))
+ if (!(data->flag & NODE_FRAME_RESIZEABLE)) {
return 0;
+ }
- if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
+ if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_RIGHT;
- if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
+ }
+ if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_LEFT;
- if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax)
+ }
+ if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax) {
dir |= NODE_RESIZE_TOP;
- if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size)
+ }
+ if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size) {
dir |= NODE_RESIZE_BOTTOM;
+ }
return dir;
}
@@ -636,8 +651,9 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
uiLayout *col;
int source;
- if (!imaptr->data)
+ if (!imaptr->data) {
return;
+ }
col = uiLayoutColumn(layout, false);
@@ -790,8 +806,9 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P
layout, C, ptr, "image",
"IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
- if (!ima)
+ if (!ima) {
return;
+ }
uiItemR(layout, &imaptr, "source", 0, IFACE_("Source"), ICON_NONE);
@@ -799,10 +816,12 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P
uiLayout *row = uiLayoutRow(layout, true);
const bool is_packed = BKE_image_has_packedfile(ima);
- if (is_packed)
+ if (is_packed) {
uiItemO(row, "", ICON_PACKAGE, "image.unpack");
- else
+ }
+ else {
uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
+ }
row = uiLayoutRow(row, true);
uiLayoutSetEnabled(row, !is_packed);
@@ -829,8 +848,9 @@ static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), Poin
uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NEW)
+ if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NEW) {
uiItemR(layout, ptr, "ground_albedo", 0, NULL, ICON_NONE);
+ }
}
static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -903,12 +923,14 @@ static void node_shader_buts_tex_pointdensity(uiLayout *layout, bContext *UNUSED
else {
uiItemR(layout, ptr, "vertex_color_source", 0, NULL, ICON_NONE);
if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTWEIGHT) {
- if (ob_ptr.data)
+ if (ob_ptr.data) {
uiItemPointerR(layout, ptr, "vertex_attribute_name", &ob_ptr, "vertex_groups", "", ICON_NONE);
+ }
}
if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTCOL) {
- if (obdata_ptr.data)
+ if (obdata_ptr.data) {
uiItemPointerR(layout, ptr, "vertex_attribute_name", &obdata_ptr, "vertex_colors", "", ICON_NONE);
+ }
}
}
}
@@ -954,8 +976,9 @@ static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRN
PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE);
}
- else
+ else {
uiItemR(layout, ptr, "uv_map", 0, "", 0);
+ }
}
}
@@ -981,11 +1004,13 @@ static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *
PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE);
}
- else
+ else {
uiItemR(row, ptr, "uv_map", 0, "", 0);
+ }
}
- else
+ else {
uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, 0);
+ }
}
static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -1034,10 +1059,12 @@ static void node_shader_buts_ies(uiLayout *layout, bContext *UNUSED(C), PointerR
row = uiLayoutRow(layout, true);
- if (RNA_enum_get(ptr, "mode") == NODE_IES_INTERNAL)
+ if (RNA_enum_get(ptr, "mode") == NODE_IES_INTERNAL) {
uiItemR(row, ptr, "ies", 0, "", ICON_NONE);
- else
+ }
+ else {
uiItemR(row, ptr, "filepath", 0, "", ICON_NONE);
+ }
}
static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -1049,10 +1076,12 @@ static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), Point
row = uiLayoutRow(layout, true);
- if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL)
+ if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL) {
uiItemR(row, ptr, "script", 0, "", ICON_NONE);
- else
+ }
+ else {
uiItemR(row, ptr, "filepath", 0, "", ICON_NONE);
+ }
uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update");
}
@@ -1247,16 +1276,19 @@ static void node_buts_image_views(uiLayout *layout, bContext *UNUSED(C), Pointer
{
uiLayout *col;
- if (!imaptr->data)
+ if (!imaptr->data) {
return;
+ }
col = uiLayoutColumn(layout, false);
if (RNA_boolean_get(ptr, "has_views")) {
- if (RNA_enum_get(ptr, "view") == 0)
+ if (RNA_enum_get(ptr, "view") == 0) {
uiItemR(col, ptr, "view", 0, NULL, ICON_CAMERA_STEREO);
- else
+ }
+ else {
uiItemR(col, ptr, "view", 0, NULL, ICON_SCENE);
+ }
}
}
@@ -1270,7 +1302,9 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *
uiTemplateID(
layout, C, ptr, "image",
"IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
- if (!node->id) return;
+ if (!node->id) {
+ return;
+ }
imaptr = RNA_pointer_get(ptr, "image");
@@ -1301,15 +1335,18 @@ static void node_composit_buts_viewlayers(uiLayout *layout, bContext *C, Pointer
uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
- if (!node->id) return;
+ if (!node->id) {
+ return;
+ }
col = uiLayoutColumn(layout, false);
row = uiLayoutRow(col, true);
uiItemR(row, ptr, "layer", 0, "", ICON_NONE);
prop = RNA_struct_find_property(ptr, "layer");
- if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name)))
+ if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name))) {
return;
+ }
scn_ptr = RNA_pointer_get(ptr, "scene");
RNA_string_get(&scn_ptr, "name", scene_name);
@@ -1431,8 +1468,9 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin
if (RNA_enum_get(ptr, "glare_type") != 1) {
uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "glare_type") != 0)
+ if (RNA_enum_get(ptr, "glare_type") != 0) {
uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ }
}
uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE);
@@ -1445,8 +1483,9 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin
if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) {
uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- if (RNA_enum_get(ptr, "glare_type") == 0)
+ if (RNA_enum_get(ptr, "glare_type") == 0) {
uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE);
+ }
}
if (RNA_enum_get(ptr, "glare_type") == 1) {
uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
@@ -1754,10 +1793,12 @@ static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C)
PointerRNA imfptr = RNA_pointer_get(ptr, "format");
const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER;
- if (multilayer)
+ if (multilayer) {
uiItemL(layout, IFACE_("Path:"), ICON_NONE);
- else
+ }
+ else {
uiItemL(layout, IFACE_("Base Path:"), ICON_NONE);
+ }
uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
}
static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
@@ -1776,8 +1817,9 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
/* disable stereo output for multilayer, too much work for something that no one will use */
/* if someone asks for that we can implement it */
- if (is_multiview)
+ if (is_multiview) {
uiTemplateImageFormatViews(layout, &imfptr, NULL);
+ }
uiItemS(layout);
@@ -1841,8 +1883,9 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == false);
uiTemplateImageSettings(col, &imfptr, false);
- if (is_multiview)
+ if (is_multiview) {
uiTemplateImageFormatViews(layout, &imfptr, NULL);
+ }
}
}
}
@@ -1991,8 +2034,9 @@ static void node_composit_buts_movieclip_ex(uiLayout *layout, bContext *C, Point
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
- if (!node->id)
+ if (!node->id) {
return;
+ }
clipptr = RNA_pointer_get(ptr, "clip");
@@ -2005,8 +2049,9 @@ static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, Pointe
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
- if (!node->id)
+ if (!node->id) {
return;
+ }
uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "invert", 0, NULL, ICON_NONE);
@@ -2029,8 +2074,9 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
- if (!node->id)
+ if (!node->id) {
return;
+ }
uiItemR(layout, ptr, "distortion_type", 0, "", ICON_NONE);
}
@@ -2913,8 +2959,9 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket
StructRNA *srna = ntype->ext.srna;
PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier);
- if (prop)
+ if (prop) {
RNA_def_property_update_runtime(prop, node_property_update_default);
+ }
}
static void node_template_properties_update(bNodeType *ntype)
@@ -2922,12 +2969,14 @@ static void node_template_properties_update(bNodeType *ntype)
bNodeSocketTemplate *stemp;
if (ntype->inputs) {
- for (stemp = ntype->inputs; stemp->type >= 0; ++stemp)
+ for (stemp = ntype->inputs; stemp->type >= 0; ++stemp) {
node_socket_template_properties_update(ntype, stemp);
+ }
}
if (ntype->outputs) {
- for (stemp = ntype->outputs; stemp->type >= 0; ++stemp)
+ for (stemp = ntype->outputs; stemp->type >= 0; ++stemp) {
node_socket_template_properties_update(ntype, stemp);
+ }
}
}
@@ -3077,8 +3126,9 @@ static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerR
uiItemL(row, input->path, ICON_NONE);
- if (!RNA_boolean_get(&inputptr, "use_node_format"))
+ if (!RNA_boolean_get(&inputptr, "use_node_format")) {
imfptr = RNA_pointer_get(&inputptr, "format");
+ }
imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop,
@@ -3206,11 +3256,13 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
void *lock;
ImBuf *ibuf;
- if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode))
+ if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode)) {
return;
+ }
- if (parent_key.value != active_viewer_key.value)
+ if (parent_key.value != active_viewer_key.value) {
return;
+ }
ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
@@ -3234,14 +3286,18 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
- if (snode->flag & SNODE_SHOW_R)
+ if (snode->flag & SNODE_SHOW_R) {
shuffle[0] = 1.0f;
- else if (snode->flag & SNODE_SHOW_G)
+ }
+ else if (snode->flag & SNODE_SHOW_G) {
shuffle[1] = 1.0f;
- else if (snode->flag & SNODE_SHOW_B)
+ }
+ else if (snode->flag & SNODE_SHOW_B) {
shuffle[2] = 1.0f;
- else
+ }
+ else {
shuffle[3] = 1.0f;
+ }
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, shuffle);
@@ -3263,8 +3319,9 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
}
- if (cache_handle)
+ if (cache_handle) {
IMB_display_buffer_release(cache_handle);
+ }
}
/** \note draw selected info on backdrop */
@@ -3330,7 +3387,9 @@ static bool node_link_bezier_handles(View2D *v2d, SpaceNode *snode, bNodeLink *l
fromreroute = (link->fromnode && link->fromnode->type == NODE_REROUTE);
}
else {
- if (snode == NULL) return 0;
+ if (snode == NULL) {
+ return 0;
+ }
copy_v2_v2(vec[0], cursor);
fromreroute = 0;
}
@@ -3340,7 +3399,9 @@ static bool node_link_bezier_handles(View2D *v2d, SpaceNode *snode, bNodeLink *l
toreroute = (link->tonode && link->tonode->type == NODE_REROUTE);
}
else {
- if (snode == NULL) return 0;
+ if (snode == NULL) {
+ return 0;
+ }
copy_v2_v2(vec[3], cursor);
toreroute = 0;
}
@@ -3477,8 +3538,9 @@ static void nodelink_batch_init(void)
float exp[2] = {0.0f, 1.0f};
/* restart */
- if (k == 1)
+ if (k == 1) {
set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
+ }
/* curve strip */
for (int i = 0; i < LINK_RESOL; ++i) {
@@ -3508,8 +3570,9 @@ static void nodelink_batch_init(void)
}
/* restart */
- if (k == 0)
+ if (k == 0) {
set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
+ }
}
g_batch_link.batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
@@ -3548,8 +3611,9 @@ static char nodelink_get_color_id(int th_col)
static void nodelink_batch_draw(SpaceNode *snode)
{
- if (g_batch_link.count == 0)
+ if (g_batch_link.count == 0) {
return;
+ }
GPU_blend(true);
@@ -3655,8 +3719,9 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
{
int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE;
- if (link->fromsock == NULL && link->tosock == NULL)
+ if (link->fromsock == NULL && link->tosock == NULL) {
return;
+ }
/* new connection */
if (!link->fromsock || !link->tosock) {
@@ -3664,10 +3729,12 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
}
else {
/* going to give issues once... */
- if (link->tosock->flag & SOCK_UNAVAIL)
+ if (link->tosock->flag & SOCK_UNAVAIL) {
return;
- if (link->fromsock->flag & SOCK_UNAVAIL)
+ }
+ if (link->fromsock->flag & SOCK_UNAVAIL) {
return;
+ }
if (link->flag & NODE_LINK_VALID) {
/* special indicated link, on drop-node */
@@ -3676,10 +3743,12 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
}
else {
/* regular link */
- if (link->fromnode && link->fromnode->flag & SELECT)
+ if (link->fromnode && link->fromnode->flag & SELECT) {
th_col1 = TH_EDGE_SELECT;
- if (link->tonode && link->tonode->flag & SELECT)
+ }
+ if (link->tonode && link->tonode->flag & SELECT) {
th_col2 = TH_EDGE_SELECT;
+ }
}
}
else {
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index fd433b48a66..814496cf59e 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -65,19 +65,19 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx
node_deselect_all(snode);
- if (idname)
+ if (idname) {
node = nodeAddNode(C, snode->edittree, idname);
- else
+ }
+ else {
node = nodeAddStaticNode(C, snode->edittree, type);
+ }
BLI_assert(node && node->typeinfo);
- /* generics */
- node->locx = locx;
- node->locy = locy + 60.0f; /* arbitrary... so its visible, (0,0) is top of node */
- nodeSetSelected(node, true);
+ /* Position mouse in node header. */
+ node->locx = locx - NODE_DY * 1.5f / UI_DPI_FAC;
+ node->locy = locy + NODE_DY * 0.5f / UI_DPI_FAC;
- node->locx = locx;
- node->locy = locy + 60.0f;
+ nodeSetSelected(node, true);
ntreeUpdateTree(bmain, snode->edittree);
ED_node_set_active(bmain, snode->edittree, node);
@@ -130,8 +130,9 @@ static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb, bNodeSocket
copy_v2_v2(socklink->point, point);
for (prev = lb->last; prev; prev = prev->prev) {
- if (prev->sock == sock)
+ if (prev->sock == sock) {
break;
+ }
}
BLI_insertlinkafter(lb, prev, socklink);
return socklink;
@@ -210,7 +211,9 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view(&ar->v2d, (short)loc[0], (short)loc[1],
&mcoords[i][0], &mcoords[i][1]);
i++;
- if (i >= 256) break;
+ if (i >= 256) {
+ break;
+ }
}
RNA_END;
@@ -230,8 +233,9 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
BLI_listbase_clear(&input_links);
for (link = ntree->links.first; link; link = link->next) {
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
if (add_reroute_intersect_check(link, mcoords, i, insert_point)) {
add_reroute_insert_socket_link(&output_links, link->fromsock, link, insert_point);
add_reroute_insert_socket_link(&input_links, link->tosock, link, insert_point);
@@ -355,10 +359,15 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&snode->cursor[0], &snode->cursor[1]);
- if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name"))
+ snode->cursor[0] /= UI_DPI_FAC;
+ snode->cursor[1] /= UI_DPI_FAC;
+
+ if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name")) {
return node_add_file_exec(C, op);
- else
+ }
+ else {
return WM_operator_filesel(C, op, event);
+ }
}
void NODE_OT_add_file(wmOperatorType *ot)
@@ -459,10 +468,12 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
prop = RNA_struct_find_property(op->ptr, "type");
RNA_property_enum_identifier(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &idname);
}
- else if (snode)
+ else if (snode) {
idname = snode->tree_idname;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
if (RNA_struct_property_is_set(op->ptr, "name")) {
RNA_string_get(op->ptr, "name", treename_buf);
diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
index da0be280f2c..13f8eb0729e 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -76,8 +76,9 @@ static void node_sockets_panel(const bContext *C, Panel *pa)
uiLayout *layout = pa->layout, *split;
char name[UI_MAX_NAME_STR];
- if (ELEM(NULL, ntree, node))
+ if (ELEM(NULL, ntree, node)) {
return;
+ }
for (sock = node->inputs.first; sock; sock = sock->next) {
BLI_snprintf(name, sizeof(name), "%s:", sock->name);
@@ -128,8 +129,9 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa)
PointerRNA ptr, sockptr, opptr;
wmOperatorType *ot;
- if (!ntree)
+ if (!ntree) {
return;
+ }
RNA_id_pointer_create((ID *)ntree, &ptr);
@@ -204,8 +206,9 @@ 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)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 0a33e5ebf12..6f7ebd36c09 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -120,8 +120,9 @@ static bNodeTree *node_tree_from_ID(ID *id)
void ED_node_tag_update_id(ID *id)
{
bNodeTree *ntree = node_tree_from_ID(id);
- if (id == NULL || ntree == NULL)
+ if (id == NULL || ntree == NULL) {
return;
+ }
/* TODO(sergey): With the new dependency graph it
* should be just enough to only tag ntree itself,
@@ -133,12 +134,15 @@ void ED_node_tag_update_id(ID *id)
if (ntree->type == NTREE_SHADER) {
DEG_id_tag_update(id, 0);
- if (GS(id->name) == ID_MA)
+ if (GS(id->name) == ID_MA) {
WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id);
- else if (GS(id->name) == ID_LA)
+ }
+ else if (GS(id->name) == ID_LA) {
WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id);
- else if (GS(id->name) == ID_WO)
+ }
+ else if (GS(id->name) == ID_WO) {
WM_main_add_notifier(NC_WORLD | ND_WORLD, id);
+ }
}
else if (ntree->type == NTREE_COMPOSIT) {
WM_main_add_notifier(NC_SCENE | ND_NODES, id);
@@ -155,8 +159,9 @@ void ED_node_tag_update_id(ID *id)
void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
{
- if (!ntree)
+ if (!ntree) {
return;
+ }
bool do_tag_update = true;
if (node != NULL) {
@@ -169,13 +174,15 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
if (do_tag_update) {
FOREACH_NODETREE_BEGIN(bmain, tntree, id) {
/* check if nodetree uses the group */
- if (ntreeHasTree(tntree, ntree))
+ if (ntreeHasTree(tntree, ntree)) {
ED_node_tag_update_id(id);
+ }
} FOREACH_NODETREE_END;
}
- if (ntree->type == NTREE_TEXTURE)
+ if (ntree->type == NTREE_TEXTURE) {
ntreeTexCheckCyclics(ntree);
+ }
}
static bool compare_nodes(const bNode *a, const bNode *b)
@@ -192,36 +199,46 @@ static bool compare_nodes(const bNode *a, const bNode *b)
* this is O(n^2) worst case */
for (parent = a->parent; parent; parent = parent->parent) {
/* if b is an ancestor, it is always behind a */
- if (parent == b)
+ if (parent == b) {
return 1;
+ }
/* any selected ancestor moves the node forward */
- if (parent->flag & NODE_ACTIVE)
+ if (parent->flag & NODE_ACTIVE) {
a_active = 1;
- if (parent->flag & NODE_SELECT)
+ }
+ if (parent->flag & NODE_SELECT) {
a_select = 1;
+ }
}
for (parent = b->parent; parent; parent = parent->parent) {
/* if a is an ancestor, it is always behind b */
- if (parent == a)
+ if (parent == a) {
return 0;
+ }
/* any selected ancestor moves the node forward */
- if (parent->flag & NODE_ACTIVE)
+ if (parent->flag & NODE_ACTIVE) {
b_active = 1;
- if (parent->flag & NODE_SELECT)
+ }
+ if (parent->flag & NODE_SELECT) {
b_select = 1;
+ }
}
/* if one of the nodes is in the background and the other not */
- if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND))
+ if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND)) {
return 0;
- else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND))
+ }
+ else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) {
return 1;
+ }
/* if one has a higher selection state (active > selected > nothing) */
- if (!b_active && a_active)
+ if (!b_active && a_active) {
return 1;
- else if (!b_select && (a_active || a_select))
+ }
+ else if (!b_select && (a_active || a_select)) {
return 1;
+ }
return 0;
}
@@ -246,8 +263,9 @@ void ED_node_sort(bNodeTree *ntree)
first_b = first_b->next;
}
/* all batches merged? */
- if (first_b == NULL)
+ if (first_b == NULL) {
break;
+ }
/* merge batches */
node_a = first_a;
@@ -271,8 +289,9 @@ void ED_node_sort(bNodeTree *ntree)
first_b = node_b;
for (; b < k; ++b) {
/* all nodes sorted? */
- if (first_b == NULL)
+ if (first_b == NULL) {
break;
+ }
first_b = first_b->next;
}
first_a = first_b;
@@ -287,8 +306,9 @@ static void do_node_internal_buttons(bContext *C, void *UNUSED(node_v), int even
{
if (event == B_NODE_EXEC) {
SpaceNode *snode = CTX_wm_space_node(C);
- if (snode && snode->id)
+ if (snode && snode->id) {
ED_node_tag_update_id(snode->id);
+ }
}
}
@@ -351,21 +371,28 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
dy -= NODE_DY;
/* little bit space in top */
- if (node->outputs.first)
+ if (node->outputs.first) {
dy -= NODE_DYS / 2;
+ }
/* output sockets */
bool add_output_space = false;
for (nsock = node->outputs.first; nsock; nsock = nsock->next) {
- if (nodeSocketIsHidden(nsock))
+ if (nodeSocketIsHidden(nsock)) {
continue;
+ }
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr);
layout = UI_block_layout(
node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get());
+
+ if (node->flag & NODE_MUTED) {
+ uiLayoutSetActive(layout, false);
+ }
+
/* context pointers for current node and socket */
uiLayoutSetContextPointer(layout, "node", &nodeptr);
uiLayoutSetContextPointer(layout, "socket", &sockptr);
@@ -387,8 +414,9 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
nsock->locy = 0.5f * (dy + buty);
dy = buty;
- if (nsock->next)
+ if (nsock->next) {
dy -= NODE_SOCKDY;
+ }
add_output_space = true;
}
@@ -404,14 +432,16 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
if (node->flag & NODE_PREVIEW) {
float aspect = 1.0f;
- if (node->preview_xsize && node->preview_ysize)
+ if (node->preview_xsize && node->preview_ysize) {
aspect = (float)node->preview_ysize / (float)node->preview_xsize;
+ }
dy -= NODE_DYS / 2;
node->prvr.ymax = dy;
- if (aspect <= 1.0f)
+ if (aspect <= 1.0f) {
node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY);
+ }
else {
/* width correction of image */
/* XXX huh? (ton) */
@@ -426,8 +456,12 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
dy = node->prvr.ymin - NODE_DYS / 2;
/* make sure that maximums are bigger or equal to minimums */
- if (node->prvr.xmax < node->prvr.xmin) SWAP(float, node->prvr.xmax, node->prvr.xmin);
- if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin);
+ if (node->prvr.xmax < node->prvr.xmin) {
+ SWAP(float, node->prvr.xmax, node->prvr.xmin);
+ }
+ if (node->prvr.ymax < node->prvr.ymin) {
+ SWAP(float, node->prvr.ymax, node->prvr.ymin);
+ }
}
/* buttons rect? */
@@ -444,6 +478,11 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
layout = UI_block_layout(
node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
locx + NODE_DYS, dy, node->butr.xmax, 0, 0, UI_style_get());
+
+ if (node->flag & NODE_MUTED) {
+ uiLayoutSetActive(layout, false);
+ }
+
uiLayoutSetContextPointer(layout, "node", &nodeptr);
node->typeinfo->draw_buttons(layout, (bContext *)C, &nodeptr);
@@ -456,14 +495,20 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
/* input sockets */
for (nsock = node->inputs.first; nsock; nsock = nsock->next) {
- if (nodeSocketIsHidden(nsock))
+ if (nodeSocketIsHidden(nsock)) {
continue;
+ }
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr);
layout = UI_block_layout(
node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get());
+
+ if (node->flag & NODE_MUTED) {
+ uiLayoutSetActive(layout, false);
+ }
+
/* context pointers for current node and socket */
uiLayoutSetContextPointer(layout, "node", &nodeptr);
uiLayoutSetContextPointer(layout, "socket", &sockptr);
@@ -483,13 +528,15 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
nsock->locy = 0.5f * (dy + buty);
dy = buty;
- if (nsock->next)
+ if (nsock->next) {
dy -= NODE_SOCKDY;
+ }
}
/* little bit space in end */
- if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0)
+ if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) {
dy -= NODE_DYS / 2;
+ }
node->totr.xmin = locx;
node->totr.xmax = locx + NODE_WIDTH(node);
@@ -519,12 +566,16 @@ static void node_update_hidden(bNode *node)
node_to_view(node, 0.0f, 0.0f, &locx, &locy);
/* calculate minimal radius */
- for (nsock = node->inputs.first; nsock; nsock = nsock->next)
- if (!nodeSocketIsHidden(nsock))
+ for (nsock = node->inputs.first; nsock; nsock = nsock->next) {
+ if (!nodeSocketIsHidden(nsock)) {
totin++;
- for (nsock = node->outputs.first; nsock; nsock = nsock->next)
- if (!nodeSocketIsHidden(nsock))
+ }
+ }
+ for (nsock = node->outputs.first; nsock; nsock = nsock->next) {
+ if (!nodeSocketIsHidden(nsock)) {
totout++;
+ }
+ }
tot = MAX2(totin, totout);
if (tot > 4) {
@@ -532,7 +583,7 @@ static void node_update_hidden(bNode *node)
}
node->totr.xmin = locx;
- node->totr.xmax = locx + 3 * hiddenrad + node->miniwidth;
+ node->totr.xmax = locx + max_ff(NODE_WIDTH(node), 2 * hiddenrad);
node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY);
node->totr.ymin = node->totr.ymax - 2 * hiddenrad;
@@ -571,10 +622,12 @@ static void node_update_hidden(bNode *node)
void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node)
{
- if (node->flag & NODE_HIDDEN)
+ if (node->flag & NODE_HIDDEN) {
node_update_hidden(node);
- else
+ }
+ else {
node_update_basis(C, ntree, node);
+ }
}
int node_select_area_default(bNode *node, int x, int y)
@@ -618,8 +671,9 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node)
GPU_blend(true);
- for (link = node->internal_links.first; link; link = link->next)
+ for (link = node->internal_links.first; link; link = link->next) {
node_draw_link_bezier(v2d, snode, link, TH_REDALERT, TH_REDALERT, -1);
+ }
GPU_blend(false);
}
@@ -632,6 +686,11 @@ static void node_socket_circle_draw(const bContext *C, bNodeTree *ntree, Pointer
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
sock->typeinfo->draw_color((bContext *)C, &ptr, &node_ptr, color);
+ bNode *node = node_ptr.data;
+ if (node->flag & NODE_MUTED) {
+ color[3] *= 0.25f;
+ }
+
immAttr4fv(col, color);
immVertex2f(pos, sock->locx, sock->locy);
}
@@ -656,10 +715,12 @@ static void node_draw_preview_background(float tile, rctf *rect)
for (x = rect->xmin; x < rect->xmax; x += tile * 2) {
float tilex = tile, tiley = tile;
- if (x + tile > rect->xmax)
+ if (x + tile > rect->xmax) {
tilex = rect->xmax - x;
- if (y + tile > rect->ymax)
+ }
+ if (y + tile > rect->ymax) {
tiley = rect->ymax - y;
+ }
immRectf(pos, x, y, x + tilex, y + tiley);
}
@@ -668,10 +729,12 @@ static void node_draw_preview_background(float tile, rctf *rect)
for (x = rect->xmin + tile; x < rect->xmax; x += tile * 2) {
float tilex = tile, tiley = tile;
- if (x + tile > rect->xmax)
+ if (x + tile > rect->xmax) {
tilex = rect->xmax - x;
- if (y + tile > rect->ymax)
+ }
+ if (y + tile > rect->ymax) {
tiley = rect->ymax - y;
+ }
immRectf(pos, x, y, x + tilex, y + tiley);
}
@@ -740,8 +803,9 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha)
rctf *rct = &node->totr;
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- if (node->parent == NULL)
+ if (node->parent == NULL) {
ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT);
+ }
else {
const float margin = 3.0f;
@@ -790,8 +854,9 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
short selected_input_len = 0;
bNodeSocket *sock;
for (sock = node->inputs.first; sock; sock = sock->next) {
- if (nodeSocketIsHidden(sock))
+ if (nodeSocketIsHidden(sock)) {
continue;
+ }
if (select_all || (sock->flag & SELECT)) {
++selected_input_len;
continue;
@@ -804,8 +869,9 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
short selected_output_len = 0;
if (draw_outputs) {
for (sock = node->outputs.first; sock; sock = sock->next) {
- if (nodeSocketIsHidden(sock))
+ if (nodeSocketIsHidden(sock)) {
continue;
+ }
if (select_all || (sock->flag & SELECT)) {
++selected_output_len;
continue;
@@ -832,12 +898,14 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
if (selected_input_len) {
/* socket inputs */
for (sock = node->inputs.first; sock; sock = sock->next) {
- if (nodeSocketIsHidden(sock))
+ if (nodeSocketIsHidden(sock)) {
continue;
+ }
if (select_all || (sock->flag & SELECT)) {
node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col);
- if (--selected_input_len == 0)
+ if (--selected_input_len == 0) {
break; /* stop as soon as last one is drawn */
+ }
}
}
}
@@ -845,12 +913,14 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
if (selected_output_len) {
/* socket outputs */
for (sock = node->outputs.first; sock; sock = sock->next) {
- if (nodeSocketIsHidden(sock))
+ if (nodeSocketIsHidden(sock)) {
continue;
+ }
if (select_all || (sock->flag & SELECT)) {
node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col);
- if (--selected_output_len == 0)
+ if (--selected_output_len == 0) {
break; /* stop as soon as last one is drawn */
+ }
}
}
}
@@ -887,16 +957,13 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
node_draw_shadow(snode, node, BASIS_RAD, 1.0f);
if (node->flag & NODE_MUTED) {
- UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color);
+ /* Muted nodes are semi-transparent and colorless. */
+ UI_GetThemeColor3fv(TH_NODE, color);
+ color[3] = 0.25f;
}
else {
- /* header uses color from backdrop, but we make it opaque */
- if (color_id == TH_NODE) {
- UI_GetThemeColorShade3fv(color_id, -20, color);
- }
- else {
- UI_GetThemeColor3fv(color_id, color);
- }
+ /* Opaque headers for regular nodes. */
+ UI_GetThemeColor3fv(color_id, color);
color[3] = 1.0f;
}
@@ -946,41 +1013,50 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
/* open/close entirely? */
{
uiBut *but;
- int but_size = UI_UNIT_X * 1.2f;
+ int but_size = U.widget_unit * 0.8f;
/* XXX button uses a custom triangle draw below, so make it invisible without icon */
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
but = uiDefBut(node->block, UI_BTYPE_BUT_TOGGLE, B_REDR, "",
- rct->xmin + 0.6f * U.widget_unit - but_size / 2, rct->ymax - NODE_DY / 2.2f - but_size / 2,
+ rct->xmin + 0.35f * U.widget_unit, rct->ymax - NODE_DY / 2.2f - but_size / 2,
but_size, but_size, NULL, 0, 0, 0, 0, "");
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle");
UI_block_emboss_set(node->block, UI_EMBOSS);
UI_GetThemeColor4fv(TH_TEXT, color);
/* custom draw function for this button */
- UI_draw_icon_tri(rct->xmin + 0.6f * U.widget_unit, rct->ymax - NODE_DY / 2.2f, 'v', color);
+ UI_draw_icon_tri(rct->xmin + 0.65f * U.widget_unit, rct->ymax - NODE_DY / 2.2f, 'v', color);
}
nodeLabel(ntree, node, showname, sizeof(showname));
- /* XXX - don't print into self! */
- //if (node->flag & NODE_MUTED)
- // BLI_snprintf(showname, sizeof(showname), "[%s]", showname);
-
- uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname,
- (int)(rct->xmin + (NODE_MARGIN_X)), (int)(rct->ymax - NODE_DY),
- (short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY,
- NULL, 0, 0, 0, 0, "");
+ uiBut *but = uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname,
+ (int)(rct->xmin + (NODE_MARGIN_X)), (int)(rct->ymax - NODE_DY),
+ (short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY,
+ NULL, 0, 0, 0, 0, "");
+ if (node->flag & NODE_MUTED) {
+ UI_but_flag_enable(but, UI_BUT_INACTIVE);
+ }
/* body */
if (!nodeIsRegistered(node)) {
/* use warning color to indicate undefined types */
UI_GetThemeColor4fv(TH_REDALERT, color);
+
+ }
+ else if (node->flag & NODE_MUTED) {
+ /* Muted nodes are semi-transparent and colorless. */
+ UI_GetThemeColor4fv(TH_NODE, color);
}
else if (node->flag & NODE_CUSTOM_COLOR) {
rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], 1.0f);
}
- else
+ else {
UI_GetThemeColor4fv(TH_NODE, color);
+ }
+
+ if (node->flag & NODE_MUTED) {
+ color[3] = 0.5f;
+ }
UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT);
UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax - NODE_DY, BASIS_RAD, color);
@@ -994,8 +1070,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
}
/* disable lines */
- if (node->flag & NODE_MUTED)
+ if (node->flag & NODE_MUTED) {
node_draw_mute_line(v2d, snode, node);
+ }
node_draw_sockets(v2d, C, ntree, node, true, false);
@@ -1033,10 +1110,14 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
node_draw_shadow(snode, node, hiddenrad, 1.0f);
/* body */
- if (node->flag & NODE_MUTED)
- UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color);
- else
+ if (node->flag & NODE_MUTED) {
+ /* Muted nodes are semi-transparent and colorless. */
+ UI_GetThemeColor4fv(TH_NODE, color);
+ color[3] = 0.25f;
+ }
+ else {
UI_GetThemeColor4fv(color_id, color);
+ }
UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad, color);
@@ -1069,35 +1150,37 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
/* open entirely icon */
{
uiBut *but;
- int but_size = UI_UNIT_X * 1.2f;
+ int but_size = U.widget_unit * 0.8f;
/* XXX button uses a custom triangle draw below, so make it invisible without icon */
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
but = uiDefBut(node->block, UI_BTYPE_BUT_TOGGLE, B_REDR, "",
- rct->xmin + 10.0f - but_size / 2, centy - but_size / 2,
+ rct->xmin + 0.35f * U.widget_unit, centy - but_size / 2,
but_size, but_size, NULL, 0, 0, 0, 0, "");
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle");
UI_block_emboss_set(node->block, UI_EMBOSS);
UI_GetThemeColor4fv(TH_TEXT, color);
/* custom draw function for this button */
- UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h', color);
+ UI_draw_icon_tri(rct->xmin + 0.65f * U.widget_unit, centy, 'h', color);
}
/* disable lines */
- if (node->flag & NODE_MUTED)
+ if (node->flag & NODE_MUTED) {
node_draw_mute_line(&ar->v2d, snode, node);
+ }
- if (node->miniwidth > 0.0f) {
- nodeLabel(ntree, node, showname, sizeof(showname));
+ nodeLabel(ntree, node, showname, sizeof(showname));
- /* XXX - don't print into self! */
- //if (node->flag & NODE_MUTED)
- // BLI_snprintf(showname, sizeof(showname), "[%s]", showname);
+ /* XXX - don't print into self! */
+ //if (node->flag & NODE_MUTED)
+ // BLI_snprintf(showname, sizeof(showname), "[%s]", showname);
- uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname,
- round_fl_to_int(rct->xmin + NODE_MARGIN_X), round_fl_to_int(centy - NODE_DY * 0.5f),
- (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY,
- NULL, 0, 0, 0, 0, "");
+ uiBut *but = uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname,
+ round_fl_to_int(rct->xmin + NODE_MARGIN_X), round_fl_to_int(centy - NODE_DY * 0.5f),
+ (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY,
+ NULL, 0, 0, 0, 0, "");
+ if (node->flag & NODE_MUTED) {
+ UI_but_flag_enable(but, UI_BUT_INACTIVE);
}
/* scale widget thing */
@@ -1137,14 +1220,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
int node_get_resize_cursor(int directions)
{
- if (directions == 0)
+ if (directions == 0) {
return CURSOR_STD;
- else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0)
+ }
+ else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) {
return CURSOR_Y_MOVE;
- else if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0)
+ }
+ else if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) {
return CURSOR_X_MOVE;
- else
+ }
+ else {
return CURSOR_EDIT;
+ }
}
void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
@@ -1161,8 +1248,9 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
else {
/* check nodes front to back */
for (node = ntree->nodes.last; node; node = node->prev) {
- if (BLI_rctf_isect_pt(&node->totr, cursor[0], cursor[1]))
+ if (BLI_rctf_isect_pt(&node->totr, cursor[0], cursor[1])) {
break; /* first hit on node stops */
+ }
}
if (node) {
int dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]);
@@ -1176,16 +1264,19 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
void node_draw_default(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key)
{
- if (node->flag & NODE_HIDDEN)
+ if (node->flag & NODE_HIDDEN) {
node_draw_hidden(C, ar, snode, ntree, node, key);
- else
+ }
+ else {
node_draw_basis(C, ar, snode, ntree, node, key);
+ }
}
static void node_update(const bContext *C, bNodeTree *ntree, bNode *node)
{
- if (node->typeinfo->draw_nodetype_prepare)
+ if (node->typeinfo->draw_nodetype_prepare) {
node->typeinfo->draw_nodetype_prepare(C, ntree, node);
+ }
}
void node_update_nodetree(const bContext *C, bNodeTree *ntree)
@@ -1203,8 +1294,9 @@ void node_update_nodetree(const bContext *C, bNodeTree *ntree)
static void node_draw(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key)
{
- if (node->typeinfo->draw_nodetype)
+ if (node->typeinfo->draw_nodetype) {
node->typeinfo->draw_nodetype(C, ar, snode, ntree, node, key);
+ }
}
#define USE_DRAW_TOT_UPDATE
@@ -1215,7 +1307,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
bNodeLink *link;
int a;
- if (ntree == NULL) return; /* groups... */
+ if (ntree == NULL) {
+ return; /* groups... */
+ }
#ifdef USE_DRAW_TOT_UPDATE
if (ntree->nodes.first) {
@@ -1233,8 +1327,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
BLI_rctf_union(&ar->v2d.tot, &node->totr);
#endif
- if (!(node->flag & NODE_BACKGROUND))
+ if (!(node->flag & NODE_BACKGROUND)) {
continue;
+ }
key = BKE_node_instance_key(parent_key, ntree, node);
node->nr = a; /* index of node in list, used for exec event code */
@@ -1245,8 +1340,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
GPU_blend(true);
nodelink_batch_start(snode);
for (link = ntree->links.first; link; link = link->next) {
- if (!nodeLinkIsHidden(link))
+ if (!nodeLinkIsHidden(link)) {
node_draw_link(&ar->v2d, snode, link);
+ }
}
nodelink_batch_end(snode);
GPU_blend(false);
@@ -1254,8 +1350,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
/* draw foreground nodes, last nodes in front */
for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) {
bNodeInstanceKey key;
- if (node->flag & NODE_BACKGROUND)
+ if (node->flag & NODE_BACKGROUND) {
continue;
+ }
key = BKE_node_instance_key(parent_key, ntree, node);
node->nr = a; /* index of node in list, used for exec event code */
@@ -1370,8 +1467,9 @@ void drawnodespace(const bContext *C, ARegion *ar)
/* store new view center in path and current edittree */
copy_v2_v2(path->view_center, center);
- if (snode->edittree)
+ if (snode->edittree) {
copy_v2_v2(snode->edittree->view_center, center);
+ }
depth = 0;
while (path->prev && depth < max_depth) {
@@ -1424,15 +1522,16 @@ void drawnodespace(const bContext *C, ARegion *ar)
GPU_blend(true);
GPU_line_smooth(true);
for (nldrag = snode->linkdrag.first; nldrag; nldrag = nldrag->next) {
- for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next)
+ for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) {
node_draw_link(v2d, snode, (bNodeLink *)linkdata->data);
+ }
}
GPU_line_smooth(false);
GPU_blend(false);
if (snode->flag & SNODE_SHOW_GPENCIL) {
/* draw grease-pencil ('canvas' strokes) */
- ED_gpencil_draw_view2d(C, true);
+ ED_annotation_draw_view2d(C, true);
}
}
else {
@@ -1451,7 +1550,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
if (snode->treepath.last) {
if (snode->flag & SNODE_SHOW_GPENCIL) {
/* draw grease-pencil (screen strokes, and also paintbuffer) */
- ED_gpencil_draw_view2d(C, false);
+ ED_annotation_draw_view2d(C, false);
}
}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index b1cada9752a..a6aaca88e62 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -97,16 +97,19 @@ static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags)
for (node = nodetree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_COMPOSITE) {
- if (recalc_flags & COM_RECALC_COMPOSITE)
+ if (recalc_flags & COM_RECALC_COMPOSITE) {
node->flag |= NODE_DO_OUTPUT_RECALC;
+ }
}
else if (node->type == CMP_NODE_VIEWER || node->type == CMP_NODE_SPLITVIEWER) {
- if (recalc_flags & COM_RECALC_VIEWER)
+ if (recalc_flags & COM_RECALC_VIEWER) {
node->flag |= NODE_DO_OUTPUT_RECALC;
+ }
}
else if (node->type == NODE_GROUP) {
- if (node->id)
+ if (node->id) {
compo_tag_output_nodes((bNodeTree *)node->id, recalc_flags);
+ }
}
}
}
@@ -125,16 +128,19 @@ static int compo_get_recalc_flags(const bContext *C)
if (sa->spacetype == SPACE_IMAGE) {
SpaceImage *sima = sa->spacedata.first;
if (sima->image) {
- if (sima->image->type == IMA_TYPE_R_RESULT)
+ if (sima->image->type == IMA_TYPE_R_RESULT) {
recalc_flags |= COM_RECALC_COMPOSITE;
- else if (sima->image->type == IMA_TYPE_COMPOSITE)
+ }
+ else if (sima->image->type == IMA_TYPE_COMPOSITE) {
recalc_flags |= COM_RECALC_VIEWER;
+ }
}
}
else if (sa->spacetype == SPACE_NODE) {
SpaceNode *snode = sa->spacedata.first;
- if (snode->flag & SNODE_BACKDRAW)
+ if (snode->flag & SNODE_BACKDRAW) {
recalc_flags |= COM_RECALC_VIEWER;
+ }
}
}
}
@@ -190,8 +196,9 @@ static void compo_initjob(void *cjv)
cj->localtree = ntreeLocalize(cj->ntree);
- if (cj->recalc_flags)
+ if (cj->recalc_flags) {
compo_tag_output_nodes(cj->localtree, cj->recalc_flags);
+ }
}
/* called before redraw notifiers, it moves finished previews over */
@@ -215,8 +222,9 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
Scene *scene = cj->scene;
SceneRenderView *srv;
- if (scene->use_nodes == false)
+ if (scene->use_nodes == false) {
return;
+ }
cj->stop = stop;
cj->do_update = do_update;
@@ -239,7 +247,9 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
}
else {
for (srv = scene->r.views.first; srv; srv = srv->next) {
- if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) continue;
+ if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) {
+ continue;
+ }
ntreeCompositExecTree(cj->scene, ntree, &cj->scene->r, false, true, &scene->view_settings, &scene->display_settings, srv->name);
}
}
@@ -300,8 +310,9 @@ bool composite_node_active(bContext *C)
{
if (ED_operator_node_active(C)) {
SpaceNode *snode = CTX_wm_space_node(C);
- if (ED_node_is_compositor(snode))
+ if (ED_node_is_compositor(snode)) {
return 1;
+ }
}
return 0;
}
@@ -311,8 +322,9 @@ bool composite_node_editable(bContext *C)
{
if (ED_operator_node_editable(C)) {
SpaceNode *snode = CTX_wm_space_node(C);
- if (ED_node_is_compositor(snode))
+ if (ED_node_is_compositor(snode)) {
return 1;
+ }
}
return 0;
}
@@ -324,8 +336,9 @@ void snode_dag_update(bContext *C, SpaceNode *snode)
/* for groups, update all ID's using this */
if (snode->edittree != snode->nodetree) {
FOREACH_NODETREE_BEGIN(bmain, tntree, id) {
- if (ntreeHasTree(tntree, snode->edittree))
+ if (ntreeHasTree(tntree, snode->edittree)) {
DEG_id_tag_update(id, 0);
+ }
} FOREACH_NODETREE_END;
}
@@ -339,25 +352,32 @@ void snode_notify(bContext *C, SpaceNode *snode)
WM_event_add_notifier(C, NC_NODE | NA_EDITED, NULL);
if (ED_node_is_shader(snode)) {
- if (GS(id->name) == ID_MA)
+ if (GS(id->name) == ID_MA) {
WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id);
- else if (GS(id->name) == ID_LA)
+ }
+ else if (GS(id->name) == ID_LA) {
WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id);
- else if (GS(id->name) == ID_WO)
+ }
+ else if (GS(id->name) == ID_WO) {
WM_main_add_notifier(NC_WORLD | ND_WORLD, id);
+ }
}
- else if (ED_node_is_compositor(snode))
+ else if (ED_node_is_compositor(snode)) {
WM_event_add_notifier(C, NC_SCENE | ND_NODES, id);
- else if (ED_node_is_texture(snode))
+ }
+ else if (ED_node_is_texture(snode)) {
WM_event_add_notifier(C, NC_TEXTURE | ND_NODES, id);
+ }
}
void ED_node_set_tree_type(SpaceNode *snode, bNodeTreeType *typeinfo)
{
- if (typeinfo)
+ if (typeinfo) {
BLI_strncpy(snode->tree_idname, typeinfo->idname, sizeof(snode->tree_idname));
- else
+ }
+ else {
snode->tree_idname[0] = '\0';
+ }
}
bool ED_node_is_compositor(struct SpaceNode *snode)
@@ -421,10 +441,12 @@ void ED_node_shader_default(const bContext *C, ID *id)
shader_type = SH_NODE_EMISSION;
copy_v3_v3(color, &la->r);
- if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA)
+ if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA) {
strength = 100.0f;
- else
+ }
+ else {
strength = 1.0f;
+ }
break;
}
default:
@@ -469,8 +491,9 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce)
/* but lets check it anyway */
if (sce->nodetree) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("error in composite initialize\n");
+ }
return;
}
@@ -504,8 +527,9 @@ void ED_node_texture_default(const bContext *C, Tex *tx)
/* but lets check it anyway */
if (tx->nodetree) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("error in texture initialize\n");
+ }
return;
}
@@ -588,8 +612,9 @@ void snode_update(SpaceNode *snode, bNode *node)
}
}
- if (node)
+ if (node) {
nodeUpdate(snode->edittree, node);
+ }
}
void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
@@ -605,49 +630,61 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
/* generic node group output: set node as active output */
if (node->type == NODE_GROUP_OUTPUT) {
bNode *tnode;
- for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
- if (tnode->type == NODE_GROUP_OUTPUT)
+ for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
+ if (tnode->type == NODE_GROUP_OUTPUT) {
tnode->flag &= ~NODE_DO_OUTPUT;
+ }
+ }
node->flag |= NODE_DO_OUTPUT;
- if (!was_output)
+ if (!was_output) {
do_update = 1;
+ }
}
/* tree specific activate calls */
if (ntree->type == NTREE_SHADER) {
/* when we select a material, active texture is cleared, for buttons */
- if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO))
+ if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO)) {
nodeClearActiveID(ntree, ID_TE);
+ }
if (ELEM(node->type, SH_NODE_OUTPUT_MATERIAL,
SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT, SH_NODE_OUTPUT_LINESTYLE))
{
bNode *tnode;
- for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
- if (tnode->type == node->type)
+ for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
+ if (tnode->type == node->type) {
tnode->flag &= ~NODE_DO_OUTPUT;
+ }
+ }
node->flag |= NODE_DO_OUTPUT;
- if (was_output == 0)
+ if (was_output == 0) {
ED_node_tag_update_nodetree(bmain, ntree, node);
+ }
}
- else if (do_update)
+ else if (do_update) {
ED_node_tag_update_nodetree(bmain, ntree, node);
+ }
/* if active texture changed, free glsl materials */
if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) {
Material *ma;
World *wo;
- for (ma = bmain->materials.first; ma; ma = ma->id.next)
- if (ma->nodetree && ma->use_nodes && ntreeHasTree(ma->nodetree, ntree))
+ for (ma = bmain->materials.first; ma; ma = ma->id.next) {
+ if (ma->nodetree && ma->use_nodes && ntreeHasTree(ma->nodetree, ntree)) {
GPU_material_free(&ma->gpumaterial);
+ }
+ }
- for (wo = bmain->worlds.first; wo; wo = wo->id.next)
- if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree))
+ for (wo = bmain->worlds.first; wo; wo = wo->id.next) {
+ if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree)) {
GPU_material_free(&wo->gpumaterial);
+ }
+ }
ED_node_tag_update_nodetree(bmain, ntree, node);
WM_main_add_notifier(NC_IMAGE, NULL);
@@ -661,13 +698,16 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
bNode *tnode;
- for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
- if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
+ for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
+ if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
tnode->flag &= ~NODE_DO_OUTPUT;
+ }
+ }
node->flag |= NODE_DO_OUTPUT;
- if (was_output == 0)
+ if (was_output == 0) {
ED_node_tag_update_nodetree(bmain, ntree, node);
+ }
/* addnode() doesn't link this yet... */
node->id = (ID *)BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
@@ -676,16 +716,19 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
if (was_output == 0) {
bNode *tnode;
- for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
- if (tnode->type == CMP_NODE_COMPOSITE)
+ for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
+ if (tnode->type == CMP_NODE_COMPOSITE) {
tnode->flag &= ~NODE_DO_OUTPUT;
+ }
+ }
node->flag |= NODE_DO_OUTPUT;
ED_node_tag_update_nodetree(bmain, ntree, node);
}
}
- else if (do_update)
+ else if (do_update) {
ED_node_tag_update_nodetree(bmain, ntree, node);
+ }
}
else if (ntree->type == NTREE_TEXTURE) {
// XXX
@@ -780,8 +823,9 @@ static bNode *visible_node(SpaceNode *snode, const rctf *rct)
bNode *node;
for (node = snode->edittree->nodes.last; node; node = node->prev) {
- if (BLI_rctf_isect(&node->totr, rct, NULL))
+ if (BLI_rctf_isect(&node->totr, rct, NULL)) {
break;
+ }
}
return node;
}
@@ -793,7 +837,6 @@ typedef struct NodeSizeWidget {
float oldlocx, oldlocy;
float oldoffsetx, oldoffsety;
float oldwidth, oldheight;
- float oldminiwidth;
int directions;
} NodeSizeWidget;
@@ -804,8 +847,8 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(
NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data");
op->customdata = nsw;
- nsw->mxstart = snode->cursor[0];
- nsw->mystart = snode->cursor[1];
+ nsw->mxstart = snode->cursor[0] * UI_DPI_FAC;
+ nsw->mystart = snode->cursor[1] * UI_DPI_FAC;
/* store old */
nsw->oldlocx = node->locx;
@@ -814,7 +857,6 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(
nsw->oldoffsety = node->offsety;
nsw->oldwidth = node->width;
nsw->oldheight = node->height;
- nsw->oldminiwidth = node->miniwidth;
nsw->directions = dir;
WM_cursor_modal_set(CTX_wm_window(C), node_get_resize_cursor(dir));
@@ -846,21 +888,12 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
dy = (my - nsw->mystart) / UI_DPI_FAC;
if (node) {
- /* width can use node->width or node->miniwidth (hidden nodes) */
float *pwidth;
float oldwidth, widthmin, widthmax;
- /* ignore hidden flag for frame nodes */
- bool use_hidden = (node->type != NODE_FRAME);
- if (use_hidden && node->flag & NODE_HIDDEN) {
- pwidth = &node->miniwidth;
- oldwidth = nsw->oldminiwidth;
- widthmin = 0.0f;
- }
- else {
- pwidth = &node->width;
- oldwidth = nsw->oldwidth;
- widthmin = node->typeinfo->minwidth;
- }
+
+ pwidth = &node->width;
+ oldwidth = nsw->oldwidth;
+ widthmin = node->typeinfo->minwidth;
widthmax = node->typeinfo->maxwidth;
{
@@ -943,10 +976,12 @@ static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int dir;
if (node) {
+ float cursor[2];
+
/* convert mouse coordinates to v2d space */
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
- &snode->cursor[0], &snode->cursor[1]);
- dir = node->typeinfo->resize_area_func(node, snode->cursor[0], snode->cursor[1]);
+ &cursor[0], &cursor[1]);
+ dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]);
if (dir != 0) {
node_resize_init(C, op, event, node, dir);
return OPERATOR_RUNNING_MODAL;
@@ -984,12 +1019,16 @@ int node_has_hidden_sockets(bNode *node)
{
bNodeSocket *sock;
- for (sock = node->inputs.first; sock; sock = sock->next)
- if (sock->flag & SOCK_HIDDEN)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (sock->flag & SOCK_HIDDEN) {
return 1;
- for (sock = node->outputs.first; sock; sock = sock->next)
- if (sock->flag & SOCK_HIDDEN)
+ }
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ if (sock->flag & SOCK_HIDDEN) {
return 1;
+ }
+ }
return 0;
}
@@ -998,20 +1037,24 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
bNodeSocket *sock;
if (set == 0) {
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_HIDDEN;
- for (sock = node->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_HIDDEN;
+ }
}
else {
/* hide unused sockets */
for (sock = node->inputs.first; sock; sock = sock->next) {
- if (sock->link == NULL)
+ if (sock->link == NULL) {
sock->flag |= SOCK_HIDDEN;
+ }
}
for (sock = node->outputs.first; sock; sock = sock->next) {
- if (nodeCountSocketLinks(snode->edittree, sock) == 0)
+ if (nodeCountSocketLinks(snode->edittree, sock) == 0) {
sock->flag |= SOCK_HIDDEN;
+ }
}
}
}
@@ -1087,8 +1130,9 @@ static void node_duplicate_reparent_recursive(bNode *node)
/* find first selected parent */
for (parent = node->parent; parent; parent = parent->parent) {
if (parent->flag & SELECT) {
- if (!(parent->flag & NODE_TEST))
+ if (!(parent->flag & NODE_TEST)) {
node_duplicate_reparent_recursive(parent);
+ }
break;
}
}
@@ -1121,8 +1165,9 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
}
/* make sure we don't copy new nodes again! */
- if (node == lastnode)
+ if (node == lastnode) {
break;
+ }
}
/* copy links between selected nodes
@@ -1154,21 +1199,25 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
}
/* make sure we don't copy new links again! */
- if (link == lastlink)
+ if (link == lastlink) {
break;
+ }
}
/* clear flags for recursive depth-first iteration */
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
node->flag &= ~NODE_TEST;
+ }
/* reparent copied nodes */
for (node = ntree->nodes.first; node; node = node->next) {
- if ((node->flag & SELECT) && !(node->flag & NODE_TEST))
+ if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) {
node_duplicate_reparent_recursive(node);
+ }
/* only has to check old nodes */
- if (node == lastnode)
+ if (node == lastnode) {
break;
+ }
}
/* deselect old nodes, select the copies instead */
@@ -1185,8 +1234,9 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
}
/* make sure we don't copy new nodes again! */
- if (node == lastnode)
+ if (node == lastnode) {
break;
+ }
}
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
@@ -1230,10 +1280,12 @@ bool ED_node_select_check(ListBase *lb)
void ED_node_select_all(ListBase *lb, int action)
{
if (action == SEL_TOGGLE) {
- if (ED_node_select_check(lb))
+ if (ED_node_select_check(lb)) {
action = SEL_DESELECT;
- else
+ }
+ else {
action = SEL_SELECT;
+ }
}
for (bNode *node = lb->first; node; node = node->next) {
@@ -1266,8 +1318,9 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
/* first tag scenes unread */
- for (scene = bmain->scenes.first; scene; scene = scene->id.next)
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->id.tag |= LIB_TAG_DOIT;
+ }
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_R_LAYERS) {
@@ -1363,29 +1416,37 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
- if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0)
+ if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) {
continue;
- if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex))
+ }
+ if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) {
continue;
+ }
- if (node->flag & toggle_flag)
+ if (node->flag & toggle_flag) {
tot_eq++;
- else
+ }
+ else {
tot_neq++;
+ }
}
}
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
- if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0)
+ if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) {
continue;
- if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex))
+ }
+ if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) {
continue;
+ }
- if ((tot_eq && tot_neq) || tot_eq == 0)
+ if ((tot_eq && tot_neq) || tot_eq == 0) {
node->flag |= toggle_flag;
- else
+ }
+ else {
node->flag &= ~toggle_flag;
+ }
}
}
}
@@ -1395,8 +1456,9 @@ static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
/* sanity checking (poll callback checks this already) */
- if ((snode == NULL) || (snode->edittree == NULL))
+ if ((snode == NULL) || (snode->edittree == NULL)) {
return OPERATOR_CANCELLED;
+ }
node_flag_toggle_exec(snode, NODE_HIDDEN);
@@ -1425,8 +1487,9 @@ static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
/* sanity checking (poll callback checks this already) */
- if ((snode == NULL) || (snode->edittree == NULL))
+ if ((snode == NULL) || (snode->edittree == NULL)) {
return OPERATOR_CANCELLED;
+ }
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -1457,8 +1520,9 @@ static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
/* sanity checking (poll callback checks this already) */
- if ((snode == NULL) || (snode->edittree == NULL))
+ if ((snode == NULL) || (snode->edittree == NULL)) {
return OPERATOR_CANCELLED;
+ }
node_flag_toggle_exec(snode, NODE_OPTIONS);
@@ -1489,8 +1553,9 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
int hidden;
/* sanity checking (poll callback checks this already) */
- if ((snode == NULL) || (snode->edittree == NULL))
+ if ((snode == NULL) || (snode->edittree == NULL)) {
return OPERATOR_CANCELLED;
+ }
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -1590,11 +1655,8 @@ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op))
for (node = snode->edittree->nodes.first; node; node = next) {
next = node->next;
if (node->flag & SELECT) {
- /* check id user here, nodeFreeNode is called for free dbase too */
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, node));
- if (node->id)
- id_us_min(node->id);
- nodeDeleteNode(bmain, snode->edittree, node);
+ nodeRemoveNode(bmain, snode->edittree, node, true);
}
}
@@ -1629,8 +1691,9 @@ static bool node_switch_view_poll(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
- if (snode && snode->edittree)
+ if (snode && snode->edittree) {
return true;
+ }
return false;
}
@@ -1684,11 +1747,7 @@ static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op))
next = node->next;
if (node->flag & SELECT) {
nodeInternalRelink(snode->edittree, node);
-
- /* check id user here, nodeFreeNode is called for free dbase too */
- if (node->id)
- id_us_min(node->id);
- nodeDeleteNode(bmain, snode->edittree, node);
+ nodeRemoveNode(bmain, snode->edittree, node, true);
}
}
@@ -1736,8 +1795,9 @@ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op)
node = nodeGetActive(snode->edittree);
}
- if (!node || node->type != CMP_NODE_OUTPUT_FILE)
+ if (!node || node->type != CMP_NODE_OUTPUT_FILE) {
return OPERATOR_CANCELLED;
+ }
RNA_string_get(op->ptr, "file_path", file_path);
ntreeCompositOutputFileAddSocket(ntree, node, file_path, &scene->r.im_format);
@@ -1782,11 +1842,13 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U
node = nodeGetActive(snode->edittree);
}
- if (!node || node->type != CMP_NODE_OUTPUT_FILE)
+ if (!node || node->type != CMP_NODE_OUTPUT_FILE) {
return OPERATOR_CANCELLED;
+ }
- if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node))
+ if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node)) {
return OPERATOR_CANCELLED;
+ }
snode_notify(C, snode);
@@ -1819,34 +1881,40 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
bNodeSocket *sock;
int direction;
- if (ptr.data)
+ if (ptr.data) {
node = ptr.data;
- else if (snode && snode->edittree)
+ }
+ else if (snode && snode->edittree) {
node = nodeGetActive(snode->edittree);
+ }
- if (!node || node->type != CMP_NODE_OUTPUT_FILE)
+ if (!node || node->type != CMP_NODE_OUTPUT_FILE) {
return OPERATOR_CANCELLED;
+ }
nimf = node->storage;
sock = BLI_findlink(&node->inputs, nimf->active_input);
- if (!sock)
+ if (!sock) {
return OPERATOR_CANCELLED;
+ }
direction = RNA_enum_get(op->ptr, "direction");
if (direction == 1) {
bNodeSocket *before = sock->prev;
- if (!before)
+ if (!before) {
return OPERATOR_CANCELLED;
+ }
BLI_remlink(&node->inputs, sock);
BLI_insertlinkbefore(&node->inputs, before, sock);
nimf->active_input--;
}
else {
bNodeSocket *after = sock->next;
- if (!after)
+ if (!after) {
return OPERATOR_CANCELLED;
+ }
BLI_remlink(&node->inputs, sock);
BLI_insertlinkafter(&node->inputs, after, sock);
nimf->active_input++;
@@ -1888,11 +1956,13 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
bNodeTree *ntree = snode->edittree;
bNode *node, *tnode;
- if (!ntree)
+ if (!ntree) {
return OPERATOR_CANCELLED;
+ }
node = nodeGetActive(ntree);
- if (!node)
+ if (!node) {
return OPERATOR_CANCELLED;
+ }
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
if (tnode->flag & NODE_SELECT && tnode != node) {
@@ -1900,8 +1970,9 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
tnode->flag |= NODE_CUSTOM_COLOR;
copy_v3_v3(tnode->color, node->color);
}
- else
+ else {
tnode->flag &= ~NODE_CUSTOM_COLOR;
+ }
}
}
@@ -2046,8 +2117,9 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_ERROR, "Cannot add node %s into node tree %s", node->name, ntree->id.name + 2);
}
}
- if (!all_nodes_valid)
+ if (!all_nodes_valid) {
return OPERATOR_CANCELLED;
+ }
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -2073,8 +2145,9 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
/* reparent copied nodes */
for (node = clipboard_nodes_lb->first; node; node = node->next) {
bNode *new_node = node->new_node;
- if (new_node->parent)
+ if (new_node->parent) {
new_node->parent = new_node->parent->new_node;
+ }
}
for (link = clipboard_links_lb->first; link; link = link->next) {
@@ -2110,9 +2183,11 @@ void NODE_OT_clipboard_paste(wmOperatorType *ot)
static bNodeSocket *ntree_get_active_interface_socket(ListBase *lb)
{
bNodeSocket *sock;
- for (sock = lb->first; sock; sock = sock->next)
- if (sock->flag & SELECT)
+ for (sock = lb->first; sock; sock = sock->next) {
+ if (sock->flag & SELECT) {
return sock;
+ }
+ }
return NULL;
}
@@ -2148,10 +2223,12 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
}
/* deactivate sockets (has to check both lists) */
- for (tsock = ntree->inputs.first; tsock; tsock = tsock->next)
+ for (tsock = ntree->inputs.first; tsock; tsock = tsock->next) {
tsock->flag &= ~SELECT;
- for (tsock = ntree->outputs.first; tsock; tsock = tsock->next)
+ }
+ for (tsock = ntree->outputs.first; tsock; tsock = tsock->next) {
tsock->flag &= ~SELECT;
+ }
/* make the new socket active */
sock->flag |= SELECT;
@@ -2188,18 +2265,21 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *UNUSED(op))
bNodeSocket *iosock, *active_sock;
iosock = ntree_get_active_interface_socket(&ntree->inputs);
- if (!iosock)
+ if (!iosock) {
iosock = ntree_get_active_interface_socket(&ntree->outputs);
- if (!iosock)
+ }
+ if (!iosock) {
return OPERATOR_CANCELLED;
+ }
/* preferably next socket becomes active, otherwise try previous socket */
active_sock = (iosock->next ? iosock->next : iosock->prev);
ntreeRemoveSocketInterface(ntree, iosock);
/* set active socket */
- if (active_sock)
+ if (active_sock) {
active_sock->flag |= SELECT;
+ }
ntreeUpdateTree(CTX_data_main(C), ntree);
@@ -2245,28 +2325,33 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
lb = &ntree->outputs;
iosock = ntree_get_active_interface_socket(lb);
}
- if (!iosock)
+ if (!iosock) {
return OPERATOR_CANCELLED;
+ }
switch (direction) {
case 1:
{ /* up */
bNodeSocket *before = iosock->prev;
BLI_remlink(lb, iosock);
- if (before)
+ if (before) {
BLI_insertlinkbefore(lb, before, iosock);
- else
+ }
+ else {
BLI_addhead(lb, iosock);
+ }
break;
}
case 2:
{ /* down */
bNodeSocket *after = iosock->next;
BLI_remlink(lb, iosock);
- if (after)
+ if (after) {
BLI_insertlinkafter(lb, after, iosock);
- else
+ }
+ else {
BLI_addtail(lb, iosock);
+ }
break;
}
}
@@ -2306,14 +2391,16 @@ static bool node_shader_script_update_poll(bContext *C)
Text *text;
/* test if we have a render engine that supports shaders scripts */
- if (!(type && type->update_script_node))
+ if (!(type && type->update_script_node)) {
return 0;
+ }
/* see if we have a shader script node in context */
node = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data;
- if (!node && snode && snode->edittree)
+ if (!node && snode && snode->edittree) {
node = nodeGetActive(snode->edittree);
+ }
if (node && node->type == SH_NODE_SCRIPT) {
NodeShaderScript *nss = node->storage;
@@ -2325,8 +2412,9 @@ static bool node_shader_script_update_poll(bContext *C)
/* see if we have a text datablock in context */
text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
- if (text)
+ if (text) {
return 1;
+ }
/* we don't check if text datablock is actually in use, too slow for poll */
@@ -2345,8 +2433,9 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP) {
bNodeTree *ngroup = (bNodeTree *)node->id;
- if (ngroup && !ngroup->done)
+ if (ngroup && !ngroup->done) {
found |= node_shader_script_update_text_recursive(engine, type, ngroup, text);
+ }
}
else if (node->type == SH_NODE_SCRIPT && node->id == &text->id) {
type->update_script_node(engine, ntree, node);
@@ -2397,19 +2486,22 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
if (text) {
/* clear flags for recursion check */
FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
- if (ntree->type == NTREE_SHADER)
+ if (ntree->type == NTREE_SHADER) {
ntree->done = false;
+ }
} FOREACH_NODETREE_END;
FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
- if (!ntree->done)
+ if (!ntree->done) {
found |= node_shader_script_update_text_recursive(engine, type, ntree, text);
+ }
}
} FOREACH_NODETREE_END;
- if (!found)
+ if (!found) {
BKE_report(op->reports, RPT_INFO, "Text not used by any node, no update done");
+ }
}
}
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 8c5bf60bc5d..3de389dca7c 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -106,12 +106,15 @@ static const char *group_node_idname(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
- if (ED_node_is_shader(snode))
+ if (ED_node_is_shader(snode)) {
return "ShaderNodeGroup";
- else if (ED_node_is_compositor(snode))
+ }
+ else if (ED_node_is_compositor(snode)) {
return "CompositorNodeGroup";
- else if (ED_node_is_texture(snode))
+ }
+ else if (ED_node_is_texture(snode)) {
return "TextureNodeGroup";
+ }
return "";
}
@@ -121,10 +124,12 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname)
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node = nodeGetActive(snode->edittree);
- if (node && STREQ(node->idname, node_idname))
+ if (node && STREQ(node->idname, node_idname)) {
return node;
- else
+ }
+ else {
return NULL;
+ }
}
/* ***************** Edit Group operator ************* */
@@ -143,11 +148,13 @@ static int node_group_edit_exec(bContext *C, wmOperator *op)
if (gnode && !exit) {
bNodeTree *ngroup = (bNodeTree *)gnode->id;
- if (ngroup)
+ if (ngroup) {
ED_node_tree_push(snode, ngroup, gnode);
+ }
}
- else
+ else {
ED_node_tree_pop(snode);
+ }
WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
@@ -185,8 +192,9 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
ngroup = (bNodeTree *)gnode->id;
/* clear new pointers, set in copytree */
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
node->new_node = NULL;
+ }
/* wgroup is a temporary copy of the NodeTree we're merging in
* - all of wgroup's nodes are transferred across to their new home
@@ -217,8 +225,9 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
path = RNA_path_from_ID_to_struct(&ptr);
- if (path)
+ if (path) {
BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ }
}
/* migrate node */
@@ -337,11 +346,11 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
while (nodes_delayed_free) {
node = BLI_linklist_pop(&nodes_delayed_free);
- nodeDeleteNode(bmain, ntree, node);
+ nodeRemoveNode(bmain, ntree, node, false);
}
/* delete the group instance */
- nodeDeleteNode(bmain, ntree, gnode);
+ nodeRemoveNode(bmain, ntree, gnode, false);
ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
@@ -359,8 +368,9 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
gnode = node_group_get_active(C, node_idname);
- if (!gnode)
+ if (!gnode) {
return OPERATOR_CANCELLED;
+ }
if (gnode->id && node_group_ungroup(bmain, snode->edittree, gnode)) {
ntreeUpdateTree(bmain, snode->nodetree);
@@ -402,18 +412,21 @@ static int node_group_separate_selected(
ListBase anim_basepaths = {NULL, NULL};
/* deselect all nodes in the target tree */
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
nodeSetSelected(node, false);
+ }
/* clear new pointers, set in BKE_node_copy_ex(). */
- for (node = ngroup->nodes.first; node; node = node->next)
+ for (node = ngroup->nodes.first; node; node = node->next) {
node->new_node = NULL;
+ }
/* add selected nodes into the ntree */
for (node = ngroup->nodes.first; node; node = node_next) {
node_next = node->next;
- if (!(node->flag & NODE_SELECT))
+ if (!(node->flag & NODE_SELECT)) {
continue;
+ }
/* ignore interface nodes */
if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) {
@@ -440,13 +453,15 @@ static int node_group_separate_selected(
RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr);
path = RNA_path_from_ID_to_struct(&ptr);
- if (path)
+ if (path) {
BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ }
}
/* ensure valid parent pointers, detach if parent stays inside the group */
- if (newnode->parent && !(newnode->parent->flag & NODE_SELECT))
+ if (newnode->parent && !(newnode->parent->flag & NODE_SELECT)) {
nodeDetachNode(newnode);
+ }
/* migrate node */
BLI_remlink(&ngroup->nodes, newnode);
@@ -469,8 +484,9 @@ static int node_group_separate_selected(
if (make_copy) {
/* make a copy of internal links */
- if (fromselect && toselect)
+ if (fromselect && toselect) {
nodeAddLink(ntree, link->fromnode->new_node, link->fromsock->new_sock, link->tonode->new_node, link->tosock->new_sock);
+ }
}
else {
/* move valid links over, delete broken links */
@@ -502,8 +518,9 @@ static int node_group_separate_selected(
}
ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
- if (!make_copy)
+ if (!make_copy) {
ngroup->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;
+ }
return 1;
}
@@ -633,16 +650,19 @@ static bool node_group_make_test_selected(bNodeTree *ntree, bNode *gnode, const
/* free local pseudo node tree again */
ntreeFreeTree(ngroup);
MEM_freeN(ngroup);
- if (!ok)
+ if (!ok) {
return false;
+ }
/* check if all connections are OK, no unselected node has both
* inputs and outputs to a selection */
for (link = ntree->links.first; link; link = link->next) {
- if (node_group_make_use_node(link->fromnode, gnode))
+ if (node_group_make_use_node(link->fromnode, gnode)) {
link->tonode->done |= 1;
- if (node_group_make_use_node(link->tonode, gnode))
+ }
+ if (node_group_make_use_node(link->tonode, gnode)) {
link->fromnode->done |= 2;
+ }
}
for (node = ntree->nodes.first; node; node = node->next) {
if (!(node->flag & NODE_SELECT) &&
@@ -696,16 +716,18 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
static const float offsety = 0.0f;
/* deselect all nodes in the target tree */
- for (node = ngroup->nodes.first; node; node = node->next)
+ for (node = ngroup->nodes.first; node; node = node->next) {
nodeSetSelected(node, false);
+ }
totselect = node_get_selected_minmax(ntree, gnode, min, max);
add_v2_v2v2(center, min, max);
mul_v2_fl(center, 0.5f);
/* auto-add interface for "solo" nodes */
- if (totselect == 1)
+ if (totselect == 1) {
expose_all = true;
+ }
/* move nodes over */
for (node = ntree->nodes.first; node; node = nextn) {
@@ -721,13 +743,15 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
path = RNA_path_from_ID_to_struct(&ptr);
- if (path)
+ if (path) {
BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ }
}
/* ensure valid parent pointers, detach if parent stays outside the group */
- if (node->parent && !(node->parent->flag & NODE_SELECT))
+ if (node->parent && !(node->parent->flag & NODE_SELECT)) {
nodeDetachNode(node);
+ }
/* change node-collection membership */
BLI_remlink(&ntree->nodes, node);
@@ -857,8 +881,9 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
break;
}
}
- if (skip)
+ if (skip) {
continue;
+ }
iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
@@ -872,11 +897,14 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
for (sock = node->outputs.first; sock; sock = sock->next) {
bNodeSocket *iosock, *output_sock;
bool skip = false;
- for (link = ngroup->links.first; link; link = link->next)
- if (link->fromsock == sock)
+ for (link = ngroup->links.first; link; link = link->next) {
+ if (link->fromsock == sock) {
skip = true;
- if (skip)
+ }
+ }
+ if (skip) {
continue;
+ }
iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
@@ -906,8 +934,9 @@ static bNode *node_group_make_from_selected(const bContext *C, bNodeTree *ntree,
totselect = node_get_selected_minmax(ntree, NULL, min, max);
/* don't make empty group */
- if (totselect == 0)
+ if (totselect == 0) {
return NULL;
+ }
/* new nodetree */
ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype);
@@ -939,8 +968,9 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
- if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports))
+ if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports)) {
return OPERATOR_CANCELLED;
+ }
gnode = node_group_make_from_selected(C, ntree, node_idname, ntree_idname);
@@ -995,12 +1025,14 @@ static int node_group_insert_exec(bContext *C, wmOperator *op)
gnode = node_group_get_active(C, node_idname);
- if (!gnode || !gnode->id)
+ if (!gnode || !gnode->id) {
return OPERATOR_CANCELLED;
+ }
ngroup = (bNodeTree *)gnode->id;
- if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports))
+ if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports)) {
return OPERATOR_CANCELLED;
+ }
node_group_make_insert_selected(C, ntree, gnode);
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index ed3190b06fe..517e4df1dc1 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -136,7 +136,9 @@ void ED_operatormacros_node(void)
ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer",
"Select node and link it to a viewer node",
OPTYPE_UNDO);
- WM_operatortype_macro_define(ot, "NODE_OT_select");
+ mot = WM_operatortype_macro_define(ot, "NODE_OT_select");
+ RNA_boolean_set(mot->ptr, "extend", false);
+ RNA_boolean_set(mot->ptr, "socket_select", true);
WM_operatortype_macro_define(ot, "NODE_OT_link_viewer");
ot = WM_operatortype_append_macro("NODE_OT_translate_attach", "Move and Attach",
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index e0fce2a5367..55a3da6f77c 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -124,7 +124,7 @@ static bool node_group_has_output_dfs(bNode *node)
static bool node_group_has_output(Main *bmain, bNode *node)
{
- BLI_assert(node->type == NODE_GROUP);
+ BLI_assert(ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP));
bNodeTree *ntree = (bNodeTree *)node->id;
if (ntree == NULL) {
return false;
@@ -153,7 +153,7 @@ bool node_connected_to_output(Main *bmain, bNodeTree *ntree, bNode *node)
* We could make check more grained here by taking which socket the node
* is connected to and so eventually.
*/
- if (current_node->type == NODE_GROUP) {
+ if (ELEM(current_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
if (current_node->id != NULL &&
ntree_has_drivers((bNodeTree *)current_node->id))
{
@@ -200,19 +200,23 @@ static int sort_nodes_locx(const void *a, const void *b)
const bNode *node1 = nli1->node;
const bNode *node2 = nli2->node;
- if (node1->locx > node2->locx)
+ if (node1->locx > node2->locx) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static bool socket_is_available(bNodeTree *UNUSED(ntree), bNodeSocket *sock, const bool allow_used)
{
- if (nodeSocketIsHidden(sock))
+ if (nodeSocketIsHidden(sock)) {
return 0;
+ }
- if (!allow_used && (sock->flag & SOCK_IN_USE))
+ if (!allow_used && (sock->flag & SOCK_IN_USE)) {
return 0;
+ }
return 1;
}
@@ -223,30 +227,35 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke
/* first look for selected output */
for (sock = node->outputs.first; sock; sock = sock->next) {
- if (!socket_is_available(ntree, sock, allow_multiple))
+ if (!socket_is_available(ntree, sock, allow_multiple)) {
continue;
+ }
- if (sock->flag & SELECT)
+ if (sock->flag & SELECT) {
return sock;
+ }
}
/* try to find a socket with a matching name */
for (sock = node->outputs.first; sock; sock = sock->next) {
- if (!socket_is_available(ntree, sock, allow_multiple))
+ if (!socket_is_available(ntree, sock, allow_multiple)) {
continue;
+ }
/* check for same types */
if (sock->type == sock_target->type) {
- if (STREQ(sock->name, sock_target->name))
+ if (STREQ(sock->name, sock_target->name)) {
return sock;
+ }
}
}
/* otherwise settle for the first available socket of the right type */
for (sock = node->outputs.first; sock; sock = sock->next) {
- if (!socket_is_available(ntree, sock, allow_multiple))
+ if (!socket_is_available(ntree, sock, allow_multiple)) {
continue;
+ }
/* check for same types */
if (sock->type == sock_target->type) {
@@ -282,8 +291,9 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in
/* increment to make sure we don't keep finding
* the same socket on every attempt running this function */
a++;
- if (a > num)
+ if (a > num) {
return sock;
+ }
}
}
}
@@ -296,8 +306,9 @@ static bool snode_autoconnect_input(SpaceNode *snode, bNode *node_fr, bNodeSocke
bNodeTree *ntree = snode->edittree;
/* then we can connect */
- if (replace)
+ if (replace) {
nodeRemSocketLinks(ntree, sock_to);
+ }
nodeAddLink(ntree, node_fr, sock_fr, node_to, sock_to);
return true;
@@ -327,7 +338,9 @@ static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_mu
bNodeSocket *sock_fr, *sock_to;
bool has_selected_inputs = false;
- if (nli->next == NULL) break;
+ if (nli->next == NULL) {
+ break;
+ }
node_fr = nli->node;
node_to = nli->next->node;
@@ -341,13 +354,15 @@ static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_mu
if (sock_to->flag & SELECT) {
has_selected_inputs = 1;
- if (!socket_is_available(ntree, sock_to, replace))
+ if (!socket_is_available(ntree, sock_to, replace)) {
continue;
+ }
/* check for an appropriate output socket to connect from */
sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple);
- if (!sock_fr)
+ if (!sock_fr) {
continue;
+ }
if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) {
numlinks++;
@@ -363,13 +378,15 @@ static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_mu
/* find the best guess input socket */
sock_to = best_socket_input(ntree, node_to, i, replace);
- if (!sock_to)
+ if (!sock_to) {
continue;
+ }
/* check for an appropriate output socket to connect from */
sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple);
- if (!sock_fr)
+ if (!sock_fr) {
continue;
+ }
if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) {
numlinks++;
@@ -397,16 +414,21 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
bNodeSocket *sock;
/* context check */
- if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs))
+ if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs)) {
return OPERATOR_CANCELLED;
- if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
+ }
+ if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
return OPERATOR_CANCELLED;
+ }
/* get viewer */
- for (node = snode->edittree->nodes.first; node; node = node->next)
- if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
- if (node->flag & NODE_DO_OUTPUT)
+ for (node = snode->edittree->nodes.first; node; node = node->next) {
+ if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
+ if (node->flag & NODE_DO_OUTPUT) {
break;
+ }
+ }
+ }
/* no viewer, we make one active */
if (node == NULL) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
@@ -422,27 +444,45 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
/* try to find an already connected socket to cycle to the next */
if (node) {
link = NULL;
- for (link = snode->edittree->links.first; link; link = link->next)
- if (link->tonode == node && link->fromnode == tonode)
- if (link->tosock == node->inputs.first)
+ for (link = snode->edittree->links.first; link; link = link->next) {
+ if (link->tonode == node && link->fromnode == tonode) {
+ if (link->tosock == node->inputs.first) {
break;
+ }
+ }
+ }
if (link) {
/* unlink existing connection */
sock = link->fromsock;
nodeRemLink(snode->edittree, link);
/* find a socket after the previously connected socket */
- for (sock = sock->next; sock; sock = sock->next)
- if (!nodeSocketIsHidden(sock))
+ for (sock = sock->next; sock; sock = sock->next) {
+ if (!nodeSocketIsHidden(sock)) {
break;
+ }
+ }
}
}
+ if (tonode) {
+ /* Find a selected socket that overrides the socket to connect to */
+ for (bNodeSocket *sock2 = tonode->outputs.first; sock2; sock2 = sock2->next) {
+ if (!nodeSocketIsHidden(sock2) && sock2->flag & SELECT) {
+ sock = sock2;
+ break;
+ }
+ }
+ }
+
+
/* find a socket starting from the first socket */
if (!sock) {
- for (sock = tonode->outputs.first; sock; sock = sock->next)
- if (!nodeSocketIsHidden(sock))
+ for (sock = tonode->outputs.first; sock; sock = sock->next) {
+ if (!nodeSocketIsHidden(sock)) {
break;
+ }
+ }
}
if (sock) {
@@ -450,16 +490,19 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
if (!node) {
/* XXX location is a quick hack, just place it next to the linked socket */
node = node_add_node(C, NULL, CMP_NODE_VIEWER, sock->locx + 100, sock->locy);
- if (!node)
+ if (!node) {
return OPERATOR_CANCELLED;
+ }
link = NULL;
}
else {
/* get link to viewer */
- for (link = snode->edittree->links.first; link; link = link->next)
- if (link->tonode == node && link->tosock == node->inputs.first)
+ for (link = snode->edittree->links.first; link; link = link->next) {
+ if (link->tonode == node && link->tosock == node->inputs.first) {
break;
+ }
+ }
}
if (link == NULL) {
@@ -486,13 +529,15 @@ static int node_active_link_viewer_exec(bContext *C, wmOperator *UNUSED(op))
node = nodeGetActive(snode->edittree);
- if (!node)
+ if (!node) {
return OPERATOR_CANCELLED;
+ }
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
- if (node_link_viewer(C, node) == OPERATOR_CANCELLED)
+ if (node_link_viewer(C, node) == OPERATOR_CANCELLED) {
return OPERATOR_CANCELLED;
+ }
snode_notify(C, snode);
@@ -531,10 +576,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;
}
@@ -549,8 +596,9 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
tlink_next = tlink->next;
- if (tlink == link)
+ if (tlink == link) {
continue;
+ }
if (tlink && tlink->fromsock == from) {
if (from_count > from->limit) {
@@ -594,10 +642,12 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
/* before actually adding the link,
* let nodes perform special link insertion handling
*/
- if (link->fromnode->typeinfo->insert_link)
+ if (link->fromnode->typeinfo->insert_link) {
link->fromnode->typeinfo->insert_link(ntree, link->fromnode, link);
- if (link->tonode->typeinfo->insert_link)
+ }
+ if (link->tonode->typeinfo->insert_link) {
link->tonode->typeinfo->insert_link(ntree, link->tonode, link);
+ }
/* add link to the node tree */
BLI_addtail(&ntree->links, link);
@@ -646,11 +696,13 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
bNodeLink *link = linkdata->data;
/* skip if this is already the target socket */
- if (link->tosock == tsock)
+ if (link->tosock == tsock) {
continue;
+ }
/* skip if socket is on the same node as the fromsock */
- if (tnode && link->fromnode == tnode)
+ if (tnode && link->fromnode == tnode) {
continue;
+ }
/* attach links to the socket */
link->tonode = tnode;
@@ -672,11 +724,13 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
bNodeLink *link = linkdata->data;
/* skip if this is already the target socket */
- if (link->fromsock == tsock)
+ if (link->fromsock == tsock) {
continue;
+ }
/* skip if socket is on the same node as the fromsock */
- if (tnode && link->tonode == tnode)
+ if (tnode && link->tonode == tnode) {
continue;
+ }
/* attach links to the socket */
link->fromnode = tnode;
@@ -818,8 +872,9 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
nodeRemLink(snode->edittree, link);
/* send changed event to original link->tonode */
- if (node)
+ if (node) {
snode_update(snode, node);
+ }
}
}
}
@@ -870,8 +925,9 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
- else
+ else {
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
+ }
}
static void node_link_cancel(bContext *C, wmOperator *op)
@@ -954,10 +1010,13 @@ static bool cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot)
if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
- for (i = 0; i < tot - 1; i++)
- for (b = 0; b < NODE_LINK_RESOL; b++)
- if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0)
+ for (i = 0; i < tot - 1; i++) {
+ for (b = 0; b < NODE_LINK_RESOL; b++) {
+ if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) {
return 1;
+ }
+ }
+ }
}
return 0;
}
@@ -979,7 +1038,9 @@ static int cut_links_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view(&ar->v2d, (int)loc[0], (int)loc[1],
&mcoords[i][0], &mcoords[i][1]);
i++;
- if (i >= 256) break;
+ if (i >= 256) {
+ break;
+ }
}
RNA_END;
@@ -991,8 +1052,9 @@ static int cut_links_exec(bContext *C, wmOperator *op)
for (link = snode->edittree->links.first; link; link = next) {
next = link->next;
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
if (cut_links_intersect(link, mcoords, i)) {
@@ -1097,12 +1159,14 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNode *frame = nodeGetActive(ntree), *node;
- if (!frame || frame->type != NODE_FRAME)
+ if (!frame || frame->type != NODE_FRAME) {
return OPERATOR_CANCELLED;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
- if (node == frame)
+ if (node == frame) {
continue;
+ }
if (node->flag & NODE_SELECT) {
nodeDetachNode(node);
nodeAttachNode(node, frame);
@@ -1145,12 +1209,14 @@ static void node_join_attach_recursive(bNode *node, bNode *frame)
}
else if (node->parent) {
/* call recursively */
- if (!(node->parent->done & NODE_JOIN_DONE))
+ if (!(node->parent->done & NODE_JOIN_DONE)) {
node_join_attach_recursive(node->parent, frame);
+ }
/* in any case: if the parent is a descendant, so is the child */
- if (node->parent->done & NODE_JOIN_IS_DESCENDANT)
+ if (node->parent->done & NODE_JOIN_IS_DESCENDANT) {
node->done |= NODE_JOIN_IS_DESCENDANT;
+ }
else if (node->flag & NODE_TEST) {
/* if parent is not an descendant of the frame, reattach the node */
nodeDetachNode(node);
@@ -1173,27 +1239,32 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op))
/* XXX save selection: node_add_node call below sets the new frame as single
* active+selected node */
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->flag & NODE_SELECT)
+ if (node->flag & NODE_SELECT) {
node->flag |= NODE_TEST;
- else
+ }
+ else {
node->flag &= ~NODE_TEST;
+ }
}
frame = node_add_node(C, NULL, NODE_FRAME, 0.0f, 0.0f);
/* reset 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->done & NODE_JOIN_DONE))
+ if (!(node->done & NODE_JOIN_DONE)) {
node_join_attach_recursive(node, frame);
+ }
}
/* restore selection */
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->flag & NODE_TEST)
+ if (node->flag & NODE_TEST) {
node->flag |= NODE_SELECT;
+ }
}
ED_node_sort(ntree);
@@ -1230,10 +1301,12 @@ static bNode *node_find_frame_to_attach(ARegion *ar, const bNodeTree *ntree, con
/* check nodes front to back */
for (frame = ntree->nodes.last; frame; frame = frame->prev) {
/* skip selected, those are the nodes we want to attach */
- if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT))
+ if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) {
continue;
- if (BLI_rctf_isect_pt_v(&frame->totr, cursor))
+ }
+ if (BLI_rctf_isect_pt_v(&frame->totr, cursor)) {
return frame;
+ }
}
return NULL;
@@ -1312,12 +1385,14 @@ static void node_detach_recursive(bNode *node)
if (node->parent) {
/* call recursively */
- if (!(node->parent->done & NODE_DETACH_DONE))
+ if (!(node->parent->done & NODE_DETACH_DONE)) {
node_detach_recursive(node->parent);
+ }
/* in any case: if the parent is a descendant, so is the child */
- if (node->parent->done & NODE_DETACH_IS_DESCENDANT)
+ if (node->parent->done & NODE_DETACH_IS_DESCENDANT) {
node->done |= NODE_DETACH_IS_DESCENDANT;
+ }
else if (node->flag & NODE_SELECT) {
/* if parent is not a descendant of a selected node, detach */
nodeDetachNode(node);
@@ -1338,14 +1413,16 @@ static int node_detach_exec(bContext *C, wmOperator *UNUSED(op))
bNode *node;
/* reset tags */
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
node->done = 0;
+ }
/* detach nodes recursively
* relative order is preserved here!
*/
for (node = ntree->nodes.first; node; node = node->next) {
- if (!(node->done & NODE_DETACH_DONE))
+ if (!(node->done & NODE_DETACH_DONE)) {
node_detach_recursive(node);
+ }
}
ED_node_sort(ntree);
@@ -1383,8 +1460,9 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode,
*r_select = NULL;
/* no unlucky accidents */
- if (sa == NULL || sa->spacetype != SPACE_NODE)
+ if (sa == NULL || sa->spacetype != SPACE_NODE) {
return false;
+ }
if (!test) {
/* no need to look for a node */
@@ -1393,27 +1471,33 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode,
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
- if (select)
+ if (select) {
break;
- else
+ }
+ else {
select = node;
+ }
}
}
/* only one selected */
- if (node || select == NULL)
+ if (node || select == NULL) {
return false;
+ }
/* correct node */
- if (BLI_listbase_is_empty(&select->inputs) || BLI_listbase_is_empty(&select->outputs))
+ if (BLI_listbase_is_empty(&select->inputs) || BLI_listbase_is_empty(&select->outputs)) {
return false;
+ }
/* test node for links */
for (link = snode->edittree->links.first; link; link = link->next) {
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
- if (link->tonode == select || link->fromnode == select)
+ if (link->tonode == select || link->fromnode == select) {
return false;
+ }
}
*r_select = select;
@@ -1428,20 +1512,26 @@ void ED_node_link_intersect_test(ScrArea *sa, int test)
bNodeLink *link, *selink = NULL;
float dist_best = FLT_MAX;
- if (!ed_node_link_conditions(sa, test, &snode, &select)) return;
+ if (!ed_node_link_conditions(sa, test, &snode, &select)) {
+ return;
+ }
/* clear flags */
- for (link = snode->edittree->links.first; link; link = link->next)
+ for (link = snode->edittree->links.first; link; link = link->next) {
link->flag &= ~NODE_LINKFLAG_HILITE;
+ }
- if (test == 0) return;
+ if (test == 0) {
+ return;
+ }
/* find link to select/highlight */
for (link = snode->edittree->links.first; link; link = link->next) {
float coord_array[NODE_LINK_RESOL + 1][2];
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
float dist = FLT_MAX;
@@ -1471,8 +1561,9 @@ void ED_node_link_intersect_test(ScrArea *sa, int test)
}
}
- if (selink)
+ if (selink) {
selink->flag |= NODE_LINKFLAG_HILITE;
+ }
}
/* assumes sockets in list */
@@ -1482,8 +1573,9 @@ static bNodeSocket *socket_best_match(ListBase *sockets)
int type, maxtype = 0;
/* find type range */
- for (sock = sockets->first; sock; sock = sock->next)
+ for (sock = sockets->first; sock; sock = sock->next) {
maxtype = max_ii(sock->type, maxtype);
+ }
/* try all types, starting from 'highest' (i.e. colors, vectors, values) */
for (type = maxtype; type >= 0; --type) {
@@ -1659,8 +1751,9 @@ static void node_link_insert_offset_ntree(
/* check nodes front to back */
for (frame = ntree->nodes.last; frame; frame = frame->prev) {
/* skip selected, those are the nodes we want to attach */
- if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT))
+ if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) {
continue;
+ }
/* for some reason frame y coords aren't correct yet */
node_to_updated_rect(frame, &totr_frame);
@@ -1746,8 +1839,9 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w
float duration;
bool redraw = false;
- if (!snode || event->type != TIMER || iofsd == NULL || iofsd->anim_timer != event->customdata)
+ if (!snode || event->type != TIMER || iofsd == NULL || iofsd->anim_timer != event->customdata) {
return OPERATOR_PASS_THROUGH;
+ }
duration = (float)iofsd->anim_timer->duration;
@@ -1797,8 +1891,9 @@ static int node_insert_offset_invoke(bContext *C, wmOperator *op, const wmEvent
const SpaceNode *snode = CTX_wm_space_node(C);
NodeInsertOfsData *iofsd = snode->iofsd;
- if (!iofsd || !iofsd->insert)
+ if (!iofsd || !iofsd->insert) {
return OPERATOR_CANCELLED;
+ }
BLI_assert((snode->flag & SNODE_SKIP_INSOFFSET) == 0);
@@ -1839,12 +1934,16 @@ void ED_node_link_insert(Main *bmain, ScrArea *sa)
bNodeLink *link;
bNodeSocket *sockto;
- if (!ed_node_link_conditions(sa, true, &snode, &select)) return;
+ if (!ed_node_link_conditions(sa, true, &snode, &select)) {
+ return;
+ }
/* get the link */
- for (link = snode->edittree->links.first; link; link = link->next)
- if (link->flag & NODE_LINKFLAG_HILITE)
+ for (link = snode->edittree->links.first; link; link = link->next) {
+ if (link->flag & NODE_LINKFLAG_HILITE) {
break;
+ }
+ }
if (link) {
bNodeSocket *best_input = socket_best_match(&select->inputs);
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index ae5413f13f4..a027481ff27 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -64,8 +64,9 @@ static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my)
for (node = ntree->nodes.last; node; node = node->prev) {
if (node->typeinfo->select_area_func) {
- if (node->typeinfo->select_area_func(node, mx, my))
+ if (node->typeinfo->select_area_func(node, mx, my)) {
return node;
+ }
}
}
return NULL;
@@ -77,8 +78,9 @@ static bNode *node_under_mouse_tweak(bNodeTree *ntree, int mx, int my)
for (node = ntree->nodes.last; node; node = node->prev) {
if (node->typeinfo->tweak_area_func) {
- if (node->typeinfo->tweak_area_func(node, mx, my))
+ if (node->typeinfo->tweak_area_func(node, mx, my)) {
return node;
+ }
}
}
return NULL;
@@ -118,8 +120,9 @@ void node_socket_select(bNode *node, bNodeSocket *sock)
sock->flag |= SELECT;
/* select node too */
- if (node)
+ if (node) {
node->flag |= SELECT;
+ }
}
void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_node)
@@ -143,17 +146,20 @@ void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_no
}
}
- if (!sel)
+ if (!sel) {
node->flag &= ~SELECT;
+ }
}
}
static void node_socket_toggle(bNode *node, bNodeSocket *sock, int deselect_node)
{
- if (sock->flag & SELECT)
+ if (sock->flag & SELECT) {
node_socket_deselect(node, sock, deselect_node);
- else
+ }
+ else {
node_socket_select(node, sock);
+ }
}
/* no undo here! */
@@ -161,8 +167,9 @@ void node_deselect_all(SpaceNode *snode)
{
bNode *node;
- for (node = snode->edittree->nodes.first; node; node = node->next)
+ for (node = snode->edittree->nodes.first; node; node = node->next) {
nodeSetSelected(node, false);
+ }
}
void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes)
@@ -178,8 +185,9 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes
for (node = snode->edittree->nodes.first; node; node = node->next) {
int sel = 0;
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
sock->flag &= ~SELECT;
+ }
/* if no selected sockets remain, also deselect the node */
if (deselect_nodes) {
@@ -190,8 +198,9 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes
}
}
- if (!sel)
+ if (!sel) {
node->flag &= ~SELECT;
+ }
}
}
}
@@ -209,8 +218,9 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node
for (node = snode->edittree->nodes.first; node; node = node->next) {
bool sel = false;
- for (sock = node->outputs.first; sock; sock = sock->next)
+ for (sock = node->outputs.first; sock; sock = sock->next) {
sock->flag &= ~SELECT;
+ }
/* if no selected sockets remain, also deselect the node */
if (deselect_nodes) {
@@ -221,8 +231,9 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node
}
}
- if (!sel)
+ if (!sel) {
node->flag &= ~SELECT;
+ }
}
}
}
@@ -397,9 +408,11 @@ void node_select_single(bContext *C, bNode *node)
SpaceNode *snode = CTX_wm_space_node(C);
bNode *tnode;
- for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next)
- if (tnode != node)
+ for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
+ if (tnode != node) {
nodeSetSelected(tnode, false);
+ }
+ }
nodeSetSelected(node, true);
ED_node_set_active(bmain, snode->edittree, node);
@@ -410,72 +423,84 @@ void node_select_single(bContext *C, bNode *node)
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
}
-static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], short extend)
+static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], bool extend, bool socket_select)
{
bNode *node, *tnode;
- bNodeSocket *sock, *tsock;
+ bNodeSocket *sock = NULL;
+ bNodeSocket *tsock;
float cursor[2];
- int selected = 0;
+ bool selected = false;
/* get mouse coordinates in view2d space */
UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &cursor[0], &cursor[1]);
- if (extend) {
- /* first do socket selection, these generally overlap with nodes.
- * socket selection only in extend mode.
- */
+ /* first do socket selection, these generally overlap with nodes. */
+ if (socket_select) {
if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN)) {
node_socket_toggle(node, sock, 1);
- selected = 1;
+ selected = true;
}
else if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_OUT)) {
if (sock->flag & SELECT) {
- node_socket_deselect(node, sock, 1);
+ if (extend) {
+ node_socket_deselect(node, sock, 1);
+ }
+ else {
+ selected = true;
+ }
}
else {
/* only allow one selected output per node, for sensible linking.
- * allows selecting outputs from different nodes though.
- */
+ * allows selecting outputs from different nodes though. */
if (node) {
- for (tsock = node->outputs.first; tsock; tsock = tsock->next)
+ for (tsock = node->outputs.first; tsock; tsock = tsock->next) {
node_socket_deselect(node, tsock, 1);
+ }
+ }
+ if (extend) {
+ /* only allow one selected output per node, for sensible linking.
+ * allows selecting outputs from different nodes though. */
+ for (tsock = node->outputs.first; tsock; tsock = tsock->next) {
+ if (tsock != sock) {
+ node_socket_deselect(node, tsock, 1);
+ }
+ }
}
node_socket_select(node, sock);
+ selected = true;
}
- selected = 1;
}
- else {
+ }
+
+ if (!sock) {
+ if (extend) {
/* find the closest visible node */
node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]);
if (node) {
if ((node->flag & SELECT) && (node->flag & NODE_ACTIVE) == 0) {
- /* if node is selected but not active make it active
- * before it'll be desleected
- */
+ /* if node is selected but not active make it active */
ED_node_set_active(bmain, snode->edittree, node);
}
else {
node_toggle(node);
ED_node_set_active(bmain, snode->edittree, node);
}
-
- selected = 1;
+ selected = true;
}
}
- }
- else { /* extend == 0 */
-
- /* find the closest visible node */
- node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]);
+ else {
+ /* find the closest visible node */
+ node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]);
- if (node) {
- for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
- nodeSetSelected(tnode, false);
+ if (node) {
+ for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
+ nodeSetSelected(tnode, false);
+ }
+ nodeSetSelected(node, true);
+ ED_node_set_active(bmain, snode->edittree, node);
+ selected = true;
}
- nodeSetSelected(node, true);
- ED_node_set_active(bmain, snode->edittree, node);
- selected = 1;
}
}
@@ -495,15 +520,18 @@ static int node_select_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
int mval[2];
short extend;
+ bool socket_select;
/* get settings from RNA properties for operator */
mval[0] = RNA_int_get(op->ptr, "mouse_x");
mval[1] = RNA_int_get(op->ptr, "mouse_y");
extend = RNA_boolean_get(op->ptr, "extend");
+ /* always do socket_select when extending selection. */
+ socket_select = extend || RNA_boolean_get(op->ptr, "socket_select");
/* perform the select */
- if (node_mouse_select(bmain, snode, ar, mval, extend)) {
+ if (node_mouse_select(bmain, snode, ar, mval, extend, socket_select)) {
/* send notifiers */
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
@@ -543,7 +571,8 @@ void NODE_OT_select(wmOperatorType *ot)
/* properties */
RNA_def_int(ot->srna, "mouse_x", 0, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX);
- RNA_def_boolean(ot->srna, "extend", 0, "Extend", "");
+ RNA_def_boolean(ot->srna, "extend", false, "Extend", "");
+ RNA_def_boolean(ot->srna, "socket_select", false, "Socket Select", "");
}
/** \} */
@@ -842,19 +871,23 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
bNodeLink *link;
bNode *node;
- for (node = snode->edittree->nodes.first; node; node = node->next)
+ for (node = snode->edittree->nodes.first; node; node = node->next) {
node->flag &= ~NODE_TEST;
+ }
for (link = snode->edittree->links.first; link; link = link->next) {
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
- if (link->fromnode && link->tonode && (link->fromnode->flag & NODE_SELECT))
+ }
+ if (link->fromnode && link->tonode && (link->fromnode->flag & NODE_SELECT)) {
link->tonode->flag |= NODE_TEST;
+ }
}
for (node = snode->edittree->nodes.first; node; node = node->next) {
- if (node->flag & NODE_TEST)
+ if (node->flag & NODE_TEST) {
nodeSetSelected(node, true);
+ }
}
ED_node_sort(snode->edittree);
@@ -890,19 +923,23 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
bNodeLink *link;
bNode *node;
- for (node = snode->edittree->nodes.first; node; node = node->next)
+ for (node = snode->edittree->nodes.first; node; node = node->next) {
node->flag &= ~NODE_TEST;
+ }
for (link = snode->edittree->links.first; link; link = link->next) {
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
- if (link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT))
+ }
+ if (link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT)) {
link->fromnode->flag |= NODE_TEST;
+ }
}
for (node = snode->edittree->nodes.first; node; node = node->next) {
- if (node->flag & NODE_TEST)
+ if (node->flag & NODE_TEST) {
nodeSetSelected(node, true);
+ }
}
ED_node_sort(snode->edittree);
@@ -948,41 +985,55 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
int a;
for (a = 0; a < totnodes; a++) {
- if (node_array[a] == active)
+ if (node_array[a] == active) {
break;
+ }
}
if (same_type) {
bNode *node = NULL;
while (node == NULL) {
- if (revert) a--;
- else a++;
+ if (revert) {
+ a--;
+ }
+ else {
+ a++;
+ }
- if (a < 0 || a >= totnodes)
+ if (a < 0 || a >= totnodes) {
break;
+ }
node = node_array[a];
- if (node->type == active->type)
+ if (node->type == active->type) {
break;
- else node = NULL;
+ }
+ else {
+ node = NULL;
+ }
}
- if (node)
+ if (node) {
active = node;
+ }
}
else {
if (revert) {
- if (a == 0)
+ if (a == 0) {
active = node_array[totnodes - 1];
- else
+ }
+ else {
active = node_array[a - 1];
+ }
}
else {
- if (a == totnodes - 1)
+ if (a == totnodes - 1) {
active = node_array[0];
- else
+ }
+ else {
active = node_array[a + 1];
+ }
}
}
@@ -997,8 +1048,9 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
}
}
- if (node_array)
+ if (node_array) {
MEM_freeN(node_array);
+ }
return OPERATOR_FINISHED;
}
@@ -1038,12 +1090,15 @@ static void node_find_cb(const struct bContext *C, void *UNUSED(arg), const char
if (BLI_strcasestr(node->name, str) || BLI_strcasestr(node->label, str)) {
char name[256];
- if (node->label[0])
+ if (node->label[0]) {
BLI_snprintf(name, 256, "%s (%s)", node->name, node->label);
- else
+ }
+ else {
BLI_strncpy(name, node->name, 256);
- if (false == UI_search_item_add(items, name, node, 0))
+ }
+ if (false == UI_search_item_add(items, name, node, 0)) {
break;
+ }
}
}
}
@@ -1070,8 +1125,6 @@ static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2
static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
{
static char search[256] = "";
- wmEvent event;
- wmWindow *win = CTX_wm_window(C);
uiBlock *block;
uiBut *but;
wmOperator *op = (wmOperator *)arg_op;
@@ -1081,20 +1134,14 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, "");
- UI_but_func_search_set(but, NULL, node_find_cb, op->type, node_find_call_cb, NULL);
+ UI_but_func_search_set(but, NULL, node_find_cb, op->type, false, node_find_call_cb, NULL);
+ UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
/* fake button, it holds space for search items */
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL);
- UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
-
- // UI_but_active_only(C, ar, block, but); XXX using this here makes Blender hang - investigate
- wm_event_init_from_window(win, &event);
- event.type = EVT_BUT_OPEN;
- event.val = KM_PRESS;
- event.customdata = but;
- event.customdatafree = false;
- wm_event_add(win, &event);
+ /* Move it downwards, mouse over button. */
+ UI_block_bounds_set_popup(block, 6, (const int[2]){0, -UI_UNIT_Y});
return block;
}
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index aef36b49814..aa6fb770c56 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -68,16 +68,17 @@ typedef struct NodeLinkItem {
*/
static bool node_link_item_compare(bNode *node, NodeLinkItem *item)
{
- if (node->type == NODE_GROUP) {
+ if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
return (node->id == (ID *)item->ngroup);
}
- else
+ else {
return true;
+ }
}
static void node_link_item_apply(Main *bmain, bNode *node, NodeLinkItem *item)
{
- if (node->type == NODE_GROUP) {
+ if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
node->id = (ID *)item->ngroup;
ntreeUpdateTree(bmain, item->ngroup);
}
@@ -85,36 +86,43 @@ static void node_link_item_apply(Main *bmain, bNode *node, NodeLinkItem *item)
/* nothing to do for now */
}
- if (node->id)
+ if (node->id) {
id_us_plus(node->id);
+ }
}
static void node_tag_recursive(bNode *node)
{
bNodeSocket *input;
- if (!node || (node->flag & NODE_TEST))
+ if (!node || (node->flag & NODE_TEST)) {
return; /* in case of cycles */
+ }
node->flag |= NODE_TEST;
- for (input = node->inputs.first; input; input = input->next)
- if (input->link)
+ for (input = node->inputs.first; input; input = input->next) {
+ if (input->link) {
node_tag_recursive(input->link->fromnode);
+ }
+ }
}
static void node_clear_recursive(bNode *node)
{
bNodeSocket *input;
- if (!node || !(node->flag & NODE_TEST))
+ if (!node || !(node->flag & NODE_TEST)) {
return; /* in case of cycles */
+ }
node->flag &= ~NODE_TEST;
- for (input = node->inputs.first; input; input = input->next)
- if (input->link)
+ for (input = node->inputs.first; input; input = input->next) {
+ if (input->link) {
node_clear_recursive(input->link->fromnode);
+ }
+ }
}
static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node)
@@ -122,30 +130,34 @@ static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node)
bNode *node, *next;
bNodeSocket *sock;
- if (!rem_node)
+ if (!rem_node) {
return;
+ }
/* tag linked nodes to be removed */
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
node->flag &= ~NODE_TEST;
+ }
node_tag_recursive(rem_node);
/* clear tags on nodes that are still used by other nodes */
- for (node = ntree->nodes.first; node; node = node->next)
- if (!(node->flag & NODE_TEST))
- for (sock = node->inputs.first; sock; sock = sock->next)
- if (sock->link && sock->link->fromnode != rem_node)
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (!(node->flag & NODE_TEST)) {
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (sock->link && sock->link->fromnode != rem_node) {
node_clear_recursive(sock->link->fromnode);
+ }
+ }
+ }
+ }
/* remove nodes */
for (node = ntree->nodes.first; node; node = next) {
next = node->next;
if (node->flag & NODE_TEST) {
- if (node->id)
- id_us_min(node->id);
- nodeDeleteNode(bmain, ntree, node);
+ nodeRemoveNode(bmain, ntree, node, true);
}
}
}
@@ -153,8 +165,9 @@ static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node)
/* disconnect socket from the node it is connected to */
static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to)
{
- if (!sock_to->link)
+ if (!sock_to->link) {
return;
+ }
nodeRemLink(ntree, sock_to->link);
sock_to->flag |= SOCK_COLLAPSED;
@@ -168,8 +181,9 @@ static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to
/* remove all nodes connected to this socket, if they aren't connected to other nodes */
static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to)
{
- if (!sock_to->link)
+ if (!sock_to->link) {
return;
+ }
node_remove_linked(bmain, ntree, sock_to->link->fromnode);
sock_to->flag |= SOCK_COLLAPSED;
@@ -196,13 +210,17 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *
}
/* find existing node that we can use */
- for (node_from = ntree->nodes.first; node_from; node_from = node_from->next)
- if (node_from->type == type)
+ for (node_from = ntree->nodes.first; node_from; node_from = node_from->next) {
+ if (node_from->type == type) {
break;
+ }
+ }
- if (node_from)
- if (node_from->inputs.first || node_from->typeinfo->draw_buttons || node_from->typeinfo->draw_buttons_ex)
+ if (node_from) {
+ if (node_from->inputs.first || node_from->typeinfo->draw_buttons || node_from->typeinfo->draw_buttons_ex) {
node_from = NULL;
+ }
+ }
if (node_prev && node_prev->type == type && node_link_item_compare(node_prev, item)) {
/* keep the previous node if it's the same type */
@@ -238,8 +256,9 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *
for (sock_prev = node_prev->inputs.first; sock_prev; sock_prev = sock_prev->next) {
for (sock_from = node_from->inputs.first; sock_from; sock_from = sock_from->next) {
- if (nodeCountSocketLinks(ntree, sock_from) >= sock_from->limit)
+ if (nodeCountSocketLinks(ntree, sock_from) >= sock_from->limit) {
continue;
+ }
if (STREQ(sock_prev->name, sock_from->name) && sock_prev->type == sock_from->type) {
bNodeLink *link = sock_prev->link;
@@ -334,8 +353,9 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it
bNodeSocketTemplate *stemp;
int i;
- for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp)
+ for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp) {
++totitems;
+ }
if (totitems > 0) {
items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
@@ -365,12 +385,15 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p)
bNodeTree *ntree = arg->ntree;
int event = POINTER_AS_INT(event_p);
- if (event == UI_NODE_LINK_DISCONNECT)
+ if (event == UI_NODE_LINK_DISCONNECT) {
node_socket_disconnect(bmain, ntree, node_to, sock_to);
- else if (event == UI_NODE_LINK_REMOVE)
+ }
+ else if (event == UI_NODE_LINK_REMOVE) {
node_socket_remove(bmain, ntree, node_to, sock_to);
- else
+ }
+ else {
node_socket_add_replace(C, ntree, node_to, sock_to, arg->node_type->type, &arg->item);
+ }
ED_undo_push(C, "Node input modify");
}
@@ -392,10 +415,12 @@ static void ui_node_sock_name(bNodeTree *ntree, bNodeSocket *sock, char name[UI_
BLI_strncpy(name, IFACE_(node_name), UI_MAX_NAME_STR);
}
}
- else if (sock->type == SOCK_SHADER)
+ else if (sock->type == SOCK_SHADER) {
BLI_strncpy(name, IFACE_("None"), UI_MAX_NAME_STR);
- else
+ }
+ else {
BLI_strncpy(name, IFACE_("Default"), UI_MAX_NAME_STR);
+ }
}
static int ui_compatible_sockets(int typeA, int typeB)
@@ -471,13 +496,16 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
ui_node_link_items(arg, SOCK_OUT, &items, &totitems);
- for (i = 0; i < totitems; ++i)
- if (ui_compatible_sockets(items[i].socket_type, sock->type))
+ for (i = 0; i < totitems; ++i) {
+ if (ui_compatible_sockets(items[i].socket_type, sock->type)) {
num++;
+ }
+ }
for (i = 0; i < totitems; ++i) {
- if (!ui_compatible_sockets(items[i].socket_type, sock->type))
+ if (!ui_compatible_sockets(items[i].socket_type, sock->type)) {
continue;
+ }
if (first) {
column = uiLayoutColumn(layout, 0);
@@ -514,8 +542,9 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
UI_but_funcN_set(but, ui_node_link, argN, NULL);
}
- if (items)
+ if (items) {
MEM_freeN(items);
+ }
}
BLI_array_free(sorted_ntypes);
@@ -525,8 +554,9 @@ static void node_menu_column_foreach_cb(void *calldata, int nclass, const char *
{
NodeLinkArg *arg = (NodeLinkArg *)calldata;
- if (!ELEM(nclass, NODE_CLASS_GROUP, NODE_CLASS_LAYOUT))
+ if (!ELEM(nclass, NODE_CLASS_GROUP, NODE_CLASS_LAYOUT)) {
ui_node_menu_column(arg, nclass, name);
+ }
}
static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_p)
@@ -548,8 +578,9 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
arg->scene = scene;
arg->layout = split;
- if (ntreetype && ntreetype->foreach_nodeclass)
+ if (ntreetype && ntreetype->foreach_nodeclass) {
ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb);
+ }
column = uiLayoutColumn(split, false);
UI_block_layout_set_current(block, column);
@@ -589,8 +620,9 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo
ui_node_sock_name(ntree, sock, name);
but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, "");
}
- else
+ else {
but = uiDefIconMenuBut(block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, "");
+ }
UI_but_type_set_menu_from_pulldown(but);
@@ -598,9 +630,11 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo
but->poin = (char *)but;
but->func_argN = arg;
- if (sock->link && sock->link->fromnode)
- if (sock->link->fromnode->flag & NODE_ACTIVE_TEXTURE)
+ if (sock->link && sock->link->fromnode) {
+ if (sock->link->fromnode->flag & NODE_ACTIVE_TEXTURE) {
but->flag |= UI_BUT_NODE_ACTIVE;
+ }
+ }
}
/**************************** Node Tree Layout *******************************/
@@ -626,8 +660,9 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b
}
}
- for (input = node->inputs.first; input; input = input->next)
+ for (input = node->inputs.first; input; input = input->next) {
ui_node_draw_input(layout, C, ntree, node, input, depth + 1);
+ }
}
static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth)
@@ -641,16 +676,18 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
int i, indent = (depth > 1) ? 2 * (depth - 1) : 0;
int dependency_loop;
- if (input->flag & SOCK_UNAVAIL)
+ if (input->flag & SOCK_UNAVAIL) {
return;
+ }
/* to avoid eternal loops on cyclic dependencies */
node->flag |= NODE_TEST;
lnode = (input->link) ? input->link->fromnode : NULL;
dependency_loop = (lnode && (lnode->flag & NODE_TEST));
- if (dependency_loop)
+ if (dependency_loop) {
lnode = NULL;
+ }
/* socket RNA pointer */
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, input, &inputptr);
@@ -675,8 +712,9 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
int icon = (input->flag & SOCK_COLLAPSED) ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN;
uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon);
}
- else
+ else {
uiItemL(row, "", ICON_BLANK1);
+ }
bt = block->buttons.last;
bt->rect.xmax = UI_UNIT_X / 2;
@@ -697,8 +735,9 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
uiTemplateNodeLink(split, ntree, node, input);
if (depth == 0 || !(input->flag & SOCK_COLLAPSED)) {
- if (depth == 0)
+ if (depth == 0) {
uiItemS(layout);
+ }
ui_node_draw_node(layout, C, ntree, lnode, depth);
}
@@ -726,8 +765,9 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
break;
}
}
- else
+ else {
row = uiLayoutRow(split, false);
+ }
uiTemplateNodeLink(row, ntree, node, input);
}
@@ -740,15 +780,19 @@ void uiTemplateNodeView(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *
{
bNode *tnode;
- if (!ntree)
+ if (!ntree) {
return;
+ }
/* clear for cycle check */
- for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
+ for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
tnode->flag &= ~NODE_TEST;
+ }
- if (input)
+ if (input) {
ui_node_draw_input(layout, C, ntree, node, input, 0);
- else
+ }
+ else {
ui_node_draw_node(layout, C, ntree, node, 0);
+ }
}
diff --git a/source/blender/editors/space_node/node_toolbar.c b/source/blender/editors/space_node/node_toolbar.c
index e2effc84870..dae8024611a 100644
--- a/source/blender/editors/space_node/node_toolbar.c
+++ b/source/blender/editors/space_node/node_toolbar.c
@@ -49,8 +49,9 @@ 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)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index d0e6c45bb07..9d4b9d18c2a 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -581,8 +581,9 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ARegion *ar = CTX_wm_region(C);
ImageSampleInfo *info;
- if (!ED_node_is_compositor(snode) || !(snode->flag & SNODE_BACKDRAW))
+ if (!ED_node_is_compositor(snode) || !(snode->flag & SNODE_BACKDRAW)) {
return OPERATOR_CANCELLED;
+ }
info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
info->art = ar->type;
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index fc8d880080d..22564061aed 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -75,8 +75,9 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from)
/* copy initial offset from bNodeTree */
copy_v2_v2(path->view_center, ntree->view_center);
- if (id)
+ if (id) {
BLI_strncpy(path->node_name, id->name + 2, sizeof(path->node_name));
+ }
BLI_addtail(&snode->treepath, path);
@@ -99,15 +100,18 @@ void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode)
bNodeTreePath *prev_path = snode->treepath.last;
path->nodetree = ntree;
if (gnode) {
- if (prev_path)
+ if (prev_path) {
path->parent_key = BKE_node_instance_key(prev_path->parent_key, prev_path->nodetree, gnode);
- else
+ }
+ else {
path->parent_key = NODE_INSTANCE_KEY_BASE;
+ }
BLI_strncpy(path->node_name, gnode->name, sizeof(path->node_name));
}
- else
+ else {
path->parent_key = NODE_INSTANCE_KEY_BASE;
+ }
/* copy initial offset from bNodeTree */
copy_v2_v2(path->view_center, ntree->view_center);
@@ -129,8 +133,9 @@ void ED_node_tree_pop(SpaceNode *snode)
bNodeTreePath *path = snode->treepath.last;
/* don't remove root */
- if (path == snode->treepath.first)
+ if (path == snode->treepath.first) {
return;
+ }
BLI_remlink(&snode->treepath, path);
MEM_freeN(path);
@@ -155,8 +160,9 @@ bNodeTree *ED_node_tree_get(SpaceNode *snode, int level)
bNodeTreePath *path;
int i;
for (path = snode->treepath.last, i = 0; path; path = path->prev, ++i) {
- if (i == level)
+ if (i == level) {
return path->nodetree;
+ }
}
return NULL;
}
@@ -168,8 +174,9 @@ int ED_node_tree_path_length(SpaceNode *snode)
int i;
for (path = snode->treepath.first, i = 0; path; path = path->next, ++i) {
length += strlen(path->node_name);
- if (i > 0)
+ if (i > 0) {
length += 1; /* for separator char */
+ }
}
return length;
}
@@ -206,8 +213,9 @@ void ED_node_tree_path_get_fixedbuf(SpaceNode *snode, char *value, int max_lengt
size = BLI_snprintf_rlen(value, max_length, "/%s", path->node_name);
}
max_length -= size;
- if (max_length <= 0)
+ if (max_length <= 0) {
break;
+ }
value += size;
}
}
@@ -230,8 +238,9 @@ void snode_group_offset(SpaceNode *snode, float *x, float *y)
*x = dcenter[0];
*y = dcenter[1];
}
- else
+ else {
*x = *y = 0.0f;
+ }
}
/* ******************** manage regions ********************* */
@@ -241,13 +250,17 @@ ARegion *node_has_buttons_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) return 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) return NULL;
+ if (ar == NULL) {
+ return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "buttons for node");
@@ -265,13 +278,17 @@ ARegion *node_has_tools_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
- if (ar) return 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) return NULL;
+ if (ar == NULL) {
+ return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "node tools");
@@ -393,8 +410,9 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
bNodeTreePath *path = snode->treepath.last;
/* shift view to node tree center */
- if (ar && path)
+ if (ar && path) {
UI_view2d_center_set(&ar->v2d, path->view_center[0], path->view_center[1]);
+ }
ED_area_tag_refresh(sa);
break;
@@ -422,21 +440,26 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w
/* future: add ID checks? */
case NC_MATERIAL:
if (ED_node_is_shader(snode)) {
- if (wmn->data == ND_SHADING)
+ if (wmn->data == ND_SHADING) {
ED_area_tag_refresh(sa);
- else if (wmn->data == ND_SHADING_DRAW)
+ }
+ else if (wmn->data == ND_SHADING_DRAW) {
ED_area_tag_refresh(sa);
- else if (wmn->data == ND_SHADING_LINKS)
+ }
+ else if (wmn->data == ND_SHADING_LINKS) {
ED_area_tag_refresh(sa);
- else if (wmn->action == NA_ADDED && snode->edittree)
+ }
+ else if (wmn->action == NA_ADDED && snode->edittree) {
nodeSetActiveID(snode->edittree, ID_MA, wmn->reference);
+ }
}
break;
case NC_TEXTURE:
if (ED_node_is_shader(snode) || ED_node_is_texture(snode)) {
- if (wmn->data == ND_NODES)
+ if (wmn->data == ND_NODES) {
ED_area_tag_refresh(sa);
+ }
}
break;
case NC_WORLD:
@@ -446,21 +469,26 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w
break;
case NC_OBJECT:
if (ED_node_is_shader(snode)) {
- if (wmn->data == ND_OB_SHADING)
+ if (wmn->data == ND_OB_SHADING) {
ED_area_tag_refresh(sa);
+ }
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_NODE)
+ if (wmn->data == ND_SPACE_NODE) {
ED_area_tag_refresh(sa);
- else if (wmn->data == ND_SPACE_NODE_VIEW)
+ }
+ else if (wmn->data == ND_SPACE_NODE_VIEW) {
ED_area_tag_redraw(sa);
+ }
break;
case NC_NODE:
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_area_tag_refresh(sa);
- else if (wmn->action == NA_SELECTED)
+ }
+ else if (wmn->action == NA_SELECTED) {
ED_area_tag_redraw(sa);
+ }
break;
case NC_SCREEN:
switch (wmn->data) {
@@ -483,8 +511,9 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w
/* note that nodeUpdateID is already called by BKE_image_signal() on all
* scenes so really this is just to know if the images is used in the compo else
* painting on images could become very slow when the compositor is open. */
- if (nodeUpdateID(snode->nodetree, wmn->reference))
+ if (nodeUpdateID(snode->nodetree, wmn->reference)) {
ED_area_tag_refresh(sa);
+ }
}
}
break;
@@ -492,8 +521,9 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w
case NC_MOVIECLIP:
if (wmn->action == NA_EDITED) {
if (ED_node_is_compositor(snode)) {
- if (nodeUpdateID(snode->nodetree, wmn->reference))
+ if (nodeUpdateID(snode->nodetree, wmn->reference)) {
ED_area_tag_refresh(sa);
+ }
}
}
break;
@@ -527,18 +557,21 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa)
if (snode->nodetree->type == NTREE_SHADER) {
if (GS(snode->id->name) == ID_MA) {
Material *ma = (Material *)snode->id;
- if (ma->use_nodes)
+ if (ma->use_nodes) {
ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
+ }
}
else if (GS(snode->id->name) == ID_LA) {
Light *la = (Light *)snode->id;
- if (la->use_nodes)
+ if (la->use_nodes) {
ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
+ }
}
else if (GS(snode->id->name) == ID_WO) {
World *wo = (World *)snode->id;
- if (wo->use_nodes)
+ if (wo->use_nodes) {
ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
+ }
}
}
else if (snode->nodetree->type == NTREE_COMPOSIT) {
@@ -755,8 +788,9 @@ static void node_region_listener(
}
break;
case NC_WM:
- if (wmn->data == ND_JOB)
+ if (wmn->data == ND_JOB) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCENE:
ED_region_tag_redraw(ar);
@@ -777,23 +811,29 @@ static void node_region_listener(
ED_region_tag_redraw(ar);
break;
case NC_OBJECT:
- if (wmn->data == ND_OB_SHADING)
+ if (wmn->data == ND_OB_SHADING) {
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;
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;
}
}
-const char *node_context_dir[] = {"selected_nodes", "active_node", NULL};
+const char *node_context_dir[] = {
+ "selected_nodes", "active_node", "light", "material", "world", NULL
+};
static int node_context(const bContext *C, const char *member, bContextDataResult *result)
{
@@ -833,6 +873,24 @@ static int node_context(const bContext *C, const char *member, bContextDataResul
CTX_data_type_set(result, CTX_DATA_TYPE_POINTER);
return 1;
}
+ else if (CTX_data_equals(member, "material")) {
+ if (snode->id && GS(snode->id->name) == ID_MA) {
+ CTX_data_id_pointer_set(result, snode->id);
+ }
+ return 1;
+ }
+ else if (CTX_data_equals(member, "light")) {
+ if (snode->id && GS(snode->id->name) == ID_LA) {
+ CTX_data_id_pointer_set(result, snode->id);
+ }
+ return 1;
+ }
+ else if (CTX_data_equals(member, "world")) {
+ if (snode->id && GS(snode->id->name) == ID_WO) {
+ CTX_data_id_pointer_set(result, snode->id);
+ }
+ return 1;
+ }
return 0;
}
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 7377faa09ac..30eaefe6149 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -195,10 +195,15 @@ static int collection_new_exec(bContext *C, wmOperator *op)
}
}
- if (data.collection == NULL) {
+ if (data.collection == NULL || ID_IS_LINKED(data.collection)) {
data.collection = BKE_collection_master(scene);
}
+ if (ID_IS_LINKED(scene)) {
+ BKE_report(op->reports, RPT_ERROR, "Can't add a new collection to linked scene/collection");
+ return OPERATOR_CANCELLED;
+ }
+
BKE_collection_add(
bmain,
data.collection,
@@ -285,7 +290,39 @@ 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) {
- BKE_collection_delete(bmain, collection, hierarchy);
+ /* 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) {
+ skip = true;
+ }
+ else {
+ for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) {
+ Collection *parent = cparent->collection;
+ if (ID_IS_LINKED(parent)) {
+ skip = true;
+ break;
+ }
+ else if (parent->flag & COLLECTION_IS_MASTER) {
+ Scene *parent_scene = BKE_collection_master_scene_search(bmain, parent);
+ if (ID_IS_LINKED(parent_scene)) {
+ skip = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!skip) {
+ BKE_collection_delete(bmain, collection, hierarchy);
+ }
+ else {
+ BKE_reportf(op->reports, RPT_WARNING,
+ "Cannot delete linked collection '%s', it is used by other linked scenes/collections",
+ collection->id.name + 2);
+ }
}
}
@@ -446,9 +483,7 @@ static TreeElement *outliner_active_collection(bContext *C)
static int collection_duplicate_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- SpaceOutliner *soops = CTX_wm_space_outliner(C);
TreeElement *te = outliner_active_collection(C);
- const bool hierarchy = strstr(op->idname, "hierarchy") != NULL;
const bool linked = strstr(op->idname, "linked") != NULL;
/* Can happen when calling from a key binding. */
@@ -460,40 +495,41 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op)
Collection *collection = outliner_collection_from_tree_element(te);
Collection *parent = (te->parent) ? outliner_collection_from_tree_element(te->parent) : NULL;
+ /* We are allowed to duplicated linked collections (they will become local IDs then),
+ * but we should not allow its parent to be a linked ID, ever.
+ * This can happen when a whole scene is linked e.g. */
+ if (parent != NULL && ID_IS_LINKED(parent)) {
+ Scene *scene = CTX_data_scene(C);
+ parent = ID_IS_LINKED(scene) ? NULL : BKE_collection_master(scene);
+ }
+ else if (parent != NULL && (parent->flag & COLLECTION_IS_MASTER) != 0) {
+ Scene *scene = BKE_collection_master_scene_search(bmain, parent);
+ BLI_assert(scene != NULL);
+ if (ID_IS_LINKED(scene)) {
+ scene = CTX_data_scene(C);
+ parent = ID_IS_LINKED(scene) ? NULL : BKE_collection_master(scene);
+ }
+ }
+
if (collection->flag & COLLECTION_IS_MASTER) {
BKE_report(op->reports, RPT_ERROR, "Can't duplicate the master collection");
return OPERATOR_CANCELLED;
}
- switch (soops->outlinevis) {
- case SO_SCENES:
- case SO_VIEW_LAYER:
- case SO_LIBRARIES:
- BKE_collection_duplicate(bmain, parent, collection, true, !hierarchy, !linked);
- break;
+ if (parent == NULL) {
+ BKE_report(op->reports, RPT_WARNING,
+ "Could not find a valid parent collection for the new duplicate, "
+ "it won't be linked to any view layer");
}
+ BKE_collection_duplicate(bmain, parent, collection, true, true, !linked);
+
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_LAYER, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
-void OUTLINER_OT_collection_duplicate_hierarchy(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Duplicate Collection Hierarchy";
- ot->idname = "OUTLINER_OT_collection_duplicate_hierarchy";
- ot->description = "Recursively duplicate the collection and all its children, with linked objects";
-
- /* api callbacks */
- ot->exec = collection_duplicate_exec;
- ot->poll = ED_outliner_collections_editor_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
void OUTLINER_OT_collection_duplicate_linked(wmOperatorType *ot)
{
/* identifiers */
@@ -526,7 +562,7 @@ void OUTLINER_OT_collection_duplicate(wmOperatorType *ot)
/**************************** Link Collection ******************************/
-static int collection_link_exec(bContext *C, wmOperator *UNUSED(op))
+static int collection_link_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -534,6 +570,13 @@ static int collection_link_exec(bContext *C, wmOperator *UNUSED(op))
SpaceOutliner *soops = CTX_wm_space_outliner(C);
struct CollectionEditData data = {.scene = scene, .soops = soops,};
+ if (ID_IS_LINKED(active_collection) ||
+ ((active_collection->flag & COLLECTION_IS_MASTER) && ID_IS_LINKED(scene)))
+ {
+ BKE_report(op->reports, RPT_ERROR, "Cannot add a colection to a linked collection/scene");
+ return OPERATOR_CANCELLED;
+ }
+
data.collections_to_edit = BLI_gset_ptr_new(__func__);
/* We first walk over and find the Collections we actually want to link (ignoring duplicates). */
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index d9dc0d182c7..647fdeccb40 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -73,15 +73,17 @@ static TreeElement *outliner_dropzone_element(TreeElement *te, const float fmval
{
if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) {
/* name and first icon */
- if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend))
+ if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) {
return te;
+ }
}
/* Not it. Let's look at its children. */
if (children && (TREESTORE(te)->flag & TSE_CLOSED) == 0 && (te->subtree.first)) {
for (te = te->subtree.first; te; te = te->next) {
TreeElement *te_valid = outliner_dropzone_element(te, fmval, children);
- if (te_valid)
+ if (te_valid) {
return te_valid;
+ }
}
}
return NULL;
@@ -94,8 +96,9 @@ static TreeElement *outliner_dropzone_find(const SpaceOutliner *soops, const flo
for (te = soops->tree.first; te; te = te->next) {
TreeElement *te_valid = outliner_dropzone_element(te, fmval, children);
- if (te_valid)
+ if (te_valid) {
return te_valid;
+ }
}
return NULL;
}
@@ -204,11 +207,15 @@ static TreeElement *outliner_drop_insert_collection_find(
TreeElementInsertType *r_insert_type)
{
TreeElement *te = outliner_drop_insert_find(C, event, r_insert_type);
- if (!te) return NULL;
+ if (!te) {
+ return NULL;
+ }
TreeElement *collection_te;
Collection *collection = outliner_collection_from_tree_element_and_parents(te, &collection_te);
- if (!collection) return NULL;
+ if (!collection) {
+ return NULL;
+ }
if (collection_te != te) {
*r_insert_type = TE_INSERT_INTO;
@@ -233,9 +240,15 @@ static bool parent_drop_allowed(SpaceOutliner *soops, TreeElement *te, Object *p
Object *potential_parent = (Object *)tselem->id;
- if (potential_parent == potential_child) return false;
- if (BKE_object_is_child_recursive(potential_child, potential_parent)) return false;
- if (potential_parent == potential_child->parent) return false;
+ if (potential_parent == potential_child) {
+ return false;
+ }
+ if (BKE_object_is_child_recursive(potential_child, potential_parent)) {
+ return false;
+ }
+ if (potential_parent == potential_child->parent) {
+ return false;
+ }
/* check that parent/child are both in the same scene */
Scene *scene = (Scene *)outliner_search_back(soops, te, ID_SCE);
@@ -276,17 +289,25 @@ static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, co
SpaceOutliner *soops = CTX_wm_space_outliner(C);
bool changed = outliner_flag_set(&soops->tree, TSE_DRAG_ANY, false);
- if (changed) ED_region_tag_redraw_no_rebuild(CTX_wm_region(C));
+ if (changed) {
+ ED_region_tag_redraw_no_rebuild(CTX_wm_region(C));
+ }
Object *potential_child = (Object *)WM_drag_ID(drag, ID_OB);
- if (!potential_child) return false;
+ if (!potential_child) {
+ return false;
+ }
if (!allow_parenting_without_modifier_key(soops)) {
- if (!event->shift) return false;
+ if (!event->shift) {
+ return false;
+ }
}
TreeElement *te = outliner_drop_find(C, event);
- if (!te) return false;
+ if (!te) {
+ return false;
+ }
if (parent_drop_allowed(soops, te, potential_child)) {
TREESTORE(te)->flag |= TSE_DRAG_INTO;
@@ -476,18 +497,26 @@ static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event, c
SpaceOutliner *soops = CTX_wm_space_outliner(C);
if (!allow_parenting_without_modifier_key(soops)) {
- if (!event->shift) return false;
+ if (!event->shift) {
+ return false;
+ }
}
Object *ob = (Object *)WM_drag_ID(drag, ID_OB);
- if (!ob) return false;
- if (!ob->parent) return false;
+ if (!ob) {
+ return false;
+ }
+ if (!ob->parent) {
+ return false;
+ }
TreeElement *te = outliner_drop_find(C, event);
if (te) {
TreeStoreElem *tselem = TREESTORE(te);
ID *id = tselem->id;
- if (!id) return true;
+ if (!id) {
+ return true;
+ }
switch (GS(id->name)) {
case ID_OB:
@@ -620,6 +649,11 @@ static int material_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve
return OPERATOR_CANCELLED;
}
+ /* only drop grease pencil material on grease pencil objects */
+ if ((ma->gp_style != NULL) && (ob->type != OB_GPENCIL)) {
+ return OPERATOR_CANCELLED;
+ }
+
assign_material(bmain, ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
@@ -772,11 +806,15 @@ static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event
break;
}
}
- if (changed) ED_region_tag_redraw_no_rebuild(ar);
+ if (changed) {
+ ED_region_tag_redraw_no_rebuild(ar);
+ }
return true;
}
else {
- if (changed) ED_region_tag_redraw_no_rebuild(ar);
+ if (changed) {
+ ED_region_tag_redraw_no_rebuild(ar);
+ }
return false;
}
}
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 489221f5a5c..fdd0936a93d 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -125,8 +125,9 @@ static void outliner_rna_width(SpaceOutliner *soops, ListBase *lb, int *w, int s
*w = te->xend;
}
#endif
- if (startx + 100 > *w)
+ if (startx + 100 > *w) {
*w = startx + 100;
+ }
if (TSELEM_OPEN(tselem, soops)) {
outliner_rna_width(soops, &te->subtree, w, startx + UI_UNIT_X);
@@ -194,8 +195,9 @@ static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2)
static void restrictbutton_bone_visibility_cb(bContext *C, void *UNUSED(poin), void *poin2)
{
Bone *bone = (Bone *)poin2;
- if (bone->flag & BONE_HIDDEN_P)
+ if (bone->flag & BONE_HIDDEN_P) {
bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
if (CTX_wm_window(C)->eventstate->ctrl) {
restrictbutton_recursive_bone(bone, BONE_HIDDEN_P, (bone->flag & BONE_HIDDEN_P) != 0);
@@ -207,8 +209,9 @@ static void restrictbutton_bone_visibility_cb(bContext *C, void *UNUSED(poin), v
static void restrictbutton_bone_select_cb(bContext *C, void *UNUSED(poin), void *poin2)
{
Bone *bone = (Bone *)poin2;
- if (bone->flag & BONE_UNSELECTABLE)
+ if (bone->flag & BONE_UNSELECTABLE) {
bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
if (CTX_wm_window(C)->eventstate->ctrl) {
restrictbutton_recursive_bone(bone, BONE_UNSELECTABLE, (bone->flag & BONE_UNSELECTABLE) != 0);
@@ -355,6 +358,7 @@ static int layer_collection_pushed_state_cb(bContext *UNUSED(C), void *poin)
static void hidebutton_layer_collection_flag_cb(bContext *C, void *poin, void *poin2)
{
+ Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = poin;
@@ -384,7 +388,8 @@ static void hidebutton_layer_collection_flag_cb(bContext *C, void *poin, void *p
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
if (depsgraph_changed) {
- DEG_relations_tag_update(CTX_data_main(C));
+ BKE_main_collection_sync_remap(bmain);
+ DEG_relations_tag_update(bmain);
}
WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL);
}
@@ -798,8 +803,9 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOutliner *s
char buf[16] = "";
int but_flag = UI_BUT_DRAG_LOCK;
- if (ID_IS_LINKED(id))
+ if (ID_IS_LINKED(id)) {
but_flag |= UI_BUT_DISABLED;
+ }
if (id->flag & LIB_FAKEUSER) {
icon = ICON_FILE_TICK;
@@ -848,7 +854,9 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex)
View2D *v2d = &ar->v2d;
float miny = v2d->cur.ymin;
- if (miny < v2d->tot.ymin) miny = v2d->tot.ymin;
+ if (miny < v2d->tot.ymin) {
+ miny = v2d->tot.ymin;
+ }
GPU_line_width(1.0f);
@@ -929,10 +937,18 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Tre
* need change this.
*/
- if (tselem->type == TSE_EBONE) len = sizeof(((EditBone *) 0)->name);
- else if (tselem->type == TSE_MODIFIER) len = sizeof(((ModifierData *) 0)->name);
- else if (tselem->id && GS(tselem->id->name) == ID_LI) len = sizeof(((Library *) 0)->name);
- else len = MAX_ID_NAME - 2;
+ if (tselem->type == TSE_EBONE) {
+ len = sizeof(((EditBone *) 0)->name);
+ }
+ else if (tselem->type == TSE_MODIFIER) {
+ len = sizeof(((ModifierData *) 0)->name);
+ }
+ else if (tselem->id && GS(tselem->id->name) == ID_LI) {
+ len = sizeof(((Library *) 0)->name);
+ }
+ else {
+ len = MAX_ID_NAME - 2;
+ }
spx = te->xs + 1.8f * UI_UNIT_X;
dx = ar->v2d.cur.xmax - (spx + 3.2f * UI_UNIT_X);
@@ -1241,18 +1257,24 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
data.icon = ICON_GROUP_BONE;
break;
case TSE_SEQUENCE:
- if (te->idcode == SEQ_TYPE_MOVIE)
+ if (te->idcode == SEQ_TYPE_MOVIE) {
data.icon = ICON_SEQUENCE;
- else if (te->idcode == SEQ_TYPE_META)
+ }
+ else if (te->idcode == SEQ_TYPE_META) {
data.icon = ICON_DOT;
- else if (te->idcode == SEQ_TYPE_SCENE)
+ }
+ else if (te->idcode == SEQ_TYPE_SCENE) {
data.icon = ICON_SCENE;
- else if (te->idcode == SEQ_TYPE_SOUND_RAM)
+ }
+ else if (te->idcode == SEQ_TYPE_SOUND_RAM) {
data.icon = ICON_SOUND;
- else if (te->idcode == SEQ_TYPE_IMAGE)
+ }
+ else if (te->idcode == SEQ_TYPE_IMAGE) {
data.icon = ICON_IMAGE;
- else
+ }
+ else {
data.icon = ICON_PARTICLES;
+ }
break;
case TSE_SEQ_STRIP:
data.icon = ICON_LIBRARY_DATA_DIRECT;
@@ -1602,8 +1624,9 @@ static void outliner_draw_iconrow(
for (TreeElement *te = lb->first; te; te = te->next) {
/* exit drawing early */
- if ((*offsx) - UI_UNIT_X > xmax)
+ if ((*offsx) - UI_UNIT_X > xmax) {
break;
+ }
TreeStoreElem *tselem = TREESTORE(te);
@@ -1711,8 +1734,9 @@ static void outliner_draw_tree_element(
}
/* icons can be ui buts, we don't want it to overlap with restrict */
- if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0)
+ if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) {
xmax -= OL_TOGW + UI_UNIT_X;
+ }
GPU_blend(true);
@@ -1809,8 +1833,9 @@ static void outliner_draw_tree_element(
tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, alpha_fac, true);
offsx += UI_UNIT_X + 4 * ufac;
}
- else
+ else {
offsx += 2 * ufac;
+ }
if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION) && ID_IS_LINKED(tselem->id)) {
if (tselem->id->tag & LIB_TAG_MISSING) {
@@ -1966,10 +1991,11 @@ static void outliner_draw_hierarchy_lines_recursive(
*starty -= UI_UNIT_Y;
- if (TSELEM_OPEN(tselem, soops))
+ if (TSELEM_OPEN(tselem, soops)) {
outliner_draw_hierarchy_lines_recursive(
pos, soops, &te->subtree, startx + UI_UNIT_X,
col, draw_childs_grayed_out, starty);
+ }
}
if (draw_grayed_out) {
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index a96d5ad183f..8b8dff9dc27 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -40,6 +40,8 @@
#include "BLT_translation.h"
#include "BKE_animsys.h"
+#include "BKE_appdir.h"
+#include "BKE_blender_copybuffer.h"
#include "BKE_collection.h"
#include "BKE_context.h"
#include "BKE_idcode.h"
@@ -139,16 +141,21 @@ static int do_outliner_item_openclose(bContext *C, SpaceOutliner *soops, TreeEle
outliner_flag_set(&te->subtree, TSE_CLOSED, !outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1));
}
else {
- if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED;
- else tselem->flag |= TSE_CLOSED;
+ if (tselem->flag & TSE_CLOSED) {
+ tselem->flag &= ~TSE_CLOSED;
+ }
+ else {
+ tselem->flag |= TSE_CLOSED;
+ }
}
return 1;
}
for (te = te->subtree.first; te; te = te->next) {
- if (do_outliner_item_openclose(C, soops, te, all, mval))
+ if (do_outliner_item_openclose(C, soops, te, all, mval)) {
return 1;
+ }
}
return 0;
@@ -166,8 +173,9 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, const wmEvent *e
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
for (te = soops->tree.first; te; te = te->next) {
- if (do_outliner_item_openclose(C, soops, te, all, fmval))
+ if (do_outliner_item_openclose(C, soops, te, all, fmval)) {
break;
+ }
}
ED_region_tag_redraw(ar);
@@ -246,7 +254,7 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem,
/* can't rename rna datablocks entries or listbases */
if (ELEM(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM, TSE_ID_BASE, TSE_SCENE_OBJECTS_BASE)) {
- /* do nothing */;
+ /* do nothing */
}
else if (ELEM(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE,
TSE_DRIVER_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_SCENE_COLLECTION_BASE,
@@ -306,7 +314,9 @@ static int do_outliner_item_rename(ReportList *reports, ARegion *ar, TreeElement
}
for (te = te->subtree.first; te; te = te->next) {
- if (do_outliner_item_rename(reports, ar, te, mval)) return 1;
+ if (do_outliner_item_rename(reports, ar, te, mval)) {
+ return 1;
+ }
}
return 0;
}
@@ -592,6 +602,104 @@ void id_remap_cb(
WM_operator_properties_free(&op_props);
}
+/* ID copy/Paste ------------------------------------------------------------- */
+
+static int outliner_id_copy_tag(SpaceOutliner *soops, ListBase *tree)
+{
+ TreeElement *te;
+ TreeStoreElem *tselem;
+ int num_ids = 0;
+
+ for (te = tree->first; te; te = te->next) {
+ tselem = TREESTORE(te);
+
+ /* if item is selected and is an ID, tag it as needing to be copied. */
+ if (tselem->flag & TSE_SELECTED && ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) {
+ ID *id = tselem->id;
+ if (!(id->tag & LIB_TAG_DOIT)) {
+ BKE_copybuffer_tag_ID(tselem->id);
+ num_ids++;
+ }
+ }
+
+ /* go over sub-tree */
+ if (TSELEM_OPEN(tselem, soops)) {
+ num_ids += outliner_id_copy_tag(soops, &te->subtree);
+ }
+ }
+
+ return num_ids;
+}
+
+static int outliner_id_copy_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+ SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ char str[FILE_MAX];
+
+ BKE_copybuffer_begin(bmain);
+
+ const int num_ids = outliner_id_copy_tag(soops, &soops->tree);
+ if (num_ids == 0) {
+ BKE_report(op->reports, RPT_INFO, "No selected data-blocks to copy");
+ return OPERATOR_CANCELLED;
+ }
+
+ BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend");
+ BKE_copybuffer_save(bmain, str, op->reports);
+
+ BKE_reportf(op->reports, RPT_INFO, "Copied %d selected data-blocks", num_ids);
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_id_copy(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Outliner ID Data Copy";
+ ot->idname = "OUTLINER_OT_id_copy";
+ ot->description = "Selected data-blocks are copied to the clipboard";
+
+ /* callbacks */
+ ot->exec = outliner_id_copy_exec;
+ ot->poll = ED_operator_outliner_active;
+
+ ot->flag = 0;
+}
+
+static int outliner_id_paste_exec(bContext *C, wmOperator *op)
+{
+ char str[FILE_MAX];
+ const short flag = FILE_AUTOSELECT | FILE_ACTIVE_COLLECTION;
+
+ BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend");
+
+ const int num_pasted = BKE_copybuffer_paste(C, str, flag, op->reports, 0);
+ if (num_pasted == 0) {
+ BKE_report(op->reports, RPT_INFO, "No data to paste");
+ return OPERATOR_CANCELLED;
+ }
+
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+
+ BKE_reportf(op->reports, RPT_INFO, "%d data-blocks pasted", num_pasted);
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_id_paste(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Outliner ID Data Paste";
+ ot->idname = "OUTLINER_OT_id_paste";
+ ot->description = "Data-blocks from the clipboard are pasted";
+
+ /* callbacks */
+ ot->exec = outliner_id_paste_exec;
+ ot->poll = ED_operator_outliner_active;
+
+ ot->flag = 0;
+}
+
/* Library relocate/reload --------------------------------------------------- */
static int lib_relocate(
@@ -765,7 +873,9 @@ static int outliner_count_levels(ListBase *lb, const int curlevel)
for (te = lb->first; te; te = te->next) {
lev = outliner_count_levels(&te->subtree, curlevel + 1);
- if (lev > level) level = lev;
+ if (lev > level) {
+ level = lev;
+ }
}
return level;
}
@@ -778,10 +888,14 @@ int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel)
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
- if (tselem->flag & flag) return curlevel;
+ if (tselem->flag & flag) {
+ return curlevel;
+ }
level = outliner_flag_is_any_test(&te->subtree, flag, curlevel + 1);
- if (level) return level;
+ if (level) {
+ return level;
+ }
}
return 0;
}
@@ -844,11 +958,13 @@ int common_restrict_check(bContext *C, Object *ob)
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit == ob) {
/* found object is hidden, reset */
- if (ob->restrictflag & OB_RESTRICT_VIEW)
+ if (ob->restrictflag & OB_RESTRICT_VIEW) {
ob->restrictflag &= ~OB_RESTRICT_VIEW;
+ }
/* found object is unselectable, reset */
- if (ob->restrictflag & OB_RESTRICT_SELECT)
+ if (ob->restrictflag & OB_RESTRICT_SELECT) {
ob->restrictflag &= ~OB_RESTRICT_SELECT;
+ }
return 0;
}
@@ -865,10 +981,12 @@ static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op))
SpaceOutliner *soops = CTX_wm_space_outliner(C);
ARegion *ar = CTX_wm_region(C);
- if (outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1))
+ if (outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1)) {
outliner_flag_set(&soops->tree, TSE_CLOSED, 0);
- else
+ }
+ else {
outliner_flag_set(&soops->tree, TSE_CLOSED, 1);
+ }
ED_region_tag_redraw(ar);
@@ -998,8 +1116,9 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
Object *obact = OBACT(view_layer);
- if (!obact)
+ if (!obact) {
return OPERATOR_CANCELLED;
+ }
te = outliner_find_id(so, &so->tree, &obact->id);
@@ -1030,7 +1149,9 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
/* make te->ys center of view */
ytop = te->ys + BLI_rcti_size_y(&v2d->mask) / 2;
- if (ytop > 0) ytop = 0;
+ if (ytop > 0) {
+ ytop = 0;
+ }
v2d->cur.ymax = (float)ytop;
v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask));
@@ -1066,10 +1187,13 @@ static int outliner_scroll_page_exec(bContext *C, wmOperator *op)
int dy = BLI_rcti_size_y(&ar->v2d.mask);
int up = 0;
- if (RNA_boolean_get(op->ptr, "up"))
+ if (RNA_boolean_get(op->ptr, "up")) {
up = 1;
+ }
- if (up == 0) dy = -dy;
+ if (up == 0) {
+ dy = -dy;
+ }
ar->v2d.cur.ymin += dy;
ar->v2d.cur.ymax += dy;
@@ -1219,10 +1343,14 @@ static void outliner_openclose_level(ListBase *lb, int curlevel, int level, int
tselem = TREESTORE(te);
if (open) {
- if (curlevel <= level) tselem->flag &= ~TSE_CLOSED;
+ if (curlevel <= level) {
+ tselem->flag &= ~TSE_CLOSED;
+ }
}
else {
- if (curlevel >= level) tselem->flag |= TSE_CLOSED;
+ if (curlevel >= level) {
+ tselem->flag |= TSE_CLOSED;
+ }
}
outliner_openclose_level(&te->subtree, curlevel + 1, level, open);
@@ -1238,11 +1366,17 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op)
level = outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1);
if (add == 1) {
- if (level) outliner_openclose_level(&soops->tree, 1, level, 1);
+ if (level) {
+ outliner_openclose_level(&soops->tree, 1, level, 1);
+ }
}
else {
- if (level == 0) level = outliner_count_levels(&soops->tree, 0);
- if (level) outliner_openclose_level(&soops->tree, 1, level - 1, 0);
+ if (level == 0) {
+ level = outliner_count_levels(&soops->tree, 0);
+ }
+ if (level) {
+ outliner_openclose_level(&soops->tree, 1, level - 1, 0);
+ }
}
ED_region_tag_redraw(ar);
@@ -1280,8 +1414,12 @@ static int subtree_has_objects(ListBase *lb)
for (te = lb->first; te; te = te->next) {
tselem = TREESTORE(te);
- if (tselem->type == 0 && te->idcode == ID_OB) return 1;
- if (subtree_has_objects(&te->subtree)) return 1;
+ if (tselem->type == 0 && te->idcode == ID_OB) {
+ return 1;
+ }
+ if (subtree_has_objects(&te->subtree)) {
+ return 1;
+ }
}
return 0;
}
@@ -1298,12 +1436,20 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOutliner *soops, List
if (tselem->type == 0) {
if (te->idcode == ID_SCE) {
- if (tselem->id != (ID *)scene) tselem->flag |= TSE_CLOSED;
- else tselem->flag &= ~TSE_CLOSED;
+ if (tselem->id != (ID *)scene) {
+ tselem->flag |= TSE_CLOSED;
+ }
+ else {
+ tselem->flag &= ~TSE_CLOSED;
+ }
}
else if (te->idcode == ID_OB) {
- if (subtree_has_objects(&te->subtree)) tselem->flag &= ~TSE_CLOSED;
- else tselem->flag |= TSE_CLOSED;
+ if (subtree_has_objects(&te->subtree)) {
+ tselem->flag &= ~TSE_CLOSED;
+ }
+ else {
+ tselem->flag |= TSE_CLOSED;
+ }
}
}
else {
@@ -1379,8 +1525,9 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
/* optimize tricks:
* - Don't do anything if the selected item is a 'struct', but arrays are allowed
*/
- if (tselem->type == TSE_RNA_STRUCT)
+ if (tselem->type == TSE_RNA_STRUCT) {
return;
+ }
/* Overview of Algorithm:
* 1. Go up the chain of parents until we find the 'root', taking note of the
@@ -1430,17 +1577,19 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
/* if possible, use name as a key in the path */
newpath = RNA_path_append(*path, NULL, prop, 0, name);
- if (name != buf)
+ if (name != buf) {
MEM_freeN(name);
+ }
}
else {
/* otherwise use index */
int index = 0;
- for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++)
- if (temsub == temnext)
+ for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++) {
+ if (temsub == temnext) {
break;
-
+ }
+ }
newpath = RNA_path_append(*path, NULL, prop, index, NULL);
}
@@ -1449,7 +1598,9 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
}
if (newpath) {
- if (*path) MEM_freeN(*path);
+ if (*path) {
+ MEM_freeN(*path);
+ }
*path = newpath;
newpath = NULL;
}
@@ -1490,7 +1641,9 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
/* path */
newpath = RNA_path_append(*path, NULL, prop, 0, NULL);
- if (*path) MEM_freeN(*path);
+ if (*path) {
+ MEM_freeN(*path);
+ }
*path = newpath;
}
@@ -1547,12 +1700,14 @@ static void do_outliner_drivers_editop(SpaceOutliner *soops, ListBase *tree, Rep
/* entire array was selected, so add drivers for all */
arraylen = RNA_property_array_length(&te->rnaptr, te->directdata);
}
- else
+ else {
arraylen = array_index;
+ }
/* we should do at least one step */
- if (arraylen == array_index)
+ if (arraylen == array_index) {
arraylen++;
+ }
/* for each array element we should affect, add driver */
for (; array_index < arraylen; array_index++) {
@@ -1581,8 +1736,9 @@ static void do_outliner_drivers_editop(SpaceOutliner *soops, ListBase *tree, Rep
}
/* go over sub-tree */
- if (TSELEM_OPEN(tselem, soops))
+ if (TSELEM_OPEN(tselem, soops)) {
do_outliner_drivers_editop(soops, &te->subtree, reports, mode);
+ }
}
}
@@ -1593,8 +1749,9 @@ static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op)
SpaceOutliner *soutliner = CTX_wm_space_outliner(C);
/* check for invalid states */
- if (soutliner == NULL)
+ if (soutliner == NULL) {
return OPERATOR_CANCELLED;
+ }
/* recursively go into tree, adding selected items */
do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD);
@@ -1628,8 +1785,9 @@ static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op)
SpaceOutliner *soutliner = CTX_wm_space_outliner(C);
/* check for invalid states */
- if (soutliner == NULL)
+ if (soutliner == NULL) {
return OPERATOR_CANCELLED;
+ }
/* recursively go into tree, adding selected items */
do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE);
@@ -1675,12 +1833,14 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add)
KeyingSet *ks = NULL;
/* sanity check */
- if (scene == NULL)
+ if (scene == NULL) {
return NULL;
+ }
/* try to find one from scene */
- if (scene->active_keyingset > 0)
+ if (scene->active_keyingset > 0) {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* add if none found */
// XXX the default settings have yet to evolve
@@ -1752,8 +1912,9 @@ static void do_outliner_keyingset_editop(SpaceOutliner *soops, KeyingSet *ks, Li
}
/* go over sub-tree */
- if (TSELEM_OPEN(tselem, soops))
+ if (TSELEM_OPEN(tselem, soops)) {
do_outliner_keyingset_editop(soops, ks, &te->subtree, mode);
+ }
}
}
@@ -1770,8 +1931,9 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Operation requires an active keying set");
return OPERATOR_CANCELLED;
}
- if (soutliner == NULL)
+ if (soutliner == NULL) {
return OPERATOR_CANCELLED;
+ }
/* recursively go into tree, adding selected items */
do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD);
@@ -1807,8 +1969,9 @@ static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(o
KeyingSet *ks = verify_active_keyingset(scene, 1);
/* check for invalid states */
- if (soutliner == NULL)
+ if (soutliner == NULL) {
return OPERATOR_CANCELLED;
+ }
/* recursively go into tree, adding selected items */
do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE);
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 5af8e2252ef..57fed22d36b 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -297,6 +297,8 @@ void OUTLINER_OT_object_operation(struct wmOperatorType *ot);
void OUTLINER_OT_lib_operation(struct wmOperatorType *ot);
void OUTLINER_OT_id_operation(struct wmOperatorType *ot);
void OUTLINER_OT_id_remap(struct wmOperatorType *ot);
+void OUTLINER_OT_id_copy(struct wmOperatorType *ot);
+void OUTLINER_OT_id_paste(struct wmOperatorType *ot);
void OUTLINER_OT_data_operation(struct wmOperatorType *ot);
void OUTLINER_OT_animdata_operation(struct wmOperatorType *ot);
void OUTLINER_OT_action_set(struct wmOperatorType *ot);
@@ -315,7 +317,6 @@ bool outliner_is_collection_tree_element(const TreeElement *te);
struct Collection *outliner_collection_from_tree_element(const TreeElement *te);
void OUTLINER_OT_collection_new(struct wmOperatorType *ot);
-void OUTLINER_OT_collection_duplicate_hierarchy(struct wmOperatorType *ot);
void OUTLINER_OT_collection_duplicate_linked(struct wmOperatorType *ot);
void OUTLINER_OT_collection_duplicate(struct wmOperatorType *ot);
void OUTLINER_OT_collection_delete(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index af73e88aa73..c14a5eace91 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -63,6 +63,8 @@ void outliner_operatortypes(void)
WM_operatortype_append(OUTLINER_OT_id_operation);
WM_operatortype_append(OUTLINER_OT_id_delete);
WM_operatortype_append(OUTLINER_OT_id_remap);
+ WM_operatortype_append(OUTLINER_OT_id_copy);
+ WM_operatortype_append(OUTLINER_OT_id_paste);
WM_operatortype_append(OUTLINER_OT_data_operation);
WM_operatortype_append(OUTLINER_OT_animdata_operation);
WM_operatortype_append(OUTLINER_OT_action_set);
@@ -93,7 +95,6 @@ void outliner_operatortypes(void)
/* collections */
WM_operatortype_append(OUTLINER_OT_collection_new);
- WM_operatortype_append(OUTLINER_OT_collection_duplicate_hierarchy);
WM_operatortype_append(OUTLINER_OT_collection_duplicate_linked);
WM_operatortype_append(OUTLINER_OT_collection_duplicate);
WM_operatortype_append(OUTLINER_OT_collection_delete);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 09fa6d63557..5ace2c291e0 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -227,8 +227,9 @@ static eOLDrawState active_viewlayer(
bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, const eOLSetState set)
{
/* paranoia check */
- if (te->idcode != ID_SCE)
+ if (te->idcode != ID_SCE) {
return OL_DRAWSEL_NONE;
+ }
ViewLayer *view_layer = te->directdata;
@@ -268,10 +269,12 @@ static void do_outliner_bone_select_recursive(bArmature *arm, Bone *bone_parent,
{
Bone *bone;
for (bone = bone_parent->childbase.first; bone; bone = bone->next) {
- if (select && PBONE_SELECTABLE(arm, bone))
+ if (select && PBONE_SELECTABLE(arm, bone)) {
bone->flag |= BONE_SELECTED;
- else
+ }
+ else {
bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
+ }
do_outliner_bone_select_recursive(arm, bone, select);
}
}
@@ -281,10 +284,12 @@ static void do_outliner_ebone_select_recursive(bArmature *arm, EditBone *ebone_p
EditBone *ebone;
for (ebone = ebone_parent->next; ebone; ebone = ebone->next) {
if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) {
- if (select && EBONE_SELECTABLE(arm, ebone))
+ if (select && EBONE_SELECTABLE(arm, ebone)) {
ebone->flag |= BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL;
- else
+ }
+ else {
ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
+ }
}
}
}
@@ -341,10 +346,12 @@ static eOLDrawState tree_element_set_active_object(
if (base) {
if (set == OL_SETSEL_EXTEND) {
/* swap select */
- if (base->flag & BASE_SELECTED)
+ if (base->flag & BASE_SELECTED) {
ED_object_base_select(base, BA_DESELECT);
- else
+ }
+ else {
ED_object_base_select(base, BA_SELECT);
+ }
}
else {
/* deleselect all */
@@ -477,8 +484,9 @@ static eOLDrawState tree_element_active_world(
tep = te->parent;
if (tep) {
tselem = TREESTORE(tep);
- if (tselem->type == 0)
+ if (tselem->type == 0) {
sce = (Scene *)tselem->id;
+ }
}
if (set != OL_SETSEL_NONE) {
@@ -522,7 +530,7 @@ static eOLDrawState tree_element_active_defgroup(
return OL_DRAWSEL_NONE;
}
-static eOLDrawState UNUSED_FUNCTION(tree_element_active_gplayer)(
+static eOLDrawState tree_element_active_gplayer(
bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tselem, const eOLSetState set)
{
bGPdata *gpd = (bGPdata *)tselem->id;
@@ -578,8 +586,9 @@ static eOLDrawState tree_element_active_posechannel(
if (set != OL_SETSEL_EXTEND) {
bPoseChannel *pchannel;
/* single select forces all other bones to get unselected */
- for (pchannel = ob->pose->chanbase.first; pchannel; pchannel = pchannel->next)
+ for (pchannel = ob->pose->chanbase.first; pchannel; pchannel = pchannel->next) {
pchannel->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
+ }
}
if ((set == OL_SETSEL_EXTEND) && (pchan->bone->flag & BONE_SELECTED)) {
@@ -665,12 +674,16 @@ static void tree_element_active_ebone__sel(bContext *C, Object *obedit, bArmatur
ebone->flag |= BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL;
arm->act_edbone = ebone;
// flush to parent?
- if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL;
+ if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
+ ebone->parent->flag |= BONE_TIPSEL;
+ }
}
else {
ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
// flush to parent?
- if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL;
+ if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
+ ebone->parent->flag &= ~BONE_TIPSEL;
+ }
}
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, obedit);
@@ -830,8 +843,9 @@ static eOLDrawState tree_element_active_sequence_dup(
seq = (Sequence *)te->directdata;
if (set == OL_SETSEL_NONE) {
- if (seq->flag & SELECT)
+ if (seq->flag & SELECT) {
return OL_DRAWSEL_NORMAL;
+ }
return OL_DRAWSEL_NONE;
}
@@ -980,7 +994,7 @@ eOLDrawState tree_element_type_active(
case TSE_KEYMAP_ITEM:
return tree_element_active_keymap_item(C, scene, view_layer, te, tselem, set);
case TSE_GP_LAYER:
- //return tree_element_active_gplayer(C, scene, s, te, tselem, set);
+ return tree_element_active_gplayer(C, scene, te, tselem, set);
break;
case TSE_VIEW_COLLECTION_BASE:
return tree_element_active_master_collection(C, te, set);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 24ca497ed5d..15d2d007ecf 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -101,10 +101,12 @@ static void set_operation_types(SpaceOutliner *soops, ListBase *lb,
if (tselem->flag & TSE_SELECTED) {
/* Layer collection points to collection ID. */
if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) {
- if (*datalevel == 0)
+ if (*datalevel == 0) {
*datalevel = tselem->type;
- else if (*datalevel != tselem->type)
+ }
+ else if (*datalevel != tselem->type) {
*datalevel = -1;
+ }
}
else {
int idcode = GS(tselem->id->name);
@@ -122,8 +124,12 @@ static void set_operation_types(SpaceOutliner *soops, ListBase *lb,
case ID_SO: case ID_KE: case ID_WO: case ID_AC:
case ID_NLA: case ID_TXT: case ID_GR: case ID_LS:
case ID_LI:
- if (*idlevel == 0) *idlevel = idcode;
- else if (*idlevel != idcode) *idlevel = -1;
+ if (*idlevel == 0) {
+ *idlevel = idcode;
+ }
+ else if (*idlevel != idcode) {
+ *idlevel = -1;
+ }
if (ELEM(*datalevel, TSE_VIEW_COLLECTION_BASE, TSE_SCENE_COLLECTION_BASE)) {
*datalevel = 0;
}
@@ -626,8 +632,9 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te
for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) {
fcu->flag &= ~FCURVE_DISABLED;
- if (fcu->driver)
+ if (fcu->driver) {
fcu->driver->flag &= ~DRIVER_FLAG_INVALID;
+ }
}
}
@@ -657,48 +664,57 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem),
{
bPoseChannel *pchan = (bPoseChannel *)te->directdata;
- if (event == OL_DOP_SELECT)
+ if (event == OL_DOP_SELECT) {
pchan->bone->flag |= BONE_SELECTED;
- else if (event == OL_DOP_DESELECT)
+ }
+ else if (event == OL_DOP_DESELECT) {
pchan->bone->flag &= ~BONE_SELECTED;
+ }
else if (event == OL_DOP_HIDE) {
pchan->bone->flag |= BONE_HIDDEN_P;
pchan->bone->flag &= ~BONE_SELECTED;
}
- else if (event == OL_DOP_UNHIDE)
+ else if (event == OL_DOP_UNHIDE) {
pchan->bone->flag &= ~BONE_HIDDEN_P;
+ }
}
static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
{
Bone *bone = (Bone *)te->directdata;
- if (event == OL_DOP_SELECT)
+ if (event == OL_DOP_SELECT) {
bone->flag |= BONE_SELECTED;
- else if (event == OL_DOP_DESELECT)
+ }
+ else if (event == OL_DOP_DESELECT) {
bone->flag &= ~BONE_SELECTED;
+ }
else if (event == OL_DOP_HIDE) {
bone->flag |= BONE_HIDDEN_P;
bone->flag &= ~BONE_SELECTED;
}
- else if (event == OL_DOP_UNHIDE)
+ else if (event == OL_DOP_UNHIDE) {
bone->flag &= ~BONE_HIDDEN_P;
+ }
}
static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
{
EditBone *ebone = (EditBone *)te->directdata;
- if (event == OL_DOP_SELECT)
+ if (event == OL_DOP_SELECT) {
ebone->flag |= BONE_SELECTED;
- else if (event == OL_DOP_DESELECT)
+ }
+ else if (event == OL_DOP_DESELECT) {
ebone->flag &= ~BONE_SELECTED;
+ }
else if (event == OL_DOP_HIDE) {
ebone->flag |= BONE_HIDDEN_A;
ebone->flag &= ~BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
}
- else if (event == OL_DOP_UNHIDE)
+ else if (event == OL_DOP_UNHIDE) {
ebone->flag &= ~BONE_HIDDEN_A;
+ }
}
static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void *scene_ptr)
@@ -719,14 +735,18 @@ static void gp_layer_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem
{
bGPDlayer *gpl = (bGPDlayer *)te->directdata;
- if (event == OL_DOP_SELECT)
+ if (event == OL_DOP_SELECT) {
gpl->flag |= GP_LAYER_SELECT;
- else if (event == OL_DOP_DESELECT)
+ }
+ else if (event == OL_DOP_DESELECT) {
gpl->flag &= ~GP_LAYER_SELECT;
- else if (event == OL_DOP_HIDE)
+ }
+ else if (event == OL_DOP_HIDE) {
gpl->flag |= GP_LAYER_HIDE;
- else if (event == OL_DOP_UNHIDE)
+ }
+ else if (event == OL_DOP_UNHIDE) {
gpl->flag &= ~GP_LAYER_HIDE;
+ }
}
static void data_select_linked_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v)
@@ -839,7 +859,9 @@ static Base *outline_delete_hierarchy(bContext *C, ReportList *reports, Scene *s
for (child_base = view_layer->object_bases.first; child_base; child_base = base_next) {
base_next = child_base->next;
- for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent);
+ for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent) {
+ /* pass */
+ }
if (parent) {
base_next = outline_delete_hierarchy(C, reports, scene, child_base);
}
@@ -877,7 +899,9 @@ static void object_delete_hierarchy_cb(
}
if (base) {
/* Check also library later. */
- for (; obedit && (obedit != base->object); obedit = obedit->parent);
+ for (; obedit && (obedit != base->object); obedit = obedit->parent) {
+ /* pass */
+ }
if (obedit == base->object) {
ED_object_editmode_exit(C, EM_FREEDATA);
}
@@ -907,7 +931,9 @@ static Base *outline_batch_delete_hierarchy(
object = base->object;
for (child_base = view_layer->object_bases.first; child_base; child_base = base_next) {
base_next = child_base->next;
- for (parent = child_base->object->parent; parent && (parent != object); parent = parent->parent);
+ for (parent = child_base->object->parent; parent && (parent != object); parent = parent->parent) {
+ /* pass */
+ }
if (parent) {
base_next = outline_batch_delete_hierarchy(reports, bmain, view_layer, scene, child_base);
}
@@ -951,7 +977,9 @@ static void object_batch_delete_hierarchy_cb(
}
if (base) {
/* Check also library later. */
- for (; obedit && (obedit != base->object); obedit = obedit->parent);
+ for (; obedit && (obedit != base->object); obedit = obedit->parent) {
+ /* pass */
+ }
if (obedit == base->object) {
ED_object_editmode_exit(C, EM_FREEDATA);
}
@@ -1008,8 +1036,9 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
const char *str = NULL;
/* check for invalid states */
- if (soops == NULL)
+ if (soops == NULL) {
return OPERATOR_CANCELLED;
+ }
event = RNA_enum_get(op->ptr, "type");
@@ -1152,6 +1181,9 @@ typedef enum eOutlinerIdOpTypes {
OUTLINER_IDOP_DELETE,
OUTLINER_IDOP_REMAP,
+ OUTLINER_IDOP_COPY,
+ OUTLINER_IDOP_PASTE,
+
OUTLINER_IDOP_FAKE_ADD,
OUTLINER_IDOP_FAKE_CLEAR,
OUTLINER_IDOP_RENAME,
@@ -1166,9 +1198,13 @@ static const EnumPropertyItem prop_id_op_types[] = {
{OUTLINER_IDOP_STATIC_OVERRIDE, "STATIC_OVERRIDE", 0, "Add Static Override",
"Add a local static override of this data-block"},
{OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
- {OUTLINER_IDOP_DELETE, "DELETE", ICON_X, "Delete", "WARNING: no undo"},
+ {OUTLINER_IDOP_DELETE, "DELETE", ICON_X, "Delete", ""},
{OUTLINER_IDOP_REMAP, "REMAP", 0, "Remap Users",
"Make all users of selected data-blocks to use instead current (clicked) one"},
+ {0, "", 0, NULL, NULL},
+ {OUTLINER_IDOP_COPY, "COPY", ICON_COPYDOWN, "Copy", ""},
+ {OUTLINER_IDOP_PASTE, "PASTE", ICON_PASTEDOWN, "Paste", ""},
+ {0, "", 0, NULL, NULL},
{OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User",
"Ensure data-block gets saved even if it isn't in use (e.g. for motion and material libraries)"},
{OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""},
@@ -1208,8 +1244,9 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
eOutlinerIdOpTypes event;
/* check for invalid states */
- if (soops == NULL)
+ if (soops == NULL) {
return OPERATOR_CANCELLED;
+ }
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
@@ -1320,6 +1357,17 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
}
break;
}
+ case OUTLINER_IDOP_COPY:
+ {
+ WM_operator_name_call(C, "OUTLINER_OT_id_copy", WM_OP_INVOKE_DEFAULT, NULL);
+ break;
+ }
+ case OUTLINER_IDOP_PASTE:
+ {
+ WM_operator_name_call(C, "OUTLINER_OT_id_paste", WM_OP_INVOKE_DEFAULT, NULL);
+ ED_undo_push(C, "Paste");
+ break;
+ }
case OUTLINER_IDOP_FAKE_ADD:
{
/* set fake user */
@@ -1411,8 +1459,9 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op)
eOutlinerLibOpTypes event;
/* check for invalid states */
- if (soops == NULL)
+ if (soops == NULL) {
return OPERATOR_CANCELLED;
+ }
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
@@ -1526,8 +1575,9 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
bAction *act;
/* check for invalid states */
- if (soops == NULL)
+ if (soops == NULL) {
return OPERATOR_CANCELLED;
+ }
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
/* get action to use */
@@ -1547,12 +1597,15 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
}
/* perform action if valid channel */
- if (datalevel == TSE_ANIM_DATA)
+ if (datalevel == TSE_ANIM_DATA) {
outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb);
- else if (idlevel == ID_AC)
+ }
+ else if (idlevel == ID_AC) {
outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
@@ -1623,14 +1676,16 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
short updateDeps = 0;
/* check for invalid states */
- if (soops == NULL)
+ if (soops == NULL) {
return OPERATOR_CANCELLED;
+ }
event = RNA_enum_get(op->ptr, "type");
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
- if (datalevel != TSE_ANIM_DATA)
+ if (datalevel != TSE_ANIM_DATA) {
return OPERATOR_CANCELLED;
+ }
/* perform the core operation */
switch (event) {
@@ -1810,8 +1865,9 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op)
eOutliner_PropDataOps event;
/* check for invalid states */
- if (soops == NULL)
+ if (soops == NULL) {
return OPERATOR_CANCELLED;
+ }
event = RNA_enum_get(op->ptr, "type");
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
@@ -1924,8 +1980,9 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOutliner *
/* select object that's clicked on and popup context menu */
if (!(tselem->flag & TSE_SELECTED)) {
- if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1))
+ if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1)) {
outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
+ }
tselem->flag |= TSE_SELECTED;
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 18623fc0b5e..72e9236636e 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -113,7 +113,9 @@ static void outliner_storage_cleanup(SpaceOutliner *soops)
BLI_mempool_iternew(ts, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
- if (tselem->id == NULL) unused++;
+ if (tselem->id == NULL) {
+ unused++;
+ }
}
if (unused) {
@@ -246,8 +248,9 @@ static void outliner_add_bone(SpaceOutliner *soops, ListBase *lb, ID *id, Bone *
static bool outliner_animdata_test(AnimData *adt)
{
- if (adt)
+ if (adt) {
return (adt->action || adt->drivers.first || adt->nla_tracks.first);
+ }
return false;
}
@@ -269,8 +272,9 @@ static void outliner_add_line_styles(SpaceOutliner *soops, ListBase *lb, Scene *
for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) {
FreestyleLineStyle *linestyle = lineset->linestyle;
if (linestyle) {
- if (!(linestyle->id.tag & LIB_TAG_DOIT))
+ if (!(linestyle->id.tag & LIB_TAG_DOIT)) {
continue;
+ }
linestyle->id.tag &= ~LIB_TAG_DOIT;
outliner_add_element(soops, lb, linestyle, te, 0, 0);
}
@@ -308,21 +312,24 @@ static void outliner_add_scene_contents(SpaceOutliner *soops, ListBase *lb, Scen
outliner_make_object_parent_hierarchy(&ten->subtree);
/* Animation Data */
- if (outliner_animdata_test(sce->adt))
+ if (outliner_animdata_test(sce->adt)) {
outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0);
+ }
}
// can be inlined if necessary
static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te, TreeStoreElem *tselem, Object *ob)
{
- if (outliner_animdata_test(ob->adt))
+ if (outliner_animdata_test(ob->adt)) {
outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0);
+ }
outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this
- if (ob->proxy && !ID_IS_LINKED(ob))
+ if (ob->proxy && !ID_IS_LINKED(ob)) {
outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
+ }
outliner_add_element(soops, &te->subtree, ob->gpd, te, 0, 0);
@@ -479,8 +486,9 @@ static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te,
}
/* duplicated group */
- if (ob->instance_collection)
+ if (ob->instance_collection) {
outliner_add_element(soops, &te->subtree, ob->instance_collection, te, 0, 0);
+ }
}
@@ -488,7 +496,9 @@ static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te,
static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, TreeStoreElem *tselem, ID *id)
{
/* tuck pointer back in object, to construct hierarchy */
- if (GS(id->name) == ID_OB) id->newid = (ID *)te;
+ if (GS(id->name) == ID_OB) {
+ id->newid = (ID *)te;
+ }
/* expand specific data always */
switch (GS(id->name)) {
@@ -512,12 +522,14 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree
Mesh *me = (Mesh *)id;
int a;
- if (outliner_animdata_test(me->adt))
+ if (outliner_animdata_test(me->adt)) {
outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0);
+ }
outliner_add_element(soops, &te->subtree, me->key, te, 0, 0);
- for (a = 0; a < me->totcol; a++)
+ for (a = 0; a < me->totcol; a++) {
outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a);
+ }
/* could do tfaces with image links, but the images are not grouped nicely.
* would require going over all tfaces, sort images in use. etc... */
break;
@@ -527,11 +539,13 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree
Curve *cu = (Curve *)id;
int a;
- if (outliner_animdata_test(cu->adt))
+ if (outliner_animdata_test(cu->adt)) {
outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0);
+ }
- for (a = 0; a < cu->totcol; a++)
+ for (a = 0; a < cu->totcol; a++) {
outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a);
+ }
break;
}
case ID_MB:
@@ -539,28 +553,31 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree
MetaBall *mb = (MetaBall *)id;
int a;
- if (outliner_animdata_test(mb->adt))
+ if (outliner_animdata_test(mb->adt)) {
outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0);
+ }
- for (a = 0; a < mb->totcol; a++)
+ for (a = 0; a < mb->totcol; a++) {
outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a);
+ }
break;
}
case ID_MA:
{
Material *ma = (Material *)id;
- if (outliner_animdata_test(ma->adt))
+ if (outliner_animdata_test(ma->adt)) {
outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_TE:
{
Tex *tex = (Tex *)id;
- if (outliner_animdata_test(tex->adt))
+ if (outliner_animdata_test(tex->adt)) {
outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0);
-
+ }
outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0);
break;
}
@@ -568,8 +585,9 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree
{
Camera *ca = (Camera *)id;
- if (outliner_animdata_test(ca->adt))
+ if (outliner_animdata_test(ca->adt)) {
outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_CF:
@@ -586,40 +604,45 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree
{
Light *la = (Light *)id;
- if (outliner_animdata_test(la->adt))
+ if (outliner_animdata_test(la->adt)) {
outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_SPK:
{
Speaker *spk = (Speaker *)id;
- if (outliner_animdata_test(spk->adt))
+ if (outliner_animdata_test(spk->adt)) {
outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_LP:
{
LightProbe *prb = (LightProbe *)id;
- if (outliner_animdata_test(prb->adt))
+ if (outliner_animdata_test(prb->adt)) {
outliner_add_element(soops, &te->subtree, prb, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_WO:
{
World *wrld = (World *)id;
- if (outliner_animdata_test(wrld->adt))
+ if (outliner_animdata_test(wrld->adt)) {
outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_KE:
{
Key *key = (Key *)id;
- if (outliner_animdata_test(key->adt))
+ if (outliner_animdata_test(key->adt)) {
outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0);
+ }
break;
}
case ID_AC:
@@ -633,8 +656,9 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree
bArmature *arm = (bArmature *)id;
int a = 0;
- if (outliner_animdata_test(arm->adt))
+ if (outliner_animdata_test(arm->adt)) {
outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0);
+ }
if (arm->edbo) {
EditBone *ebone;
@@ -680,12 +704,14 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
int a;
- if (outliner_animdata_test(linestyle->adt))
+ if (outliner_animdata_test(linestyle->adt)) {
outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0);
+ }
for (a = 0; a < MAX_MTEX; a++) {
- if (linestyle->mtex[a])
+ if (linestyle->mtex[a]) {
outliner_add_element(soops, &te->subtree, linestyle->mtex[a]->tex, te, 0, a);
+ }
}
break;
}
@@ -695,11 +721,12 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree
bGPDlayer *gpl;
int a = 0;
- if (outliner_animdata_test(gpd->adt))
+ if (outliner_animdata_test(gpd->adt)) {
outliner_add_element(soops, &te->subtree, gpd, te, TSE_ANIM_DATA, 0);
+ }
// TODO: base element for layers?
- for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ for (gpl = gpd->layers.last; gpl; gpl = gpl->prev) {
outliner_add_element(soops, &te->subtree, gpl, te, TSE_GP_LAYER, a);
a++;
}
@@ -729,7 +756,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
if (ELEM(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
id = ((PointerRNA *)idv)->id.data;
- if (!id) id = ((PointerRNA *)idv)->data;
+ if (!id) {
+ id = ((PointerRNA *)idv)->data;
+ }
}
else if (type == TSE_GP_LAYER) {
/* idv is the layer its self */
@@ -757,8 +786,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
tselem = TREESTORE(te);
/* if we are searching for something expand to see child elements */
- if (SEARCHING_OUTLINER(soops))
+ if (SEARCHING_OUTLINER(soops)) {
tselem->flag |= TSE_CHILDSEARCH;
+ }
te->parent = parent;
te->index = index; // for data arrays
@@ -782,10 +812,12 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
}
else {
/* do here too, for blend file viewer, own ID_LI then shows file name */
- if (GS(id->name) == ID_LI)
+ if (GS(id->name) == ID_LI) {
te->name = ((Library *)id)->name;
- else
+ }
+ else {
te->name = id->name + 2; // default, can be overridden by Library or non-ID data
+ }
te->idcode = GS(id->name);
}
@@ -855,7 +887,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
for (strip = nlt->strips.first; strip; strip = strip->next, b++) {
ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b);
- if (ten) ten->directdata = strip;
+ if (ten) {
+ ten->directdata = strip;
+ }
}
}
}
@@ -893,17 +927,20 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
p = p->next;
}
}
- else
+ else {
outliner_add_element(soops, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index);
+ }
}
}
else if (type == TSE_SEQ_STRIP) {
Strip *strip = (Strip *)idv;
- if (strip->dir[0] != '\0')
+ if (strip->dir[0] != '\0') {
te->name = strip->dir;
- else
+ }
+ else {
te->name = IFACE_("Strip None");
+ }
te->directdata = strip;
}
else if (type == TSE_SEQUENCE_DUP) {
@@ -934,22 +971,28 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
/* struct */
te->name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
- if (te->name)
+ if (te->name) {
te->flag |= TE_FREE_NAME;
- else
+ }
+ else {
te->name = RNA_struct_ui_name(ptr->type);
+ }
/* If searching don't expand RNA entries */
- if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH;
+ if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) {
+ tselem->flag &= ~TSE_CHILDSEARCH;
+ }
iterprop = RNA_struct_iterator_property(ptr->type);
tot = RNA_property_collection_length(ptr, iterprop);
CLAMP_MAX(tot, tot_limit);
/* auto open these cases */
- if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER)
- if (!tselem->used)
+ if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) {
+ if (!tselem->used) {
tselem->flag &= ~TSE_CLOSED;
+ }
+ }
if (TSELEM_OPEN(tselem, soops)) {
for (a = 0; a < tot; a++) {
@@ -959,8 +1002,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
}
}
}
- else if (tot)
+ else if (tot) {
te->flag |= TE_LAZY_CLOSED;
+ }
te->rnaptr = *ptr;
}
@@ -977,16 +1021,20 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
te->rnaptr = *ptr;
/* If searching don't expand RNA entries */
- if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH;
+ if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) {
+ tselem->flag &= ~TSE_CHILDSEARCH;
+ }
if (proptype == PROP_POINTER) {
pptr = RNA_property_pointer_get(ptr, prop);
if (pptr.data) {
- if (TSELEM_OPEN(tselem, soops))
+ if (TSELEM_OPEN(tselem, soops)) {
outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1);
- else
+ }
+ else {
te->flag |= TE_LAZY_CLOSED;
+ }
}
}
else if (proptype == PROP_COLLECTION) {
@@ -999,19 +1047,22 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a);
}
}
- else if (tot)
+ else if (tot) {
te->flag |= TE_LAZY_CLOSED;
+ }
}
else if (ELEM(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) {
tot = RNA_property_array_length(ptr, prop);
CLAMP_MAX(tot, tot_limit);
if (TSELEM_OPEN(tselem, soops)) {
- for (a = 0; a < tot; a++)
+ for (a = 0; a < tot; a++) {
outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a);
+ }
}
- else if (tot)
+ else if (tot) {
te->flag |= TE_LAZY_CLOSED;
+ }
}
}
else if (type == TSE_RNA_ARRAY_ELEM) {
@@ -1026,8 +1077,12 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
c = RNA_property_array_item_char(prop, index);
te->name = MEM_callocN(sizeof(char) * 20, "OutlinerRNAArrayName");
- if (c) sprintf((char *)te->name, " %c", c);
- else sprintf((char *)te->name, " %d", index + 1);
+ if (c) {
+ sprintf((char *)te->name, " %c", c);
+ }
+ else {
+ sprintf((char *)te->name, " %d", index + 1);
+ }
te->flag |= TE_FREE_NAME;
}
}
@@ -1072,8 +1127,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi
}
}
}
- else
+ else {
te->flag |= TE_LAZY_CLOSED;
+ }
}
return te;
@@ -1087,8 +1143,9 @@ static int need_add_seq_dup(Sequence *seq)
{
Sequence *p;
- if ((!seq->strip) || (!seq->strip->stripdata))
- return(1);
+ if ((!seq->strip) || (!seq->strip->stripdata)) {
+ return 1;
+ }
/*
* First check backward, if we found a duplicate
@@ -1101,8 +1158,9 @@ static int need_add_seq_dup(Sequence *seq)
continue;
}
- if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name))
- return(2);
+ if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
+ return 2;
+ }
p = p->prev;
}
@@ -1113,8 +1171,9 @@ static int need_add_seq_dup(Sequence *seq)
continue;
}
- if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name))
- return(0);
+ if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
+ return 0;
+ }
p = p->next;
}
return(1);
@@ -1132,8 +1191,9 @@ static void outliner_add_seq_dup(SpaceOutliner *soops, Sequence *seq, TreeElemen
continue;
}
- if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name))
+ if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
/* ch = */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
+ }
p = p->next;
}
}
@@ -1194,9 +1254,11 @@ static TreeElement *outliner_add_library_contents(Main *mainvar, SpaceOutliner *
ID *id = lbarray[a]->first;
/* check if there's data in current lib */
- for (; id; id = id->next)
- if (id->lib == lib)
+ for (; id; id = id->next) {
+ if (id->lib == lib) {
break;
+ }
+ }
if (id) {
if (!tenlib) {
@@ -1253,8 +1315,9 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops
/* check if there are any datablocks of this type which are orphans */
for (; id; id = id->next) {
- if (ID_REAL_USERS(id) <= 0)
+ if (ID_REAL_USERS(id) <= 0) {
break;
+ }
}
if (id) {
@@ -1270,8 +1333,9 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops
/* add the orphaned datablocks - these will not be added with any subtrees attached */
for (id = lbarray[a]->first; id; id = id->next) {
- if (ID_REAL_USERS(id) <= 0)
+ if (ID_REAL_USERS(id) <= 0) {
outliner_add_element(soops, (ten) ? &ten->subtree : &soops->tree, id, ten, 0, 0);
+ }
}
}
}
@@ -1395,7 +1459,9 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb)
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;
+ for (te = tep->subtree.first; te; te = te->next) {
+ te->parent = tep;
+ }
}
}
te = ten;
@@ -1419,15 +1485,25 @@ static int treesort_alpha_ob(const void *v1, const void *v2)
/* first put objects last (hierarchy) */
comp = (x1->idcode == ID_OB);
- if (x2->idcode == ID_OB) comp += 2;
+ if (x2->idcode == ID_OB) {
+ comp += 2;
+ }
- if (comp == 1) return 1;
- else if (comp == 2) return -1;
+ if (comp == 1) {
+ return 1;
+ }
+ else if (comp == 2) {
+ return -1;
+ }
else if (comp == 3) {
comp = strcmp(x1->name, x2->name);
- if (comp > 0) return 1;
- else if (comp < 0) return -1;
+ if (comp > 0) {
+ return 1;
+ }
+ else if (comp < 0) {
+ return -1;
+ }
return 0;
}
return 0;
@@ -1441,8 +1517,12 @@ static int treesort_alpha(const void *v1, const void *v2)
comp = strcmp(x1->name, x2->name);
- if (comp > 0) return 1;
- else if (comp < 0) return -1;
+ if (comp > 0) {
+ return 1;
+ }
+ else if (comp < 0) {
+ return -1;
+ }
return 0;
}
@@ -1485,7 +1565,9 @@ static void outliner_sort(ListBase *lb)
TreeStoreElem *tselem;
te = lb->last;
- if (te == NULL) return;
+ if (te == NULL) {
+ return;
+ }
tselem = TREESTORE(te);
/* sorting rules; only object lists, ID lists, or deformgroups */
@@ -1503,10 +1585,12 @@ static void outliner_sort(ListBase *lb)
tp->name = te->name;
tp->idcode = te->idcode;
- if (tselem->type && tselem->type != TSE_DEFGROUP)
+ if (tselem->type && tselem->type != TSE_DEFGROUP) {
tp->idcode = 0; // don't sort this
- if (tselem->type == TSE_ID_BASE)
+ }
+ if (tselem->type == TSE_ID_BASE) {
tp->idcode = 1; // do sort this
+ }
tp->id = tselem->id;
}
@@ -1517,11 +1601,15 @@ static void outliner_sort(ListBase *lb)
}
else {
/* keep beginning of list */
- for (tp = tear, skip = 0; skip < totelem; skip++, tp++)
- if (tp->idcode) break;
+ for (tp = tear, skip = 0; skip < totelem; skip++, tp++) {
+ if (tp->idcode) {
+ break;
+ }
+ }
- if (skip < totelem)
+ if (skip < totelem) {
qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob);
+ }
}
BLI_listbase_clear(lb);
@@ -1567,7 +1655,9 @@ static void outliner_restore_scrolling_position(SpaceOutliner *soops, ARegion *a
ys_old = focus->ys;
ytop = v2d->cur.ymax + (ys_new - ys_old) -1;
- if (ytop > 0) ytop = 0;
+ if (ytop > 0) {
+ ytop = 0;
+ }
v2d->cur.ymax = (float)ytop;
v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask));
@@ -1836,8 +1926,9 @@ static bool outliner_filter_has_name(TreeElement *te, const char *name, int flag
{
int fn_flag = 0;
- if ((flags & SO_FIND_CASE_SENSITIVE) == 0)
+ if ((flags & SO_FIND_CASE_SENSITIVE) == 0) {
fn_flag |= FNM_CASEFOLD;
+ }
return fnmatch(name, te->name, fn_flag) == 0;
}
@@ -1932,10 +2023,12 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
/* Are we looking for something - we want to tag parents to filter child matches
* - NOT in datablocks view - searching all datablocks takes way too long to be useful
* - this variable is only set once per tree build */
- if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATA_API)
+ if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATA_API) {
soops->search_flags |= SO_SEARCH_RECURSIVE;
- else
+ }
+ else {
soops->search_flags &= ~SO_SEARCH_RECURSIVE;
+ }
if (soops->treehash && (soops->storeflag & SO_TREESTORE_REBUILD) && soops->treestore) {
soops->storeflag &= ~SO_TREESTORE_REBUILD;
@@ -1960,8 +2053,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
ten = outliner_add_library_contents(mainvar, soops, &soops->tree, NULL);
if (ten) {
tselem = TREESTORE(ten);
- if (!tselem->used)
+ if (!tselem->used) {
tselem->flag &= ~TSE_CLOSED;
+ }
}
for (lib = mainvar->libraries.first; lib; lib = lib->id.next) {
@@ -1999,8 +2093,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
}
}
/* restore newid pointers */
- for (lib = mainvar->libraries.first; lib; lib = lib->id.next)
+ for (lib = mainvar->libraries.first; lib; lib = lib->id.next) {
lib->id.newid = NULL;
+ }
}
else if (soops->outlinevis == SO_SCENES) {
@@ -2021,12 +2116,14 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa
Editing *ed = BKE_sequencer_editing_get(scene, false);
int op;
- if (ed == NULL)
+ if (ed == NULL) {
return;
+ }
seq = ed->seqbasep->first;
- if (!seq)
+ if (!seq) {
return;
+ }
while (seq) {
op = need_add_seq_dup(seq);
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 3afb4f4d75a..a44a6e605de 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -91,9 +91,13 @@ TreeElement *outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store
{
TreeElement *te, *tes;
for (te = lb->first; te; te = te->next) {
- if (te->store_elem == store_elem) return te;
+ if (te->store_elem == store_elem) {
+ return te;
+ }
tes = outliner_find_tree_element(&te->subtree, store_elem);
- if (tes) return tes;
+ if (tes) {
+ return tes;
+ }
}
return NULL;
}
@@ -120,12 +124,15 @@ TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse)
{
TreeStoreElem *tselem;
- if (tse->id == NULL) return NULL;
+ if (tse->id == NULL) {
+ return NULL;
+ }
/* check if 'tse' is in treestore */
tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id);
- if (tselem)
+ if (tselem) {
return outliner_find_tree_element(&soops->tree, tselem);
+ }
return NULL;
}
@@ -192,7 +199,9 @@ ID *outliner_search_back(SpaceOutliner *UNUSED(soops), TreeElement *te, short id
while (te) {
tselem = TREESTORE(te);
- if (tselem->type == 0 && te->idcode == idcode) return tselem->id;
+ if (tselem->type == 0 && te->idcode == idcode) {
+ return tselem->id;
+ }
te = te->parent;
}
return NULL;
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 822f9ec61ac..dc51d501b99 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -172,16 +172,19 @@ static void outliner_main_region_listener(
break;
case NC_LAMP:
/* For updating light icons, when changing light type */
- if (wmn->data == ND_LIGHTING_DRAW)
+ if (wmn->data == ND_LIGHTING_DRAW) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_OUTLINER)
+ if (wmn->data == ND_SPACE_OUTLINER) {
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;
case NC_MATERIAL:
switch (wmn->data) {
@@ -205,14 +208,16 @@ static void outliner_main_region_listener(
ED_region_tag_redraw(ar);
break;
case ND_ANIMCHAN:
- if (wmn->action == NA_SELECTED)
+ if (wmn->action == NA_SELECTED) {
ED_region_tag_redraw(ar);
+ }
break;
}
break;
case NC_GPENCIL:
- if (ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+ if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCREEN:
if (ELEM(wmn->data, ND_LAYER)) {
@@ -276,12 +281,14 @@ static void outliner_header_region_listener(
/* context changes */
switch (wmn->category) {
case NC_SCENE:
- if (wmn->data == ND_KEYINGSET)
+ if (wmn->data == ND_KEYINGSET) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_OUTLINER)
+ if (wmn->data == ND_SPACE_OUTLINER) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index b408369dc04..5e36ad9e8bc 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -166,8 +166,9 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, i
RNA_int_set(op->ptr, "frame_start", cfra);
- if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0)
+ if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0) {
RNA_int_set(op->ptr, "frame_end", cfra + 25); // XXX arbitrary but ok for now.
+ }
if (!(flag & SEQPROP_NOPATHS)) {
sequencer_generic_invoke_path__internal(C, op, "filepath");
@@ -201,28 +202,34 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato
is_file = 0;
}
- if ((is_file != -1) && relative)
+ if ((is_file != -1) && relative) {
BLI_path_rel(seq_load->path, BKE_main_blendfile_path(bmain));
+ }
if ((prop = RNA_struct_find_property(op->ptr, "frame_end"))) {
seq_load->end_frame = RNA_property_int_get(op->ptr, prop);
}
- if ((prop = RNA_struct_find_property(op->ptr, "replace_sel")) && RNA_property_boolean_get(op->ptr, prop))
+ if ((prop = RNA_struct_find_property(op->ptr, "replace_sel")) && RNA_property_boolean_get(op->ptr, prop)) {
seq_load->flag |= SEQ_LOAD_REPLACE_SEL;
+ }
- if ((prop = RNA_struct_find_property(op->ptr, "cache")) && RNA_property_boolean_get(op->ptr, prop))
+ if ((prop = RNA_struct_find_property(op->ptr, "cache")) && RNA_property_boolean_get(op->ptr, prop)) {
seq_load->flag |= SEQ_LOAD_SOUND_CACHE;
+ }
- if ((prop = RNA_struct_find_property(op->ptr, "mono")) && RNA_property_boolean_get(op->ptr, prop))
+ if ((prop = RNA_struct_find_property(op->ptr, "mono")) && RNA_property_boolean_get(op->ptr, prop)) {
seq_load->flag |= SEQ_LOAD_SOUND_MONO;
+ }
- if ((prop = RNA_struct_find_property(op->ptr, "sound")) && RNA_property_boolean_get(op->ptr, prop))
+ if ((prop = RNA_struct_find_property(op->ptr, "sound")) && RNA_property_boolean_get(op->ptr, prop)) {
seq_load->flag |= SEQ_LOAD_MOVIE_SOUND;
+ }
- if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) && RNA_property_boolean_get(op->ptr, prop))
+ if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) && RNA_property_boolean_get(op->ptr, prop)) {
seq_load->flag |= SEQ_LOAD_SYNC_FPS;
+ }
/* always use this for ops */
seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE;
@@ -338,8 +345,9 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!RNA_struct_property_is_set(op->ptr, "scene"))
+ if (!RNA_struct_property_is_set(op->ptr, "scene")) {
return WM_enum_search_invoke(C, op, event);
+ }
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SCENE);
return sequencer_add_scene_strip_exec(C, op);
@@ -424,8 +432,9 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!RNA_struct_property_is_set(op->ptr, "clip"))
+ if (!RNA_struct_property_is_set(op->ptr, "clip")) {
return WM_enum_search_invoke(C, op, event);
+ }
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIECLIP);
return sequencer_add_movieclip_strip_exec(C, op);
@@ -509,8 +518,9 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
static int sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!RNA_struct_property_is_set(op->ptr, "mask"))
+ if (!RNA_struct_property_is_set(op->ptr, "mask")) {
return WM_enum_search_invoke(C, op, event);
+ }
sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MASK);
return sequencer_add_mask_strip_exec(C, op);
@@ -554,13 +564,16 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
seq_load_operator_info(&seq_load, C, op);
- if (seq_load.flag & SEQ_LOAD_REPLACE_SEL)
+ if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) {
ED_sequencer_deselect_all(scene);
+ }
- if (RNA_struct_property_is_set(op->ptr, "files"))
+ if (RNA_struct_property_is_set(op->ptr, "files")) {
tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
- else
+ }
+ else {
tot_files = 0;
+ }
if (tot_files) {
/* multiple files */
@@ -607,8 +620,9 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
return OPERATOR_CANCELLED;
}
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
BKE_sequencer_sort(scene);
BKE_sequencer_update_muting(ed);
@@ -626,8 +640,9 @@ static void sequencer_add_init(bContext *UNUSED(C), wmOperator *op)
static void sequencer_add_cancel(bContext *UNUSED(C), wmOperator *op)
{
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
op->customdata = NULL;
}
@@ -697,14 +712,15 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, sequencer_add_draw_check_prop, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
+ uiDefAutoButsRNA(layout, &ptr, sequencer_add_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
/* multiview template */
- if (RNA_boolean_get(op->ptr, "show_multiview"))
+ if (RNA_boolean_get(op->ptr, "show_multiview")) {
uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
+ }
}
void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
@@ -835,7 +851,7 @@ void sequencer_image_seq_reserve_frames(wmOperator *op, StripElem *se, int len,
char ext[PATH_MAX];
char filename_stripped[PATH_MAX];
/* strip the frame from filename and substitute with # */
- BLI_path_frame_strip(filename, true, ext);
+ BLI_path_frame_strip(filename, ext);
for (i = 0; i < len; i++, se++) {
BLI_strncpy(filename_stripped, filename, sizeof(filename_stripped));
@@ -872,11 +888,13 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
seq_load.len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
}
- if (seq_load.len == 0)
+ if (seq_load.len == 0) {
return OPERATOR_CANCELLED;
+ }
- if (seq_load.flag & SEQ_LOAD_REPLACE_SEL)
+ if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) {
ED_sequencer_deselect_all(scene);
+ }
/* main adding function */
seq = BKE_sequencer_add_image_strip(C, ed->seqbasep, &seq_load);
@@ -916,8 +934,9 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
sequencer_add_apply_overlap(C, op, seq);
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
@@ -1057,8 +1076,9 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0,
seq->seq2 ? seq->seq2->machine : 0,
seq->seq3 ? seq->seq3->machine : 0);
- if (chan < MAXSEQ)
+ if (chan < MAXSEQ) {
seq->machine = chan;
+ }
}
}
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index c1b70a7f14a..7b7f6599404 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -132,8 +132,9 @@ 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)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 31a4b15425c..7bd19287e29 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -82,6 +82,8 @@
#define SEQ_HANDLE_SIZE_MIN 7.0f
#define SEQ_HANDLE_SIZE_MAX 40.0f
+#define SEQ_SCROLLER_TEXT_OFFSET 8
+
/* Note, Don't use SEQ_BEGIN/SEQ_END while drawing!
* it messes up transform, - Campbell */
@@ -132,9 +134,9 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3])
UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col);
/* slightly offset hue to distinguish different effects */
- if (seq->type == SEQ_TYPE_CROSS) rgb_byte_set_hue_float_offset(col, 0.04);
- if (seq->type == SEQ_TYPE_GAMCROSS) rgb_byte_set_hue_float_offset(col, 0.08);
- if (seq->type == SEQ_TYPE_WIPE) rgb_byte_set_hue_float_offset(col, 0.12);
+ if (seq->type == SEQ_TYPE_CROSS) { rgb_byte_set_hue_float_offset(col, 0.04); }
+ if (seq->type == SEQ_TYPE_GAMCROSS) { rgb_byte_set_hue_float_offset(col, 0.08); }
+ if (seq->type == SEQ_TYPE_WIPE) { rgb_byte_set_hue_float_offset(col, 0.12); }
break;
/* effects */
@@ -154,18 +156,18 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3])
UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col);
/* slightly offset hue to distinguish different effects */
- if (seq->type == SEQ_TYPE_ADD) rgb_byte_set_hue_float_offset(col, 0.04);
- else if (seq->type == SEQ_TYPE_SUB) rgb_byte_set_hue_float_offset(col, 0.08);
- else if (seq->type == SEQ_TYPE_MUL) rgb_byte_set_hue_float_offset(col, 0.12);
- else if (seq->type == SEQ_TYPE_ALPHAOVER) rgb_byte_set_hue_float_offset(col, 0.16);
- else if (seq->type == SEQ_TYPE_ALPHAUNDER) rgb_byte_set_hue_float_offset(col, 0.20);
- else if (seq->type == SEQ_TYPE_OVERDROP) rgb_byte_set_hue_float_offset(col, 0.24);
- else if (seq->type == SEQ_TYPE_GLOW) rgb_byte_set_hue_float_offset(col, 0.28);
- else if (seq->type == SEQ_TYPE_TRANSFORM) rgb_byte_set_hue_float_offset(col, 0.36);
- else if (seq->type == SEQ_TYPE_MULTICAM) rgb_byte_set_hue_float_offset(col, 0.32);
- else if (seq->type == SEQ_TYPE_ADJUSTMENT) rgb_byte_set_hue_float_offset(col, 0.40);
- else if (seq->type == SEQ_TYPE_GAUSSIAN_BLUR) rgb_byte_set_hue_float_offset(col, 0.42);
- else if (seq->type == SEQ_TYPE_COLORMIX) rgb_byte_set_hue_float_offset(col, 0.46);
+ if (seq->type == SEQ_TYPE_ADD) { rgb_byte_set_hue_float_offset(col, 0.04); }
+ else if (seq->type == SEQ_TYPE_SUB) { rgb_byte_set_hue_float_offset(col, 0.08); }
+ else if (seq->type == SEQ_TYPE_MUL) { rgb_byte_set_hue_float_offset(col, 0.12); }
+ else if (seq->type == SEQ_TYPE_ALPHAOVER) { rgb_byte_set_hue_float_offset(col, 0.16); }
+ else if (seq->type == SEQ_TYPE_ALPHAUNDER) { rgb_byte_set_hue_float_offset(col, 0.20); }
+ else if (seq->type == SEQ_TYPE_OVERDROP) { rgb_byte_set_hue_float_offset(col, 0.24); }
+ else if (seq->type == SEQ_TYPE_GLOW) { rgb_byte_set_hue_float_offset(col, 0.28); }
+ else if (seq->type == SEQ_TYPE_TRANSFORM) { rgb_byte_set_hue_float_offset(col, 0.36); }
+ else if (seq->type == SEQ_TYPE_MULTICAM) { rgb_byte_set_hue_float_offset(col, 0.32); }
+ else if (seq->type == SEQ_TYPE_ADJUSTMENT) { rgb_byte_set_hue_float_offset(col, 0.40); }
+ else if (seq->type == SEQ_TYPE_GAUSSIAN_BLUR) { rgb_byte_set_hue_float_offset(col, 0.42); }
+ else if (seq->type == SEQ_TYPE_COLORMIX) { rgb_byte_set_hue_float_offset(col, 0.46); }
break;
case SEQ_TYPE_COLOR:
@@ -175,7 +177,9 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3])
case SEQ_TYPE_SOUND_RAM:
UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col);
blendcol[0] = blendcol[1] = blendcol[2] = 128;
- if (seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
+ if (seq->flag & SEQ_MUTE) {
+ UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
+ }
break;
case SEQ_TYPE_TEXT:
@@ -189,7 +193,7 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3])
}
static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *scene, Sequence *seq,
- float x1, float y1, float x2, float y2, float stepsize, unsigned int pos)
+ float x1, float y1, float x2, float y2, float stepsize)
{
/*
* x1 is the starting x value to draw the wave,
@@ -255,10 +259,11 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
return;
}
- immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
-
GPU_blend(true);
-
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
immBegin(GPU_PRIM_TRI_STRIP, length * 2);
for (i = 0; i < length; i++) {
@@ -270,11 +275,13 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
if (samplestep > 1.0f) {
for (j = p + 1; (j < waveform->length) && (j < p + samplestep); j++) {
- if (value1 > waveform->data[j * 3])
+ if (value1 > waveform->data[j * 3]) {
value1 = waveform->data[j * 3];
+ }
- if (value2 < waveform->data[j * 3 + 1])
+ if (value2 < waveform->data[j * 3 + 1]) {
value2 = waveform->data[j * 3 + 1];
+ }
}
}
else if (p + 1 < waveform->length) {
@@ -284,12 +291,25 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
value2 = (1.0f - f) * value2 + f * waveform->data[p * 3 + 4];
}
+ value1 *= seq->volume;
+ value2 *= seq->volume;
+
+ if (value2 > 1 || value1 < -1) {
+ immAttr4f(col, 1.0f, 0.0f, 0.0f, 0.5f);
+
+ CLAMP_MAX(value2, 1.0f);
+ CLAMP_MIN(value1, -1.0f);
+ }
+ else {
+ immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.5f);
+ }
+
immVertex2f(pos, x1_offset + i * stepsize, ymid + value1 * yscale);
immVertex2f(pos, x1_offset + i * stepsize, ymid + value2 * yscale);
}
immEnd();
-
+ immUnbindProgram();
GPU_blend(false);
}
}
@@ -361,8 +381,12 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
immUniformColor4ubv(col);
/* clamp within parent sequence strip bounds */
- if (x1_chan < x1) x1_chan = x1;
- if (x2_chan > x2) x2_chan = x2;
+ if (x1_chan < x1) {
+ x1_chan = x1;
+ }
+ if (x2_chan > x2) {
+ x2_chan = x2;
+ }
y1_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSBOTTOM);
y2_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSTOP);
@@ -492,8 +516,9 @@ static void draw_seq_text(
char col[4];
/* note, all strings should include 'name' */
- if (name[0] == '\0')
+ if (name[0] == '\0') {
name = BKE_sequence_give_name(seq);
+ }
if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) {
str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
@@ -612,7 +637,9 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u
pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
- if (pixely <= 0) return; /* can happen when the view is split/resized */
+ if (pixely <= 0) {
+ return; /* can happen when the view is split/resized */
+ }
blendcol[0] = blendcol[1] = blendcol[2] = 120;
@@ -769,15 +796,15 @@ static void draw_seq_strip(
x1 = seq->startdisp;
x2 = seq->enddisp;
+ immUnbindProgram();
+
/* draw sound wave */
if (seq->type == SEQ_TYPE_SOUND_RAM) {
if (!(sseq->flag & SEQ_NO_WAVEFORMS)) {
- drawseqwave(v2d, C, sseq, scene, seq, x1, y1, x2, y2, BLI_rctf_size_x(&ar->v2d.cur) / ar->winx, pos);
+ drawseqwave(v2d, C, sseq, scene, seq, x1, y1, x2, y2, BLI_rctf_size_x(&ar->v2d.cur) / ar->winx);
}
}
- immUnbindProgram();
-
/* draw lock */
if (seq->flag & SEQ_LOCK) {
GPU_blend(true);
@@ -823,11 +850,13 @@ static void draw_seq_strip(
if (seq->flag & SEQ_OVERLAP) {
col[0] = 255; col[1] = col[2] = 40;
}
- else
+ else {
UI_GetColorPtrShade3ubv(col, col, 120 + outline_tint);
+ }
}
- else
+ else {
UI_GetColorPtrShade3ubv(col, col, outline_tint);
+ }
if ((seq->type == SEQ_TYPE_META) ||
((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS)))
@@ -860,11 +889,21 @@ static void draw_seq_strip(
x1 = seq->startdisp + handsize_clamped;
x2 = seq->enddisp - handsize_clamped;
+ float scroller_vert_xoffs = (V2D_SCROLL_WIDTH_TEXT + SEQ_SCROLLER_TEXT_OFFSET) * pixelx;
+
/* info text on the strip */
- if (x1 < v2d->cur.xmin) x1 = v2d->cur.xmin;
- else if (x1 > v2d->cur.xmax) x1 = v2d->cur.xmax;
- if (x2 < v2d->cur.xmin) x2 = v2d->cur.xmin;
- else if (x2 > v2d->cur.xmax) x2 = v2d->cur.xmax;
+ if (x1 < v2d->cur.xmin + scroller_vert_xoffs) {
+ x1 = v2d->cur.xmin + scroller_vert_xoffs;
+ }
+ else if (x1 > v2d->cur.xmax) {
+ x1 = v2d->cur.xmax;
+ }
+ if (x2 < v2d->cur.xmin) {
+ x2 = v2d->cur.xmin;
+ }
+ else if (x2 > v2d->cur.xmax) {
+ x2 = v2d->cur.xmax;
+ }
/* nice text here would require changing the view matrix for texture text */
if ((x2 - x1) / pixelx > 32) {
@@ -934,12 +973,23 @@ ImBuf *sequencer_ibuf_get(
*/
G.is_break = false;
- if (special_seq_update)
+ /* Rendering can change OGL context. Save & Restore framebuffer. */
+ GPUFrameBuffer *fb = GPU_framebuffer_active_get();
+ GPU_framebuffer_restore();
+
+ if (special_seq_update) {
ibuf = BKE_sequencer_give_ibuf_direct(&context, cfra + frame_ofs, special_seq_update);
- else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) {
+ }
+ else if (!U.prefetchframes) { // XXX || (G.f & G_PLAYANIM) == 0) {
ibuf = BKE_sequencer_give_ibuf(&context, cfra + frame_ofs, sseq->chanshown);
- else
+ }
+ else {
ibuf = BKE_sequencer_give_ibuf_threaded(&context, cfra + frame_ofs, sseq->chanshown);
+ }
+
+ if (fb) {
+ GPU_framebuffer_bind(fb);
+ }
/* restore state so real rendering would be canceled (if needed) */
G.is_break = is_break;
@@ -982,8 +1032,9 @@ static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scop
ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
ImBuf *scope;
- IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
- &scene->display_settings);
+ IMB_colormanagement_imbuf_make_display_space(
+ display_ibuf, &scene->view_settings,
+ &scene->display_settings);
scope = make_scope_cb(display_ibuf);
@@ -1004,13 +1055,13 @@ static void sequencer_display_size(Scene *scene, float r_viewrect[2])
static void sequencer_draw_gpencil(const bContext *C)
{
/* draw grease-pencil (image aligned) */
- ED_gpencil_draw_2dimage(C);
+ ED_annotation_draw_2dimage(C);
/* ortho at pixel level */
UI_view2d_view_restore(C);
/* draw grease-pencil (screen aligned) */
- ED_gpencil_draw_view2d(C, 0);
+ ED_annotation_draw_view2d(C, 0);
}
/* draws content borders plus safety borders if needed */
@@ -1078,12 +1129,13 @@ void sequencer_draw_maskedit(const bContext *C, Scene *scene, ARegion *ar, Space
width = (scene->r.size * scene->r.xsch) / 100;
height = (scene->r.size * scene->r.ysch) / 100;
- ED_mask_draw_region(mask, ar,
- 0, 0, 0, /* TODO */
- width, height,
- aspx, aspy,
- false, true,
- NULL, C);
+ ED_mask_draw_region(
+ mask, ar,
+ 0, 0, 0, /* TODO */
+ width, height,
+ aspx, aspy,
+ false, true,
+ NULL, C);
}
}
}
@@ -1150,8 +1202,9 @@ static void *sequencer_OCIO_transform_ibuf(const bContext *C, ImBuf *ibuf, bool
*format = GL_RGBA;
*type = GL_UNSIGNED_BYTE;
}
- if (cache_handle)
+ if (cache_handle) {
IMB_display_buffer_release(cache_handle);
+ }
return display_buffer;
}
@@ -1347,24 +1400,28 @@ static ImBuf *sequencer_get_scope(Scene *scene, SpaceSeq *sseq, ImBuf *ibuf, boo
break;
case SEQ_DRAW_IMG_WAVEFORM:
if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
- if (!scopes->sep_waveform_ibuf)
+ if (!scopes->sep_waveform_ibuf) {
scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf);
+ }
scope = scopes->sep_waveform_ibuf;
}
else {
- if (!scopes->waveform_ibuf)
+ if (!scopes->waveform_ibuf) {
scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf);
+ }
scope = scopes->waveform_ibuf;
}
break;
case SEQ_DRAW_IMG_VECTORSCOPE:
- if (!scopes->vector_ibuf)
+ if (!scopes->vector_ibuf) {
scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf);
+ }
scope = scopes->vector_ibuf;
break;
case SEQ_DRAW_IMG_HISTOGRAM:
- if (!scopes->histogram_ibuf)
+ if (!scopes->histogram_ibuf) {
scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf);
+ }
scope = scopes->histogram_ibuf;
break;
}
@@ -1538,12 +1595,12 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
/* loop through strips, checking for those that are visible */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
/* boundbox and selection tests for NOT drawing the strip... */
- if ((seq->flag & SELECT) != sel) continue;
- else if (seq == last_seq) continue;
- else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) continue;
- else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue;
- else if (seq->machine + 1.0f < v2d->cur.ymin) continue;
- else if (seq->machine > v2d->cur.ymax) continue;
+ if ((seq->flag & SELECT) != sel) { continue; }
+ else if (seq == last_seq) { continue; }
+ else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) { continue; }
+ else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) { continue; }
+ else if (seq->machine + 1.0f < v2d->cur.ymin) { continue; }
+ else if (seq->machine > v2d->cur.ymax) { continue; }
/* strip passed all tests unscathed... so draw it now */
draw_seq_strip(C, sseq, scene, ar, seq, outline_tint, pixelx);
@@ -1555,8 +1612,9 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
/* draw the last selected last (i.e. 'active' in other parts of Blender),
* removes some overlapping error */
- if (last_seq)
+ if (last_seq) {
draw_seq_strip(C, sseq, scene, ar, last_seq, 120, pixelx);
+ }
/* draw highlight when previewing a single strip */
if (special_seq_update) {
@@ -1648,10 +1706,12 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
- if (ed && ed->metastack.first)
+ if (ed && ed->metastack.first) {
GPU_clear_color(col[0], col[1], col[2] - 0.1f, 0.0f);
- else
+ }
+ else {
GPU_clear_color(col[0], col[1], col[2], 0.0f);
+ }
GPU_clear(GPU_COLOR_BIT);
UI_view2d_view_ortho(v2d);
@@ -1690,7 +1750,9 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
/* current frame */
UI_view2d_view_ortho(v2d);
- if ((sseq->flag & SEQ_DRAWFRAMES) == 0) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ if ((sseq->flag & SEQ_DRAWFRAMES) == 0) {
+ cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
/* markers */
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 3c6e2abee12..b7d3bec326a 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -229,11 +229,20 @@ static void seq_proxy_build_job(const bContext *C)
void seq_rectf(Sequence *seq, rctf *rectf)
{
- if (seq->startstill) rectf->xmin = seq->start;
- else rectf->xmin = seq->startdisp;
+ if (seq->startstill) {
+ rectf->xmin = seq->start;
+ }
+ else {
+ rectf->xmin = seq->startdisp;
+ }
+
rectf->ymin = seq->machine + SEQ_STRIP_OFSBOTTOM;
- if (seq->endstill) rectf->xmax = seq->start + seq->len;
- else rectf->xmax = seq->enddisp;
+ if (seq->endstill) {
+ rectf->xmax = seq->start + seq->len;
+ }
+ else {
+ rectf->xmax = seq->enddisp;
+ }
rectf->ymax = seq->machine + SEQ_STRIP_OFSTOP;
}
@@ -244,7 +253,9 @@ void boundbox_seq(Scene *scene, rctf *rect)
float min[2], max[2];
- if (ed == NULL) return;
+ if (ed == NULL) {
+ return;
+ }
min[0] = 0.0;
max[0] = EFRA + 1;
@@ -254,9 +265,15 @@ void boundbox_seq(Scene *scene, rctf *rect)
seq = ed->seqbasep->first;
while (seq) {
- if (min[0] > seq->startdisp - 1) min[0] = seq->startdisp - 1;
- if (max[0] < seq->enddisp + 1) max[0] = seq->enddisp + 1;
- if (max[1] < seq->machine + 2) max[1] = seq->machine + 2;
+ if (min[0] > seq->startdisp - 1) {
+ min[0] = seq->startdisp - 1;
+ }
+ if (max[0] < seq->enddisp + 1) {
+ max[0] = seq->enddisp + 1;
+ }
+ if (max[1] < seq->machine + 2) {
+ max[1] = seq->machine + 2;
+ }
seq = seq->next;
}
@@ -289,9 +306,13 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL) return NULL;
+ if (ed == NULL) {
+ return NULL;
+ }
- if (sel > 0) sel = SELECT;
+ if (sel > 0) {
+ sel = SELECT;
+ }
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq != test) &&
@@ -325,7 +346,9 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i
best_dist = MAXFRAME * 2;
- if (ed == NULL) return NULL;
+ if (ed == NULL) {
+ return NULL;
+ }
seq = ed->seqbasep->first;
while (seq) {
@@ -375,7 +398,9 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[
*hand = SEQ_SIDE_NONE;
- if (ed == NULL) return NULL;
+ if (ed == NULL) {
+ return NULL;
+ }
pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
@@ -409,10 +434,12 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[
CLAMP(handsize, 7 * pixelx, 30 * pixelx);
}
- if (handsize + seq->startdisp >= x)
+ if (handsize + seq->startdisp >= x) {
*hand = SEQ_SIDE_LEFT;
- else if (-handsize + seq->enddisp <= x)
+ }
+ else if (-handsize + seq->enddisp <= x) {
*hand = SEQ_SIDE_RIGHT;
+ }
}
}
return seq;
@@ -431,12 +458,12 @@ static bool seq_is_parent(Sequence *par, Sequence *seq)
static bool seq_is_predecessor(Sequence *pred, Sequence *seq)
{
- if (!pred) return 0;
- if (pred == seq) return 0;
- else if (seq_is_parent(pred, seq)) return 1;
- else if (pred->seq1 && seq_is_predecessor(pred->seq1, seq)) return 1;
- else if (pred->seq2 && seq_is_predecessor(pred->seq2, seq)) return 1;
- else if (pred->seq3 && seq_is_predecessor(pred->seq3, seq)) return 1;
+ if (!pred) { return 0; }
+ if (pred == seq) { return 0; }
+ else if (seq_is_parent(pred, seq)) { return 1; }
+ else if (pred->seq1 && seq_is_predecessor(pred->seq1, seq)) { return 1; }
+ else if (pred->seq2 && seq_is_predecessor(pred->seq2, seq)) { return 1; }
+ else if (pred->seq3 && seq_is_predecessor(pred->seq3, seq)) { return 1; }
return 0;
}
@@ -447,7 +474,9 @@ void ED_sequencer_deselect_all(Scene *scene)
Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL) return;
+ if (ed == NULL) {
+ return;
+ }
SEQP_BEGIN (ed, seq)
{
@@ -463,11 +492,19 @@ void recurs_sel_seq(Sequence *seqm)
seq = seqm->seqbase.first;
while (seq) {
- if (seqm->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) seq->flag &= ~SEQ_ALLSEL;
- else if (seqm->flag & SELECT) seq->flag |= SELECT;
- else seq->flag &= ~SEQ_ALLSEL;
+ if (seqm->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
+ else if (seqm->flag & SELECT) {
+ seq->flag |= SELECT;
+ }
+ else {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
- if (seq->seqbase.first) recurs_sel_seq(seq);
+ if (seq->seqbase.first) {
+ recurs_sel_seq(seq);
+ }
seq = seq->next;
}
@@ -521,8 +558,9 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
*error_str = NULL;
- if (!activeseq)
+ if (!activeseq) {
seq2 = BKE_sequencer_active_get(scene);
+ }
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT) {
@@ -531,9 +569,15 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
return 0;
}
if ((seq != activeseq) && (seq != seq2)) {
- if (seq2 == NULL) seq2 = seq;
- else if (seq1 == NULL) seq1 = seq;
- else if (seq3 == NULL) seq3 = seq;
+ if (seq2 == NULL) {
+ seq2 = seq;
+ }
+ else if (seq1 == NULL) {
+ seq1 = seq;
+ }
+ else if (seq3 == NULL) {
+ seq3 = seq;
+ }
else {
*error_str = N_("Cannot apply effect to more than 3 sequence strips");
return 0;
@@ -560,15 +604,21 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
*error_str = N_("At least one selected sequence strip is needed");
return 0;
}
- if (seq1 == NULL) seq1 = seq2;
- if (seq3 == NULL) seq3 = seq2;
+ if (seq1 == NULL) {
+ seq1 = seq2;
+ }
+ if (seq3 == NULL) {
+ seq3 = seq2;
+ }
ATTR_FALLTHROUGH;
case 2:
if (seq1 == NULL || seq2 == NULL) {
*error_str = N_("2 selected sequence strips are needed");
return 0;
}
- if (seq3 == NULL) seq3 = seq2;
+ if (seq3 == NULL) {
+ seq3 = seq2;
+ }
break;
}
@@ -591,10 +641,12 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq)
/* try to find a replacement input sequence, and flag for later deletion if
* no replacement can be found */
- if (!seq)
+ if (!seq) {
return NULL;
- else if (!(seq->type & SEQ_TYPE_EFFECT))
+ }
+ else if (!(seq->type & SEQ_TYPE_EFFECT)) {
return ((seq->flag & SELECT) ? NULL : seq);
+ }
else if (!(seq->flag & SELECT)) {
/* try to find replacement for effect inputs */
seq1 = del_seq_find_replace_recurs(scene, seq->seq1);
@@ -611,18 +663,22 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq)
BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1);
}
- else
+ else {
seq->flag |= SELECT; /* mark for delete */
+ }
}
if (seq->flag & SELECT) {
- if ((seq1 = del_seq_find_replace_recurs(scene, seq->seq1))) return seq1;
- if ((seq2 = del_seq_find_replace_recurs(scene, seq->seq2))) return seq2;
- if ((seq3 = del_seq_find_replace_recurs(scene, seq->seq3))) return seq3;
- else return NULL;
+ if ((seq1 = del_seq_find_replace_recurs(scene, seq->seq1))) { return seq1; }
+ if ((seq2 = del_seq_find_replace_recurs(scene, seq->seq2))) { return seq2; }
+ if ((seq3 = del_seq_find_replace_recurs(scene, seq->seq3))) { return seq3; }
+ else {
+ return NULL;
+ }
}
- else
+ else {
return seq;
+ }
}
static void del_seq_clear_modifiers_recurs(Scene *scene, Sequence *deleting_sequence)
@@ -654,8 +710,12 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de
seqn = seq->next;
if ((seq->flag & flag) || deleteall) {
BLI_remlink(lb, seq);
- if (seq == last_seq) BKE_sequencer_active_set(scene, NULL);
- if (seq->type == SEQ_TYPE_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
+ if (seq == last_seq) {
+ BKE_sequencer_active_set(scene, NULL);
+ }
+ if (seq->type == SEQ_TYPE_META) {
+ recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
+ }
BKE_sequence_free(scene, seq);
}
seq = seqn;
@@ -945,7 +1005,9 @@ static bool sequence_offset_after_frame(Scene *scene, const int delta, const int
/* all strips >= cfra are shifted */
- if (ed == NULL) return 0;
+ if (ed == NULL) {
+ return 0;
+ }
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->startdisp >= cfra) {
@@ -998,8 +1060,9 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene)
char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX];
- if (last_seq == NULL)
+ if (last_seq == NULL) {
return;
+ }
BLI_strncpy(from, last_seq->strip->dir, sizeof(from));
// XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: "))
@@ -1009,8 +1072,9 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene)
// XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: "))
// return;
- if (STREQ(to, from))
+ if (STREQ(to, from)) {
return;
+ }
SEQP_BEGIN (ed, seq)
{
@@ -1056,15 +1120,21 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
for ( ; cfra < efra; cfra++) {
/* first == 0 means there's still no strip to remove a gap for */
if (first == false) {
- if (BKE_sequencer_evaluate_frame(scene, cfra) ) first = true;
+ if (BKE_sequencer_evaluate_frame(scene, cfra) ) {
+ first = true;
+ }
}
else if (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
done = true;
while (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
done = sequence_offset_after_frame(scene, -1, cfra);
- if (done == false) break;
+ if (done == false) {
+ break;
+ }
+ }
+ if (done == false || do_all == false) {
+ break;
}
- if (done == false || do_all == false) break;
}
}
@@ -1166,8 +1236,9 @@ bool sequencer_view_preview_poll(bContext *C)
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), false);
- if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF))
+ if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF)) {
return 1;
+ }
return 0;
}
@@ -1175,8 +1246,9 @@ bool sequencer_view_preview_poll(bContext *C)
bool sequencer_view_strips_poll(bContext *C)
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
- if (sseq && ED_space_sequencer_check_show_strip(sseq))
+ if (sseq && ED_space_sequencer_check_show_strip(sseq)) {
return 1;
+ }
return 0;
}
@@ -1227,12 +1299,15 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
}
}
else if (seq->type & SEQ_TYPE_EFFECT) {
- if (seq->seq1 && (seq->seq1->flag & SELECT))
+ if (seq->seq1 && (seq->seq1->flag & SELECT)) {
BKE_sequence_calc(scene, seq);
- else if (seq->seq2 && (seq->seq2->flag & SELECT))
+ }
+ else if (seq->seq2 && (seq->seq2->flag & SELECT)) {
BKE_sequence_calc(scene, seq);
- else if (seq->seq3 && (seq->seq3->flag & SELECT))
+ }
+ else if (seq->seq3 && (seq->seq3->flag & SELECT)) {
BKE_sequence_calc(scene, seq);
+ }
}
}
@@ -1372,8 +1447,9 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve
/* first recursively count the trimmed elements */
num_seq = slip_count_sequences_rec(ed->seqbasep, true);
- if (num_seq == 0)
+ if (num_seq == 0) {
return OPERATOR_CANCELLED;
+ }
data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata");
data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform");
@@ -1457,8 +1533,9 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int 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
* This way we can avoid an extra loop just for effects*/
- if (!(seq->type & SEQ_TYPE_EFFECT))
+ if (!(seq->type & SEQ_TYPE_EFFECT)) {
BKE_sequence_calc(scene, seq);
+ }
}
BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
@@ -1480,8 +1557,9 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op)
/* first recursively count the trimmed elements */
num_seq = slip_count_sequences_rec(ed->seqbasep, true);
- if (num_seq == 0)
+ if (num_seq == 0) {
return OPERATOR_CANCELLED;
+ }
data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata");
data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform");
@@ -1817,7 +1895,7 @@ void SEQUENCER_OT_lock(struct wmOperatorType *ot)
/* identifiers */
ot->name = "Lock Strips";
ot->idname = "SEQUENCER_OT_lock";
- ot->description = "Lock the active strip so that it can't be transformed";
+ ot->description = "Lock strips so they can't be transformed";
/* api callbacks */
ot->exec = sequencer_lock_exec;
@@ -1850,7 +1928,7 @@ void SEQUENCER_OT_unlock(struct wmOperatorType *ot)
/* identifiers */
ot->name = "Unlock Strips";
ot->idname = "SEQUENCER_OT_unlock";
- ot->description = "Unlock the active strip so that it can't be transformed";
+ ot->description = "Unlock strips so they can be transformed";
/* api callbacks */
ot->exec = sequencer_unlock_exec;
@@ -1874,8 +1952,9 @@ static int sequencer_reload_exec(bContext *C, wmOperator *op)
BKE_sequence_reload_new_file(scene, seq, !adjust_length);
if (adjust_length) {
- if (BKE_sequence_test_overlap(ed->seqbasep, seq))
+ if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
+ }
}
}
}
@@ -2171,8 +2250,9 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
ListBase nseqbase = {NULL, NULL};
- if (ed == NULL)
+ if (ed == NULL) {
return OPERATOR_CANCELLED;
+ }
BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0);
@@ -2181,8 +2261,9 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
/* rely on the nseqbase list being added at the end */
BLI_movelisttolist(ed->seqbasep, &nseqbase);
- for (; seq; seq = seq->next)
+ for (; seq; seq = seq->next) {
BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
+ }
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
@@ -2277,8 +2358,9 @@ static int sequencer_delete_invoke(bContext *C, wmOperator *op, const wmEvent *e
/* bounding box of 30 pixels is used for markers shortcuts,
* prevent conflict with markers shortcuts here
*/
- if (event->mval[1] <= 30)
+ if (event->mval[1] <= 30) {
return OPERATOR_PASS_THROUGH;
+ }
}
return WM_operator_confirm(C, op, event);
@@ -2483,8 +2565,9 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
Sequence *seq;
- if (BLI_listbase_is_empty(&ed->metastack))
+ if (BLI_listbase_is_empty(&ed->metastack)) {
return OPERATOR_CANCELLED;
+ }
ms = ed->metastack.last;
BLI_remlink(&ed->metastack, ms);
@@ -2497,8 +2580,9 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
}
/* recalc all: the meta can have effects connected to it */
- for (seq = ed->seqbasep->first; seq; seq = seq->next)
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
BKE_sequence_calc(scene, seq);
+ }
/* 2.73+, keeping endpoings is important!
* moving them around means you can't usefully use metas in a complex edit */
@@ -2508,8 +2592,9 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
BKE_sequence_single_fix(ms->parseq);
BKE_sequence_calc(scene, ms->parseq);
#else
- if (BKE_sequence_test_overlap(ed->seqbasep, ms->parseq))
+ if (BKE_sequence_test_overlap(ed->seqbasep, ms->parseq)) {
BKE_sequence_base_shuffle(ed->seqbasep, ms->parseq, scene);
+ }
#endif
BKE_sequencer_active_set(scene, ms->parseq);
@@ -2583,7 +2668,9 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
BKE_sequencer_active_set(scene, seqm);
- if (BKE_sequence_test_overlap(ed->seqbasep, seqm) ) BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene);
+ if (BKE_sequence_test_overlap(ed->seqbasep, seqm)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene);
+ }
BKE_sequencer_update_muting(ed);
@@ -2612,11 +2699,21 @@ void SEQUENCER_OT_meta_make(wmOperatorType *ot)
static int seq_depends_on_meta(Sequence *seq, Sequence *seqm)
{
- if (seq == seqm) return 1;
- else if (seq->seq1 && seq_depends_on_meta(seq->seq1, seqm)) return 1;
- else if (seq->seq2 && seq_depends_on_meta(seq->seq2, seqm)) return 1;
- else if (seq->seq3 && seq_depends_on_meta(seq->seq3, seqm)) return 1;
- else return 0;
+ if (seq == seqm) {
+ return 1;
+ }
+ else if (seq->seq1 && seq_depends_on_meta(seq->seq1, seqm)) {
+ return 1;
+ }
+ else if (seq->seq2 && seq_depends_on_meta(seq->seq2, seqm)) {
+ return 1;
+ }
+ else if (seq->seq3 && seq_depends_on_meta(seq->seq3, seqm)) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
/* separate_meta_make operator */
@@ -2627,8 +2724,9 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); /* last_seq checks (ed == NULL) */
- if (last_seq == NULL || last_seq->type != SEQ_TYPE_META)
+ if (last_seq == NULL || last_seq->type != SEQ_TYPE_META) {
return OPERATOR_CANCELLED;
+ }
for (seq = last_seq->seqbase.first; seq != NULL; seq = seq->next) {
BKE_sequence_invalidate_cache(scene, seq);
@@ -2642,9 +2740,11 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
BKE_sequence_free(scene, last_seq);
/* empty meta strip, delete all effects depending on it */
- for (seq = ed->seqbasep->first; seq; seq = seq->next)
- if ((seq->type & SEQ_TYPE_EFFECT) && seq_depends_on_meta(seq, last_seq))
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq->type & SEQ_TYPE_EFFECT) && seq_depends_on_meta(seq, last_seq)) {
seq->flag |= SEQ_FLAG_DELETE;
+ }
+ }
recurs_del_seq_flag(scene, ed->seqbasep, SEQ_FLAG_DELETE, 0);
@@ -2850,7 +2950,9 @@ static int sequencer_view_toggle_exec(bContext *C, wmOperator *UNUSED(op))
SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C);
sseq->view++;
- if (sseq->view > SEQ_VIEW_SEQUENCE_PREVIEW) sseq->view = SEQ_VIEW_SEQUENCE;
+ if (sseq->view > SEQ_VIEW_SEQUENCE_PREVIEW) {
+ sseq->view = SEQ_VIEW_SEQUENCE;
+ }
ED_area_tag_refresh(CTX_wm_area(C));
@@ -2893,8 +2995,9 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
int ymargin = 1;
int xmargin = FPS;
- if (ed == NULL)
+ if (ed == NULL) {
return OPERATOR_CANCELLED;
+ }
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq->flag & SELECT) || (seq == last_seq)) {
@@ -2974,8 +3077,9 @@ static bool strip_jump_internal(Scene *scene,
static bool sequencer_strip_jump_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return sequencer_edit_poll(C);
}
@@ -3059,17 +3163,21 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
Sequence *seq, *iseq;
int side = RNA_enum_get(op->ptr, "side");
- if (active_seq == NULL) return OPERATOR_CANCELLED;
+ if (active_seq == NULL) {
+ return OPERATOR_CANCELLED;
+ }
seq = find_next_prev_sequence(scene, active_seq, side, -1);
if (seq) {
/* disallow effect strips */
- if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3))
+ if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) {
return OPERATOR_CANCELLED;
- if ((BKE_sequence_effect_get_num_inputs(active_seq->type) >= 1) && (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3))
+ }
+ if ((BKE_sequence_effect_get_num_inputs(active_seq->type) >= 1) && (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3)) {
return OPERATOR_CANCELLED;
+ }
switch (side) {
case SEQ_SIDE_LEFT:
@@ -3134,8 +3242,9 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op))
Sequence *active_seq = BKE_sequencer_active_get(scene);
StripElem *se = NULL;
- if (active_seq == NULL)
+ if (active_seq == NULL) {
return OPERATOR_CANCELLED;
+ }
if (active_seq->strip) {
@@ -3223,8 +3332,9 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
Sequence *seq, *first_seq = nseqbase.first;
BLI_movelisttolist(ed->seqbasep, &nseqbase);
- for (seq = first_seq; seq; seq = seq->next)
+ for (seq = first_seq; seq; seq = seq->next) {
BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
+ }
seqbase_clipboard.first = first_seq;
seqbase_clipboard.last = ed->seqbasep->last;
@@ -3350,11 +3460,13 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (seq_act->scene_sound)
+ if (seq_act->scene_sound) {
BKE_sound_remove_scene_sound(scene, seq_act->scene_sound);
+ }
- if (seq_other->scene_sound)
+ if (seq_other->scene_sound) {
BKE_sound_remove_scene_sound(scene, seq_other->scene_sound);
+ }
seq_act->scene_sound = NULL;
seq_other->scene_sound = NULL;
@@ -3362,8 +3474,12 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op)
BKE_sequence_calc(scene, seq_act);
BKE_sequence_calc(scene, seq_other);
- if (seq_act->sound) BKE_sound_add_scene_sound_defaults(scene, seq_act);
- if (seq_other->sound) BKE_sound_add_scene_sound_defaults(scene, seq_other);
+ if (seq_act->sound) {
+ BKE_sound_add_scene_sound_defaults(scene, seq_act);
+ }
+ if (seq_other->sound) {
+ BKE_sound_add_scene_sound_defaults(scene, seq_other);
+ }
BKE_sequence_invalidate_cache(scene, seq_act);
BKE_sequence_invalidate_cache(scene, seq_other);
@@ -3541,30 +3657,40 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
continue;
}
- if (proxy_25)
+ if (proxy_25) {
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25;
- else
+ }
+ else {
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25;
+ }
- if (proxy_50)
+ if (proxy_50) {
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50;
- else
+ }
+ else {
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50;
+ }
- if (proxy_75)
+ if (proxy_75) {
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75;
- else
+ }
+ else {
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75;
+ }
- if (proxy_100)
+ if (proxy_100) {
seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100;
- else
+ }
+ else {
seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100;
+ }
- if (!overwrite)
+ if (!overwrite) {
seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
- else
+ }
+ else {
seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
+ }
}
}
} SEQ_END;
@@ -3742,8 +3868,9 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op)
else {
len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
}
- if (len == 0)
+ if (len == 0) {
return OPERATOR_CANCELLED;
+ }
RNA_string_get(op->ptr, "directory", directory);
if (is_relative_path) {
@@ -3865,10 +3992,12 @@ static int sequencer_export_subtitles_invoke(bContext *C, wmOperator *op, const
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
char filepath[FILE_MAX];
- if (BKE_main_blendfile_path(bmain)[0] == '\0')
+ if (BKE_main_blendfile_path(bmain)[0] == '\0') {
BLI_strncpy(filepath, "untitled", sizeof(filepath));
- else
+ }
+ else {
BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
+ }
BLI_path_extension_replace(filepath, sizeof(filepath), ".srt");
RNA_string_set(op->ptr, "filepath", filepath);
diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c
index c3df5a0c5ee..41ca52e0431 100644
--- a/source/blender/editors/space_sequencer/sequencer_modifier.c
+++ b/source/blender/editors/space_sequencer/sequencer_modifier.c
@@ -51,8 +51,9 @@ static bool strip_modifier_active_poll(bContext *C)
if (ed) {
Sequence *seq = BKE_sequencer_active_get(scene);
- if (seq)
+ if (seq) {
return BKE_sequence_supports_modifiers(seq);
+ }
}
return false;
@@ -105,8 +106,9 @@ static int strip_modifier_remove_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "name", name);
smd = BKE_sequence_modifier_find_by_name(seq, name);
- if (!smd)
+ if (!smd) {
return OPERATOR_CANCELLED;
+ }
BLI_remlink(&seq->modifiers, smd);
BKE_sequence_modifier_free(smd);
@@ -154,8 +156,9 @@ static int strip_modifier_move_exec(bContext *C, wmOperator *op)
direction = RNA_enum_get(op->ptr, "direction");
smd = BKE_sequence_modifier_find_by_name(seq, name);
- if (!smd)
+ if (!smd) {
return OPERATOR_CANCELLED;
+ }
if (direction == SEQ_MODIFIER_MOVE_UP) {
if (smd->prev) {
@@ -216,14 +219,16 @@ static int strip_modifier_copy_exec(bContext *C, wmOperator *op)
Sequence *seq_iter;
const int type = RNA_enum_get(op->ptr, "type");
- if (!seq || !seq->modifiers.first)
+ if (!seq || !seq->modifiers.first) {
return OPERATOR_CANCELLED;
+ }
SEQP_BEGIN(ed, seq_iter)
{
if (seq_iter->flag & SELECT) {
- if (seq_iter == seq)
+ if (seq_iter == seq) {
continue;
+ }
if (type == SEQ_MODIFIER_COPY_REPLACE) {
if (seq_iter->modifiers.first) {
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index f93eaa5bce5..5ccd9e86e12 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -513,12 +513,15 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
nr = nb = ng = 0;
for (x = 0; x < HIS_STEPS; x++) {
- if (bins[0][x] > nr)
+ if (bins[0][x] > nr) {
nr = bins[0][x];
- if (bins[1][x] > ng)
+ }
+ if (bins[1][x] > ng) {
ng = bins[1][x];
- if (bins[2][x] > nb)
+ }
+ if (bins[2][x] > nb) {
nb = bins[2][x];
+ }
}
for (x = 0; x < HIS_STEPS; x++) {
@@ -598,12 +601,15 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
nr = nb = ng = 0;
for (x = 0; x < HIS_STEPS; x++) {
- if (bins[0][x] > nr)
+ if (bins[0][x] > nr) {
nr = bins[0][x];
- if (bins[1][x] > ng)
+ }
+ if (bins[1][x] > ng) {
ng = bins[1][x];
- if (bins[2][x] > nb)
+ }
+ if (bins[2][x] > nb) {
nb = bins[2][x];
+ }
}
for (x = 0; x < HIS_STEPS; x++) {
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index b87e0b185a4..7742d74d559 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -131,11 +131,13 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
/* clear for reselection */
seq->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
- if (left_match && seq_link->flag & SEQ_LEFTSEL)
+ if (left_match && seq_link->flag & SEQ_LEFTSEL) {
seq->flag |= SELECT | SEQ_LEFTSEL;
+ }
- if (right_match && seq_link->flag & SEQ_RIGHTSEL)
+ if (right_match && seq_link->flag & SEQ_RIGHTSEL) {
seq->flag |= SELECT | SEQ_RIGHTSEL;
+ }
recurs_sel_seq(seq);
}
@@ -159,18 +161,21 @@ void ED_sequencer_select_sequence_single(Scene *scene, Sequence *seq, bool desel
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (deselect_all)
+ if (deselect_all) {
ED_sequencer_deselect_all(scene);
+ }
BKE_sequencer_active_set(scene, seq);
if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
- if (seq->strip)
+ if (seq->strip) {
BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
+ }
}
else if (seq->type == SEQ_TYPE_SOUND_RAM) {
- if (seq->strip)
+ if (seq->strip) {
BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
+ }
}
seq->flag |= SELECT;
recurs_sel_seq(seq);
@@ -322,16 +327,18 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
int hand, sel_side;
TimeMarker *marker;
- if (ed == NULL)
+ if (ed == NULL) {
return OPERATOR_CANCELLED;
+ }
marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now
seq = find_nearest_seq(scene, v2d, &hand, event->mval);
// XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip
- if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE))
+ if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE)) {
left_right = SEQ_SELECT_LR_NONE;
+ }
if (marker) {
@@ -339,10 +346,12 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
/* select timeline marker */
if (extend) {
oldflag = marker->flag;
- if (oldflag & SELECT)
+ if (oldflag & SELECT) {
marker->flag &= ~SELECT;
- else
+ }
+ else {
marker->flag |= SELECT;
+ }
}
else {
/* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */
@@ -402,8 +411,9 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
act_orig = ed->act_seq;
- if (extend == 0 && linked_handle == 0)
+ if (extend == 0 && linked_handle == 0) {
ED_sequencer_deselect_all(scene);
+ }
if (seq) {
BKE_sequencer_active_set(scene, seq);
@@ -448,13 +458,17 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
switch (sel_side) {
case SEQ_SIDE_LEFT:
if ((seq->flag & SEQ_LEFTSEL) && (neighbor->flag & SEQ_RIGHTSEL)) {
- if (extend == 0) ED_sequencer_deselect_all(scene);
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
seq->flag |= SELECT;
select_active_side(ed->seqbasep, SEQ_SIDE_LEFT, seq->machine, seq->startdisp);
}
else {
- if (extend == 0) ED_sequencer_deselect_all(scene);
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
seq->flag |= SELECT;
neighbor->flag |= SELECT;
@@ -465,13 +479,17 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
break;
case SEQ_SIDE_RIGHT:
if ((seq->flag & SEQ_RIGHTSEL) && (neighbor->flag & SEQ_LEFTSEL)) {
- if (extend == 0) ED_sequencer_deselect_all(scene);
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
seq->flag |= SELECT;
select_active_side(ed->seqbasep, SEQ_SIDE_RIGHT, seq->machine, seq->startdisp);
}
else {
- if (extend == 0) ED_sequencer_deselect_all(scene);
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
seq->flag |= SELECT;
neighbor->flag |= SELECT;
@@ -483,7 +501,9 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
}
else {
- if (extend == 0) ED_sequencer_deselect_all(scene);
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
select_active_side(ed->seqbasep, sel_side, seq->machine, seq->startdisp);
}
}
@@ -492,8 +512,9 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
if (extend && (seq->flag & SELECT) && ed->act_seq == act_orig) {
switch (hand) {
case SEQ_SIDE_NONE:
- if (linked_handle == 0)
+ if (linked_handle == 0) {
seq->flag &= ~SEQ_ALLSEL;
+ }
break;
case SEQ_SIDE_LEFT:
seq->flag ^= SEQ_LEFTSEL;
@@ -505,8 +526,12 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
else {
seq->flag |= SELECT;
- if (hand == SEQ_SIDE_LEFT) seq->flag |= SEQ_LEFTSEL;
- if (hand == SEQ_SIDE_RIGHT) seq->flag |= SEQ_RIGHTSEL;
+ if (hand == SEQ_SIDE_LEFT) {
+ seq->flag |= SEQ_LEFTSEL;
+ }
+ if (hand == SEQ_SIDE_RIGHT) {
+ seq->flag |= SEQ_RIGHTSEL;
+ }
}
}
@@ -581,8 +606,9 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li
bool changed = false;
int isel;
- if (ed == NULL)
+ if (ed == NULL) {
return changed;
+ }
if (sel) {
sel = SELECT;
@@ -646,8 +672,9 @@ static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- if (!select_more_less_seq__internal(scene, true, false))
+ if (!select_more_less_seq__internal(scene, true, false)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
@@ -677,8 +704,9 @@ static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- if (!select_more_less_seq__internal(scene, false, false))
+ if (!select_more_less_seq__internal(scene, false, false)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
@@ -716,11 +744,13 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons
/* this works like UV, not mesh */
mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval);
- if (!mouse_seq)
+ if (!mouse_seq) {
return OPERATOR_FINISHED; /* user error as with mesh?? */
+ }
- if (extend == 0)
+ if (extend == 0) {
ED_sequencer_deselect_all(scene);
+ }
mouse_seq->flag |= SELECT;
recurs_sel_seq(mouse_seq);
@@ -845,8 +875,9 @@ static int sequencer_select_active_side_exec(bContext *C, wmOperator *op)
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq_act = BKE_sequencer_active_get(scene);
- if (ed == NULL || seq_act == NULL)
+ if (ed == NULL || seq_act == NULL) {
return OPERATOR_CANCELLED;
+ }
seq_act->flag |= SELECT;
@@ -1028,8 +1059,9 @@ static bool select_grouped_data(Editing *ed, Sequence *actseq, const int channel
bool changed = false;
const char *dir = actseq->strip ? actseq->strip->dir : NULL;
- if (!SEQ_USE_DATA(actseq))
+ if (!SEQ_USE_DATA(actseq)) {
return changed;
+ }
if (SEQ_HAS_PATH(actseq) && dir) {
SEQP_BEGIN (ed, seq)
@@ -1085,8 +1117,9 @@ static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int chann
bool effects[SEQ_TYPE_MAX + 1];
int i;
- for (i = 0; i <= SEQ_TYPE_MAX; i++)
+ for (i = 0; i <= SEQ_TYPE_MAX; i++) {
effects[i] = false;
+ }
SEQP_BEGIN (ed, seq)
{
@@ -1101,9 +1134,9 @@ static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int chann
SEQP_BEGIN (ed, seq)
{
if (SEQ_CHANNEL_CHECK(seq, channel) && effects[seq->type]) {
- if (seq->seq1) seq->seq1->flag |= SELECT;
- if (seq->seq2) seq->seq2->flag |= SELECT;
- if (seq->seq3) seq->seq3->flag |= SELECT;
+ if (seq->seq1) { seq->seq1->flag |= SELECT; }
+ if (seq->seq2) { seq->seq2->flag |= SELECT; }
+ if (seq->seq3) { seq->seq3->flag |= SELECT; }
changed = true;
}
}
@@ -1166,9 +1199,15 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int
(seq->seq2 && seq->seq2->tmp) ||
(seq->seq3 && seq->seq3->tmp)))
{
- if (startdisp > seq->startdisp) startdisp = seq->startdisp;
- if (enddisp < seq->enddisp) enddisp = seq->enddisp;
- if (machine < seq->machine) machine = seq->machine;
+ if (startdisp > seq->startdisp) {
+ startdisp = seq->startdisp;
+ }
+ if (enddisp < seq->enddisp) {
+ enddisp = seq->enddisp;
+ }
+ if (machine < seq->machine) {
+ machine = seq->machine;
+ }
seq->tmp = POINTER_FROM_INT(true);
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index d500a9a081d..30f526c0675 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -100,8 +100,10 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy);
- fx += (float) ibuf->x / 2.0f;
- fy += (float) ibuf->y / 2.0f;
+ fx += (float)scene->r.xsch / 2.0f;
+ fy += (float)scene->r.ysch / 2.0f;
+ fx *= (float)ibuf->x / (float)scene->r.xsch;
+ fy *= (float)ibuf->y / (float)scene->r.ysch;
if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) {
const float *fp;
@@ -175,8 +177,9 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
SpaceSeq *sseq = CTX_wm_space_seq(C);
ImageSampleInfo *info;
- if (sseq->mainb != SEQ_DRAW_IMG_IMBUF)
+ if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) {
return OPERATOR_CANCELLED;
+ }
info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
info->art = ar->type;
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index dec70c4bf43..561d603ab08 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -74,13 +74,17 @@ ARegion *sequencer_has_buttons_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) return 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) return NULL;
+ if (ar == NULL) {
+ return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "buttons for sequencer");
@@ -97,9 +101,11 @@ static ARegion *sequencer_find_region(ScrArea *sa, short type)
{
ARegion *ar = NULL;
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar->regiontype == type)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == type) {
return ar;
+ }
+ }
return ar;
}
@@ -199,20 +205,25 @@ static void sequencer_free(SpaceLink *sl)
// XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd);
- if (scopes->zebra_ibuf)
+ if (scopes->zebra_ibuf) {
IMB_freeImBuf(scopes->zebra_ibuf);
+ }
- if (scopes->waveform_ibuf)
+ if (scopes->waveform_ibuf) {
IMB_freeImBuf(scopes->waveform_ibuf);
+ }
- if (scopes->sep_waveform_ibuf)
+ if (scopes->sep_waveform_ibuf) {
IMB_freeImBuf(scopes->sep_waveform_ibuf);
+ }
- if (scopes->vector_ibuf)
+ if (scopes->vector_ibuf) {
IMB_freeImBuf(scopes->vector_ibuf);
+ }
- if (scopes->histogram_ibuf)
+ if (scopes->histogram_ibuf) {
IMB_freeImBuf(scopes->histogram_ibuf);
+ }
}
@@ -347,12 +358,14 @@ static void sequencer_listener(
break;
case NC_WINDOW:
case NC_SPACE:
- if (wmn->data == ND_SPACE_SEQUENCER)
+ if (wmn->data == ND_SPACE_SEQUENCER) {
sequencer_scopes_tag_refresh(sa);
+ }
break;
case NC_GPENCIL:
- if (wmn->data & ND_GPENCIL_EDITMODE)
+ if (wmn->data & ND_GPENCIL_EDITMODE) {
ED_area_tag_redraw(sa);
+ }
break;
}
}
@@ -365,10 +378,13 @@ static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, con
Scene *scene = CTX_data_scene(C);
int hand;
- if (drag->type == WM_DRAG_PATH)
- if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */
- if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL)
+ if (drag->type == WM_DRAG_PATH) {
+ if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* rule might not work? */
+ if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) {
return 1;
+ }
+ }
+ }
return 0;
}
@@ -379,10 +395,13 @@ static bool movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, con
Scene *scene = CTX_data_scene(C);
int hand;
- if (drag->type == WM_DRAG_PATH)
- if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) /* rule might not work? */
- if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL)
+ if (drag->type == WM_DRAG_PATH) {
+ if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* rule might not work? */
+ if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) {
return 1;
+ }
+ }
+ }
return 0;
}
@@ -392,18 +411,22 @@ static bool sound_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, con
Scene *scene = CTX_data_scene(C);
int hand;
- if (drag->type == WM_DRAG_PATH)
- if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) /* rule might not work? */
- if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL)
+ if (drag->type == WM_DRAG_PATH) {
+ if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* rule might not work? */
+ if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) {
return 1;
+ }
+ }
+ }
return 0;
}
static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop)
{
/* copy drag path to properties */
- if (RNA_struct_find_property(drop->ptr, "filepath"))
+ if (RNA_struct_find_property(drop->ptr, "filepath")) {
RNA_string_set(drop->ptr, "filepath", drag->path);
+ }
if (RNA_struct_find_property(drop->ptr, "directory")) {
PointerRNA itemptr;
@@ -514,16 +537,19 @@ static void sequencer_main_region_listener(
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_SEQUENCER)
+ if (wmn->data == ND_SPACE_SEQUENCER) {
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;
case NC_SCREEN:
- if (ELEM(wmn->data, ND_ANIMPLAY))
+ if (ELEM(wmn->data, ND_ANIMPLAY)) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -627,21 +653,27 @@ static void sequencer_preview_region_draw(const bContext *C, ARegion *ar)
(sseq->mainb == SEQ_DRAW_IMG_IMBUF));
/* XXX temp fix for wrong setting in sseq->mainb */
- if (sseq->mainb == SEQ_DRAW_SEQUENCE) sseq->mainb = SEQ_DRAW_IMG_IMBUF;
+ if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
+ sseq->mainb = SEQ_DRAW_IMG_IMBUF;
+ }
- if (!show_split || sseq->overlay_type != SEQ_DRAW_OVERLAY_REFERENCE)
+ if (!show_split || sseq->overlay_type != SEQ_DRAW_OVERLAY_REFERENCE) {
sequencer_draw_preview(C, scene, ar, sseq, scene->r.cfra, 0, false, false);
+ }
if (show_split && sseq->overlay_type != SEQ_DRAW_OVERLAY_CURRENT) {
int over_cfra;
- if (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS)
+ if (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) {
over_cfra = scene->ed->over_cfra;
- else
+ }
+ else {
over_cfra = scene->r.cfra + scene->ed->over_ofs;
+ }
- if (over_cfra != scene->r.cfra || sseq->overlay_type != SEQ_DRAW_OVERLAY_RECT)
+ if (over_cfra != scene->r.cfra || sseq->overlay_type != SEQ_DRAW_OVERLAY_RECT) {
sequencer_draw_preview(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra, true, false);
+ }
}
if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) {
@@ -685,8 +717,9 @@ static void sequencer_preview_region_listener(
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_SEQUENCER)
+ if (wmn->data == ND_SPACE_SEQUENCER) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_ID:
switch (wmn->data) {
@@ -741,12 +774,14 @@ static void sequencer_buttons_region_listener(
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_SEQUENCER)
+ if (wmn->data == ND_SPACE_SEQUENCER) {
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;
}
}
diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c
index e85d438e80d..3c5ccb7e59b 100644
--- a/source/blender/editors/space_statusbar/space_statusbar.c
+++ b/source/blender/editors/space_statusbar/space_statusbar.c
@@ -116,20 +116,24 @@ static void statusbar_header_region_listener(
}
break;
case NC_WM:
- if (wmn->data == ND_JOB)
+ if (wmn->data == ND_JOB) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCENE:
- if (wmn->data == ND_RENDER_RESULT)
+ if (wmn->data == ND_RENDER_RESULT) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_INFO)
+ if (wmn->data == ND_SPACE_INFO) {
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;
}
}
diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c
index d7dc9d625f5..85c3c4220c0 100644
--- a/source/blender/editors/space_text/text_format_py.c
+++ b/source/blender/editors/space_text/text_format_py.c
@@ -116,18 +116,22 @@ static int txtfmt_py_find_specialvar(const char *string)
static int txtfmt_py_find_decorator(const char *string)
{
- if (string[0] == '@') {
- int i = 1;
- /* Whitespace is ok '@ foo' */
- while (text_check_whitespace(string[i])) {
- i++;
- }
- while (text_check_identifier(string[i])) {
- i++;
- }
- return i;
+ if (string[0] != '@') {
+ return -1;
+ }
+ if (!text_check_identifier(string[1])) {
+ return -1;
}
- return -1;
+ /* Interpret as matrix multiplication when followed by whitespace. */
+ if (text_check_whitespace(string[1])) {
+ return -1;
+ }
+
+ int i = 1;
+ while (text_check_identifier(string[i])) {
+ i++;
+ }
+ return i;
}
static int txtfmt_py_find_bool(const char *string)
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
index e31f29cec8c..a65ced8987f 100644
--- a/source/blender/editors/space_topbar/space_topbar.c
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -72,15 +72,11 @@ 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), "left aligned main region for topbar");
- BLI_addtail(&stopbar->regionbase, ar);
- ar->regiontype = RGN_TYPE_WINDOW;
- ar->alignment = RGN_ALIGN_LEFT;
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), "center main region for topbar");
+ ar = MEM_callocN(sizeof(ARegion), "main region of topbar");
BLI_addtail(&stopbar->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
@@ -117,7 +113,7 @@ static void topbar_main_region_init(wmWindowManager *wm, ARegion *region)
wmKeyMap *keymap;
/* force delayed UI_view2d_region_reinit call */
- if (ELEM(region->alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
+ if (ELEM(region->alignment, RGN_ALIGN_RIGHT)) {
region->flag |= RGN_FLAG_DYNAMIC_SIZE;
}
UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_HEADER, region->winx, region->winy);
@@ -151,20 +147,24 @@ static void topbar_main_region_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(s
/* 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_VIEW3D)
+ if (wmn->data == ND_SPACE_VIEW3D) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_GPENCIL:
- if (wmn->data == ND_DATA)
+ if (wmn->data == ND_DATA) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -175,20 +175,24 @@ static void topbar_header_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), A
/* context changes */
switch (wmn->category) {
case NC_WM:
- if (wmn->data == ND_JOB)
+ if (wmn->data == ND_JOB) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_INFO)
+ if (wmn->data == ND_SPACE_INFO) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCREEN:
- if (wmn->data == ND_LAYER)
+ if (wmn->data == ND_LAYER) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCENE:
- if (wmn->data == ND_SCENEBROWSE)
+ if (wmn->data == ND_SCENEBROWSE) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index e6e0438164c..d4745247ae3 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -47,6 +47,8 @@
#include "UI_resources.h"
+#include "DRW_engine.h"
+
#include "view3d_intern.h" /* bad level include */
#include "../../draw/intern/draw_cache_impl.h" /* bad level include (temporary) */
@@ -61,15 +63,18 @@ int view3d_effective_drawtype(const struct View3D *v3d)
static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
{
- if ((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0)
+ if ((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0) {
return false;
+ }
- if (G.f & G_FLAG_BACKBUFSEL)
+ if (G.f & G_FLAG_BACKBUFSEL) {
return false;
+ }
/* if its drawing textures with zbuf sel, then don't draw dots */
- if (dt == OB_TEXTURE && vd->shading.type == OB_TEXTURE)
+ if (dt == OB_TEXTURE && vd->shading.type == OB_TEXTURE) {
return false;
+ }
return true;
}
@@ -281,7 +286,7 @@ static void bbs_mesh_solid_faces(Scene *UNUSED(scene), Object *ob, const float w
bbs_mesh_face(geom_faces, true, world_clip_planes);
}
-void draw_object_backbufsel(
+void draw_object_select_id(
Depsgraph *depsgraph, Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob,
short select_mode)
{
@@ -328,8 +333,9 @@ void draw_object_backbufsel(
bbs_mesh_face_dot(geom_facedots, world_clip_planes);
}
- if (select_mode & SCE_SELECT_FACE)
+ if (select_mode & SCE_SELECT_FACE) {
bm_solidoffs = 1 + em->bm->totface;
+ }
else {
bm_solidoffs = 1;
}
@@ -380,6 +386,52 @@ void draw_object_backbufsel(
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], const int facemap)
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index cf4b4b270f6..06c10b1b253 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -88,13 +88,17 @@ ARegion *view3d_has_buttons_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) return 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) return NULL;
+ if (ar == NULL) {
+ return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "buttons for view3d");
@@ -112,8 +116,9 @@ 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)
+ if (ar->regiontype == RGN_TYPE_TOOLS) {
artool = ar;
+ }
}
/* tool region hide/unhide also hides props */
@@ -123,12 +128,16 @@ ARegion *view3d_has_tools_region(ScrArea *sa)
if (artool == NULL) {
/* add subdiv level; after header */
- for (arhead = sa->regionbase.first; arhead; arhead = arhead->next)
- if (arhead->regiontype == RGN_TYPE_HEADER)
+ for (arhead = sa->regionbase.first; arhead; arhead = arhead->next) {
+ if (arhead->regiontype == RGN_TYPE_HEADER) {
break;
+ }
+ }
/* is error! */
- if (arhead == NULL) return NULL;
+ if (arhead == NULL) {
+ return NULL;
+ }
artool = MEM_callocN(sizeof(ARegion), "tools for view3d");
@@ -402,14 +411,20 @@ static void view3d_free(SpaceLink *sl)
{
View3D *vd = (View3D *) sl;
- if (vd->localvd) MEM_freeN(vd->localvd);
+ if (vd->localvd) {
+ MEM_freeN(vd->localvd);
+ }
- if (vd->properties_storage) MEM_freeN(vd->properties_storage);
+ if (vd->properties_storage) {
+ MEM_freeN(vd->properties_storage);
+ }
- if (vd->fx_settings.ssao)
+ if (vd->fx_settings.ssao) {
MEM_freeN(vd->fx_settings.ssao);
- if (vd->fx_settings.dof)
+ }
+ if (vd->fx_settings.dof) {
MEM_freeN(vd->fx_settings.dof);
+ }
}
@@ -431,16 +446,19 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
v3dn->properties_storage = NULL;
}
- if (v3dn->shading.type == OB_RENDER)
+ if (v3dn->shading.type == OB_RENDER) {
v3dn->shading.type = OB_SOLID;
+ }
/* copy or clear inside new stuff */
v3dn->properties_storage = NULL;
- if (v3dn->fx_settings.dof)
+ if (v3dn->fx_settings.dof) {
v3dn->fx_settings.dof = MEM_dupallocN(v3do->fx_settings.dof);
- if (v3dn->fx_settings.ssao)
+ }
+ if (v3dn->fx_settings.ssao) {
v3dn->fx_settings.ssao = MEM_dupallocN(v3do->fx_settings.ssao);
+ }
return (SpaceLink *)v3dn;
}
@@ -533,14 +551,7 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar)
static void view3d_main_region_exit(wmWindowManager *wm, ARegion *ar)
{
- RegionView3D *rv3d = ar->regiondata;
-
ED_view3d_stop_render_preview(wm, ar);
-
- if (rv3d->gpuoffscreen) {
- GPU_offscreen_free(rv3d->gpuoffscreen);
- rv3d->gpuoffscreen = NULL;
- }
}
static bool view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip))
@@ -716,22 +727,26 @@ static void view3d_main_region_free(ARegion *ar)
RegionView3D *rv3d = ar->regiondata;
if (rv3d) {
- if (rv3d->localvd) MEM_freeN(rv3d->localvd);
- if (rv3d->clipbb) MEM_freeN(rv3d->clipbb);
+ if (rv3d->localvd) {
+ MEM_freeN(rv3d->localvd);
+ }
+ if (rv3d->clipbb) {
+ MEM_freeN(rv3d->clipbb);
+ }
- if (rv3d->render_engine)
+ if (rv3d->render_engine) {
RE_engine_free(rv3d->render_engine);
+ }
if (rv3d->depths) {
- if (rv3d->depths->depths) MEM_freeN(rv3d->depths->depths);
+ if (rv3d->depths->depths) {
+ MEM_freeN(rv3d->depths->depths);
+ }
MEM_freeN(rv3d->depths);
}
if (rv3d->sms) {
MEM_freeN(rv3d->sms);
}
- if (rv3d->gpuoffscreen) {
- GPU_offscreen_free(rv3d->gpuoffscreen);
- }
MEM_freeN(rv3d);
ar->regiondata = NULL;
@@ -745,13 +760,14 @@ static void *view3d_main_region_duplicate(void *poin)
RegionView3D *rv3d = poin, *new;
new = MEM_dupallocN(rv3d);
- if (rv3d->localvd)
+ if (rv3d->localvd) {
new->localvd = MEM_dupallocN(rv3d->localvd);
- if (rv3d->clipbb)
+ }
+ if (rv3d->clipbb) {
new->clipbb = MEM_dupallocN(rv3d->clipbb);
+ }
new->depths = NULL;
- new->gpuoffscreen = NULL;
new->render_engine = NULL;
new->sms = NULL;
new->smooth_timer = NULL;
@@ -784,12 +800,14 @@ static void view3d_main_region_listener(
break;
case ND_NLA:
case ND_KEYFRAME:
- if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED))
+ if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) {
ED_region_tag_redraw(ar);
+ }
break;
case ND_ANIMCHAN:
- if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED, NA_SELECTED))
+ if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED, NA_SELECTED)) {
ED_region_tag_redraw(ar);
+ }
break;
}
break;
@@ -832,8 +850,9 @@ static void view3d_main_region_listener(
break;
}
}
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_OBJECT:
switch (wmn->data) {
@@ -960,8 +979,9 @@ static void view3d_main_region_listener(
ED_region_tag_redraw(ar);
break;
case NC_MOVIECLIP:
- if (wmn->data == ND_DISPLAY || wmn->action == NA_EDITED)
+ if (wmn->data == ND_DISPLAY || wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SPACE:
if (wmn->data == ND_SPACE_VIEW3D) {
@@ -973,8 +993,9 @@ static void view3d_main_region_listener(
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCREEN:
switch (wmn->data) {
@@ -1148,12 +1169,14 @@ static void view3d_header_region_listener(
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_VIEW3D)
+ if (wmn->data == ND_SPACE_VIEW3D) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_GPENCIL:
- if (wmn->data & ND_GPENCIL_EDITMODE)
+ if (wmn->data & ND_GPENCIL_EDITMODE) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -1218,8 +1241,9 @@ static void view3d_buttons_region_listener(
break;
case ND_NLA:
case ND_KEYFRAME:
- if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED))
+ if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) {
ED_region_tag_redraw(ar);
+ }
break;
}
break;
@@ -1263,8 +1287,9 @@ static void view3d_buttons_region_listener(
ED_region_tag_redraw(ar);
break;
}
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_TEXTURE:
case NC_MATERIAL:
@@ -1273,25 +1298,30 @@ static void view3d_buttons_region_listener(
break;
case NC_BRUSH:
/* NA_SELECTED is used on brush changes */
- if (ELEM(wmn->action, NA_EDITED, NA_SELECTED))
+ if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_VIEW3D)
+ if (wmn->data == ND_SPACE_VIEW3D) {
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;
case NC_GPENCIL:
- if ((wmn->data & (ND_DATA | ND_GPENCIL_EDITMODE)) || (wmn->action == NA_EDITED))
+ if ((wmn->data & (ND_DATA | ND_GPENCIL_EDITMODE)) || (wmn->action == NA_EDITED)) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_IMAGE:
/* Update for the image layers in texture paint. */
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -1323,8 +1353,9 @@ static void space_view3d_listener(
case NC_SCENE:
switch (wmn->data) {
case ND_WORLD:
- if (v3d->flag2 & V3D_HIDE_OVERLAYS)
+ if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW);
+ }
break;
}
break;
@@ -1341,8 +1372,9 @@ static void space_view3d_listener(
case NC_MATERIAL:
switch (wmn->data) {
case ND_NODES:
- if (v3d->shading.type == OB_TEXTURE)
+ if (v3d->shading.type == OB_TEXTURE) {
ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW);
+ }
break;
}
break;
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 706215f8fae..3baf297e580 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -124,10 +124,12 @@ typedef struct {
*/
static float compute_scale_factor(const float ve_median, const float median)
{
- if (ve_median <= 0.0f)
+ if (ve_median <= 0.0f) {
return 0.0f;
- else if (ve_median >= 1.0f)
+ }
+ else if (ve_median >= 1.0f) {
return 1.0f;
+ }
else {
/* Scale value to target median. */
float median_new = ve_median;
@@ -337,8 +339,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
nu = nu->next;
}
- if (totcurvedata == 1)
+ if (totcurvedata == 1) {
RNA_pointer_create(&cu->id, seltype, selp, &data_ptr);
+ }
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
@@ -364,8 +367,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
bp++;
}
- if (totlattdata == 1)
+ if (totlattdata == 1) {
RNA_pointer_create(&lt->id, seltype, selp, &data_ptr);
+ }
}
if (tot == 0) {
@@ -375,8 +379,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
/* Location, X/Y/Z */
mul_v3_fl(median_basis.generic.location, 1.0f / (float)tot);
- if (v3d->flag & V3D_GLOBAL_STATS)
+ if (v3d->flag & V3D_GLOBAL_STATS) {
mul_m4_v3(ob->obmat, median_basis.generic.location);
+ }
if (has_meshdata) {
TransformMedian_Mesh *median = &median_basis.mesh;
@@ -419,13 +424,18 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
UI_block_align_begin(block);
if (tot == 1) {
- if (totcurvedata) /* Curve */
+ if (totcurvedata) {
+ /* Curve */
c = IFACE_("Control Point:");
- else /* Mesh or lattice */
+ }
+ else {
+ /* Mesh or lattice */
c = IFACE_("Vertex:");
+ }
}
- else
+ else {
c = IFACE_("Median:");
+ }
uiDefBut(block, UI_BTYPE_LABEL, 0, c, 0, yi -= buth, butw, buth, NULL, 0, 0, 0, 0, "");
UI_block_align_begin(block);
@@ -993,10 +1003,12 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr)
colsub = uiLayoutColumn(split, true);
uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE);
uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE);
- if (RNA_boolean_get(ptr, "lock_rotations_4d"))
+ if (RNA_boolean_get(ptr, "lock_rotations_4d")) {
uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE + UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED);
- else
+ }
+ else {
uiItemL(colsub, "", ICON_NONE);
+ }
uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED);
break;
case ROT_MODE_AXISANGLE: /* axis angle */
@@ -1005,10 +1017,12 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr)
colsub = uiLayoutColumn(split, true);
uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE);
uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE);
- if (RNA_boolean_get(ptr, "lock_rotations_4d"))
+ if (RNA_boolean_get(ptr, "lock_rotations_4d")) {
uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED);
- else
+ }
+ else {
uiItemL(colsub, "", ICON_NONE);
+ }
uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED);
break;
default: /* euler rotations */
@@ -1093,8 +1107,9 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob)
MetaBall *mball = ob->data;
uiLayout *col;
- if (!mball || !(mball->lastelem))
+ if (!mball || !(mball->lastelem)) {
return;
+ }
RNA_pointer_create(&mball->id, &RNA_MetaBall, mball, &mbptr);
@@ -1257,8 +1272,9 @@ 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)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c
index d1ff73d1f87..3f7356de465 100644
--- a/source/blender/editors/space_view3d/view3d_camera_control.c
+++ b/source/blender/editors/space_view3d/view3d_camera_control.c
@@ -162,8 +162,9 @@ struct View3DCameraControl *ED_view3d_cameracontrol_acquire(
if (rv3d->persp == RV3D_CAMOB) {
Object *ob_back;
if (use_parent_root && (vctrl->root_parent = v3d->camera->parent)) {
- while (vctrl->root_parent->parent)
+ while (vctrl->root_parent->parent) {
vctrl->root_parent = vctrl->root_parent->parent;
+ }
ob_back = vctrl->root_parent;
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 5e59c36a80f..522d081fdd6 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -93,7 +93,9 @@
#include "view3d_intern.h" /* own include */
-/* ******************** general functions ***************** */
+/* -------------------------------------------------------------------- */
+/** \name General Functions
+ * \{ */
/**
* \note keep this synced with #ED_view3d_mats_rv3d_backup/#ED_view3d_mats_rv3d_restore
@@ -105,10 +107,12 @@ void ED_view3d_update_viewmat(
RegionView3D *rv3d = ar->regiondata;
/* setup window matrices */
- if (winmat)
+ if (winmat) {
copy_m4_m4(rv3d->winmat, winmat);
- else
+ }
+ else {
view3d_winmatrix_set(depsgraph, ar, v3d, rect);
+ }
/* setup view matrix */
if (viewmat) {
@@ -231,8 +235,9 @@ static void view3d_stereo3d_setup(
const char *viewname;
/* show only left or right camera */
- if (v3d->stereo3d_camera != STEREO_3D_ID)
+ if (v3d->stereo3d_camera != STEREO_3D_ID) {
v3d->multiview_eye = v3d->stereo3d_camera;
+ }
is_left = v3d->multiview_eye == STEREO_LEFT_ID;
viewname = names[is_left ? STEREO_LEFT_ID : STEREO_RIGHT_ID];
@@ -291,7 +296,11 @@ void ED_view3d_draw_setup_view(
}
}
-/* ******************** view border ***************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Draw View Border
+ * \{ */
static void view3d_camera_border(
const Scene *scene, struct Depsgraph *depsgraph,
@@ -305,8 +314,9 @@ static void view3d_camera_border(
/* get viewport viewplane */
BKE_camera_params_init(&params);
BKE_camera_params_from_view3d(&params, depsgraph, v3d, rv3d);
- if (no_zoom)
+ if (no_zoom) {
params.zoom = 1.0f;
+ }
BKE_camera_params_compute_viewplane(&params, ar->winx, ar->winy, 1.0f, 1.0f);
rect_view = params.viewplane;
@@ -393,7 +403,9 @@ static void drawviewborder_triangle(
else {
ofs = h * (h / w);
}
- if (dir == 'B') SWAP(float, y1, y2);
+ if (dir == 'B') {
+ SWAP(float, y1, y2);
+ }
immVertex2f(shdr_pos, x1, y1);
immVertex2f(shdr_pos, x2, y2);
@@ -411,7 +423,9 @@ static void drawviewborder_triangle(
else {
ofs = w * (w / h);
}
- if (dir == 'B') SWAP(float, x1, x2);
+ if (dir == 'B') {
+ SWAP(float, x1, x2);
+ }
immVertex2f(shdr_pos, x1, y1);
immVertex2f(shdr_pos, x2, y2);
@@ -435,10 +449,12 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
Camera *ca = NULL;
RegionView3D *rv3d = ar->regiondata;
- if (v3d->camera == NULL)
+ if (v3d->camera == NULL) {
return;
- if (v3d->camera->type == OB_CAMERA)
+ }
+ if (v3d->camera->type == OB_CAMERA) {
ca = v3d->camera->data;
+ }
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false);
/* the offsets */
@@ -482,14 +498,18 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
immUniformColor4f(0.0f, 0.0f, 0.0f, alpha);
- if (x1i > 0.0f)
+ if (x1i > 0.0f) {
immRectf(shdr_pos, 0.0f, winy, x1i, 0.0f);
- if (x2i < winx)
+ }
+ if (x2i < winx) {
immRectf(shdr_pos, x2i, winy, winx, 0.0f);
- if (y2i < winy)
+ }
+ if (y2i < winy) {
immRectf(shdr_pos, x1i, winy, x2i, y2i);
- if (y2i > 0.0f)
+ }
+ if (y2i > 0.0f) {
immRectf(shdr_pos, x1i, y1i, x2i, 0.0f);
+ }
GPU_blend(false);
}
@@ -731,7 +751,8 @@ void ED_view3d_draw_depth(
GPU_depth_test(true);
- DRW_draw_depth_loop(depsgraph, ar, v3d);
+ GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0);
+ DRW_draw_depth_loop(depsgraph, ar, v3d, viewport);
if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_disable();
@@ -762,8 +783,9 @@ float ED_scene_grid_scale(Scene *scene, const char **grid_unit)
if (usys) {
int i = bUnit_GetBaseUnit(usys);
- if (grid_unit)
+ if (grid_unit) {
*grid_unit = bUnit_GetNameDisplay(usys, i);
+ }
return (float)bUnit_GetScaler(usys, i) / scene->unit.scale_length;
}
}
@@ -963,8 +985,9 @@ static void draw_rotation_guide(const RegionView3D *rv3d)
color[3] = 255; /* solid dot */
}
- else
+ else {
color[3] = 127; /* see-through dot */
+ }
immUnbindProgram();
@@ -989,8 +1012,6 @@ static void draw_rotation_guide(const RegionView3D *rv3d)
}
#endif /* WITH_INPUT_NDOF */
-/* ******************** info ***************** */
-
/**
* Render and camera border
*/
@@ -1009,8 +1030,14 @@ static void view3d_draw_border(const bContext *C, ARegion *ar)
}
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Draw Text & Info
+ * \{ */
+
/**
- * Grease Pencil
+ * Draw Info
*/
static void view3d_draw_grease_pencil(const bContext *UNUSED(C))
{
@@ -1026,28 +1053,52 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d)
switch (rv3d->view) {
case RV3D_VIEW_FRONT:
- if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Front Orthographic");
- else name = IFACE_("Front Perspective");
+ if (rv3d->persp == RV3D_ORTHO) {
+ name = IFACE_("Front Orthographic");
+ }
+ else {
+ name = IFACE_("Front Perspective");
+ }
break;
case RV3D_VIEW_BACK:
- if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Back Orthographic");
- else name = IFACE_("Back Perspective");
+ if (rv3d->persp == RV3D_ORTHO) {
+ name = IFACE_("Back Orthographic");
+ }
+ else {
+ name = IFACE_("Back Perspective");
+ }
break;
case RV3D_VIEW_TOP:
- if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Top Orthographic");
- else name = IFACE_("Top Perspective");
+ if (rv3d->persp == RV3D_ORTHO) {
+ name = IFACE_("Top Orthographic");
+ }
+ else {
+ name = IFACE_("Top Perspective");
+ }
break;
case RV3D_VIEW_BOTTOM:
- if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Bottom Orthographic");
- else name = IFACE_("Bottom Perspective");
+ if (rv3d->persp == RV3D_ORTHO) {
+ name = IFACE_("Bottom Orthographic");
+ }
+ else {
+ name = IFACE_("Bottom Perspective");
+ }
break;
case RV3D_VIEW_RIGHT:
- if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Right Orthographic");
- else name = IFACE_("Right Perspective");
+ if (rv3d->persp == RV3D_ORTHO) {
+ name = IFACE_("Right Orthographic");
+ }
+ else {
+ name = IFACE_("Right Perspective");
+ }
break;
case RV3D_VIEW_LEFT:
- if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Left Orthographic");
- else name = IFACE_("Left Perspective");
+ if (rv3d->persp == RV3D_ORTHO) {
+ name = IFACE_("Left Orthographic");
+ }
+ else {
+ name = IFACE_("Left Perspective");
+ }
break;
default:
@@ -1217,10 +1268,12 @@ static void draw_selected_name(Scene *scene, ViewLayer *view_layer, Object *ob,
}
else {
/* no object */
- if (ED_gpencil_has_keyframe_v3d(scene, NULL, cfra))
+ if (ED_gpencil_has_keyframe_v3d(scene, NULL, cfra)) {
UI_FontThemeColor(font_id, TH_TIME_GP_KEYFRAME);
- else
+ }
+ else {
UI_FontThemeColor(font_id, TH_TEXT_HI);
+ }
}
if (markern) {
@@ -1237,8 +1290,6 @@ static void draw_selected_name(Scene *scene, ViewLayer *view_layer, Object *ob,
BLF_disable(font_id, BLF_SHADOW);
}
-/* ******************** view loop ***************** */
-
/**
* Information drawn on top of the solid plates and composed data
*/
@@ -1324,6 +1375,12 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar)
BLF_batch_draw_end();
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Draw Viewport Contents
+ * \{ */
+
static void view3d_draw_view(const bContext *C, ARegion *ar)
{
ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, CTX_wm_view3d(C), NULL, NULL, NULL);
@@ -1365,6 +1422,8 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar)
v3d->flag |= V3D_INVALID_BACKBUF;
}
+/** \} */
+
/* -------------------------------------------------------------------- */
/** \name Offscreen Drawing
* \{ */
@@ -1396,7 +1455,7 @@ void ED_view3d_draw_offscreen(
View3D *v3d, ARegion *ar, int winx, int winy,
float viewmat[4][4], float winmat[4][4],
bool do_sky, bool UNUSED(is_persp), const char *viewname,
- GPUFXSettings *UNUSED(fx_settings),
+ GPUFXSettings *UNUSED(fx_settings), const bool do_color_management,
GPUOffScreen *ofs, GPUViewport *viewport)
{
RegionView3D *rv3d = ar->regiondata;
@@ -1432,15 +1491,17 @@ void ED_view3d_draw_offscreen(
GPU_matrix_push();
GPU_matrix_identity_set();
- if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera)
+ if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera) {
view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, ar, winmat, viewname);
- else
+ }
+ else {
view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, NULL);
+ }
/* main drawing call */
DRW_draw_render_loop_offscreen(
depsgraph, engine_type, ar, v3d,
- do_sky, ofs, viewport);
+ do_sky, do_color_management, ofs, viewport);
/* restore size */
ar->winx = bwinx;
@@ -1543,12 +1604,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
}
if ((samples && use_full_sample) == 0) {
+ const bool do_color_management = (ibuf->rect_float == NULL);
/* Single-pass render, common case */
ED_view3d_draw_offscreen(
depsgraph, scene, drawtype,
v3d, ar, sizex, sizey, NULL, winmat,
draw_sky, !is_ortho, viewname,
- &fx_settings, ofs, NULL);
+ &fx_settings, do_color_management, ofs, NULL);
if (ibuf->rect_float) {
GPU_offscreen_read_pixels(ofs, GL_FLOAT, ibuf->rect_float);
@@ -1573,7 +1635,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
depsgraph, scene, drawtype,
v3d, ar, sizex, sizey, NULL, winmat,
draw_sky, !is_ortho, viewname,
- &fx_settings, ofs, viewport);
+ &fx_settings, false, ofs, viewport);
GPU_offscreen_read_pixels(ofs, GL_FLOAT, accum_buffer);
/* skip the first sample */
@@ -1588,7 +1650,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
depsgraph, scene, drawtype,
v3d, ar, sizex, sizey, NULL, winmat_jitter,
draw_sky, !is_ortho, viewname,
- &fx_settings, ofs, viewport);
+ &fx_settings, false, ofs, viewport);
GPU_offscreen_read_pixels(ofs, GL_FLOAT, rect_temp);
uint i = sizex * sizey * 4;
@@ -1638,8 +1700,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
GPU_framebuffer_bind(old_fb);
}
- if (ibuf->rect_float && ibuf->rect)
+ if (ibuf->rect_float && ibuf->rect) {
IMB_rect_from_float(ibuf);
+ }
return ibuf;
}
@@ -1727,11 +1790,15 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
static bool view3d_clipping_test(const float co[3], const float clip[6][4])
{
- if (plane_point_side_v3(clip[0], co) > 0.0f)
- if (plane_point_side_v3(clip[1], co) > 0.0f)
- if (plane_point_side_v3(clip[2], co) > 0.0f)
- if (plane_point_side_v3(clip[3], co) > 0.0f)
+ if (plane_point_side_v3(clip[0], co) > 0.0f) {
+ if (plane_point_side_v3(clip[1], co) > 0.0f) {
+ if (plane_point_side_v3(clip[2], co) > 0.0f) {
+ if (plane_point_side_v3(clip[3], co) > 0.0f) {
return false;
+ }
+ }
+ }
+ }
return true;
}
@@ -1743,5 +1810,4 @@ bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], const
return view3d_clipping_test(co, is_local ? rv3d->clip_local : rv3d->clip);
}
-
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index a52fd89d284..454315afa57 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -95,6 +95,7 @@
#include "GPU_select.h"
#include "GPU_matrix.h"
#include "GPU_state.h"
+#include "GPU_viewport.h"
#include "RE_engine.h"
@@ -149,7 +150,7 @@ void ED_view3d_clipping_enable(void)
/* *********************** backdraw for selection *************** */
-static void backdrawview3d(
+static void validate_object_select_id(
struct Depsgraph *depsgraph, Scene *scene,
ARegion *ar, View3D *v3d,
Object *obact, Object *obedit,
@@ -187,8 +188,9 @@ static void backdrawview3d(
return;
}
- if (!(v3d->flag & V3D_INVALID_BACKBUF))
+ if (!(v3d->flag & V3D_INVALID_BACKBUF)) {
return;
+ }
#if 0
if (test) {
@@ -200,102 +202,116 @@ static void backdrawview3d(
#endif
#if 0 /* v3d->zbuf deprecated */
- if (v3d->shading.type > OB_WIRE) v3d->zbuf = true;
-#endif
-
- /* dithering and AA break color coding, so disable */
- glDisable(GL_DITHER);
-
- if (false) {
- /* for multisample we use an offscreen FBO. multisample drawing can fail
- * with color coded selection drawing, and reading back depths from such
- * a buffer can also cause a few seconds freeze on OS X / NVidia.
- *
- * NOTE: code is no longer used now, but offscreen drawing is likely
- * what we will always want to do for the new viewport. */
- int w = BLI_rcti_size_x(&ar->winrct);
- int h = BLI_rcti_size_y(&ar->winrct);
- char error[256];
-
- if (rv3d->gpuoffscreen) {
- if (GPU_offscreen_width(rv3d->gpuoffscreen) != w ||
- GPU_offscreen_height(rv3d->gpuoffscreen) != h)
- {
- GPU_offscreen_free(rv3d->gpuoffscreen);
- rv3d->gpuoffscreen = NULL;
- }
- }
-
- if (!rv3d->gpuoffscreen) {
- rv3d->gpuoffscreen = GPU_offscreen_create(w, h, 0, true, false, error);
-
- if (!rv3d->gpuoffscreen)
- fprintf(stderr, "Failed to create offscreen selection buffer for multisample: %s\n", error);
- }
+ if (v3d->shading.type > OB_WIRE) {
+ v3d->zbuf = true;
}
-
- if (rv3d->gpuoffscreen)
- GPU_offscreen_bind(rv3d->gpuoffscreen, true);
- else
- GPU_scissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
-
- GPU_clear_color(0.0, 0.0, 0.0, 0.0);
- GPU_depth_test(true);
- GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
-
- if (rv3d->rflag & RV3D_CLIPPING)
- ED_view3d_clipping_set(rv3d);
+#endif
G.f |= G_FLAG_BACKBUFSEL;
if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE) != 0)) {
- draw_object_backbufsel(depsgraph, scene_eval, v3d, rv3d, obact_eval, select_mode);
+ DRW_framebuffer_select_id_setup(ar, true);
+ draw_object_select_id(depsgraph, scene_eval, v3d, rv3d, obact_eval, select_mode);
+ DRW_framebuffer_select_id_release(ar);
}
- if (rv3d->gpuoffscreen)
- GPU_offscreen_unbind(rv3d->gpuoffscreen, true);
-
+ /* TODO: Create a flag in `DRW_manager` because the drawing is no longer
+ * made on the backbuffer in this case. */
v3d->flag &= ~V3D_INVALID_BACKBUF;
G.f &= ~G_FLAG_BACKBUFSEL;
- GPU_depth_test(false);
- glEnable(GL_DITHER);
-
- if (rv3d->rflag & RV3D_CLIPPING)
- ED_view3d_clipping_disable();
}
void view3d_opengl_read_pixels(ARegion *ar, int x, int y, int w, int h, int format, int type, void *data)
{
- RegionView3D *rv3d = ar->regiondata;
+ glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data);
+}
- if (rv3d->gpuoffscreen) {
- GPU_offscreen_bind(rv3d->gpuoffscreen, true);
- glReadBuffer(GL_COLOR_ATTACHMENT0);
- glReadPixels(x, y, w, h, format, type, data);
- GPU_offscreen_unbind(rv3d->gpuoffscreen, true);
- }
- else {
- 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)
+{
+ DefaultTextureList *dtxl = (DefaultTextureList *)GPU_viewport_texture_list_get(viewport);
+
+ 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,
+ BLI_rcti_size_x(rect), BLI_rcti_size_y(rect),
+ GL_DEPTH_COMPONENT, GL_FLOAT, data);
+
+ glEnable(GL_SCISSOR_TEST);
+ GPU_framebuffer_restore();
+
+ GPU_framebuffer_free(tmp_fb);
+}
+
+void ED_view3d_select_id_validate_with_select_mode(ViewContext *vc, short select_mode)
+{
+ /* TODO: Create a flag in `DRW_manager` because the drawing is no longer
+ * made on the backbuffer in this case. */
+ if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
+ validate_object_select_id(
+ vc->depsgraph, vc->scene, vc->ar, vc->v3d,
+ vc->obact, vc->obedit, select_mode);
}
}
-/* XXX depth reading exception, for code not using gpu offscreen */
-static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h, int format, int type, void *data)
+void ED_view3d_select_id_validate(ViewContext *vc)
{
- glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data);
+ ED_view3d_select_id_validate_with_select_mode(vc, -1);
}
-void ED_view3d_backbuf_validate_with_select_mode(ViewContext *vc, short select_mode)
+void ED_view3d_backbuf_depth_validate(ViewContext *vc)
{
if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
- backdrawview3d(vc->depsgraph, vc->scene, vc->ar, vc->v3d, vc->obact, vc->obedit, select_mode);
+ 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);
+ }
+
+ vc->v3d->flag &= ~V3D_INVALID_BACKBUF;
}
}
-void ED_view3d_backbuf_validate(ViewContext *vc)
+uint *ED_view3d_select_id_read_rect(ViewContext *vc, const rcti *clip, uint *r_buf_len)
{
- ED_view3d_backbuf_validate_with_select_mode(vc, -1);
+ ED_view3d_select_id_validate(vc);
+
+ uint width = BLI_rcti_size_x(clip);
+ uint height = BLI_rcti_size_y(clip);
+ uint buf_len = width * height;
+ uint *buf = MEM_mallocN(buf_len * sizeof(*buf), __func__);
+
+ DRW_framebuffer_select_id_read(clip, buf);
+
+ if (r_buf_len) {
+ *r_buf_len = buf_len;
+ }
+
+ return buf;
}
/**
@@ -308,140 +324,119 @@ int ED_view3d_backbuf_sample_size_clamp(ARegion *ar, const float dist)
}
/* samples a single pixel (copied from vpaint) */
-uint ED_view3d_backbuf_sample(
+uint ED_view3d_select_id_sample(
ViewContext *vc, int x, int y)
{
if (x >= vc->ar->winx || y >= vc->ar->winy) {
return 0;
}
- ED_view3d_backbuf_validate(vc);
-
- uint col;
- view3d_opengl_read_pixels(vc->ar, x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
- glReadBuffer(GL_BACK);
+ uint buf_len;
+ uint *buf = ED_view3d_select_id_read(vc, x, y, x, y, &buf_len);
+ BLI_assert(0 != buf_len);
+ uint ret = buf[0];
+ MEM_freeN(buf);
- if (ENDIAN_ORDER == B_ENDIAN) {
- BLI_endian_switch_uint32(&col);
- }
-
- return GPU_select_to_index(col);
+ return ret;
}
/* reads full rect, converts indices */
-ImBuf *ED_view3d_backbuf_read(
- ViewContext *vc, int xmin, int ymin, int xmax, int ymax)
+uint *ED_view3d_select_id_read(
+ ViewContext *vc, int xmin, int ymin, int xmax, int ymax, uint *r_buf_len)
{
- /* clip */
- const rcti clip = {
- max_ii(xmin, 0), min_ii(xmax, vc->ar->winx - 1),
- max_ii(ymin, 0), min_ii(ymax, vc->ar->winy - 1)};
- const int size_clip[2] = {
- BLI_rcti_size_x(&clip) + 1,
- BLI_rcti_size_y(&clip) + 1};
-
- if (UNLIKELY((clip.xmin > clip.xmax) ||
- (clip.ymin > clip.ymax)))
- {
+ if (UNLIKELY((xmin > xmax) || (ymin > ymax))) {
return NULL;
}
- ImBuf *ibuf_clip = IMB_allocImBuf(size_clip[0], size_clip[1], 32, IB_rect);
-
- ED_view3d_backbuf_validate(vc);
-
- view3d_opengl_read_pixels(vc->ar, clip.xmin, clip.ymin, size_clip[0], size_clip[1], GL_RGBA, GL_UNSIGNED_BYTE, ibuf_clip->rect);
+ const rcti rect = {
+ .xmin = xmin, .xmax = xmax + 1,
+ .ymin = ymin, .ymax = ymax + 1,
+ };
- glReadBuffer(GL_BACK);
+ uint buf_len;
+ uint *buf = ED_view3d_select_id_read_rect(vc, &rect, &buf_len);
- if (ENDIAN_ORDER == B_ENDIAN) {
- IMB_convert_rgba_to_abgr(ibuf_clip);
+ if (r_buf_len) {
+ *r_buf_len = buf_len;
}
- GPU_select_to_index_array(ibuf_clip->rect, size_clip[0] * size_clip[1]);
-
- if ((clip.xmin == xmin) &&
- (clip.xmax == xmax) &&
- (clip.ymin == ymin) &&
- (clip.ymax == ymax))
- {
- return ibuf_clip;
- }
- else {
- /* put clipped result into a non-clipped buffer */
- const int size[2] = {
- (xmax - xmin + 1),
- (ymax - ymin + 1)};
-
- ImBuf *ibuf_full = IMB_allocImBuf(size[0], size[1], 32, IB_rect);
-
- IMB_rectcpy(
- ibuf_full, ibuf_clip,
- clip.xmin - xmin, clip.ymin - ymin,
- 0, 0,
- size_clip[0], size_clip[1]);
- IMB_freeImBuf(ibuf_clip);
- return ibuf_full;
- }
+ return buf;
}
/* smart function to sample a rect spiralling outside, nice for backbuf selection */
-uint ED_view3d_backbuf_sample_rect(
- ViewContext *vc, const int mval[2], int size,
- uint min, uint max, float *r_dist)
+uint ED_view3d_select_id_read_nearest(
+ struct ViewContext *UNUSED(vc), const int mval[2],
+ const uint id_min, const uint id_max, uint *r_dist)
{
- int dirvec[4][2];
-
- const int amount = (size - 1) / 2;
+ /* Create region around mouse cursor. This must be square and have an odd
+ * width, the spiralling algorithm does not work with arbitrary rectangles. */
+ rcti rect;
+ BLI_rcti_init_pt_radius(&rect, mval, *r_dist);
+ rect.xmax += 1;
+ rect.ymax += 1;
- const int minx = mval[0] - (amount + 1);
- const int miny = mval[1] - (amount + 1);
- ImBuf *buf = ED_view3d_backbuf_read(vc, minx, miny, minx + size - 1, miny + size - 1);
- if (!buf) return 0;
+ int width = BLI_rcti_size_x(&rect);
+ int height = width;
+ BLI_assert(width == height);
- unsigned index = 0;
- int rc = 0;
+ /* Read from selection framebuffer. */
+ uint *buf = MEM_mallocN(width * height * sizeof(*buf), __func__);
+ DRW_framebuffer_select_id_read(&rect, buf);
- dirvec[0][0] = 1; dirvec[0][1] = 0;
- dirvec[1][0] = 0; dirvec[1][1] = -size;
- dirvec[2][0] = -1; dirvec[2][1] = 0;
- dirvec[3][0] = 0; dirvec[3][1] = size;
+ /* Spiral, starting from center of buffer. */
+ int spiral_offset = height * (int)(width / 2) + (height / 2);
+ int spiral_direction = 0;
- const unsigned *bufmin = buf->rect;
- const unsigned *tbuf = buf->rect;
- const unsigned *bufmax = buf->rect + size * size;
- tbuf += amount * size + amount;
+ uint index = 0;
- for (int nr = 1; nr <= size; nr++) {
+ for (int nr = 1; nr <= height; nr++) {
for (int a = 0; a < 2; a++) {
for (int b = 0; b < nr; b++) {
- if (*tbuf && *tbuf >= min && *tbuf < max) {
- /* we got a hit */
+ /* Find hit within the specified range. */
+ uint hit_id = buf[spiral_offset];
+
+ if (hit_id && hit_id >= id_min && hit_id < id_max) {
+ /* Get x/y from spiral offset. */
+ int hit_x = spiral_offset % width;
+ int hit_y = spiral_offset / width;
- /* get x,y pixel coords from the offset
- * (manhatten distance in keeping with other screen-based selection) */
- *r_dist = (float)(
- abs(((int)(tbuf - buf->rect) % size) - (size / 2)) +
- abs(((int)(tbuf - buf->rect) / size) - (size / 2)));
+ int center_x = width / 2;
+ int center_y = height / 2;
- /* indices start at 1 here */
- index = (*tbuf - min) + 1;
+ /* Manhatten distance in keeping with other screen-based selection. */
+ *r_dist = (uint)(abs(hit_x - center_x) + abs(hit_y - center_y));
+
+ /* Indices start at 1 here. */
+ index = (hit_id - id_min) + 1;
goto exit;
}
- tbuf += (dirvec[rc][0] + dirvec[rc][1]);
+ /* Next spiral step. */
+ if (spiral_direction == 0) {
+ spiral_offset += 1; /* right */
+ }
+ else if (spiral_direction == 1) {
+ spiral_offset -= width; /* down */
+ }
+ else if (spiral_direction == 2) {
+ spiral_offset -= 1; /* left */
+ }
+ else {
+ spiral_offset += width; /* up */
+ }
- if (tbuf < bufmin || tbuf >= bufmax) {
+ /* Stop if we are outside the buffer. */
+ if (spiral_offset < 0 || spiral_offset >= width * height) {
goto exit;
}
}
- rc++;
- rc &= 3;
+
+ spiral_direction = (spiral_direction + 1) % 4;
}
}
exit:
- IMB_freeImBuf(buf);
+ MEM_freeN(buf);
return index;
}
@@ -480,8 +475,9 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
Camera *cam = v3d->camera->data;
for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
- if ((bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != fg_flag)
+ if ((bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != fg_flag) {
continue;
+ }
{
float image_aspect[2];
@@ -492,16 +488,18 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
Image *ima = NULL;
/* disable individual images */
- if ((bgpic->flag & CAM_BGIMG_FLAG_DISABLED))
+ if ((bgpic->flag & CAM_BGIMG_FLAG_DISABLED)) {
continue;
+ }
ImBuf *ibuf = NULL;
ImBuf *freeibuf = NULL;
ImBuf *releaseibuf = NULL;
if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) {
ima = bgpic->ima;
- if (ima == NULL)
+ if (ima == NULL) {
continue;
+ }
ImageUser iuser = bgpic->iuser;
iuser.scene = scene; /* Needed for render results. */
@@ -523,15 +521,17 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
MovieClip *clip = NULL;
if (bgpic->flag & CAM_BGIMG_FLAG_CAMERACLIP) {
- if (scene->camera)
+ if (scene->camera) {
clip = BKE_object_movieclip_get(scene, scene->camera, true);
+ }
}
else {
clip = bgpic->clip;
}
- if (clip == NULL)
+ if (clip == NULL) {
continue;
+ }
BKE_movieclip_user_set_frame(&bgpic->cuser, (int)DEG_get_ctime(depsgraph));
ibuf = BKE_movieclip_get_ibuf(clip, &bgpic->cuser);
@@ -550,21 +550,25 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
copy_v2_fl(image_aspect, 1.0f);
}
- if (ibuf == NULL)
+ if (ibuf == NULL) {
continue;
+ }
if ((ibuf->rect == NULL && ibuf->rect_float == NULL) || ibuf->channels != 4) {
/* invalid image format */
- if (freeibuf)
+ if (freeibuf) {
IMB_freeImBuf(freeibuf);
- if (releaseibuf)
+ }
+ if (releaseibuf) {
BKE_image_release_ibuf(ima, releaseibuf, lock);
+ }
continue;
}
- if (ibuf->rect == NULL)
+ if (ibuf->rect == NULL) {
IMB_rect_from_float(ibuf);
+ }
BLI_assert(rv3d->persp == RV3D_CAMOB);
{
@@ -637,10 +641,12 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
}
if (clip_rect.xmax < 0 || clip_rect.ymax < 0 || clip_rect.xmin > ar->winx || clip_rect.ymin > ar->winy) {
- if (freeibuf)
+ if (freeibuf) {
IMB_freeImBuf(freeibuf);
- if (releaseibuf)
+ }
+ if (releaseibuf) {
BKE_image_release_ibuf(ima, releaseibuf, lock);
+ }
continue;
}
@@ -657,8 +663,9 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
IMB_remakemipmap(ibuf, 0);
ibuf->userflags &= ~IB_MIPMAP_INVALID;
}
- else if (ibuf->mipmap[0] == NULL)
+ else if (ibuf->mipmap[0] == NULL) {
IMB_makemipmap(ibuf, 0);
+ }
while (tzoom < 1.0f && mip < 8 && ibuf->mipmap[mip]) {
tzoom *= 2.0f;
@@ -666,8 +673,9 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
zoomy *= 2.0f;
mip++;
}
- if (mip > 0)
+ if (mip > 0) {
ibuf = ibuf->mipmap[mip - 1];
+ }
}
GPU_depth_test(!do_foreground);
@@ -706,10 +714,12 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
glDepthMask(GL_TRUE);
GPU_depth_test(true);
- if (freeibuf)
+ if (freeibuf) {
IMB_freeImBuf(freeibuf);
- if (releaseibuf)
+ }
+ if (releaseibuf) {
BKE_image_release_ibuf(ima, releaseibuf, lock);
+ }
}
}
}
@@ -734,8 +744,9 @@ void ED_view3d_draw_bgpic_test(
/* disabled - mango request, since footage /w only render is quite useful
* and this option is easy to disable all background images at once */
#if 0
- if (v3d->flag2 & V3D_HIDE_OVERLAYS)
+ if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
return;
+ }
#endif
if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) {
@@ -750,7 +761,6 @@ void ED_view3d_draw_bgpic_test(
/* *********************** */
-/* XXX warning, not using gpu offscreen here */
void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
{
/* clamp rect by region */
@@ -772,8 +782,9 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
int h = BLI_rcti_size_y(rect);
if (w <= 0 || h <= 0) {
- if (d->depths)
+ if (d->depths) {
MEM_freeN(d->depths);
+ }
d->depths = NULL;
d->damaged = false;
@@ -790,8 +801,9 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
d->w = w;
d->h = h;
- if (d->depths)
+ if (d->depths) {
MEM_freeN(d->depths);
+ }
d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths Subset");
@@ -799,8 +811,8 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
}
if (d->damaged) {
- /* XXX using special function here, it doesn't use the gpu offscreen system */
- view3d_opengl_read_Z_pixels(ar, d->x, d->y, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths);
+ GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0);
+ view3d_opengl_read_Z_pixels(viewport, rect, d->depths);
glGetDoublev(GL_DEPTH_RANGE, d->depth_range);
d->damaged = false;
}
@@ -812,7 +824,9 @@ void ED_view3d_depth_update(ARegion *ar)
RegionView3D *rv3d = ar->regiondata;
/* Create storage for, and, if necessary, copy depth buffer */
- if (!rv3d->depths) rv3d->depths = MEM_callocN(sizeof(ViewDepths), "ViewDepths");
+ if (!rv3d->depths) {
+ rv3d->depths = MEM_callocN(sizeof(ViewDepths), "ViewDepths");
+ }
if (rv3d->depths) {
ViewDepths *d = rv3d->depths;
if (d->w != ar->winx ||
@@ -821,8 +835,9 @@ void ED_view3d_depth_update(ARegion *ar)
{
d->w = ar->winx;
d->h = ar->winy;
- if (d->depths)
+ if (d->depths) {
MEM_freeN(d->depths);
+ }
d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths");
d->damaged = true;
}
@@ -863,8 +878,6 @@ float view3d_depth_near(ViewDepths *d)
void ED_view3d_draw_depth_gpencil(
Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d)
{
- ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
-
/* Setup view matrix. */
ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL);
@@ -872,7 +885,8 @@ void ED_view3d_draw_depth_gpencil(
GPU_depth_test(true);
- ED_gpencil_draw_view3d(NULL, scene, view_layer, depsgraph, v3d, ar, true);
+ GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0);
+ DRW_draw_depth_loop_gpencil(depsgraph, ar, v3d, viewport);
GPU_depth_test(false);
}
@@ -887,8 +901,9 @@ void ED_view3d_datamask(
if (ELEM(drawtype, OB_TEXTURE, OB_MATERIAL)) {
r_cddata_masks->lmask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL;
- if (drawtype == OB_MATERIAL)
+ if (drawtype == OB_MATERIAL) {
r_cddata_masks->vmask |= CD_MASK_ORCO;
+ }
}
if ((CTX_data_mode_enum(C) == CTX_MODE_EDIT_MESH) &&
@@ -962,8 +977,9 @@ void ED_scene_draw_fps(Scene *scene, int xoffset, int *yoffset)
ScreenFrameRateInfo *fpsi = scene->fps_info;
char printable[16];
- if (!fpsi || !fpsi->lredrawtime || !fpsi->redrawtime)
+ if (!fpsi || !fpsi->lredrawtime || !fpsi->redrawtime) {
return;
+ }
printable[0] = '\0';
@@ -985,8 +1001,9 @@ void ED_scene_draw_fps(Scene *scene, int xoffset, int *yoffset)
fpsi->redrawtime_index = (fpsi->redrawtime_index + 1) % REDRAW_FRAME_AVERAGE;
//fpsi->redrawtime_index++;
- //if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE)
+ //if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) {
// fpsi->redrawtime = 0;
+ //}
fps = fps / tot;
}
@@ -1031,17 +1048,21 @@ bool ED_view3d_calc_render_border(const Scene *scene, Depsgraph *depsgraph, View
bool use_border;
/* test if there is a 3d view rendering */
- if (v3d->shading.type != OB_RENDER || !view3d_main_region_do_render_draw(scene))
+ if (v3d->shading.type != OB_RENDER || !view3d_main_region_do_render_draw(scene)) {
return false;
+ }
/* test if there is a border render */
- if (rv3d->persp == RV3D_CAMOB)
+ if (rv3d->persp == RV3D_CAMOB) {
use_border = (scene->r.mode & R_BORDER) != 0;
- else
+ }
+ else {
use_border = (v3d->flag2 & V3D_RENDER_BORDER) != 0;
+ }
- if (!use_border)
+ if (!use_border) {
return false;
+ }
/* compute border */
if (rv3d->persp == RV3D_CAMOB) {
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 638efab4598..19008ebd122 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -80,6 +80,12 @@
#include "view3d_intern.h" /* own include */
+
+enum {
+ HAS_TRANSLATE = (1 << 0),
+ HAS_ROTATE = (1 << 0),
+};
+
/* -------------------------------------------------------------------- */
/** \name Generic View Operator Properties
* \{ */
@@ -501,8 +507,9 @@ static void viewops_data_create(
}
vod->reverse = 1.0f;
- if (rv3d->persmat[2][1] < 0.0f)
+ if (rv3d->persmat[2][1] < 0.0f) {
vod->reverse = -1.0f;
+ }
rv3d->rflag |= RV3D_NAVIGATING;
}
@@ -518,8 +525,9 @@ static void viewops_data_free(bContext *C, wmOperator *op)
ar = vod->ar;
vod->rv3d->rflag &= ~RV3D_NAVIGATING;
- if (vod->timer)
+ if (vod->timer) {
WM_event_remove_timer(CTX_wm_manager(C), vod->timer->win, vod->timer);
+ }
MEM_freeN(vod);
op->customdata = NULL;
@@ -531,7 +539,9 @@ static void viewops_data_free(bContext *C, wmOperator *op)
#if 0
if (p && (p->flags & PAINT_FAST_NAVIGATE))
#endif
+ {
ED_region_tag_redraw(ar);
+ }
}
/** \} */
@@ -574,7 +584,9 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Rotate Modal");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items) return;
+ if (keymap && keymap->modal_items) {
+ return;
+ }
keymap = WM_modalkeymap_add(keyconf, "View3D Rotate Modal", modal_items);
@@ -1064,8 +1076,9 @@ static void view3d_ndof_pan_zoom(
if (ndof->tvec[2]) {
float zoom_distance = rv3d->dist * ndof->dt * ndof->tvec[2];
- if (U.ndof_flag & NDOF_ZOOM_INVERT)
+ if (U.ndof_flag & NDOF_ZOOM_INVERT) {
zoom_distance = -zoom_distance;
+ }
rv3d->dist += zoom_distance;
}
@@ -1191,8 +1204,9 @@ void view3d_ndof_fly(
float speed = view3d_ndof_pan_speed_calc_from_dist(rv3d, 1.0f);
float trans[3], trans_orig_y;
- if (use_precision)
+ if (use_precision) {
speed *= 0.2f;
+ }
WM_event_ndof_pan_get(ndof, trans, false);
mul_v3_fl(trans, speed * ndof->dt);
@@ -1212,9 +1226,15 @@ void view3d_ndof_fly(
if (rv3d->persp == RV3D_CAMOB) {
/* respect camera position locks */
- if (protectflag & OB_LOCK_LOCX) trans[0] = 0.0f;
- if (protectflag & OB_LOCK_LOCY) trans[1] = 0.0f;
- if (protectflag & OB_LOCK_LOCZ) trans[2] = 0.0f;
+ if (protectflag & OB_LOCK_LOCX) {
+ trans[0] = 0.0f;
+ }
+ if (protectflag & OB_LOCK_LOCY) {
+ trans[1] = 0.0f;
+ }
+ if (protectflag & OB_LOCK_LOCZ) {
+ trans[2] = 0.0f;
+ }
}
if (!is_zero_v3(trans)) {
@@ -1238,8 +1258,9 @@ void view3d_ndof_fly(
if (fabsf(angle) > 0.0001f) {
has_rotate = true;
- if (use_precision)
+ if (use_precision) {
angle *= 0.2f;
+ }
/* transform rotation axis from view to world coordinates */
mul_qt_v3(view_inv, axis);
@@ -1286,11 +1307,7 @@ void view3d_ndof_fly(
/** \} */
/* -------------------------------------------------------------------- */
-/** \name NDOF Operators
- *
- * - "orbit" navigation (trackball/turntable)
- * - zooming
- * - panning in rotationally-locked views
+/** \name NDOF Orbit/Translate Operator
* \{ */
static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -1298,53 +1315,58 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (event->type != NDOF_MOTION) {
return OPERATOR_CANCELLED;
}
- else {
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
- ViewOpsData *vod;
- View3D *v3d;
- RegionView3D *rv3d;
- const wmNDOFMotionData *ndof = event->customdata;
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ViewOpsData *vod;
+ View3D *v3d;
+ RegionView3D *rv3d;
+ char xform_flag = 0;
- viewops_data_alloc(C, op);
- viewops_data_create(
- C, op, event,
- viewops_flag_from_args((U.uiflag & USER_ORBIT_SELECTION) != 0, false));
- vod = op->customdata;
+ const wmNDOFMotionData *ndof = event->customdata;
- ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar);
+ viewops_data_alloc(C, op);
+ viewops_data_create(
+ C, op, event,
+ viewops_flag_from_args((U.uiflag & USER_ORBIT_SELECTION) != 0, false));
+ vod = op->customdata;
- v3d = vod->v3d;
- rv3d = vod->rv3d;
+ ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar);
- /* off by default, until changed later this function */
- rv3d->rot_angle = 0.0f;
+ v3d = vod->v3d;
+ rv3d = vod->rv3d;
- ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
+ /* off by default, until changed later this function */
+ rv3d->rot_angle = 0.0f;
- if (ndof->progress != P_FINISHING) {
- const bool has_rotation = NDOF_HAS_ROTATE;
- /* if we can't rotate, fallback to translate (locked axis views) */
- const bool has_translate = NDOF_HAS_TRANSLATE && (rv3d->viewlock & RV3D_LOCKED);
- const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp;
+ ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
- if (has_translate || has_zoom) {
- view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom);
- }
+ if (ndof->progress != P_FINISHING) {
+ const bool has_rotation = NDOF_HAS_ROTATE;
+ /* if we can't rotate, fallback to translate (locked axis views) */
+ const bool has_translate = NDOF_HAS_TRANSLATE && (rv3d->viewlock & RV3D_LOCKED);
+ const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp;
- if (has_rotation) {
- view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, true);
- }
+ if (has_translate || has_zoom) {
+ view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom);
+ xform_flag |= HAS_TRANSLATE;
}
- ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
+ if (has_rotation) {
+ view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, true);
+ xform_flag |= HAS_ROTATE;
+ }
+ }
- ED_region_tag_redraw(vod->ar);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
+ if (xform_flag) {
+ ED_view3d_camera_lock_autokey(v3d, rv3d, C, xform_flag & HAS_ROTATE, xform_flag & HAS_TRANSLATE);
+ }
- viewops_data_free(C, op);
+ ED_region_tag_redraw(vod->ar);
- return OPERATOR_FINISHED;
- }
+ viewops_data_free(C, op);
+
+ return OPERATOR_FINISHED;
}
void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot)
@@ -1362,91 +1384,105 @@ void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot)
ot->flag = 0;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name NDOF Orbit/Zoom Operator
+ * \{ */
+
static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
if (event->type != NDOF_MOTION) {
return OPERATOR_CANCELLED;
}
- else {
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
- ViewOpsData *vod;
- View3D *v3d;
- RegionView3D *rv3d;
- const wmNDOFMotionData *ndof = event->customdata;
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ViewOpsData *vod;
+ View3D *v3d;
+ RegionView3D *rv3d;
+ char xform_flag = 0;
- viewops_data_alloc(C, op);
- viewops_data_create(
- C, op, event,
- viewops_flag_from_args((U.uiflag & USER_ORBIT_SELECTION) != 0, false));
+ const wmNDOFMotionData *ndof = event->customdata;
- vod = op->customdata;
+ viewops_data_alloc(C, op);
+ viewops_data_create(
+ C, op, event,
+ viewops_flag_from_args((U.uiflag & USER_ORBIT_SELECTION) != 0, false));
- ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar);
+ vod = op->customdata;
- v3d = vod->v3d;
- rv3d = vod->rv3d;
+ ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar);
- /* off by default, until changed later this function */
- rv3d->rot_angle = 0.0f;
+ v3d = vod->v3d;
+ rv3d = vod->rv3d;
- ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
+ /* off by default, until changed later this function */
+ rv3d->rot_angle = 0.0f;
- if (ndof->progress == P_FINISHING) {
- /* pass */
- }
- else if ((rv3d->persp == RV3D_ORTHO) && RV3D_VIEW_IS_AXIS(rv3d->view)) {
- /* if we can't rotate, fallback to translate (locked axis views) */
- const bool has_translate = NDOF_HAS_TRANSLATE;
- const bool has_zoom = (ndof->tvec[2] != 0.0f) && ED_view3d_offset_lock_check(v3d, rv3d);
+ ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
- if (has_translate || has_zoom) {
- view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, true);
- }
- }
- else if ((U.ndof_flag & NDOF_MODE_ORBIT) ||
- ED_view3d_offset_lock_check(v3d, rv3d))
- {
- const bool has_rotation = NDOF_HAS_ROTATE;
- const bool has_zoom = (ndof->tvec[2] != 0.0f);
+ if (ndof->progress == P_FINISHING) {
+ /* pass */
+ }
+ else if ((rv3d->persp == RV3D_ORTHO) && RV3D_VIEW_IS_AXIS(rv3d->view)) {
+ /* if we can't rotate, fallback to translate (locked axis views) */
+ const bool has_translate = NDOF_HAS_TRANSLATE;
+ const bool has_zoom = (ndof->tvec[2] != 0.0f) && ED_view3d_offset_lock_check(v3d, rv3d);
- if (has_zoom) {
- view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, false, has_zoom);
- }
+ if (has_translate || has_zoom) {
+ view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, true);
+ xform_flag |= HAS_TRANSLATE;
+ }
+ }
+ else if ((U.ndof_flag & NDOF_MODE_ORBIT) ||
+ ED_view3d_offset_lock_check(v3d, rv3d))
+ {
+ const bool has_rotation = NDOF_HAS_ROTATE;
+ const bool has_zoom = (ndof->tvec[2] != 0.0f);
- if (has_rotation) {
- view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, true);
- }
+ if (has_zoom) {
+ view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, false, has_zoom);
+ xform_flag |= HAS_TRANSLATE;
}
- else { /* free/explore (like fly mode) */
- const bool has_rotation = NDOF_HAS_ROTATE;
- const bool has_translate = NDOF_HAS_TRANSLATE;
- const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp;
- float dist_backup;
+ if (has_rotation) {
+ view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, true);
+ xform_flag |= HAS_ROTATE;
+ }
+ }
+ else { /* free/explore (like fly mode) */
+ const bool has_rotation = NDOF_HAS_ROTATE;
+ const bool has_translate = NDOF_HAS_TRANSLATE;
+ const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp;
- if (has_translate || has_zoom) {
- view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom);
- }
+ float dist_backup;
- dist_backup = rv3d->dist;
- ED_view3d_distance_set(rv3d, 0.0f);
+ if (has_translate || has_zoom) {
+ view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom);
+ xform_flag |= HAS_TRANSLATE;
+ }
- if (has_rotation) {
- view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, false);
- }
+ dist_backup = rv3d->dist;
+ ED_view3d_distance_set(rv3d, 0.0f);
- ED_view3d_distance_set(rv3d, dist_backup);
+ if (has_rotation) {
+ view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, false);
+ xform_flag |= HAS_ROTATE;
}
- ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
+ ED_view3d_distance_set(rv3d, dist_backup);
+ }
- ED_region_tag_redraw(vod->ar);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
+ if (xform_flag) {
+ ED_view3d_camera_lock_autokey(v3d, rv3d, C, xform_flag & HAS_ROTATE, xform_flag & HAS_TRANSLATE);
+ }
- viewops_data_free(C, op);
+ ED_region_tag_redraw(vod->ar);
- return OPERATOR_FINISHED;
- }
+ viewops_data_free(C, op);
+
+ return OPERATOR_FINISHED;
}
void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot)
@@ -1464,46 +1500,54 @@ void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot)
ot->flag = 0;
}
-/* -- "pan" navigation
- * -- zoom or dolly?
- */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name NDOF Pan/Zoom Operator
+ * \{ */
+
static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
if (event->type != NDOF_MOTION) {
return OPERATOR_CANCELLED;
}
- else {
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
- const wmNDOFMotionData *ndof = event->customdata;
- const bool has_translate = NDOF_HAS_TRANSLATE;
- const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp;
+ const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ const wmNDOFMotionData *ndof = event->customdata;
+ char xform_flag = 0;
- /* we're panning here! so erase any leftover rotation from other operators */
- rv3d->rot_angle = 0.0f;
+ const bool has_translate = NDOF_HAS_TRANSLATE;
+ const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp;
- if (!(has_translate || has_zoom))
- return OPERATOR_CANCELLED;
+ /* we're panning here! so erase any leftover rotation from other operators */
+ rv3d->rot_angle = 0.0f;
+
+ if (!(has_translate || has_zoom)) {
+ return OPERATOR_CANCELLED;
+ }
- ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
+ ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false);
- if (ndof->progress != P_FINISHING) {
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = CTX_wm_region(C);
+ if (ndof->progress != P_FINISHING) {
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
- if (has_translate || has_zoom) {
- view3d_ndof_pan_zoom(ndof, sa, ar, has_translate, has_zoom);
- }
+ if (has_translate || has_zoom) {
+ view3d_ndof_pan_zoom(ndof, sa, ar, has_translate, has_zoom);
+ xform_flag |= HAS_TRANSLATE;
}
+ }
- ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
+ ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
+ if (xform_flag) {
+ ED_view3d_camera_lock_autokey(v3d, rv3d, C, false, xform_flag & HAS_TRANSLATE);
+ }
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_FINISHED;
- }
+ return OPERATOR_FINISHED;
}
void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot)
@@ -1521,6 +1565,11 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot)
ot->flag = 0;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name NDOF Transform All Operator
+ * \{ */
/**
* wraps #ndof_orbit_zoom but never restrict to orbit.
@@ -1543,7 +1592,7 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void VIEW3D_OT_ndof_all(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "NDOF Pan View";
+ ot->name = "NDOF Transform View";
ot->description = "Pan and rotate the view with the 3D mouse";
ot->idname = "VIEW3D_OT_ndof_all";
@@ -1580,7 +1629,9 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Move Modal");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items) return;
+ if (keymap && keymap->modal_items) {
+ return;
+ }
keymap = WM_modalkeymap_add(keyconf, "View3D Move Modal", modal_items);
@@ -1772,7 +1823,9 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Zoom Modal");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items) return;
+ if (keymap && keymap->modal_items) {
+ return;
+ }
keymap = WM_modalkeymap_add(keyconf, "View3D Zoom Modal", modal_items);
@@ -2303,7 +2356,9 @@ void viewdolly_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Dolly Modal");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items) return;
+ if (keymap && keymap->modal_items) {
+ return;
+ }
keymap = WM_modalkeymap_add(keyconf, "View3D Dolly Modal", modal_items);
@@ -2482,8 +2537,9 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ViewOpsData *vod;
- if (viewdolly_offset_lock_check(C, op))
+ if (viewdolly_offset_lock_check(C, op)) {
return OPERATOR_CANCELLED;
+ }
/* makes op->customdata */
viewops_data_alloc(C, op);
@@ -2850,13 +2906,16 @@ static int viewselected_exec(bContext *C, wmOperator *op)
Base *base_eval;
for (base_eval = view_layer_eval->object_bases.first; base_eval; base_eval = base_eval->next) {
if (BASE_SELECTED_EDITABLE(v3d, base_eval)) {
- if (base_eval->object->type == OB_ARMATURE)
- if (base_eval->object->mode & OB_MODE_POSE)
+ if (base_eval->object->type == OB_ARMATURE) {
+ if (base_eval->object->mode & OB_MODE_POSE) {
break;
+ }
+ }
}
}
- if (base_eval)
+ if (base_eval) {
ob_eval = base_eval->object;
+ }
}
if (is_gp_edit) {
@@ -2874,15 +2933,6 @@ static int viewselected_exec(bContext *C, wmOperator *op)
mul_m4_v3(ob_eval->obmat, max);
}
}
- else if (ob_eval && (ob_eval->type == OB_GPENCIL)) {
- ok |= BKE_gpencil_data_minmax(ob_eval, gpd, min, max);
- /* if no strokes, use object location */
- if ((ob_eval) && (!ok)) {
- copy_v3_v3(min, ob_eval->obmat[3]);
- copy_v3_v3(max, ob_eval->obmat[3]);
- ok = true;
- }
- }
else if (is_face_map) {
ok = WM_gizmomap_minmax(ar->gizmo_map, true, true, min, max);
}
@@ -3306,16 +3356,20 @@ static int render_border_exec(bContext *C, wmOperator *op)
/* drawing a border outside the camera view switches off border rendering */
if ((border.xmin == border.xmax || border.ymin == border.ymax)) {
- if (rv3d->persp == RV3D_CAMOB)
+ if (rv3d->persp == RV3D_CAMOB) {
scene->r.mode &= ~R_BORDER;
- else
+ }
+ else {
v3d->flag2 &= ~V3D_RENDER_BORDER;
+ }
}
else {
- if (rv3d->persp == RV3D_CAMOB)
+ if (rv3d->persp == RV3D_CAMOB) {
scene->r.mode |= R_BORDER;
- else
+ }
+ else {
v3d->flag2 |= V3D_RENDER_BORDER;
+ }
}
if (rv3d->persp == RV3D_CAMOB) {
@@ -3888,19 +3942,24 @@ static int view_camera_exec(bContext *C, wmOperator *op)
}
/* if the camera isn't found, check a number of options */
- if (v3d->camera == NULL && ob && ob->type == OB_CAMERA)
+ if (v3d->camera == NULL && ob && ob->type == OB_CAMERA) {
v3d->camera = ob;
+ }
- if (v3d->camera == NULL)
+ if (v3d->camera == NULL) {
v3d->camera = BKE_view_layer_camera_find(view_layer);
+ }
/* couldn't find any useful camera, bail out */
- if (v3d->camera == NULL)
+ if (v3d->camera == NULL) {
return OPERATOR_CANCELLED;
+ }
/* important these don't get out of sync for locked scenes */
- if (v3d->scenelock)
+ if (v3d->scenelock && scene->camera != v3d->camera) {
scene->camera = v3d->camera;
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+ }
/* finally do snazzy view zooming */
rv3d->persp = RV3D_CAMOB;
@@ -4102,8 +4161,9 @@ static void viewroll_apply(ViewOpsData *vod, int x, int UNUSED(y))
angle = (len1 - len2) * (float)M_PI * 4.0f;
}
- if (angle != 0.0f)
+ if (angle != 0.0f) {
view_roll_angle(vod->ar, vod->rv3d->viewquat, vod->init.quat, vod->init.mousevec, angle);
+ }
if (vod->use_dyn_ofs) {
view3d_orbit_apply_dyn_ofs(vod->rv3d->ofs, vod->init.ofs, vod->init.quat, vod->rv3d->viewquat, vod->dyn_ofs);
@@ -4379,9 +4439,12 @@ static int viewpersportho_exec(bContext *C, wmOperator *UNUSED(op))
rv3d = ar->regiondata;
if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
- if (rv3d->persp != RV3D_ORTHO)
+ if (rv3d->persp != RV3D_ORTHO) {
rv3d->persp = RV3D_ORTHO;
- else rv3d->persp = RV3D_PERSP;
+ }
+ else {
+ rv3d->persp = RV3D_PERSP;
+ }
ED_region_tag_redraw(ar);
}
@@ -4591,8 +4654,9 @@ static void calc_local_clipping(float clip_local[6][4], BoundBox *clipbb, float
void ED_view3d_clipping_local(RegionView3D *rv3d, float mat[4][4])
{
- if (rv3d->rflag & RV3D_CLIPPING)
+ if (rv3d->rflag & RV3D_CLIPPING) {
calc_local_clipping(rv3d->clip_local, rv3d->clipbb, mat);
+ }
}
static int view3d_clipping_exec(bContext *C, wmOperator *op)
@@ -4620,7 +4684,9 @@ static int view3d_clipping_invoke(bContext *C, wmOperator *op, const wmEvent *ev
if (rv3d->rflag & RV3D_CLIPPING) {
rv3d->rflag &= ~RV3D_CLIPPING;
ED_region_tag_redraw(ar);
- if (rv3d->clipbb) MEM_freeN(rv3d->clipbb);
+ if (rv3d->clipbb) {
+ MEM_freeN(rv3d->clipbb);
+ }
rv3d->clipbb = NULL;
return OPERATOR_FINISHED;
}
@@ -4670,8 +4736,9 @@ void ED_view3d_cursor3d_position(bContext *C, const int mval[2], const bool use_
/* normally the caller should ensure this,
* but this is called from areas that aren't already dealing with the viewport */
- if (rv3d == NULL)
+ if (rv3d == NULL) {
return;
+ }
ED_view3d_calc_zfac(rv3d, cursor_co, &flip);
@@ -4710,8 +4777,9 @@ void ED_view3d_cursor3d_position_rotation(
RegionView3D *rv3d = ar->regiondata;
/* XXX, caller should check. */
- if (rv3d == NULL)
+ if (rv3d == NULL) {
return;
+ }
ED_view3d_cursor3d_position(C, mval, use_depth, cursor_co);
@@ -4846,10 +4914,12 @@ void ED_view3d_cursor3d_update(
}
}
- if (v3d->localvd)
+ if (v3d->localvd) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
- else
+ }
+ else {
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
+ }
{
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 47961371530..b80ce2c49b0 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -129,8 +129,9 @@ void fly_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Fly Modal");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return;
+ }
keymap = WM_modalkeymap_add(keyconf, "View3D Fly Modal", modal_items);
@@ -402,8 +403,9 @@ static int flyEnd(bContext *C, FlyInfo *fly)
wmWindow *win;
RegionView3D *rv3d;
- if (fly->state == FLY_RUNNING)
+ if (fly->state == FLY_RUNNING) {
return OPERATOR_RUNNING_MODAL;
+ }
#ifdef NDOF_FLY_DEBUG
puts("\n-- fly end --");
@@ -421,8 +423,9 @@ static int flyEnd(bContext *C, FlyInfo *fly)
rv3d->rflag &= ~RV3D_NAVIGATING;
#ifdef WITH_INPUT_NDOF
- if (fly->ndof)
+ if (fly->ndof) {
MEM_freeN(fly->ndof);
+ }
#endif
if (fly->state == FLY_CONFIRM) {
@@ -504,12 +507,15 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
float fac = 0.02f * (event->prevy - event->y);
/* allowing to brake immediate */
- if (fac > 0.0f && fly->speed < 0.0f)
+ if (fac > 0.0f && fly->speed < 0.0f) {
fly->speed = 0.0f;
- else if (fac < 0.0f && fly->speed > 0.0f)
+ }
+ else if (fac < 0.0f && fly->speed > 0.0f) {
fly->speed = 0.0f;
- else
+ }
+ else {
fly->speed += fly->grid * fac;
+ }
break;
}
@@ -581,8 +587,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
else {
/* flip speed rather than stopping, game like motion,
* else increase like mousewheel if were already moving in that direction */
- if (fly->speed < 0.0f) fly->speed = -fly->speed;
- else if (fly->axis == 2) fly->speed += fly->grid;
+ if (fly->speed < 0.0f) {
+ fly->speed = -fly->speed;
+ }
+ else if (fly->axis == 2) {
+ fly->speed += fly->grid;
+ }
fly->axis = 2;
}
break;
@@ -591,8 +601,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
fly->axis = -1;
}
else {
- if (fly->speed > 0.0f) fly->speed = -fly->speed;
- else if (fly->axis == 2) fly->speed -= fly->grid;
+ if (fly->speed > 0.0f) {
+ fly->speed = -fly->speed;
+ }
+ else if (fly->axis == 2) {
+ fly->speed -= fly->grid;
+ }
fly->axis = 2;
}
@@ -602,8 +616,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
fly->axis = -1;
}
else {
- if (fly->speed < 0.0f) fly->speed = -fly->speed;
- else if (fly->axis == 0) fly->speed += fly->grid;
+ if (fly->speed < 0.0f) {
+ fly->speed = -fly->speed;
+ }
+ else if (fly->axis == 0) {
+ fly->speed += fly->grid;
+ }
fly->axis = 0;
}
@@ -613,8 +631,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
fly->axis = -1;
}
else {
- if (fly->speed > 0.0f) fly->speed = -fly->speed;
- else if (fly->axis == 0) fly->speed -= fly->grid;
+ if (fly->speed > 0.0f) {
+ fly->speed = -fly->speed;
+ }
+ else if (fly->axis == 0) {
+ fly->speed -= fly->grid;
+ }
fly->axis = 0;
}
@@ -624,8 +646,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
fly->axis = -1;
}
else {
- if (fly->speed < 0.0f) fly->speed = -fly->speed;
- else if (fly->axis == 1) fly->speed += fly->grid;
+ if (fly->speed < 0.0f) {
+ fly->speed = -fly->speed;
+ }
+ else if (fly->axis == 1) {
+ fly->speed += fly->grid;
+ }
fly->axis = 1;
}
break;
@@ -634,15 +660,20 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
fly->axis = -1;
}
else {
- if (fly->speed > 0.0f) fly->speed = -fly->speed;
- else if (fly->axis == 1) fly->speed -= fly->grid;
+ if (fly->speed > 0.0f) {
+ fly->speed = -fly->speed;
+ }
+ else if (fly->axis == 1) {
+ fly->speed -= fly->grid;
+ }
fly->axis = 1;
}
break;
case FLY_MODAL_AXIS_LOCK_X:
- if (fly->xlock != FLY_AXISLOCK_STATE_OFF)
+ if (fly->xlock != FLY_AXISLOCK_STATE_OFF) {
fly->xlock = FLY_AXISLOCK_STATE_OFF;
+ }
else {
fly->xlock = FLY_AXISLOCK_STATE_ACTIVE;
fly->xlock_momentum = 0.0;
@@ -650,8 +681,9 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
fly_update_header(C, op, fly);
break;
case FLY_MODAL_AXIS_LOCK_Z:
- if (fly->zlock != FLY_AXISLOCK_STATE_OFF)
+ if (fly->zlock != FLY_AXISLOCK_STATE_OFF) {
fly->zlock = FLY_AXISLOCK_STATE_OFF;
+ }
else {
fly->zlock = FLY_AXISLOCK_STATE_ACTIVE;
fly->zlock_momentum = 0.0;
@@ -723,13 +755,25 @@ static int flyApply(bContext *C, FlyInfo *fly)
moffset[1] = fly->mval[1] - fly->center_mval[1];
/* enforce a view margin */
- if (moffset[0] > xmargin) moffset[0] -= xmargin;
- else if (moffset[0] < -xmargin) moffset[0] += xmargin;
- else moffset[0] = 0;
+ if (moffset[0] > xmargin) {
+ moffset[0] -= xmargin;
+ }
+ else if (moffset[0] < -xmargin) {
+ moffset[0] += xmargin;
+ }
+ else {
+ moffset[0] = 0;
+ }
- if (moffset[1] > ymargin) moffset[1] -= ymargin;
- else if (moffset[1] < -ymargin) moffset[1] += ymargin;
- else moffset[1] = 0;
+ if (moffset[1] > ymargin) {
+ moffset[1] -= ymargin;
+ }
+ else if (moffset[1] < -ymargin) {
+ moffset[1] += ymargin;
+ }
+ else {
+ moffset[1] = 0;
+ }
/* scale the mouse movement by this value - scales mouse movement to the view size
@@ -774,8 +818,9 @@ static int flyApply(bContext *C, FlyInfo *fly)
/* Scale the time to use shift to scale the speed down- just like
* shift slows many other areas of blender down */
- if (fly->use_precision)
+ if (fly->use_precision) {
fly->speed = fly->speed * (1.0f - time_redraw_clamped);
+ }
copy_m3_m4(mat, rv3d->viewinv);
@@ -804,10 +849,12 @@ static int flyApply(bContext *C, FlyInfo *fly)
axis_angle_to_quat(tmp_quat, upvec, moffset[1] * time_redraw * -FLY_ROTATE_FAC);
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
- if (fly->xlock != FLY_AXISLOCK_STATE_OFF)
+ if (fly->xlock != FLY_AXISLOCK_STATE_OFF) {
fly->xlock = FLY_AXISLOCK_STATE_ACTIVE; /* check for rotation */
- if (fly->zlock != FLY_AXISLOCK_STATE_OFF)
+ }
+ if (fly->zlock != FLY_AXISLOCK_STATE_OFF) {
fly->zlock = FLY_AXISLOCK_STATE_ACTIVE;
+ }
fly->xlock_momentum = 0.0f;
}
@@ -818,8 +865,9 @@ static int flyApply(bContext *C, FlyInfo *fly)
copy_v3_fl3(upvec, 0.0f, 1.0f, 0.0f);
mul_m3_v3(mat, upvec);
- if (upvec[2] < 0.0f)
+ if (upvec[2] < 0.0f) {
moffset[0] = -moffset[0];
+ }
/* make the lock vectors */
if (fly->zlock) {
@@ -834,10 +882,12 @@ static int flyApply(bContext *C, FlyInfo *fly)
axis_angle_to_quat(tmp_quat, upvec, moffset[0] * time_redraw * FLY_ROTATE_FAC);
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
- if (fly->xlock != FLY_AXISLOCK_STATE_OFF)
+ if (fly->xlock != FLY_AXISLOCK_STATE_OFF) {
fly->xlock = FLY_AXISLOCK_STATE_ACTIVE; /* check for rotation */
- if (fly->zlock != FLY_AXISLOCK_STATE_OFF)
+ }
+ if (fly->zlock != FLY_AXISLOCK_STATE_OFF) {
fly->zlock = FLY_AXISLOCK_STATE_ACTIVE;
+ }
}
if (fly->zlock == FLY_AXISLOCK_STATE_ACTIVE) {
@@ -917,9 +967,15 @@ static int flyApply(bContext *C, FlyInfo *fly)
if (rv3d->persp == RV3D_CAMOB) {
Object *lock_ob = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control);
- if (lock_ob->protectflag & OB_LOCK_LOCX) dvec[0] = 0.0;
- if (lock_ob->protectflag & OB_LOCK_LOCY) dvec[1] = 0.0;
- if (lock_ob->protectflag & OB_LOCK_LOCZ) dvec[2] = 0.0;
+ if (lock_ob->protectflag & OB_LOCK_LOCX) {
+ dvec[0] = 0.0;
+ }
+ if (lock_ob->protectflag & OB_LOCK_LOCY) {
+ dvec[1] = 0.0;
+ }
+ if (lock_ob->protectflag & OB_LOCK_LOCZ) {
+ dvec[2] = 0.0;
+ }
}
add_v3_v3(rv3d->ofs, dvec);
@@ -970,8 +1026,9 @@ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RegionView3D *rv3d = CTX_wm_region_view3d(C);
FlyInfo *fly;
- if (rv3d->viewlock & RV3D_LOCKED)
+ if (rv3d->viewlock & RV3D_LOCKED) {
return OPERATOR_CANCELLED;
+ }
fly = MEM_callocN(sizeof(FlyInfo), "FlyOperation");
@@ -1026,8 +1083,9 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
exit_code = flyEnd(C, fly);
- if (exit_code != OPERATOR_RUNNING_MODAL)
+ if (exit_code != OPERATOR_RUNNING_MODAL) {
do_draw = true;
+ }
if (do_draw) {
if (rv3d->persp == RV3D_CAMOB) {
@@ -1038,8 +1096,9 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
ED_region_tag_redraw(CTX_wm_region(C));
}
- if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED))
+ if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) {
ED_workspace_status_text(C, NULL);
+ }
return exit_code;
}
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.c b/source/blender/editors/space_view3d/view3d_gizmo_armature.c
index 47f9cc580ea..a2b93dcd309 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_armature.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.c
@@ -185,8 +185,9 @@ static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = BKE_object_pose_armature_get(OBACT(view_layer));
- if (!gzgroup->customdata)
+ if (!gzgroup->customdata) {
return;
+ }
struct BoneSplineWidgetGroup *bspline_group = gzgroup->customdata;
bPoseChannel *pchan = BKE_pose_channel_active(ob);
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c
index a3859a8468e..2aa10dc3040 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c
@@ -130,8 +130,9 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *gzgroup)
static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
- if (!gzgroup->customdata)
+ if (!gzgroup->customdata) {
return;
+ }
struct CameraWidgetGroup *cagzgroup = gzgroup->customdata;
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -163,6 +164,8 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
const float aspy = (float)scene->r.ysch * scene->r.yasp;
const bool is_ortho = (ca->type == CAM_ORTHO);
const int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, aspx, aspy);
+ /* Important to use camera value, not calculated fit since 'AUTO' uses width always. */
+ const float sensor_size = BKE_camera_sensor_size(ca->sensor_fit, ca->sensor_x, ca->sensor_y);
wmGizmo *widget = is_ortho ? cagzgroup->ortho_scale : cagzgroup->focal_len;
float scale_matrix;
if (true) {
@@ -226,7 +229,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
((range / ca->ortho_scale) * ca->drawsize) :
(scale_matrix * range /
/* Half sensor, intentionally use sensor from camera and not calculated above. */
- (0.5f * ((sensor_fit == CAMERA_SENSOR_FIT_HOR) ? ca->sensor_x : ca->sensor_y))));
+ (0.5f * sensor_size)));
WM_gizmo_target_property_def_rna_ptr(widget, gz_prop_type, &camera_ptr, prop, -1);
}
@@ -253,6 +256,7 @@ static void WIDGETGROUP_camera_message_subscribe(
extern PropertyRNA rna_Camera_ortho_scale;
extern PropertyRNA rna_Camera_sensor_fit;
extern PropertyRNA rna_Camera_sensor_width;
+ extern PropertyRNA rna_Camera_sensor_height;
extern PropertyRNA rna_Camera_shift_x;
extern PropertyRNA rna_Camera_shift_y;
extern PropertyRNA rna_Camera_type;
@@ -263,6 +267,7 @@ static void WIDGETGROUP_camera_message_subscribe(
&rna_Camera_ortho_scale,
&rna_Camera_sensor_fit,
&rna_Camera_sensor_width,
+ &rna_Camera_sensor_height,
&rna_Camera_shift_x,
&rna_Camera_shift_y,
&rna_Camera_type,
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 78bda66b8ff..de3f0392ff0 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -68,9 +68,18 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event);
static int toggle_matcap_flip(bContext *C, wmOperator *UNUSED(op))
{
View3D *v3d = CTX_wm_view3d(C);
- v3d->shading.flag ^= V3D_SHADING_MATCAP_FLIP_X;
- ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C));
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+
+ if (v3d) {
+ v3d->shading.flag ^= V3D_SHADING_MATCAP_FLIP_X;
+ ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C));
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+ }
+ else {
+ Scene *scene = CTX_data_scene(C);
+ scene->display.shading.flag ^= V3D_SHADING_MATCAP_FLIP_X;
+ WM_event_add_notifier(C, NC_SCENE | NA_EDITED, v3d);
+ }
+
return OPERATOR_FINISHED;
}
@@ -83,11 +92,13 @@ void VIEW3D_OT_toggle_matcap_flip(wmOperatorType *ot)
/* api callbacks */
ot->exec = toggle_matcap_flip;
- ot->poll = ED_operator_view3d_active;
}
/** \} */
+/* -------------------------------------------------------------------- */
+/** \name UI Templates
+ * \{ */
static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
{
@@ -181,3 +192,5 @@ void uiTemplateHeader3D_mode(uiLayout *layout, struct bContext *C)
uiTemplatePaintModeSelection(layout, C);
}
}
+
+/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index bb6b96b96d5..e85558765b6 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -123,11 +123,13 @@ void VIEW3D_OT_fly(struct wmOperatorType *ot);
void VIEW3D_OT_walk(struct wmOperatorType *ot);
/* drawobject.c */
-void draw_object_backbufsel(
+void draw_object_select_id(
struct Depsgraph *depsgraph, Scene *scene,
View3D *v3d, RegionView3D *rv3d, 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 */
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index e551f1ea130..3efd0e32440 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -65,44 +65,34 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
char str[FILE_MAX];
+ int num_copied = 0;
BKE_copybuffer_begin(bmain);
/* context, selection, could be generalized */
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
- BKE_copybuffer_tag_ID(&ob->id);
- }
- CTX_DATA_END;
-
- for (Collection *collection = bmain->collections.first; collection; collection = collection->id.next) {
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
- Object *object = cob->ob;
-
- if (object && (object->id.tag & LIB_TAG_DOIT)) {
- BKE_copybuffer_tag_ID(&collection->id);
- /* don't expand out to all other objects */
- collection->id.tag &= ~LIB_TAG_NEED_EXPAND;
- break;
- }
+ if ((ob->id.tag & LIB_TAG_DOIT) == 0) {
+ BKE_copybuffer_tag_ID(&ob->id);
+ num_copied++;
}
}
+ CTX_DATA_END;
BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend");
BKE_copybuffer_save(bmain, str, op->reports);
- BKE_report(op->reports, RPT_INFO, "Copied selected objects to buffer");
+ BKE_reportf(op->reports, RPT_INFO, "Copied %d selected objects", num_copied);
return OPERATOR_FINISHED;
}
static void VIEW3D_OT_copybuffer(wmOperatorType *ot)
{
-
/* identifiers */
- ot->name = "Copy Selection to Buffer";
+ ot->name = "Copy Objects";
ot->idname = "VIEW3D_OT_copybuffer";
- ot->description = "Selected objects are saved in a temp file";
+ ot->description = "Selected objects are copied to the clipboard";
/* api callbacks */
ot->exec = view3d_copybuffer_exec;
@@ -114,32 +104,35 @@ static int view3d_pastebuffer_exec(bContext *C, wmOperator *op)
char str[FILE_MAX];
short flag = 0;
- if (RNA_boolean_get(op->ptr, "autoselect"))
+ if (RNA_boolean_get(op->ptr, "autoselect")) {
flag |= FILE_AUTOSELECT;
- if (RNA_boolean_get(op->ptr, "active_collection"))
+ }
+ if (RNA_boolean_get(op->ptr, "active_collection")) {
flag |= FILE_ACTIVE_COLLECTION;
+ }
BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend");
- if (BKE_copybuffer_paste(C, str, flag, op->reports)) {
- WM_event_add_notifier(C, NC_WINDOW, NULL);
-
- BKE_report(op->reports, RPT_INFO, "Objects pasted from buffer");
- return OPERATOR_FINISHED;
+ const int num_pasted = BKE_copybuffer_paste(C, str, flag, op->reports, FILTER_ID_OB);
+ if (num_pasted == 0) {
+ BKE_report(op->reports, RPT_INFO, "No objects to paste");
+ return OPERATOR_CANCELLED;
}
- BKE_report(op->reports, RPT_INFO, "No buffer to paste from");
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
- return OPERATOR_CANCELLED;
+ BKE_reportf(op->reports, RPT_INFO, "%d objects pasted", num_pasted);
+
+ return OPERATOR_FINISHED;
}
static void VIEW3D_OT_pastebuffer(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Paste Selection from Buffer";
+ ot->name = "Paste Objects";
ot->idname = "VIEW3D_OT_pastebuffer";
- ot->description = "Contents of copy buffer gets pasted";
+ ot->description = "Objects from the clipboard are pasted";
/* api callbacks */
ot->exec = view3d_pastebuffer_exec;
@@ -149,7 +142,8 @@ static void VIEW3D_OT_pastebuffer(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "autoselect", true, "Select", "Select pasted objects");
- RNA_def_boolean(ot->srna, "active_collection", true, "Active Collection", "Put pasted objects on the active collection");
+ RNA_def_boolean(ot->srna, "active_collection", true,
+ "Active Collection", "Put pasted objects in the active collection");
}
/* ************************** registration **********************************/
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index bb5fdeabc2b..760cbb3f3ef 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -315,8 +315,12 @@ static void view3d_win_to_ray_segment(
RegionView3D *rv3d = ar->regiondata;
float _ray_co[3], _ray_dir[3], start_offset, end_offset;
- if (!r_ray_co) r_ray_co = _ray_co;
- if (!r_ray_dir) r_ray_dir = _ray_dir;
+ if (!r_ray_co) {
+ r_ray_co = _ray_co;
+ }
+ if (!r_ray_dir) {
+ r_ray_dir = _ray_dir;
+ }
ED_view3d_win_to_origin(ar, mval, r_ray_co);
ED_view3d_win_to_vector(ar, mval, r_ray_dir);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index fc13968def7..ea44f19c4fe 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -344,8 +344,9 @@ static bool view3d_selectable_data(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (!ED_operator_region_view3d_active(C))
+ if (!ED_operator_region_view3d_active(C)) {
return 0;
+ }
if (ob) {
if (ob->mode & OB_MODE_EDIT) {
@@ -377,13 +378,23 @@ static bool edge_inside_rect(const rctf *rect, const float v1[2], const float v2
int d1, d2, d3, d4;
/* check points in rect */
- if (edge_fully_inside_rect(rect, v1, v2)) return 1;
+ if (edge_fully_inside_rect(rect, v1, v2)) {
+ return 1;
+ }
/* check points completely out rect */
- if (v1[0] < rect->xmin && v2[0] < rect->xmin) return 0;
- if (v1[0] > rect->xmax && v2[0] > rect->xmax) return 0;
- if (v1[1] < rect->ymin && v2[1] < rect->ymin) return 0;
- if (v1[1] > rect->ymax && v2[1] > rect->ymax) return 0;
+ if (v1[0] < rect->xmin && v2[0] < rect->xmin) {
+ return 0;
+ }
+ if (v1[0] > rect->xmax && v2[0] > rect->xmax) {
+ return 0;
+ }
+ if (v1[1] < rect->ymin && v2[1] < rect->ymin) {
+ return 0;
+ }
+ if (v1[1] > rect->ymax && v2[1] > rect->ymax) {
+ return 0;
+ }
/* simple check lines intersecting. */
d1 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymin);
@@ -391,8 +402,12 @@ static bool edge_inside_rect(const rctf *rect, const float v1[2], const float v2
d3 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymax);
d4 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymin);
- if (d1 < 0 && d2 < 0 && d3 < 0 && d4 < 0) return 0;
- if (d1 > 0 && d2 > 0 && d3 > 0 && d4 > 0) return 0;
+ if (d1 < 0 && d2 < 0 && d3 < 0 && d4 < 0) {
+ return 0;
+ }
+ if (d1 > 0 && d2 > 0 && d3 > 0 && d4 > 0) {
+ return 0;
+ }
return 1;
}
@@ -459,7 +474,7 @@ static void do_lasso_tag_pose(ViewContext *vc, Object *ob, const int mcords[][2]
pose_foreachScreenBone(&vc_tmp, do_lasso_select_pose__do_tag, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
}
-static void do_lasso_select_objects(
+static bool do_lasso_select_objects(
ViewContext *vc, const int mcords[][2], const short moves,
const eSelectOp sel_op)
{
@@ -468,7 +483,7 @@ static void do_lasso_select_objects(
bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- changed = object_deselect_all_visible(vc->view_layer, vc->v3d);
+ changed |= object_deselect_all_visible(vc->view_layer, vc->v3d);
}
for (base = vc->view_layer->object_bases.first; base; base = base->next) {
@@ -489,6 +504,7 @@ static void do_lasso_select_objects(
DEG_id_tag_update(&vc->scene->id, ID_RECALC_SELECT);
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, vc->scene);
}
+ return changed;
}
@@ -569,7 +585,7 @@ static bool do_pose_tag_select_op_exec(Base **bases, const uint bases_len, const
return changed_multi;
}
-static void do_lasso_select_pose(
+static bool do_lasso_select_pose(
ViewContext *vc, const int mcords[][2], const short moves,
const eSelectOp sel_op)
{
@@ -588,9 +604,8 @@ static void do_lasso_select_pose(
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, vc->scene);
}
- if (bases != NULL) {
- MEM_freeN(bases);
- }
+ MEM_freeN(bases);
+ return changed_multi;
}
static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, const float screen_co[2], int UNUSED(index))
@@ -603,6 +618,7 @@ static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, cons
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
BM_vert_select_set(data->vc->em->bm, eve, sel_op_result);
+ data->is_changed = true;
}
}
static void do_lasso_select_mesh__doSelectEdge_pass0(
@@ -619,6 +635,7 @@ static void do_lasso_select_mesh__doSelectEdge_pass0(
if (sel_op_result != -1) {
BM_edge_select_set(data->vc->em->bm, eed, sel_op_result);
data->is_done = true;
+ data->is_changed = true;
}
}
static void do_lasso_select_mesh__doSelectEdge_pass1(
@@ -633,6 +650,7 @@ static void do_lasso_select_mesh__doSelectEdge_pass1(
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
BM_edge_select_set(data->vc->em->bm, eed, sel_op_result);
+ data->is_changed = true;
}
}
@@ -647,10 +665,11 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, cons
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
BM_face_select_set(data->vc->em->bm, efa, sel_op_result);
+ data->is_changed = true;
}
}
-static void do_lasso_select_mesh(
+static bool do_lasso_select_mesh(
ViewContext *vc,
const int mcords[][2], short moves, const eSelectOp sel_op)
{
@@ -667,7 +686,10 @@ static void do_lasso_select_mesh(
view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, sel_op);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT);
+ if (vc->em->bm->totvertsel) {
+ EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT);
+ data.is_changed = true;
+ }
}
/* for non zbuf projections, don't change the GL state */
@@ -678,7 +700,7 @@ static void do_lasso_select_mesh(
if (ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
- edbm_backbuf_check_and_select_verts(vc->em, sel_op);
+ data.is_changed = edbm_backbuf_check_and_select_verts(vc->em, sel_op);
}
else {
mesh_foreachScreenVert(vc, do_lasso_select_mesh__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
@@ -694,7 +716,7 @@ static void do_lasso_select_mesh(
if (ts->selectmode & SCE_SELECT_FACE) {
if (bbsel) {
- edbm_backbuf_check_and_select_faces(vc->em, sel_op);
+ data.is_changed = edbm_backbuf_check_and_select_faces(vc->em, sel_op);
}
else {
mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
@@ -702,7 +724,11 @@ static void do_lasso_select_mesh(
}
EDBM_backbuf_free();
- EDBM_selectmode_flush(vc->em);
+
+ if (data.is_changed) {
+ EDBM_selectmode_flush(vc->em);
+ }
+ return data.is_changed;
}
static void do_lasso_select_curve__doSelect(
@@ -716,6 +742,7 @@ static void do_lasso_select_curve__doSelect(
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(bp->f1, sel_op_result, SELECT);
+ data->is_changed = true;
}
}
else {
@@ -727,6 +754,7 @@ static void do_lasso_select_curve__doSelect(
SET_FLAG_FROM_TEST(bezt->f2, sel_op_result, SELECT);
}
bezt->f1 = bezt->f3 = bezt->f2;
+ data->is_changed = true;
}
else {
char *flag_p = (&bezt->f1) + beztindex;
@@ -734,12 +762,13 @@ static void do_lasso_select_curve__doSelect(
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(*flag_p, sel_op_result, SELECT);
+ data->is_changed = true;
}
}
}
}
-static void do_lasso_select_curve(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
+static bool do_lasso_select_curve(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
{
LassoSelectUserData data;
rcti rect;
@@ -750,12 +779,15 @@ static void do_lasso_select_curve(ViewContext *vc, const int mcords[][2], short
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
Curve *curve = (Curve *) vc->obedit->data;
- ED_curve_deselect_all(curve->editnurb);
+ data.is_changed |= ED_curve_deselect_all(curve->editnurb);
}
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
nurbs_foreachScreenVert(vc, do_lasso_select_curve__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
- BKE_curve_nurb_vert_active_validate(vc->obedit->data);
+ if (data.is_changed) {
+ BKE_curve_nurb_vert_active_validate(vc->obedit->data);
+ }
+ return data.is_changed;
}
static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, const float screen_co[2])
@@ -768,9 +800,10 @@ static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, const
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(bp->f1, sel_op_result, SELECT);
+ data->is_changed = true;
}
}
-static void do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
+static bool do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
{
LassoSelectUserData data;
rcti rect;
@@ -780,11 +813,12 @@ static void do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], shor
view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, sel_op);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- ED_lattice_flags_set(vc->obedit, 0);
+ data.is_changed |= ED_lattice_flags_set(vc->obedit, 0);
}
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
lattice_foreachScreenVert(vc, do_lasso_select_lattice__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ return data.is_changed;
}
static void do_lasso_select_armature__doSelectBone(
@@ -830,7 +864,7 @@ static void do_lasso_select_armature__doSelectBone(
}
}
-static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
+static bool do_lasso_select_armature(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
{
LassoSelectUserData data;
rcti rect;
@@ -839,23 +873,24 @@ static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], sho
view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, sel_op);
- ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
-
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- ED_armature_edit_deselect_all_visible(vc->obedit);
+ data.is_changed |= ED_armature_edit_deselect_all_visible(vc->obedit);
}
bArmature *arm = vc->obedit->data;
ED_armature_ebone_listbase_temp_clear(arm->edbo);
+ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
+
armature_foreachScreenBone(vc, do_lasso_select_armature__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
- data.is_changed = ED_armature_edit_select_op_from_tagged(vc->obedit->data, sel_op);
+ data.is_changed |= ED_armature_edit_select_op_from_tagged(vc->obedit->data, sel_op);
if (data.is_changed) {
WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit);
}
+ return data.is_changed;
}
static void do_lasso_select_mball__doSelectElem(void *userData, struct MetaElem *ml, const float screen_co[2])
@@ -871,24 +906,26 @@ static void do_lasso_select_mball__doSelectElem(void *userData, struct MetaElem
data->is_changed = true;
}
}
-static void do_lasso_select_meta(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
+static bool do_lasso_select_meta(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
{
LassoSelectUserData data;
rcti rect;
MetaBall *mb = (MetaBall *)vc->obedit->data;
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- BKE_mball_deselect_all(mb);
- }
-
BLI_lasso_boundbox(&rect, mcords, moves);
view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, sel_op);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ data.is_changed |= BKE_mball_deselect_all(mb);
+ }
+
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
mball_foreachScreenElem(vc, do_lasso_select_mball__doSelectElem, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+
+ return data.is_changed;
}
static void do_lasso_select_meshobject__doSelectVert(void *userData, MVert *mv, const float screen_co[2], int UNUSED(index))
@@ -904,18 +941,21 @@ static void do_lasso_select_meshobject__doSelectVert(void *userData, MVert *mv,
data->is_changed = true;
}
}
-static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
+static bool do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
{
const bool use_zbuf = V3D_IS_ZBUF(vc->v3d);
Object *ob = vc->obact;
Mesh *me = ob->data;
rcti rect;
- if (me == NULL || me->totvert == 0)
- return;
+ if (me == NULL || me->totvert == 0) {
+ return false;
+ }
+ bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- paintvert_deselect_all_visible(ob, SEL_DESELECT, false); /* flush selection at the end */
+ /* flush selection at the end */
+ changed |= paintvert_deselect_all_visible(ob, SEL_DESELECT, false);
}
BLI_lasso_boundbox(&rect, mcords, moves);
@@ -925,7 +965,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh
EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
- edbm_backbuf_check_and_select_verts_obmode(me, sel_op);
+ changed |= edbm_backbuf_check_and_select_verts_obmode(me, sel_op);
EDBM_backbuf_free();
}
@@ -938,26 +978,26 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh
meshobject_foreachScreenVert(vc, do_lasso_select_meshobject__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ changed |= data.is_changed;
}
- if (SEL_OP_CAN_DESELECT(sel_op)) {
- BKE_mesh_mselect_validate(me);
+ if (changed) {
+ if (SEL_OP_CAN_DESELECT(sel_op)) {
+ BKE_mesh_mselect_validate(me);
+ }
+ paintvert_flush_flags(ob);
+ paintvert_tag_select_update(vc->C, ob);
}
- paintvert_flush_flags(ob);
- paintvert_tag_select_update(vc->C, ob);
+ return changed;
}
-static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
+static bool do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], short moves, const eSelectOp sel_op)
{
Object *ob = vc->obact;
Mesh *me = ob->data;
rcti rect;
- if (me == NULL || me->totpoly == 0)
- return;
-
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- /* flush selection at the end */
- paintface_deselect_all_visible(vc->C, ob, SEL_DESELECT, false);
+ if (me == NULL || me->totpoly == 0) {
+ return false;
}
bm_vertoffs = me->totpoly + 1; /* max index array */
@@ -965,11 +1005,19 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh
BLI_lasso_boundbox(&rect, mcords, moves);
EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
- edbm_backbuf_check_and_select_tfaces(me, sel_op);
+ bool changed = false;
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ /* flush selection at the end */
+ changed |= paintface_deselect_all_visible(vc->C, ob, SEL_DESELECT, false);
+ }
+ changed |= edbm_backbuf_check_and_select_tfaces(me, sel_op);
EDBM_backbuf_free();
- paintface_flush_flags(vc->C, ob, SELECT);
+ if (changed) {
+ paintface_flush_flags(vc->C, ob, SELECT);
+ }
+ return changed;
}
#if 0
@@ -981,6 +1029,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, const eSelectOp s
rcti rect;
int node_cent[2];
float node_centf[2];
+ bool changed = false;
BLI_lasso_boundbox(&rect, mcords, moves);
@@ -997,71 +1046,80 @@ static void do_lasso_select_node(int mcords[][2], short moves, const eSelectOp s
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(node->flag, sel_op_result, SELECT);
+ changed = true;
}
}
- BIF_undo_push("Lasso select nodes");
+ if (changed) {
+ BIF_undo_push("Lasso select nodes");
+ }
}
#endif
-static void view3d_lasso_select(
+static bool view3d_lasso_select(
bContext *C, ViewContext *vc,
const int mcords[][2], short moves,
const eSelectOp sel_op)
{
Object *ob = CTX_data_active_object(C);
+ bool changed_multi = false;
if (vc->obedit == NULL) { /* Object Mode */
if (BKE_paint_select_face_test(ob)) {
- do_lasso_select_paintface(vc, mcords, moves, sel_op);
+ changed_multi = do_lasso_select_paintface(vc, mcords, moves, sel_op);
}
else if (BKE_paint_select_vert_test(ob)) {
- do_lasso_select_paintvert(vc, mcords, moves, sel_op);
+ changed_multi = do_lasso_select_paintvert(vc, mcords, moves, sel_op);
}
else if (ob && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
/* pass */
}
else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
- PE_lasso_select(C, mcords, moves, sel_op);
+ changed_multi = PE_lasso_select(C, mcords, moves, sel_op);
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
- do_lasso_select_pose(vc, mcords, moves, sel_op);
+ changed_multi = do_lasso_select_pose(vc, mcords, moves, sel_op);
}
else {
- do_lasso_select_objects(vc, mcords, moves, sel_op);
+ changed_multi = do_lasso_select_objects(vc, mcords, moves, sel_op);
}
}
else { /* Edit Mode */
FOREACH_OBJECT_IN_MODE_BEGIN (vc->view_layer, vc->v3d, ob->type, ob->mode, ob_iter) {
ED_view3d_viewcontext_init_object(vc, ob_iter);
+ bool changed = false;
switch (vc->obedit->type) {
case OB_MESH:
- do_lasso_select_mesh(vc, mcords, moves, sel_op);
+ changed = do_lasso_select_mesh(vc, mcords, moves, sel_op);
break;
case OB_CURVE:
case OB_SURF:
- do_lasso_select_curve(vc, mcords, moves, sel_op);
+ changed = do_lasso_select_curve(vc, mcords, moves, sel_op);
break;
case OB_LATTICE:
- do_lasso_select_lattice(vc, mcords, moves, sel_op);
+ changed = do_lasso_select_lattice(vc, mcords, moves, sel_op);
break;
case OB_ARMATURE:
- do_lasso_select_armature(vc, mcords, moves, sel_op);
+ changed = do_lasso_select_armature(vc, mcords, moves, sel_op);
break;
case OB_MBALL:
- do_lasso_select_meta(vc, mcords, moves, sel_op);
+ changed = do_lasso_select_meta(vc, mcords, moves, sel_op);
break;
default:
assert(!"lasso select on incorrect object type");
break;
}
- DEG_id_tag_update(vc->obedit->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc->obedit->data);
+ if (changed) {
+ DEG_id_tag_update(vc->obedit->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc->obedit->data);
+ changed_multi = true;
+ }
}
FOREACH_OBJECT_IN_MODE_END;
}
+ return changed_multi;
}
@@ -1080,11 +1138,16 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op)
ED_view3d_viewcontext_init(C, &vc);
eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
- view3d_lasso_select(C, &vc, mcords, mcords_tot, sel_op);
+ bool changed_multi = view3d_lasso_select(C, &vc, mcords, mcords_tot, sel_op);
MEM_freeN((void *)mcords);
- return OPERATOR_FINISHED;
+ if (changed_multi) {
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
}
return OPERATOR_PASS_THROUGH;
}
@@ -1258,8 +1321,9 @@ static Base *object_mouse_select_menu(
baseCount++;
BLI_linklist_prepend(&linklist, base);
- if (baseCount == SEL_MENU_SIZE)
+ if (baseCount == SEL_MENU_SIZE) {
break;
+ }
}
}
CTX_DATA_END;
@@ -1410,7 +1474,7 @@ static int mixed_bones_object_selectbuffer_extended(
if (use_cycle) {
if (v3d->shading.type > OB_WIRE) {
do_nearest = true;
- if (len_manhattan_v2v2_int(mval, last_mval) < 3) {
+ if (len_manhattan_v2v2_int(mval, last_mval) <= WM_EVENT_CURSOR_MOTION_THRESHOLD) {
do_nearest = false;
}
}
@@ -1499,7 +1563,9 @@ static Base *mouse_select_eval_buffer(
}
base = base->next;
}
- if (base) basact = base;
+ if (base) {
+ basact = base;
+ }
}
else {
@@ -1509,8 +1575,12 @@ static Base *mouse_select_eval_buffer(
* with an un-selectable choice */
if ((base->flag & BASE_SELECTABLE) == 0) {
base = base->next;
- if (base == NULL) base = FIRSTBASE(view_layer);
- if (base == startbase) break;
+ if (base == NULL) {
+ base = FIRSTBASE(view_layer);
+ }
+ if (base == startbase) {
+ break;
+ }
}
if (BASE_SELECTABLE(v3d, base)) {
@@ -1531,11 +1601,17 @@ static Base *mouse_select_eval_buffer(
}
}
- if (basact) break;
+ if (basact) {
+ break;
+ }
base = base->next;
- if (base == NULL) base = FIRSTBASE(view_layer);
- if (base == startbase) break;
+ if (base == NULL) {
+ base = FIRSTBASE(view_layer);
+ }
+ if (base == startbase) {
+ break;
+ }
}
}
@@ -1569,7 +1645,9 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2])
Object *ED_view3d_give_object_under_cursor(bContext *C, const int mval[2])
{
Base *base = ED_view3d_give_base_under_cursor(C, mval);
- if (base) return base->object;
+ if (base) {
+ return base->object;
+ }
return NULL;
}
@@ -1924,7 +2002,7 @@ static bool ed_wpaint_vertex_select_pick(
uint index = 0;
MVert *mv;
- if (ED_mesh_pick_vert(C, obact, mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, use_zbuf)) {
+ if (ED_mesh_pick_vert(C, obact, mval, ED_MESH_PICK_DEFAULT_VERT_DIST, use_zbuf, &index)) {
mv = &me->mvert[index];
if (extend) {
mv->flag |= SELECT;
@@ -1957,10 +2035,12 @@ static bool ed_wpaint_vertex_select_pick(
static int view3d_select_exec(bContext *C, wmOperator *op)
{
+ Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
bool extend = RNA_boolean_get(op->ptr, "extend");
bool deselect = RNA_boolean_get(op->ptr, "deselect");
+ bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
bool toggle = RNA_boolean_get(op->ptr, "toggle");
bool center = RNA_boolean_get(op->ptr, "center");
bool enumerate = RNA_boolean_get(op->ptr, "enumerate");
@@ -1990,36 +2070,85 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
}
if (obedit && object == false) {
- if (obedit->type == OB_MESH)
+ if (obedit->type == OB_MESH) {
retval = EDBM_select_pick(C, location, extend, deselect, toggle);
- else if (obedit->type == OB_ARMATURE)
+ if (!retval && deselect_all) {
+ retval = EDBM_mesh_deselect_all_multi(C);
+ }
+ }
+ else if (obedit->type == OB_ARMATURE) {
retval = ED_armature_edit_select_pick(C, location, extend, deselect, toggle);
- else if (obedit->type == OB_LATTICE)
+ if (!retval && deselect_all) {
+ retval = ED_armature_edit_deselect_all_visible_multi(C);
+ }
+ }
+ else if (obedit->type == OB_LATTICE) {
retval = ED_lattice_select_pick(C, location, extend, deselect, toggle);
- else if (ELEM(obedit->type, OB_CURVE, OB_SURF))
+ if (!retval && deselect_all) {
+ retval = ED_lattice_deselect_all_multi(C);
+ }
+ }
+ else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
retval = ED_curve_editnurb_select_pick(C, location, extend, deselect, toggle);
- else if (obedit->type == OB_MBALL)
+ if (!retval && deselect_all) {
+ retval = ED_curve_deselect_all_multi(C);
+ }
+ }
+ else if (obedit->type == OB_MBALL) {
retval = ED_mball_select_pick(C, location, extend, deselect, toggle);
- else if (obedit->type == OB_FONT)
+ if (!retval && deselect_all) {
+ retval = ED_mball_deselect_all_multi(C);
+ }
+ }
+ else if (obedit->type == OB_FONT) {
retval = ED_curve_editfont_select_pick(C, location, extend, deselect, toggle);
+ if (!retval && deselect_all) {
+ /* pass */
+ }
+ }
}
- else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
- return PE_mouse_particles(C, location, extend, deselect, toggle);
- else if (obact && BKE_paint_select_face_test(obact))
+ else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
+ retval = PE_mouse_particles(C, location, extend, deselect, toggle);
+ if (!retval && deselect_all) {
+ retval = PE_deselect_all_visible(C);
+ }
+ }
+ else if (obact && BKE_paint_select_face_test(obact)) {
retval = paintface_mouse_select(C, obact, location, extend, deselect, toggle);
- else if (BKE_paint_select_vert_test(obact))
+ if (!retval && deselect_all) {
+ retval = paintface_deselect_all_visible(C, CTX_data_active_object(C), SEL_DESELECT, false);
+ }
+ }
+ else if (BKE_paint_select_vert_test(obact)) {
retval = ed_wpaint_vertex_select_pick(C, location, extend, deselect, toggle, obact);
- else
+ if (!retval && deselect_all) {
+ retval = paintvert_deselect_all_visible(obact, SEL_DESELECT, false);
+ }
+ }
+ else {
retval = ed_object_select_pick(C, location, extend, deselect, toggle, center, enumerate, object);
+ if (!retval && deselect_all) {
+ if (ED_pose_object_from_context(C)) {
+ retval = ED_pose_deselect_all_multi(C, SEL_DESELECT, false);
+ }
+ else {
+ retval = ED_object_base_deselect_all(CTX_data_view_layer(C), CTX_wm_view3d(C), SEL_DESELECT);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
+ }
+ }
+ }
/* passthrough allows tweaks
* FINISHED to signal one operator worked
* */
- if (retval)
+ if (retval) {
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_PASS_THROUGH; /* nothing selected, just passthrough */
+ }
}
static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2048,6 +2177,8 @@ void VIEW3D_OT_select(wmOperatorType *ot)
/* properties */
WM_operator_properties_mouse_select(ot);
+ prop = RNA_def_boolean(ot->srna, "deselect_all", 0, "Deselect", "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "center", 0, "Center", "Use the object center when selecting, in editmode used to extend object selection");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -2109,48 +2240,38 @@ static void do_paintvert_box_select__doSelectVert(void *userData, MVert *mv, con
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(mv->flag, sel_op_result, SELECT);
+ data->is_changed = true;
}
}
-static int do_paintvert_box_select(
- ViewContext *vc, rcti *rect, const eSelectOp sel_op)
+static bool do_paintvert_box_select(
+ ViewContext *vc, const rcti *rect, const eSelectOp sel_op)
{
const bool use_zbuf = V3D_IS_ZBUF(vc->v3d);
Mesh *me;
MVert *mvert;
- struct ImBuf *ibuf;
- uint *rt;
+ unsigned int *rt;
int a, index;
char *selar;
- const int size[2] = {
- BLI_rcti_size_x(rect) + 1,
- BLI_rcti_size_y(rect) + 1};
me = vc->obact->data;
-
- if ((me == NULL) || (me->totvert == 0) || (size[0] * size[1] <= 0)) {
+ if ((me == NULL) || (me->totvert == 0) || BLI_rcti_is_empty(rect)) {
return OPERATOR_CANCELLED;
}
+ bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- paintvert_deselect_all_visible(vc->obact, SEL_DESELECT, false);
+ changed |= paintvert_deselect_all_visible(vc->obact, SEL_DESELECT, false);
}
if (use_zbuf) {
selar = MEM_callocN(me->totvert + 1, "selar");
- ED_view3d_backbuf_validate(vc);
- ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect);
- rt = ibuf->rect;
- glReadPixels(
- rect->xmin + vc->ar->winrct.xmin,
- rect->ymin + vc->ar->winrct.ymin,
- size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
- if (ENDIAN_ORDER == B_ENDIAN) {
- IMB_convert_rgba_to_abgr(ibuf);
- }
- GPU_select_to_index_array(ibuf->rect, size[0] * size[1]);
+ uint buf_len;
+ uint *buf = ED_view3d_select_id_read_rect(vc, rect, &buf_len);
- a = size[0] * size[1];
+ rt = buf;
+
+ a = buf_len;
while (a--) {
if (*rt) {
index = *rt;
@@ -2169,11 +2290,12 @@ static int do_paintvert_box_select(
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(mvert->flag, sel_op_result, SELECT);
+ changed = true;
}
}
}
- IMB_freeImBuf(ibuf);
+ MEM_freeN(buf);
MEM_freeN(selar);
#ifdef __APPLE__
@@ -2188,15 +2310,17 @@ static int do_paintvert_box_select(
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d);
meshobject_foreachScreenVert(vc, do_paintvert_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+ changed |= data.is_changed;
}
- if (SEL_OP_CAN_DESELECT(sel_op)) {
- BKE_mesh_mselect_validate(me);
+ if (changed) {
+ if (SEL_OP_CAN_DESELECT(sel_op)) {
+ BKE_mesh_mselect_validate(me);
+ }
+ paintvert_flush_flags(vc->obact);
+ paintvert_tag_select_update(vc->C, vc->obact);
}
- paintvert_flush_flags(vc->obact);
- paintvert_tag_select_update(vc->C, vc->obact);
-
- return OPERATOR_FINISHED;
+ return changed;
}
static void do_nurbs_box_select__doSelect(
@@ -2210,6 +2334,7 @@ static void do_nurbs_box_select__doSelect(
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(bp->f1, sel_op_result, SELECT);
+ data->is_changed = true;
}
}
else {
@@ -2219,6 +2344,7 @@ static void do_nurbs_box_select__doSelect(
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(bezt->f2, sel_op_result, SELECT);
+ data->is_changed = true;
}
bezt->f1 = bezt->f3 = bezt->f2;
}
@@ -2228,11 +2354,12 @@ static void do_nurbs_box_select__doSelect(
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(*flag_p, sel_op_result, SELECT);
+ data->is_changed = true;
}
}
}
}
-static int do_nurbs_box_select(ViewContext *vc, rcti *rect, const eSelectOp sel_op)
+static bool do_nurbs_box_select(ViewContext *vc, rcti *rect, const eSelectOp sel_op)
{
BoxSelectUserData data;
@@ -2240,14 +2367,14 @@ static int do_nurbs_box_select(ViewContext *vc, rcti *rect, const eSelectOp sel_
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
Curve *curve = (Curve *) vc->obedit->data;
- ED_curve_deselect_all(curve->editnurb);
+ data.is_changed |= ED_curve_deselect_all(curve->editnurb);
}
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
nurbs_foreachScreenVert(vc, do_nurbs_box_select__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
BKE_curve_nurb_vert_active_validate(vc->obedit->data);
- return OPERATOR_FINISHED;
+ return data.is_changed;
}
static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, const float screen_co[2])
@@ -2258,22 +2385,23 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, const fl
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(bp->f1, sel_op_result, SELECT);
+ data->is_changed = true;
}
}
-static int do_lattice_box_select(ViewContext *vc, rcti *rect, const eSelectOp sel_op)
+static bool do_lattice_box_select(ViewContext *vc, rcti *rect, const eSelectOp sel_op)
{
BoxSelectUserData data;
view3d_userdata_boxselect_init(&data, vc, rect, sel_op);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- ED_lattice_flags_set(vc->obedit, 0);
+ data.is_changed |= ED_lattice_flags_set(vc->obedit, 0);
}
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
lattice_foreachScreenVert(vc, do_lattice_box_select__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
- return OPERATOR_FINISHED;
+ return data.is_changed;
}
static void do_mesh_box_select__doSelectVert(void *userData, BMVert *eve, const float screen_co[2], int UNUSED(index))
@@ -2284,6 +2412,7 @@ static void do_mesh_box_select__doSelectVert(void *userData, BMVert *eve, const
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
BM_vert_select_set(data->vc->em->bm, eve, sel_op_result);
+ data->is_changed = true;
}
}
static void do_mesh_box_select__doSelectEdge_pass0(
@@ -2298,6 +2427,7 @@ static void do_mesh_box_select__doSelectEdge_pass0(
if (sel_op_result != -1) {
BM_edge_select_set(data->vc->em->bm, eed, sel_op_result);
data->is_done = true;
+ data->is_changed = true;
}
}
static void do_mesh_box_select__doSelectEdge_pass1(
@@ -2311,6 +2441,7 @@ static void do_mesh_box_select__doSelectEdge_pass1(
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
BM_edge_select_set(data->vc->em->bm, eed, sel_op_result);
+ data->is_changed = true;
}
}
static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, const float screen_co[2], int UNUSED(index))
@@ -2321,9 +2452,10 @@ static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, const
const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside);
if (sel_op_result != -1) {
BM_face_select_set(data->vc->em->bm, efa, sel_op_result);
+ data->is_changed = true;
}
}
-static int do_mesh_box_select(
+static bool do_mesh_box_select(
ViewContext *vc, rcti *rect, const eSelectOp sel_op)
{
BoxSelectUserData data;
@@ -2333,7 +2465,10 @@ static int do_mesh_box_select(
view3d_userdata_boxselect_init(&data, vc, rect, sel_op);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT);
+ if (vc->em->bm->totvertsel) {
+ EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT);
+ data.is_changed = true;
+ }
}
/* for non zbuf projections, don't change the GL state */
@@ -2344,7 +2479,7 @@ static int do_mesh_box_select(
if (ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
- edbm_backbuf_check_and_select_verts(vc->em, sel_op);
+ data.is_changed = edbm_backbuf_check_and_select_verts(vc->em, sel_op);
}
else {
mesh_foreachScreenVert(vc, do_mesh_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
@@ -2360,7 +2495,7 @@ static int do_mesh_box_select(
if (ts->selectmode & SCE_SELECT_FACE) {
if (bbsel) {
- edbm_backbuf_check_and_select_faces(vc->em, sel_op);
+ data.is_changed = edbm_backbuf_check_and_select_faces(vc->em, sel_op);
}
else {
mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
@@ -2369,12 +2504,13 @@ static int do_mesh_box_select(
EDBM_backbuf_free();
- EDBM_selectmode_flush(vc->em);
-
- return OPERATOR_FINISHED;
+ if (data.is_changed) {
+ EDBM_selectmode_flush(vc->em);
+ }
+ return data.is_changed;
}
-static int do_meta_box_select(
+static bool do_meta_box_select(
ViewContext *vc,
const rcti *rect, const eSelectOp sel_op)
{
@@ -2382,6 +2518,7 @@ static int do_meta_box_select(
MetaBall *mb = (MetaBall *)ob->data;
MetaElem *ml;
int a;
+ bool changed = false;
uint buffer[MAXPICKBUF];
int hits;
@@ -2391,7 +2528,7 @@ static int do_meta_box_select(
VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- BKE_mball_deselect_all(mb);
+ changed |= BKE_mball_deselect_all(mb);
}
int metaelem_id = 0;
@@ -2428,6 +2565,7 @@ static int do_meta_box_select(
break;
}
}
+ const int flag_prev = ml->flag;
if (is_inside_radius) {
ml->flag |= MB_SCALE_RAD;
}
@@ -2442,12 +2580,13 @@ static int do_meta_box_select(
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(ml->flag, sel_op_result, SELECT);
}
+ changed |= (flag_prev != ml->flag);
}
- return OPERATOR_FINISHED;
+ return changed;
}
-static int do_armature_box_select(
+static bool do_armature_box_select(
ViewContext *vc,
const rcti *rect, const eSelectOp sel_op)
{
@@ -2461,16 +2600,15 @@ static int do_armature_box_select(
vc, buffer, MAXPICKBUF, rect,
VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP);
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc->view_layer, vc->v3d, &objects_len);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, vc->v3d, &bases_len);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- ED_armature_edit_deselect_all_visible_multi(objects, objects_len);
- changed = true;
+ changed |= ED_armature_edit_deselect_all_visible_multi_ex(bases, bases_len);
}
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
obedit->id.tag &= ~LIB_TAG_DOIT;
bArmature *arm = obedit->data;
@@ -2486,23 +2624,23 @@ static int do_armature_box_select(
}
EditBone *ebone;
- Object *obedit = ED_armature_object_and_ebone_from_select_buffer(objects, objects_len, select_id, &ebone);
+ Base *base_edit = ED_armature_base_and_ebone_from_select_buffer(bases, bases_len, select_id, &ebone);
ebone->temp.i |= select_id & BONESEL_ANY;
- obedit->id.tag |= LIB_TAG_DOIT;
+ base_edit->object->id.tag |= LIB_TAG_DOIT;
}
}
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Object *obedit = bases[base_index]->object;
if (obedit->id.tag & LIB_TAG_DOIT) {
obedit->id.tag &= ~LIB_TAG_DOIT;
changed |= ED_armature_edit_select_op_from_tagged(obedit->data, sel_op);
}
}
- MEM_freeN(objects);
+ MEM_freeN(bases);
- return (hits > 0 || changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+ return changed;
}
/**
@@ -2531,10 +2669,9 @@ static int opengl_bone_select_buffer_cmp(const void *sel_a_p, const void *sel_b_
}
}
-static int do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const eSelectOp sel_op)
+static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const eSelectOp sel_op)
{
View3D *v3d = vc->v3d;
- bool changed = false;
int totobj = MAXPICKBUF; /* XXX solve later */
/* selection buffer now has bones potentially too, so we add MAXPICKBUF */
@@ -2551,9 +2688,9 @@ static int do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const
Base **bases = NULL;
BLI_array_declare(bases);
+ bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- object_deselect_all_visible(vc->view_layer, vc->v3d);
- changed = true;
+ changed |= object_deselect_all_visible(vc->view_layer, vc->v3d);
}
if ((hits == -1) && !SEL_OP_USE_OUTSIDE(sel_op)) {
@@ -2601,14 +2738,11 @@ finally:
if (changed) {
DEG_id_tag_update(&vc->scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene);
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
}
+ return changed;
}
-static int do_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const eSelectOp sel_op)
+static bool do_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const eSelectOp sel_op)
{
uint bases_len;
Base **bases = do_pose_tag_select_op_prepare(vc, &bases_len);
@@ -2681,14 +2815,14 @@ static int do_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const eS
}
MEM_freeN(vbuffer);
- return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+ return changed_multi;
}
static int view3d_box_select_exec(bContext *C, wmOperator *op)
{
ViewContext vc;
rcti rect;
- int ret = OPERATOR_CANCELLED;
+ bool changed_multi = false;
view3d_operator_needs_opengl(C);
@@ -2702,41 +2836,42 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op)
FOREACH_OBJECT_IN_MODE_BEGIN (vc.view_layer, vc.v3d, vc.obedit->type, vc.obedit->mode, ob_iter) {
ED_view3d_viewcontext_init_object(&vc, ob_iter);
+ bool changed = false;
switch (vc.obedit->type) {
case OB_MESH:
vc.em = BKE_editmesh_from_object(vc.obedit);
- ret |= do_mesh_box_select(&vc, &rect, sel_op);
- if (ret & OPERATOR_FINISHED) {
+ changed = do_mesh_box_select(&vc, &rect, sel_op);
+ if (changed) {
DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
break;
case OB_CURVE:
case OB_SURF:
- ret |= do_nurbs_box_select(&vc, &rect, sel_op);
- if (ret & OPERATOR_FINISHED) {
+ changed = do_nurbs_box_select(&vc, &rect, sel_op);
+ if (changed) {
DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
break;
case OB_MBALL:
- ret |= do_meta_box_select(&vc, &rect, sel_op);
- if (ret & OPERATOR_FINISHED) {
+ changed = do_meta_box_select(&vc, &rect, sel_op);
+ if (changed) {
DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
break;
case OB_ARMATURE:
- ret |= do_armature_box_select(&vc, &rect, sel_op);
- if (ret & OPERATOR_FINISHED) {
+ changed = do_armature_box_select(&vc, &rect, sel_op);
+ if (changed) {
DEG_id_tag_update(&vc.obedit->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit);
}
break;
case OB_LATTICE:
- ret |= do_lattice_box_select(&vc, &rect, sel_op);
- if (ret & OPERATOR_FINISHED) {
+ changed = do_lattice_box_select(&vc, &rect, sel_op);
+ if (changed) {
DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
}
@@ -2745,39 +2880,38 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op)
assert(!"box select on incorrect object type");
break;
}
+ changed_multi |= changed;
}
FOREACH_OBJECT_IN_MODE_END;
}
else { /* no editmode, unified for bones and objects */
if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
/* XXX, this is not selection, could be it's own operator. */
- ret |= ED_sculpt_mask_box_select(C, &vc, &rect, sel_op == SEL_OP_ADD ? true : false);
+ changed_multi = ED_sculpt_mask_box_select(C, &vc, &rect, sel_op == SEL_OP_ADD ? true : false);
}
else if (vc.obact && BKE_paint_select_face_test(vc.obact)) {
- ret |= do_paintface_box_select(&vc, &rect, sel_op);
+ changed_multi = do_paintface_box_select(&vc, &rect, sel_op);
}
else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) {
- ret |= do_paintvert_box_select(&vc, &rect, sel_op);
+ changed_multi = do_paintvert_box_select(&vc, &rect, sel_op);
}
else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
- ret |= PE_box_select(C, &rect, sel_op);
+ changed_multi = PE_box_select(C, &rect, sel_op);
}
else if (vc.obact && vc.obact->mode & OB_MODE_POSE) {
- ret |= do_pose_box_select(C, &vc, &rect, sel_op);
+ changed_multi = do_pose_box_select(C, &vc, &rect, sel_op);
}
else { /* object mode with none active */
- ret |= do_object_box_select(C, &vc, &rect, sel_op);
+ changed_multi = do_object_box_select(C, &vc, &rect, sel_op);
}
}
- if (ret & OPERATOR_FINISHED) {
- ret = OPERATOR_FINISHED;
+ if (changed_multi) {
+ return OPERATOR_FINISHED;
}
else {
- ret = OPERATOR_CANCELLED;
+ return OPERATOR_CANCELLED;
}
-
- return ret;
}
void VIEW3D_OT_select_box(wmOperatorType *ot)
@@ -2875,8 +3009,10 @@ static bool mesh_circle_select(ViewContext *vc, eSelectOp sel_op, const int mval
bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT);
- changed = true;
+ if (vc->em->bm->totvertsel) {
+ EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT);
+ changed = true;
+ }
}
const bool select = (sel_op != SEL_OP_SUB);
@@ -2919,7 +3055,6 @@ static bool mesh_circle_select(ViewContext *vc, eSelectOp sel_op, const int mval
if (changed) {
EDBM_selectmode_flush(vc->em);
}
-
return changed;
}
@@ -2929,11 +3064,11 @@ static bool paint_facesel_circle_select(ViewContext *vc, const eSelectOp sel_op,
Object *ob = vc->obact;
Mesh *me = ob->data;
bool bbsel;
- bool changed = false;
+ bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- paintface_deselect_all_visible(vc->C, ob, SEL_DESELECT, false);
- changed = true;
+ /* flush selection at the end */
+ changed |= paintface_deselect_all_visible(vc->C, ob, SEL_DESELECT, false);
}
bm_vertoffs = me->totpoly + 1; /* max index array */
@@ -2955,6 +3090,7 @@ static void paint_vertsel_circle_select_doSelectVert(void *userData, MVert *mv,
if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
SET_FLAG_FROM_TEST(mv->flag, data->select, SELECT);
+ data->is_changed = true;
}
}
static bool paint_vertsel_circle_select(ViewContext *vc, const eSelectOp sel_op, const int mval[2], float rad)
@@ -2965,11 +3101,10 @@ static bool paint_vertsel_circle_select(ViewContext *vc, const eSelectOp sel_op,
Mesh *me = ob->data;
bool bbsel;
/* CircleSelectUserData data = {NULL}; */ /* UNUSED */
- bool changed = false;
+ bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- paintvert_deselect_all_visible(ob, SEL_DESELECT, false); /* flush selection at the end */
- changed = true;
+ changed |= paintvert_deselect_all_visible(ob, SEL_DESELECT, false); /* flush selection at the end */
}
const bool select = (sel_op != SEL_OP_SUB);
@@ -3039,8 +3174,7 @@ static bool nurbscurve_circle_select(ViewContext *vc, const eSelectOp sel_op, co
bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
Curve *curve = vc->obedit->data;
- ED_curve_deselect_all(curve->editnurb);
- changed = true;
+ changed |= ED_curve_deselect_all(curve->editnurb);
}
const bool select = (sel_op != SEL_OP_SUB);
@@ -3066,20 +3200,18 @@ static void latticecurve_circle_doSelect(void *userData, BPoint *bp, const float
static bool lattice_circle_select(ViewContext *vc, const eSelectOp sel_op, const int mval[2], float rad)
{
CircleSelectUserData data;
- bool changed = false;
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- Curve *curve = vc->obedit->data;
- ED_curve_deselect_all(curve->editnurb);
- changed = true;
- }
const bool select = (sel_op != SEL_OP_SUB);
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ data.is_changed |= ED_lattice_flags_set(vc->obedit, 0);
+ }
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
+
lattice_foreachScreenVert(vc, latticecurve_circle_doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
- return changed || data.is_changed;
+ return data.is_changed;
}
@@ -3089,10 +3221,12 @@ static bool pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, cons
CircleSelectUserData *data = userData;
if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
- if (data->select)
+ if (data->select) {
pchan->bone->flag |= BONE_SELECTED;
- else
+ }
+ else {
pchan->bone->flag &= ~BONE_SELECTED;
+ }
return 1;
}
return 0;
@@ -3133,8 +3267,12 @@ static void do_circle_select_pose__doSelectBone(
if ((is_point_done == false) && (points_proj_tot == 2) &&
edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b))
{
- if (data->select) pchan->bone->flag |= BONE_SELECTED;
- else pchan->bone->flag &= ~BONE_SELECTED;
+ if (data->select) {
+ pchan->bone->flag |= BONE_SELECTED;
+ }
+ else {
+ pchan->bone->flag &= ~BONE_SELECTED;
+ }
data->is_changed = true;
}
@@ -3145,23 +3283,22 @@ static bool pose_circle_select(ViewContext *vc, const eSelectOp sel_op, const in
{
BLI_assert(ELEM(sel_op, SEL_OP_SET, SEL_OP_ADD, SEL_OP_SUB));
CircleSelectUserData data;
- bool changed = false;
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- changed |= ED_pose_deselect_all(vc->obact, SEL_DESELECT, false);
- }
const bool select = (sel_op != SEL_OP_SUB);
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ data.is_changed |= ED_pose_deselect_all(vc->obact, SEL_DESELECT, false);
+ }
+
ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */
pose_foreachScreenBone(vc, do_circle_select_pose__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
- changed |= data.is_changed;
- if (changed) {
+ if (data.is_changed) {
ED_pose_bone_select_tag_update(vc->obact);
}
- return changed;
+ return data.is_changed;
}
static bool armature_circle_doSelectJoint(void *userData, EditBone *ebone, const float screen_co[2], bool head)
@@ -3170,16 +3307,20 @@ static bool armature_circle_doSelectJoint(void *userData, EditBone *ebone, const
if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
if (head) {
- if (data->select)
+ if (data->select) {
ebone->flag |= BONE_ROOTSEL;
- else
+ }
+ else {
ebone->flag &= ~BONE_ROOTSEL;
+ }
}
else {
- if (data->select)
+ if (data->select) {
ebone->flag |= BONE_TIPSEL;
- else
+ }
+ else {
ebone->flag &= ~BONE_TIPSEL;
+ }
}
return 1;
}
@@ -3221,8 +3362,12 @@ static void do_circle_select_armature__doSelectBone(
if ((is_point_done == false) && (points_proj_tot == 2) &&
edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b))
{
- if (data->select) ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ if (data->select) {
+ ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
+ else {
+ ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
data->is_changed = true;
}
@@ -3234,15 +3379,14 @@ static bool armature_circle_select(ViewContext *vc, const eSelectOp sel_op, cons
CircleSelectUserData data;
bArmature *arm = vc->obedit->data;
- bool changed = false;
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- ED_armature_edit_deselect_all_visible(vc->obedit);
- changed = true;
- }
const bool select = (sel_op != SEL_OP_SUB);
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ data.is_changed |= ED_armature_edit_deselect_all_visible(vc->obedit);
+ }
+
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
armature_foreachScreenBone(vc, do_circle_select_armature__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
@@ -3252,8 +3396,7 @@ static bool armature_circle_select(ViewContext *vc, const eSelectOp sel_op, cons
ED_armature_edit_validate_active(arm);
WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit);
}
- changed |= data.is_changed;
- return changed;
+ return data.is_changed;
}
static void do_circle_select_mball__doSelectElem(void *userData, struct MetaElem *ml, const float screen_co[2])
@@ -3261,8 +3404,12 @@ static void do_circle_select_mball__doSelectElem(void *userData, struct MetaElem
CircleSelectUserData *data = userData;
if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) {
- if (data->select) ml->flag |= SELECT;
- else ml->flag &= ~SELECT;
+ if (data->select) {
+ ml->flag |= SELECT;
+ }
+ else {
+ ml->flag &= ~SELECT;
+ }
data->is_changed = true;
}
}
@@ -3270,20 +3417,18 @@ static bool mball_circle_select(ViewContext *vc, const eSelectOp sel_op, const i
{
CircleSelectUserData data;
- bool changed = false;
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- BKE_mball_deselect_all(vc->obedit->data);
- changed = true;
- }
const bool select = (sel_op != SEL_OP_SUB);
view3d_userdata_circleselect_init(&data, vc, select, mval, rad);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ data.is_changed |= BKE_mball_deselect_all(vc->obedit->data);
+ }
+
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
mball_foreachScreenElem(vc, do_circle_select_mball__doSelectElem, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
- changed |= data.is_changed;
- return changed;
+ return data.is_changed;
}
/** Callbacks for circle selection in Editmode */
@@ -3321,9 +3466,7 @@ static bool object_circle_select(ViewContext *vc, const eSelectOp sel_op, const
bool changed = false;
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- if (object_deselect_all_visible(vc->view_layer, vc->v3d)) {
- changed = true;
- }
+ changed |= object_deselect_all_visible(vc->view_layer, vc->v3d);
}
const bool select = (sel_op != SEL_OP_SUB);
const int select_flag = select ? BASE_SELECTED : 0;
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 2108fc1ac07..711e084f2ac 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -40,6 +40,7 @@
#include "BKE_mball.h"
#include "BKE_object.h"
#include "BKE_report.h"
+#include "BKE_scene.h"
#include "BKE_tracking.h"
#include "DEG_depsgraph.h"
@@ -64,7 +65,7 @@ static bool snap_calc_active_center(bContext *C, const bool select_only, float r
/* *********************** operators ******************** */
-/** Snaps every individual object center to its nearest point on the grid. **/
+/** Snaps every individual object center to its nearest point on the grid. */
static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
@@ -155,12 +156,15 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
/* adjust location on the original pchan*/
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, pchan_eval->name);
- if ((pchan->protectflag & OB_LOCK_LOCX) == 0)
+ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) {
pchan->loc[0] = vec[0];
- if ((pchan->protectflag & OB_LOCK_LOCY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_LOCY) == 0) {
pchan->loc[1] = vec[1];
- if ((pchan->protectflag & OB_LOCK_LOCZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) {
pchan->loc[2] = vec[2];
+ }
/* auto-keyframing */
ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
@@ -187,12 +191,15 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, vec);
}
- if ((ob->protectflag & OB_LOCK_LOCX) == 0)
+ if ((ob->protectflag & OB_LOCK_LOCX) == 0) {
ob->loc[0] = ob_eval->loc[0] + vec[0];
- if ((ob->protectflag & OB_LOCK_LOCY) == 0)
+ }
+ if ((ob->protectflag & OB_LOCK_LOCY) == 0) {
ob->loc[1] = ob_eval->loc[1] + vec[1];
- if ((ob->protectflag & OB_LOCK_LOCZ) == 0)
+ }
+ if ((ob->protectflag & OB_LOCK_LOCZ) == 0) {
ob->loc[2] = ob_eval->loc[2] + vec[2];
+ }
/* auto-keyframing */
ED_autokeyframe_object(C, scene, ob, ks);
@@ -230,7 +237,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
* \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], const bool use_offset)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
@@ -358,12 +365,15 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
}
/* copy new position */
- if ((pchan->protectflag & OB_LOCK_LOCX) == 0)
+ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) {
pchan->loc[0] = cursor_pose[0];
- if ((pchan->protectflag & OB_LOCK_LOCY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_LOCY) == 0) {
pchan->loc[1] = cursor_pose[1];
- if ((pchan->protectflag & OB_LOCK_LOCZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) {
pchan->loc[2] = cursor_pose[2];
+ }
/* auto-keyframing */
ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
@@ -424,12 +434,15 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, cursor_parent);
}
- if ((ob->protectflag & OB_LOCK_LOCX) == 0)
+ if ((ob->protectflag & OB_LOCK_LOCX) == 0) {
ob->loc[0] += cursor_parent[0];
- if ((ob->protectflag & OB_LOCK_LOCY) == 0)
+ }
+ if ((ob->protectflag & OB_LOCK_LOCY) == 0) {
ob->loc[1] += cursor_parent[1];
- if ((ob->protectflag & OB_LOCK_LOCZ) == 0)
+ }
+ if ((ob->protectflag & OB_LOCK_LOCZ) == 0) {
ob->loc[2] += cursor_parent[2];
+ }
/* auto-keyframing */
ED_autokeyframe_object(C, scene, ob, ks);
@@ -472,13 +485,14 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
/* rna */
- RNA_def_boolean(ot->srna, "use_offset", 1, "Offset",
- "If the selection should be snapped as a whole or by each object center");
+ RNA_def_boolean(
+ ot->srna, "use_offset", 1, "Offset",
+ "If the selection should be snapped as a whole or by each object center");
}
/* *************************************************** */
-/** Snaps each selected object to the location of the active selected object. **/
+/** Snaps each selected object to the location of the active selected object. */
static int snap_selected_to_active_exec(bContext *C, wmOperator *op)
{
float snap_target_global[3];
@@ -509,7 +523,7 @@ void VIEW3D_OT_snap_selected_to_active(wmOperatorType *ot)
/* *************************************************** */
-/** Snaps the 3D cursor location to its nearest point on the grid. **/
+/** Snaps the 3D cursor location to its nearest point on the grid. */
static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@@ -559,8 +573,9 @@ static void bundle_midpoint(Scene *scene, Object *ob, float r_vec[3])
bool ok = false;
float min[3], max[3], mat[4][4], pos[3], cammat[4][4];
- if (!clip)
+ if (!clip) {
return;
+ }
tracking = &clip->tracking;
@@ -603,7 +618,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float r_vec[3])
}
}
-/** Snaps the 3D cursor location to the median point of the selection. **/
+/** Snaps the 3D cursor location to the median point of the selection. */
static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
@@ -799,12 +814,15 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
/* **************************************************** */
-/** Snaps the 3D cursor location to the origin. **/
+/** Snaps the 3D cursor location to the origin and clears cursor rotation. */
static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
+ float mat3[3][3];
+ unit_m3(mat3);
zero_v3(scene->cursor.location);
+ BKE_scene_cursor_mat3_to_rot(&scene->cursor, mat3, false);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
@@ -852,11 +870,13 @@ bool ED_view3d_minmax_verts(Object *obedit, float r_min[3], float r_max[3])
return changed;
}
- if (ED_transverts_check_obedit(obedit))
+ if (ED_transverts_check_obedit(obedit)) {
ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS);
+ }
- if (tvs.transverts_tot == 0)
+ if (tvs.transverts_tot == 0) {
return false;
+ }
copy_m3_m4(bmat, obedit->obmat);
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index 438cab21134..c96e524ec2b 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -46,8 +46,9 @@ 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)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index ab2d09e0862..0639bdaa71c 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -141,8 +141,12 @@ bool ED_view3d_clip_range_get(
params.clip_end *= fac;
}
- if (r_clipsta) *r_clipsta = params.clip_start;
- if (r_clipend) *r_clipend = params.clip_end;
+ if (r_clipsta) {
+ *r_clipsta = params.clip_start;
+ }
+ if (r_clipend) {
+ *r_clipend = params.clip_end;
+ }
return params.is_ortho;
}
@@ -158,10 +162,18 @@ bool ED_view3d_viewplane_get(
BKE_camera_params_from_view3d(&params, depsgraph, v3d, rv3d);
BKE_camera_params_compute_viewplane(&params, winx, winy, 1.0f, 1.0f);
- if (r_viewplane) *r_viewplane = params.viewplane;
- if (r_clip_start) *r_clip_start = params.clip_start;
- if (r_clip_end) *r_clip_end = params.clip_end;
- if (r_pixsize) *r_pixsize = params.viewdx;
+ if (r_viewplane) {
+ *r_viewplane = params.viewplane;
+ }
+ if (r_clip_start) {
+ *r_clip_start = params.clip_start;
+ }
+ if (r_clip_end) {
+ *r_clip_end = params.clip_end;
+ }
+ if (r_pixsize) {
+ *r_pixsize = params.viewdx;
+ }
return params.is_ortho;
}
@@ -327,15 +339,29 @@ static bool view3d_boundbox_clip_m4(const BoundBox *bb, float persmatob[4][4])
min = -vec[3];
fl = 0;
- if (vec[0] < min) fl += 1;
- if (vec[0] > max) fl += 2;
- if (vec[1] < min) fl += 4;
- if (vec[1] > max) fl += 8;
- if (vec[2] < min) fl += 16;
- if (vec[2] > max) fl += 32;
+ if (vec[0] < min) {
+ fl += 1;
+ }
+ if (vec[0] > max) {
+ fl += 2;
+ }
+ if (vec[1] < min) {
+ fl += 4;
+ }
+ if (vec[1] > max) {
+ fl += 8;
+ }
+ if (vec[2] < min) {
+ fl += 16;
+ }
+ if (vec[2] > max) {
+ fl += 32;
+ }
flag &= fl;
- if (flag == 0) return true;
+ if (flag == 0) {
+ return true;
+ }
}
return false;
@@ -347,8 +373,12 @@ bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const BoundBox *bb, fl
float persmatob[4][4];
- if (bb == NULL) return true;
- if (bb->flag & BOUNDBOX_DISABLED) return true;
+ if (bb == NULL) {
+ return true;
+ }
+ if (bb->flag & BOUNDBOX_DISABLED) {
+ return true;
+ }
mul_m4_m4m4(persmatob, (float(*)[4])rv3d->persmat, obmat);
@@ -357,8 +387,12 @@ bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const BoundBox *bb, fl
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const BoundBox *bb)
{
- if (bb == NULL) return true;
- if (bb->flag & BOUNDBOX_DISABLED) return true;
+ if (bb == NULL) {
+ return true;
+ }
+ if (bb->flag & BOUNDBOX_DISABLED) {
+ return true;
+ }
return view3d_boundbox_clip_m4(bb, rv3d->persmatob);
}
@@ -431,8 +465,9 @@ bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *ar
BLI_assert((rv3d->viewlock & RV3D_LOCKED) == 0);
- if (ED_view3d_camera_lock_check(v3d, rv3d))
+ if (ED_view3d_camera_lock_check(v3d, rv3d)) {
return false;
+ }
if (rv3d->persp != RV3D_PERSP) {
if (rv3d->persp == RV3D_CAMOB) {
@@ -645,38 +680,56 @@ static void view3d_boxview_clip(ScrArea *sa)
if (rv3d->viewlock & RV3D_BOXCLIP) {
if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) {
- if (ar->winx > ar->winy) x1 = rv3d->dist;
- else x1 = ar->winx * rv3d->dist / ar->winy;
+ if (ar->winx > ar->winy) {
+ x1 = rv3d->dist;
+ }
+ else {
+ x1 = ar->winx * rv3d->dist / ar->winy;
+ }
- if (ar->winx > ar->winy) y1 = ar->winy * rv3d->dist / ar->winx;
- else y1 = rv3d->dist;
+ if (ar->winx > ar->winy) {
+ y1 = ar->winy * rv3d->dist / ar->winx;
+ }
+ else {
+ y1 = rv3d->dist;
+ }
copy_v2_v2(ofs, rv3d->ofs);
}
else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) {
ofs[2] = rv3d->ofs[2];
- if (ar->winx > ar->winy) z1 = ar->winy * rv3d->dist / ar->winx;
- else z1 = rv3d->dist;
+ if (ar->winx > ar->winy) {
+ z1 = ar->winy * rv3d->dist / ar->winx;
+ }
+ else {
+ z1 = rv3d->dist;
+ }
}
}
}
}
for (val = 0; val < 8; val++) {
- if (ELEM(val, 0, 3, 4, 7))
+ if (ELEM(val, 0, 3, 4, 7)) {
bb->vec[val][0] = -x1 - ofs[0];
- else
+ }
+ else {
bb->vec[val][0] = x1 - ofs[0];
+ }
- if (ELEM(val, 0, 1, 4, 5))
+ if (ELEM(val, 0, 1, 4, 5)) {
bb->vec[val][1] = -y1 - ofs[1];
- else
+ }
+ else {
bb->vec[val][1] = y1 - ofs[1];
+ }
- if (val > 3)
+ if (val > 3) {
bb->vec[val][2] = -z1 - ofs[2];
- else
+ }
+ else {
bb->vec[val][2] = z1 - ofs[2];
+ }
}
/* normals for plane equations */
@@ -700,7 +753,9 @@ static void view3d_boxview_clip(ScrArea *sa)
if (rv3d->viewlock & RV3D_BOXCLIP) {
rv3d->rflag |= RV3D_CLIPPING;
memcpy(rv3d->clip, clip, sizeof(clip));
- if (rv3d->clipbb) MEM_freeN(rv3d->clipbb);
+ if (rv3d->clipbb) {
+ MEM_freeN(rv3d->clipbb);
+ }
rv3d->clipbb = MEM_dupallocN(bb);
}
}
@@ -969,13 +1024,16 @@ bool ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_world
float depth;
/* Get Z Depths, needed for perspective, nice for ortho */
- if (force_depth)
+ if (force_depth) {
depth = *force_depth;
- else
+ }
+ else {
depth = view_autodist_depth_margin(ar, mval, margin);
+ }
- if (depth == FLT_MAX)
+ if (depth == FLT_MAX) {
return false;
+ }
float centx = (float)mval[0] + 0.5f;
float centy = (float)mval[1] + 0.5f;
@@ -1299,8 +1357,9 @@ void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float
normalize_m3(nmat);
/* Offset */
- if (ofs)
+ if (ofs) {
negate_v3_v3(ofs, mat[3]);
+ }
/* Quat */
if (quat) {
@@ -1464,8 +1523,9 @@ bool ED_view3d_depth_unproject(
void ED_view3d_depth_tag_update(RegionView3D *rv3d)
{
- if (rv3d->depths)
+ if (rv3d->depths) {
rv3d->depths->damaged = true;
+ }
}
/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index b6defa1ad62..21716f28b85 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -154,14 +154,18 @@ void ED_view3d_smooth_view_ex(
}
/* store the options we want to end with */
- if (sview->ofs)
+ if (sview->ofs) {
copy_v3_v3(sms.dst.ofs, sview->ofs);
- if (sview->quat)
+ }
+ if (sview->quat) {
copy_qt_qt(sms.dst.quat, sview->quat);
- if (sview->dist)
+ }
+ if (sview->dist) {
sms.dst.dist = *sview->dist;
- if (sview->lens)
+ }
+ if (sview->lens) {
sms.dst.lens = *sview->lens;
+ }
if (sview->dyn_ofs) {
BLI_assert(sview->ofs == NULL);
@@ -185,16 +189,21 @@ void ED_view3d_smooth_view_ex(
if (smooth_viewtx && v3d->shading.type != OB_RENDER) {
bool changed = false; /* zero means no difference */
- if (sview->camera_old != sview->camera)
+ if (sview->camera_old != sview->camera) {
changed = true;
- else if (sms.dst.dist != rv3d->dist)
+ }
+ else if (sms.dst.dist != rv3d->dist) {
changed = true;
- else if (sms.dst.lens != v3d->lens)
+ }
+ else if (sms.dst.lens != v3d->lens) {
changed = true;
- else if (!equals_v3v3(sms.dst.ofs, rv3d->ofs))
+ }
+ else if (!equals_v3v3(sms.dst.ofs, rv3d->ofs)) {
changed = true;
- else if (!equals_v4v4(sms.dst.quat, rv3d->viewquat))
+ }
+ else if (!equals_v4v4(sms.dst.quat, rv3d->viewquat)) {
changed = true;
+ }
/* The new view is different from the old one
* so animate the view */
@@ -301,10 +310,12 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
struct SmoothView3DStore *sms = rv3d->sms;
float step, step_inv;
- if (sms->time_allowed != 0.0)
+ if (sms->time_allowed != 0.0) {
step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed);
- else
+ }
+ else {
step = 1.0f;
+ }
/* end timer */
if (step >= 1.0f) {
@@ -639,8 +650,10 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
Object *camera_old = (rv3d->persp == RV3D_CAMOB) ? V3D_CAMERA_SCENE(scene, v3d) : NULL;
rv3d->persp = RV3D_CAMOB;
v3d->camera = ob;
- if (v3d->scenelock)
+ if (v3d->scenelock && scene->camera != ob) {
scene->camera = ob;
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+ }
/* unlikely but looks like a glitch when set to the same */
if (camera_old != ob) {
@@ -777,11 +790,14 @@ void view3d_viewmatrix_set(
/* should be moved to better initialize later on XXX */
- if (rv3d->viewlock & RV3D_LOCKED)
+ if (rv3d->viewlock & RV3D_LOCKED) {
ED_view3d_lock(rv3d);
+ }
quat_to_mat4(rv3d->viewmat, rv3d->viewquat);
- if (rv3d->persp == RV3D_PERSP) rv3d->viewmat[3][2] -= rv3d->dist;
+ if (rv3d->persp == RV3D_PERSP) {
+ rv3d->viewmat[3][2] -= rv3d->dist;
+ }
if (v3d->ob_centre) {
Object *ob_eval = DEG_get_evaluated_object(depsgraph, v3d->ob_centre);
float vec[3];
@@ -942,7 +958,7 @@ int view3d_opengl_select(
rcti rect;
int hits = 0;
const bool use_obedit_skip = (OBEDIT_FROM_VIEW_LAYER(vc->view_layer) != NULL) && (vc->obedit == NULL);
- const bool is_pick_select = (U.gpu_select_pick_deph != 0);
+ const bool is_pick_select = (U.gpu_flag & USER_GPU_FLAG_NO_DEPT_PICK) == 0;
const bool do_passes = (
(is_pick_select == false) &&
(select_mode == VIEW3D_SELECT_PICK_NEAREST));
@@ -1092,14 +1108,17 @@ int view3d_opengl_select(
GPU_depth_test(false);
}
- if (vc->rv3d->rflag & RV3D_CLIPPING)
+ if (vc->rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_disable();
+ }
DRW_opengl_context_disable();
finally:
- if (hits < 0) printf("Too many objects in select buffer\n"); /* XXX make error message */
+ if (hits < 0) {
+ printf("Too many objects in select buffer\n"); /* XXX make error message */
+ }
UI_Theme_Restore(&theme_state);
@@ -1273,7 +1292,9 @@ static void view3d_localview_exit(
{
View3D *v3d = sa->spacedata.first;
- if (v3d->localvd == NULL) return;
+ if (v3d->localvd == NULL) {
+ return;
+ }
for (Base *base = FIRSTBASE(view_layer); base; base = base->next) {
if (base->local_view_bits & v3d->local_view_uuid) {
@@ -1441,47 +1462,3 @@ void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
}
/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name View Layer Utilities
- * \{ */
-
-int ED_view3d_view_layer_set(int lay, const bool *values, int *active)
-{
- int i, tot = 0;
-
- /* ensure we always have some layer selected */
- for (i = 0; i < 20; i++)
- if (values[i])
- tot++;
-
- if (tot == 0)
- return lay;
-
- for (i = 0; i < 20; i++) {
-
- if (active) {
- /* if this value has just been switched on, make that layer active */
- if (values[i] && (lay & (1 << i)) == 0) {
- *active = (1 << i);
- }
- }
-
- if (values[i]) lay |= (1 << i);
- else lay &= ~(1 << i);
- }
-
- /* ensure always an active layer */
- if (active && (lay & *active) == 0) {
- for (i = 0; i < 20; i++) {
- if (lay & (1 << i)) {
- *active = 1 << i;
- break;
- }
- }
- }
-
- return lay;
-}
-
-/** \} */
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 0caaf6eb113..a015b7f9945 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -166,8 +166,9 @@ void walk_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Walk Modal");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return;
+ }
keymap = WM_modalkeymap_add(keyconf, "View3D Walk Modal", modal_items);
@@ -498,10 +499,12 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->teleport.duration = U.walk_navigation.teleport_time;
walk->mouse_speed = U.walk_navigation.mouse_speed;
- if ((U.walk_navigation.flag & USER_WALK_GRAVITY))
+ if ((U.walk_navigation.flag & USER_WALK_GRAVITY)) {
walk_navigation_mode_set(C, op, walk, WALK_MODE_GRAVITY);
- else
+ }
+ else {
walk_navigation_mode_set(C, op, walk, WALK_MODE_FREE);
+ }
walk->view_height = U.walk_navigation.view_height;
walk->jump_height = U.walk_navigation.jump_height;
@@ -583,8 +586,9 @@ static int walkEnd(bContext *C, WalkInfo *walk)
wmWindow *win;
RegionView3D *rv3d;
- if (walk->state == WALK_RUNNING)
+ if (walk->state == WALK_RUNNING) {
return OPERATOR_RUNNING_MODAL;
+ }
#ifdef NDOF_WALK_DEBUG
puts("\n-- walk end --");
@@ -604,8 +608,9 @@ static int walkEnd(bContext *C, WalkInfo *walk)
rv3d->rflag &= ~RV3D_NAVIGATING;
#ifdef WITH_INPUT_NDOF
- if (walk->ndof)
+ if (walk->ndof) {
MEM_freeN(walk->ndof);
+ }
#endif
/* restore the cursor */
@@ -1019,11 +1024,12 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
/* it ranges from 90.0f to -90.0f */
angle = -asinf(rv3d->viewmat[2][2]);
- if (angle > WALK_TOP_LIMIT && y > 0.0f)
+ if (angle > WALK_TOP_LIMIT && y > 0.0f) {
y = 0.0f;
-
- else if (angle < WALK_BOTTOM_LIMIT && y < 0.0f)
+ }
+ else if (angle < WALK_BOTTOM_LIMIT && y < 0.0f) {
y = 0.0f;
+ }
copy_v3_fl3(upvec, 1.0f, 0.0f, 0.0f);
mul_m3_v3(mat, upvec);
@@ -1041,8 +1047,9 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
copy_v3_fl3(upvec, 0.0f, 1.0f, 0.0f);
mul_m3_v3(mat, upvec);
- if (upvec[2] < 0.0f)
+ if (upvec[2] < 0.0f) {
moffset[0] = -moffset[0];
+ }
/* relative offset */
x = (float) moffset[0] / ar->winx;
@@ -1073,11 +1080,13 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
direction = 0;
- if ((walk->active_directions & WALK_BIT_FORWARD))
+ if ((walk->active_directions & WALK_BIT_FORWARD)) {
direction += 1;
+ }
- if ((walk->active_directions & WALK_BIT_BACKWARD))
+ if ((walk->active_directions & WALK_BIT_BACKWARD)) {
direction -= 1;
+ }
copy_v3_fl3(dvec_tmp, 0.0f, 0.0f, direction);
mul_m3_v3(mat, dvec_tmp);
@@ -1097,11 +1106,13 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
direction = 0;
- if ((walk->active_directions & WALK_BIT_LEFT))
+ if ((walk->active_directions & WALK_BIT_LEFT)) {
direction += 1;
+ }
- if ((walk->active_directions & WALK_BIT_RIGHT))
+ if ((walk->active_directions & WALK_BIT_RIGHT)) {
direction -= 1;
+ }
dvec_tmp[0] = direction * rv3d->viewinv[0][0];
dvec_tmp[1] = direction * rv3d->viewinv[0][1];
@@ -1120,11 +1131,13 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
direction = 0;
- if ((walk->active_directions & WALK_BIT_UP))
+ if ((walk->active_directions & WALK_BIT_UP)) {
direction -= 1;
+ }
- if ((walk->active_directions & WALK_BIT_DOWN))
+ if ((walk->active_directions & WALK_BIT_DOWN)) {
direction = 1;
+ }
copy_v3_fl3(dvec_tmp, 0.0f, 0.0f, direction);
add_v3_v3(dvec, dvec_tmp);
@@ -1162,8 +1175,9 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
dvec[2] -= difference;
/* in case we switched from FREE to GRAVITY too close to the ground */
- if (walk->gravity_state == WALK_GRAVITY_STATE_START)
+ if (walk->gravity_state == WALK_GRAVITY_STATE_START) {
walk->gravity_state = WALK_GRAVITY_STATE_OFF;
+ }
}
else {
/* hijack the teleport variables */
@@ -1249,9 +1263,15 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
if (rv3d->persp == RV3D_CAMOB) {
Object *lock_ob = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control);
- if (lock_ob->protectflag & OB_LOCK_LOCX) dvec[0] = 0.0f;
- if (lock_ob->protectflag & OB_LOCK_LOCY) dvec[1] = 0.0f;
- if (lock_ob->protectflag & OB_LOCK_LOCZ) dvec[2] = 0.0f;
+ if (lock_ob->protectflag & OB_LOCK_LOCX) {
+ dvec[0] = 0.0f;
+ }
+ if (lock_ob->protectflag & OB_LOCK_LOCY) {
+ dvec[1] = 0.0f;
+ }
+ if (lock_ob->protectflag & OB_LOCK_LOCZ) {
+ dvec[2] = 0.0f;
+ }
}
/* scale the movement to the scene size */
@@ -1310,8 +1330,9 @@ static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RegionView3D *rv3d = CTX_wm_region_view3d(C);
WalkInfo *walk;
- if (rv3d->viewlock & RV3D_LOCKED)
+ if (rv3d->viewlock & RV3D_LOCKED) {
return OPERATOR_CANCELLED;
+ }
walk = MEM_callocN(sizeof(WalkInfo), "NavigationWalkOperation");
@@ -1366,8 +1387,9 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event)
exit_code = walkEnd(C, walk);
- if (exit_code != OPERATOR_RUNNING_MODAL)
+ if (exit_code != OPERATOR_RUNNING_MODAL) {
do_draw = true;
+ }
if (do_draw) {
if (rv3d->persp == RV3D_CAMOB) {
@@ -1379,8 +1401,9 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event)
ED_region_tag_redraw(CTX_wm_region(C));
}
- if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED))
+ if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) {
ED_workspace_status_text(C, NULL);
+ }
return exit_code;
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 4e41b3a1065..e785268b80a 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2633,7 +2633,10 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
/* Constraint init from operator */
- if (t->flag & T_MODAL) {
+ if ((t->flag & T_MODAL) ||
+ /* For mirror operator the constraint axes are effectively the values. */
+ (RNA_struct_find_property(op->ptr, "values") == NULL))
+ {
if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")) &&
RNA_property_is_set(op->ptr, prop))
{
@@ -2644,21 +2647,14 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) {
t->con.mode |= CON_APPLY;
- /* Only for interactive operation, when redoing, ignore these values since the numbers
- * will be constrainted already. */
- if (t->flag & T_MODAL) {
- if (constraint_axis[0]) {
- t->con.mode |= CON_AXIS0;
- }
- if (constraint_axis[1]) {
- t->con.mode |= CON_AXIS1;
- }
- if (constraint_axis[2]) {
- t->con.mode |= CON_AXIS2;
- }
+ if (constraint_axis[0]) {
+ t->con.mode |= CON_AXIS0;
}
- else {
- t->con.mode |= CON_AXIS0 | CON_AXIS1 | CON_AXIS2;
+ if (constraint_axis[1]) {
+ t->con.mode |= CON_AXIS1;
+ }
+ if (constraint_axis[2]) {
+ t->con.mode |= CON_AXIS2;
}
setUserConstraint(t, t->orientation.user, t->con.mode, "%s");
@@ -4189,7 +4185,7 @@ static void headerRotation(TransInfo *t, char str[UI_MAX_DRAW_STR], float final)
}
else {
ofs += BLI_snprintf(str + ofs, UI_MAX_DRAW_STR - ofs, IFACE_("Rot: %.2f%s %s"),
- RAD2DEGF(final), t->con.text, t->proptext);
+ RAD2DEGF(final), t->con.text, t->proptext);
}
if (t->flag & T_PROP_EDIT_ALL) {
@@ -4650,7 +4646,7 @@ void freeCustomNormalArray(TransInfo *t, TransDataContainer *tc, TransCustomData
/* Restore custom loop normal on cancel */
for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) {
BKE_lnor_space_custom_normal_to_data(
- bm->lnor_spacearr->lspacearr[lnor_ed->loop_index], lnor_ed->niloc, lnor_ed->clnors_data);
+ bm->lnor_spacearr->lspacearr[lnor_ed->loop_index], lnor_ed->niloc, lnor_ed->clnors_data);
}
}
@@ -4727,7 +4723,7 @@ static void applyNormalRotation(TransInfo *t, const int UNUSED(mval[2]))
mul_v3_m3v3(lnor_ed->nloc, mat, lnor_ed->niloc);
BKE_lnor_space_custom_normal_to_data(
- bm->lnor_spacearr->lspacearr[lnor_ed->loop_index], lnor_ed->nloc, lnor_ed->clnors_data);
+ bm->lnor_spacearr->lspacearr[lnor_ed->loop_index], lnor_ed->nloc, lnor_ed->clnors_data);
}
}
@@ -5146,7 +5142,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
if (t->proptext[0]) {
ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, " %s", t->proptext);
}
- ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, ", (");
+ ofs += BLI_strncpy_rlen(str + ofs, ", (", sizeof(str) - ofs);
if (t->keymap) {
wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE);
@@ -6131,7 +6127,8 @@ static void slide_origdata_create_data(
for (i = 0; i < tc->data_len; i++, td++) {
BMVert *eve = td->extra;
- if (eve) {
+ /* Check the vertex has been used since both sides of the mirror may be selected & sliding. */
+ if (eve && !BLI_ghash_haskey(sod->origverts, eve)) {
sv_mirror->v = eve;
copy_v3_v3(sv_mirror->co_orig_3d, eve->co);
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index e79f510d308..0fc36858e13 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -2255,7 +2255,7 @@ void flushTransParticles(TransInfo *t)
}
PE_update_object(t->depsgraph, scene, OBACT(view_layer), 1);
- DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
+ DEG_id_tag_update(&ob->id, ID_RECALC_PSYS_REDO);
}
}
@@ -6442,7 +6442,7 @@ static void special_aftertrans_update__node(bContext *C, TransInfo *t)
for (node = ntree->nodes.first; node; node = node_next) {
node_next = node->next;
if (node->flag & NODE_SELECT)
- nodeDeleteNode(bmain, ntree, node);
+ nodeRemoveNode(bmain, ntree, node, true);
}
}
}
@@ -8480,8 +8480,9 @@ static void createTransGPencil(bContext *C, TransInfo *t)
float falloff = 1.0f; /* by default no falloff */
if ((is_multiedit) && (use_multiframe_falloff)) {
/* Faloff depends on distance to active frame (relative to the overall frame range) */
- falloff = BKE_gpencil_multiframe_falloff_calc(gpf, gpl->actframe->framenum,
- f_init, f_end, ts->gp_sculpt.cur_falloff);
+ falloff = BKE_gpencil_multiframe_falloff_calc(
+ gpf, gpl->actframe->framenum,
+ f_init, f_end, ts->gp_sculpt.cur_falloff);
}
for (gps = gpf->strokes.first; gps; gps = gps->next) {
@@ -8934,6 +8935,10 @@ void createTransData(bContext *C, TransInfo *t)
has_transform_context = false;
}
}
+ else if (ob && (ob->mode == OB_MODE_PAINT_GPENCIL)) {
+ /* In grease pencil draw mode all transformations must be canceled. */
+ has_transform_context = false;
+ }
else {
createTransObject(C, t);
countAndCleanTransDataContainer(t);
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 2e6a399d0ea..d1e91cd2a73 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -1377,7 +1377,7 @@ void drawDial3d(const TransInfo *t)
GPU_line_smooth(true);
ED_gizmotypes_dial_3d_draw_util(
- mat_basis, mat_final, line_with, color,
+ mat_basis, mat_final, line_with, color, false,
&(struct Dial3dParams){
.draw_options = ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE,
.angle_delta = t->values[0],
@@ -1423,7 +1423,7 @@ static GizmoGroup *gizmogroup_init(wmGizmoGroup *gzgroup)
/* add/init widgets - order matters! */
GIZMO_NEW_DIAL(MAN_AXIS_ROT_T, ED_GIZMO_DIAL_DRAW_FLAG_FILL);
- GIZMO_NEW_DIAL(MAN_AXIS_SCALE_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP);
+ GIZMO_NEW_DIAL(MAN_AXIS_SCALE_C, ED_GIZMO_DIAL_DRAW_FLAG_FILL_SELECT);
GIZMO_NEW_ARROW(MAN_AXIS_SCALE_X, ED_GIZMO_ARROW_STYLE_BOX);
GIZMO_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_GIZMO_ARROW_STYLE_BOX);
@@ -1440,7 +1440,7 @@ static GizmoGroup *gizmogroup_init(wmGizmoGroup *gzgroup)
/* init screen aligned widget last here, looks better, behaves better */
GIZMO_NEW_DIAL(MAN_AXIS_ROT_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP);
- GIZMO_NEW_DIAL(MAN_AXIS_TRANS_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP);
+ GIZMO_NEW_DIAL(MAN_AXIS_TRANS_C, ED_GIZMO_DIAL_DRAW_FLAG_FILL_SELECT);
GIZMO_NEW_ARROW(MAN_AXIS_TRANS_X, ED_GIZMO_ARROW_STYLE_NORMAL);
GIZMO_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_GIZMO_ARROW_STYLE_NORMAL);
@@ -1620,18 +1620,18 @@ static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup)
ScrArea *sa = CTX_wm_area(C);
const bToolRef *tref = sa->runtime.tool;
- if (tref == NULL || STREQ(tref->idname, "Transform")) {
+ if (tref == NULL || STREQ(tref->idname, "builtin.transform")) {
/* Setup all gizmos, they can be toggled via 'ToolSettings.gizmo_flag' */
ggd->twtype = SCE_GIZMO_SHOW_TRANSLATE | SCE_GIZMO_SHOW_ROTATE | SCE_GIZMO_SHOW_SCALE;
ggd->use_twtype_refresh = true;
}
- else if (STREQ(tref->idname, "Move")) {
+ else if (STREQ(tref->idname, "builtin.move")) {
ggd->twtype |= SCE_GIZMO_SHOW_TRANSLATE;
}
- else if (STREQ(tref->idname, "Rotate")) {
+ else if (STREQ(tref->idname, "builtin.rotate")) {
ggd->twtype |= SCE_GIZMO_SHOW_ROTATE;
}
- else if (STREQ(tref->idname, "Scale")) {
+ else if (STREQ(tref->idname, "builtin.scale")) {
ggd->twtype |= SCE_GIZMO_SHOW_SCALE;
}
BLI_assert(ggd->twtype != 0);
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index a1bb970e844..648e616a27c 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -161,11 +161,14 @@ const EnumPropertyItem rna_enum_transform_mode_types[] =
static int select_orientation_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+
int orientation = RNA_enum_get(op->ptr, "orientation");
BKE_scene_orientation_slot_set_index(&scene->orientation_slots[SCE_ORIENT_DEFAULT], orientation);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
WM_msg_publish_rna_prop(mbus, &scene->id, scene, TransformOrientationSlot, type);
@@ -518,6 +521,15 @@ static bool transform_poll_property(const bContext *UNUSED(C), wmOperator *op, c
PropertyRNA *prop_con = RNA_struct_find_property(op->ptr, "orient_type");
if (prop_con != NULL && (prop_con != prop)) {
if (STRPREFIX(prop_id, "constraint")) {
+
+ /* Special case: show constraint axis if we don't have values,
+ * needed for mirror operator. */
+ if (STREQ(prop_id, "constraint_axis") &&
+ (RNA_struct_find_property(op->ptr, "value") == NULL))
+ {
+ return true;
+ }
+
return false;
}
}
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index e7c4c2e441c..ea3657b8729 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -685,6 +685,11 @@ static bool raycastObj(
switch (ob->type) {
case OB_MESH:
{
+ if (ob->dt == OB_BOUNDBOX || ob->dt == OB_WIRE) {
+ /* Do not hit objects that are in wire or bounding box display mode */
+ return false;
+ }
+
Mesh *me = ob->data;
if (BKE_object_is_in_editmode(ob)) {
BMEditMesh *em = BKE_editmesh_from_object(ob);
@@ -1215,6 +1220,7 @@ static short snap_mesh_polygon(
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
if (snapdata->snap_to_flag & SCE_SNAP_MODE_EDGE) {
elem = SCE_SNAP_MODE_EDGE;
+ BM_mesh_elem_index_ensure(em->bm, BM_EDGE);
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE);
do {
cb_snap_edge(
@@ -1226,6 +1232,7 @@ static short snap_mesh_polygon(
}
else {
elem = SCE_SNAP_MODE_VERTEX;
+ BM_mesh_elem_index_ensure(em->bm, BM_VERT);
BM_mesh_elem_table_ensure(em->bm, BM_VERT);
do {
cb_snap_vert(
@@ -1320,7 +1327,7 @@ static short snap_mesh_edge_verts_mixed(
neasrest_precalc.ray_direction,
v_pair[0], v_pair[1], &lambda))
{
- /* do nothing */;
+ /* do nothing */
}
else if (lambda < 0.25f || 0.75f < lambda) {
int v_id = lambda < 0.5f ? 0 : 1;
@@ -2183,6 +2190,11 @@ static short snapObject(
me = em->mesh_eval_final;
}
}
+ else if (ob->dt == OB_BOUNDBOX) {
+ /* Do not snap to objects that are in bounding box display mode */
+ return 0;
+ }
+
retval = snapMesh(
sctx, snapdata, ob, me, obmat,
dist_px,
diff --git a/source/blender/editors/util/select_utils.c b/source/blender/editors/util/select_utils.c
index 80b103e0c4b..b8167632fd9 100644
--- a/source/blender/editors/util/select_utils.c
+++ b/source/blender/editors/util/select_utils.c
@@ -97,7 +97,7 @@ int ED_select_similar_compare_float(const float delta, const float thresh, const
}
}
-bool ED_select_similar_compare_float_tree(const KDTree *tree, const float length, const float thresh, const int compare)
+bool ED_select_similar_compare_float_tree(const KDTree_1d *tree, const float length, const float thresh, const int compare)
{
/* Length of the edge we want to compare against. */
float nearest_edge_length;
@@ -123,9 +123,8 @@ bool ED_select_similar_compare_float_tree(const KDTree *tree, const float length
return false;
}
- KDTreeNearest nearest;
- float dummy[3] = {nearest_edge_length, 0.0f, 0.0f};
- if (BLI_kdtree_find_nearest(tree, dummy, &nearest) != -1) {
+ KDTreeNearest_1d nearest;
+ if (BLI_kdtree_1d_find_nearest(tree, &nearest_edge_length, &nearest) != -1) {
float delta = length - nearest.co[0];
return ED_select_similar_compare_float(delta, thresh, compare);
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index ae532a8e5c7..a4247ec370d 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -159,7 +159,17 @@ bool ED_object_get_active_image(
if (node && is_image_texture_node(node)) {
if (r_ima) *r_ima = (Image *)node->id;
- if (r_iuser) *r_iuser = NULL;
+ if (r_iuser) {
+ if (node->type == SH_NODE_TEX_IMAGE) {
+ *r_iuser = &((NodeTexImage *)node->storage)->iuser;
+ }
+ else if (node->type == SH_NODE_TEX_ENVIRONMENT) {
+ *r_iuser = &((NodeTexEnvironment *)node->storage)->iuser;
+ }
+ else {
+ *r_iuser = NULL;
+ }
+ }
if (r_node) *r_node = node;
if (r_ntree) *r_ntree = ntree;
return true;
@@ -187,14 +197,6 @@ void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *i
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Assign Image
- * \{ */
-
-//#define USE_SWITCH_ASPECT
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Space Conversion
* \{ */
@@ -1851,7 +1853,7 @@ static int uv_remove_doubles_to_selected(bContext *C, wmOperator *op)
uv_maxlen += em->bm->totloop;
}
- KDTree *tree = BLI_kdtree_new(uv_maxlen);
+ KDTree_2d *tree = BLI_kdtree_2d_new(uv_maxlen);
int *duplicates = NULL;
BLI_array_declare(duplicates);
@@ -1861,7 +1863,6 @@ static int uv_remove_doubles_to_selected(bContext *C, wmOperator *op)
int mloopuv_count = 0; /* Also used for *duplicates count. */
- float uvw[3];
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
BMIter iter, liter;
BMFace *efa;
@@ -1883,8 +1884,7 @@ static int uv_remove_doubles_to_selected(bContext *C, wmOperator *op)
BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- copy_v3_fl3(uvw, luv->uv[0], luv->uv[1], 0.0f);
- BLI_kdtree_insert(tree, mloopuv_count, uvw);
+ BLI_kdtree_2d_insert(tree, mloopuv_count, luv->uv);
BLI_array_append(duplicates, -1);
BLI_array_append(mloopuv_arr, luv);
mloopuv_count++;
@@ -1895,8 +1895,8 @@ static int uv_remove_doubles_to_selected(bContext *C, wmOperator *op)
ob_mloopuv_max_idx[ob_index] = mloopuv_count - 1;
}
- BLI_kdtree_balance(tree);
- int found_duplicates = BLI_kdtree_calc_duplicates_fast(tree, threshold, false, duplicates);
+ BLI_kdtree_2d_balance(tree);
+ int found_duplicates = BLI_kdtree_2d_calc_duplicates_fast(tree, threshold, false, duplicates);
if (found_duplicates > 0) {
/* Calculate average uv for duplicates. */
@@ -1953,7 +1953,7 @@ static int uv_remove_doubles_to_selected(bContext *C, wmOperator *op)
}
}
- BLI_kdtree_free(tree);
+ BLI_kdtree_2d_free(tree);
BLI_array_free(mloopuv_arr);
BLI_array_free(duplicates);
MEM_freeN(changed);
@@ -1985,14 +1985,13 @@ static int uv_remove_doubles_to_unselected(bContext *C, wmOperator *op)
uv_maxlen += em->bm->totloop;
}
- KDTree *tree = BLI_kdtree_new(uv_maxlen);
+ KDTree_2d *tree = BLI_kdtree_2d_new(uv_maxlen);
MLoopUV **mloopuv_arr = NULL;
BLI_array_declare(mloopuv_arr);
int mloopuv_count = 0;
- float uvw[3];
/* Add visible non-selected uvs to tree */
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
BMIter iter, liter;
@@ -2015,8 +2014,7 @@ static int uv_remove_doubles_to_unselected(bContext *C, wmOperator *op)
BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
if (!uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- copy_v3_fl3(uvw, luv->uv[0], luv->uv[1], 0.0f);
- BLI_kdtree_insert(tree, mloopuv_count, uvw);
+ BLI_kdtree_2d_insert(tree, mloopuv_count, luv->uv);
BLI_array_append(mloopuv_arr, luv);
mloopuv_count++;
}
@@ -2024,7 +2022,7 @@ static int uv_remove_doubles_to_unselected(bContext *C, wmOperator *op)
}
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_2d_balance(tree);
/* For each selected uv, find duplicate non selected uv. */
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -2049,10 +2047,8 @@ static int uv_remove_doubles_to_unselected(bContext *C, wmOperator *op)
BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- copy_v3_fl3(uvw, luv->uv[0], luv->uv[1], 0.0f);
-
- KDTreeNearest nearest;
- const int i = BLI_kdtree_find_nearest(tree, uvw, &nearest);
+ KDTreeNearest_2d nearest;
+ const int i = BLI_kdtree_2d_find_nearest(tree, luv->uv, &nearest);
if (i != -1 && nearest.dist < threshold) {
copy_v2_v2(luv->uv, mloopuv_arr[i]->uv);
@@ -2069,7 +2065,7 @@ static int uv_remove_doubles_to_unselected(bContext *C, wmOperator *op)
}
}
- BLI_kdtree_free(tree);
+ BLI_kdtree_2d_free(tree);
BLI_array_free(mloopuv_arr);
MEM_freeN(objects);
@@ -2135,7 +2131,6 @@ static void UV_OT_weld(wmOperatorType *ot)
/** \name (De)Select All Operator
* \{ */
-
static bool uv_select_is_any_selected(Scene *scene, Image *ima, Object *obedit)
{
ToolSettings *ts = scene->toolsettings;
@@ -2632,7 +2627,7 @@ static void UV_OT_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = uv_select_exec;
ot->invoke = uv_select_invoke;
- ot->poll = ED_operator_uvedit; /* requires space image */;
+ ot->poll = ED_operator_uvedit; /* requires space image */
/* properties */
RNA_def_boolean(ot->srna, "extend", 0,
@@ -2681,7 +2676,7 @@ static void UV_OT_select_loop(wmOperatorType *ot)
/* api callbacks */
ot->exec = uv_select_loop_exec;
ot->invoke = uv_select_loop_invoke;
- ot->poll = ED_operator_uvedit; /* requires space image */;
+ ot->poll = ED_operator_uvedit; /* requires space image */
/* properties */
RNA_def_boolean(ot->srna, "extend", 0,
@@ -2704,7 +2699,8 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
ViewLayer *view_layer = CTX_data_view_layer(C);
Image *ima = CTX_data_edit_image(C);
float limit[2];
- int extend, deselect;
+ bool extend = true;
+ bool deselect = false;
bool select_faces = (ts->uv_flag & UV_SYNC_SELECTION) && (ts->selectmode & SCE_SELECT_FACE);
UvNearestHit hit = UV_NEAREST_HIT_INIT;
@@ -2714,8 +2710,10 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_CANCELLED;
}
- extend = RNA_boolean_get(op->ptr, "extend");
- deselect = RNA_boolean_get(op->ptr, "deselect");
+ if (pick) {
+ extend = RNA_boolean_get(op->ptr, "extend");
+ deselect = RNA_boolean_get(op->ptr, "deselect");
+ }
uvedit_pixel_to_float(sima, limit, 0.05f);
uint objects_len = 0;
@@ -2784,13 +2782,14 @@ static void UV_OT_select_linked(wmOperatorType *ot)
/* api callbacks */
ot->exec = uv_select_linked_exec;
ot->poll = ED_operator_uvedit; /* requires space image */
-
- /* properties */
- RNA_def_boolean(ot->srna, "extend", 0,
- "Extend", "Extend selection rather than clearing the existing selection");
- RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect linked UV vertices rather than selecting them");
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Linked (Cursor Pick) Operator
+ * \{ */
+
static int uv_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
return uv_select_linked_internal(C, op, event, 1);
@@ -2812,7 +2811,7 @@ static void UV_OT_select_linked_pick(wmOperatorType *ot)
/* api callbacks */
ot->invoke = uv_select_linked_pick_invoke;
ot->exec = uv_select_linked_pick_exec;
- ot->poll = ED_operator_uvedit; /* requires space image */;
+ ot->poll = ED_operator_uvedit; /* requires space image */
/* properties */
RNA_def_boolean(ot->srna, "extend", 0,
@@ -2822,6 +2821,12 @@ static void UV_OT_select_linked_pick(wmOperatorType *ot)
"Location", "Mouse location in normalized coordinates, 0.0 to 1.0 is within the image bounds", -100.0f, 100.0f);
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Split Operator
+ * \{ */
+
/* 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
@@ -2912,7 +2917,7 @@ static void UV_OT_select_split(wmOperatorType *ot)
/* api callbacks */
ot->exec = uv_select_split_exec;
- ot->poll = ED_operator_uvedit; /* requires space image */;
+ ot->poll = ED_operator_uvedit; /* requires space image */
}
static void uv_select_sync_flush(ToolSettings *ts, BMEditMesh *em, const short select)
@@ -3307,7 +3312,7 @@ static void UV_OT_select_box(wmOperatorType *ot)
ot->invoke = WM_gesture_box_invoke;
ot->exec = uv_box_select_exec;
ot->modal = WM_gesture_box_modal;
- ot->poll = ED_operator_uvedit_space_image; /* requires space image */;
+ ot->poll = ED_operator_uvedit_space_image; /* requires space image */
ot->cancel = WM_gesture_box_cancel;
/* flags */
@@ -3455,7 +3460,7 @@ static void UV_OT_select_circle(wmOperatorType *ot)
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
ot->exec = uv_circle_select_exec;
- ot->poll = ED_operator_uvedit_space_image; /* requires space image */;
+ ot->poll = ED_operator_uvedit_space_image; /* requires space image */
ot->cancel = WM_gesture_circle_cancel;
/* flags */
@@ -3692,7 +3697,7 @@ static void UV_OT_snap_cursor(wmOperatorType *ot)
/* api callbacks */
ot->exec = uv_snap_cursor_exec;
- ot->poll = ED_operator_uvedit_space_image; /* requires space image */;
+ ot->poll = ED_operator_uvedit_space_image; /* requires space image */
/* properties */
RNA_def_enum(ot->srna, "target", target_items, 0, "Target", "Target to snap the selected UVs to");
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 1587bc3d9eb..e7fc162ee1c 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -242,7 +242,7 @@ unsigned int BlenderStrokeRenderer::get_stroke_mesh_id(void) const
return mesh_id;
}
-Material* BlenderStrokeRenderer::GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user)
+Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user)
{
Material *ma = BKE_material_add(bmain, "stroke_shader");
bNodeTree *ntree;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
index 1d488f5accf..686e7272cc8 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.h
@@ -67,7 +67,7 @@ public:
Render *RenderScene(Render *re, bool render);
- static Material* GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user);
+ static Material *GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user);
protected:
Main *freestyle_bmain;
@@ -87,8 +87,9 @@ protected:
float get_stroke_vertex_z(void) const;
unsigned int get_stroke_mesh_id(void) const;
bool test_triangle_visibility(StrokeVertexRep *svRep[3]) const;
- void test_strip_visibility(Strip::vertex_container& strip_vertices,
- int *visible_faces, int *visible_segments) const;
+ void test_strip_visibility(
+ Strip::vertex_container& strip_vertices,
+ int *visible_faces, int *visible_segments) const;
vector<StrokeRep *> _strokeReps;
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
index d5a2cad86dc..b875be7200e 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
@@ -176,7 +176,7 @@ public:
return _Normals;
}
- virtual const FrsMaterial*const* frs_materials() const
+ virtual const FrsMaterial * const *frs_materials() const
{
return _FrsMaterials;
}
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
index 7298c3d9355..9a593c93b08 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
@@ -376,8 +376,8 @@ void Strip::cleanUpSingularities (const vector<StrokeVertex*>& iStrokeVertices)
if (iStrokeVertices.size() < 2)
return;
int i = 0, j;
- vector<StrokeVertex *>::const_iterator v, vend, v2, vPrev;
- StrokeVertex *sv, *sv2; //soc unused - *svPrev;
+ vector<StrokeVertex *>::const_iterator v, vend, v2;
+ StrokeVertex *sv, *sv2;
bool singu1 = false, singu2 = false;
int timeSinceSingu1 = 0, timeSinceSingu2 = 0;
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h
index b282aca690c..3c14d9fa75a 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.h
@@ -144,7 +144,7 @@ protected:
public:
Strip(const std::vector<StrokeVertex*>& iStrokeVertices, bool hasTex = false,
- bool tipBegin = false, bool tipEnd = false, float texStep = 1.0);
+ bool tipBegin = false, bool tipEnd = false, float texStep = 1.0);
Strip(const Strip& iBrother);
virtual ~Strip();
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
index f3448fe2c1c..f2e387c0374 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
@@ -119,9 +119,11 @@ static void bakeModifier(
Main *bmain, Depsgraph *depsgraph,
GpencilModifierData *md, Object *ob)
{
- ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
- bGPdata *gpd = ob->data;
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+ ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)md;
+ GpencilModifierData *md_eval = BKE_gpencil_modifiers_findByName(object_eval, md->name);
+ bGPdata *gpd = (bGPdata *)ob->data;
int oldframe = (int)DEG_get_ctime(depsgraph);
if (mmd->object == NULL)
@@ -137,7 +139,7 @@ static void bakeModifier(
/* compute armature effects on this frame */
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
- deformStroke(md, depsgraph, ob, gpl, gps);
+ deformStroke(md_eval, depsgraph, object_eval, gpl, gps);
}
}
}
@@ -178,7 +180,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Armature = {
/* structName */ "ArmatureGpencilModifierData",
/* structSize */ sizeof(ArmatureGpencilModifierData),
/* type */ eGpencilModifierTypeType_Gpencil,
- /* flags */ 0,
+ /* flags */ eGpencilModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
index 361b8de9288..7dbb79b1ae9 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
@@ -135,8 +135,7 @@ static void BKE_gpencil_instance_modifier_instance_tfm(
add_v3_v3(mat_offset[3], mmd->offset);
invert_m4_m4(obinv, ob->obmat);
- mul_m4_series(r_offset, mat_offset,
- obinv, mmd->object->obmat);
+ mul_m4_series(r_offset, mat_offset, obinv, mmd->object->obmat);
copy_m4_m4(mat_offset, r_offset);
/* clear r_mat locations to avoid double transform */
@@ -321,7 +320,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Array = {
/* structName */ "ArrayGpencilModifierData",
/* structSize */ sizeof(ArrayGpencilModifierData),
/* type */ eGpencilModifierTypeType_Gpencil,
- /* flags */ 0,
+ /* flags */ eGpencilModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index b1e9a45bfa1..d057c7083bd 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -81,7 +81,7 @@ static bool dependsOnTime(GpencilModifierData *UNUSED(md))
* - Stroke points are generally equally spaced. This implies that we can just add/remove points,
* without worrying about distances between them / adding extra interpolated points between
* an visible point and one about to be added/removed (or any similar tapering effects).
-
+ *
* - All strokes present are fully visible (i.e. we don't have to ignore any)
*/
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
index 5d63c238f60..85fabd865ca 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
@@ -329,7 +329,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Hook = {
/* structName */ "HookGpencilModifierData",
/* structSize */ sizeof(HookGpencilModifierData),
/* type */ eGpencilModifierTypeType_Gpencil,
- /* flags */ 0,
+ /* flags */ eGpencilModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
index 9bfbe20343e..97ac6fa56cd 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
@@ -101,11 +101,16 @@ static void deformStroke(
const int def_nr = defgroup_name_index(ob, mmd->vgname);
const float unit_v3[3] = { 1.0f, 1.0f, 1.0f };
- /* Random generator, only init once. */
- if (mmd->rng == NULL) {
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+ GpencilModifierData *md_eval = BKE_gpencil_modifiers_findByName(object_eval, md->name);
+ NoiseGpencilModifierData *mmd_eval = (NoiseGpencilModifierData *)md_eval;
+
+ /* Random generator, only init once. (it uses eval to get same value in render) */
+ if (mmd_eval->rng == NULL) {
uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX);
rng_seed ^= POINTER_AS_UINT(mmd);
- mmd->rng = BLI_rng_new(rng_seed);
+ mmd_eval->rng = BLI_rng_new(rng_seed);
+ mmd->rng = mmd_eval->rng;
}
if (!is_stroke_affected_by_modifier(
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 95eb59a57ae..3d013eb8af4 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -39,7 +39,7 @@ typedef enum {
GPU_BATCH_READY_TO_DRAW
} GPUBatchPhase;
-#define GPU_BATCH_VBO_MAX_LEN 3
+#define GPU_BATCH_VBO_MAX_LEN 4
#define GPU_BATCH_VAO_STATIC_LEN 3
#define GPU_BATCH_VAO_DYN_ALLOC_COUNT 16
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index f9ea9a35084..ce9a20bcf7c 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -99,11 +99,6 @@ void GPU_create_smoke_velocity(struct SmokeModifierData *smd);
void GPU_free_unused_buffers(struct Main *bmain);
/* utilities */
-void GPU_select_index_set(int index);
-void GPU_select_index_get(int index, int *r_col);
-int GPU_select_to_index(unsigned int col);
-void GPU_select_to_index_array(unsigned int *col, const unsigned int size);
-
typedef enum eGPUAttrMask {
GPU_DEPTH_BUFFER_BIT = (1 << 0),
GPU_ENABLE_BIT = (1 << 1),
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index 3154119592d..b656bb74d4b 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -42,7 +42,6 @@ int GPU_max_cube_map_size(void);
int GPU_max_ubo_binds(void);
int GPU_max_ubo_size(void);
float GPU_max_line_width(void);
-int GPU_color_depth(void);
void GPU_get_dfdy_factors(float fac[2]);
bool GPU_mip_render_workaround(void);
bool GPU_depth_blitting_workaround(void);
diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h
index b635f9489d0..e822c33ab4a 100644
--- a/source/blender/gpu/GPU_framebuffer.h
+++ b/source/blender/gpu/GPU_framebuffer.h
@@ -84,22 +84,24 @@ void GPU_framebuffer_texture_detach_slot(
GPUFrameBuffer *fb, struct GPUTexture *tex, int type);
/**
- * How to use GPU_framebuffer_ensure_config().
+ * How to use #GPU_framebuffer_ensure_config().
*
- * Example :
+ * Example:
+ * \code{.c}
* GPU_framebuffer_ensure_config(&fb, {
* GPU_ATTACHMENT_TEXTURE(depth), // must be depth buffer
* GPU_ATTACHMENT_TEXTURE(tex1),
* GPU_ATTACHMENT_TEXTURE_CUBEFACE(tex2, 0),
* GPU_ATTACHMENT_TEXTURE_LAYER_MIP(tex2, 0, 0)
* })
+ * \encode
*
- * Note : Unspecified attachements (i.e: those beyond the last
- * GPU_ATTACHMENT_* in GPU_framebuffer_ensure_config list)
- * are left unchanged.
- * Note : Make sure that the dimensions of your textures matches
- * otherwise you will have an invalid framebuffer error.
- **/
+ * \note Unspecified attachements (i.e: those beyond the last
+ * GPU_ATTACHMENT_* in GPU_framebuffer_ensure_config list) are left unchanged.
+ *
+ * \note Make sure that the dimensions of your textures matches
+ * otherwise you will have an invalid framebuffer error.
+ */
#define GPU_framebuffer_ensure_config(_fb, ...) do { \
if (*(_fb) == NULL) { \
*(_fb) = GPU_framebuffer_create(); \
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index fac8270cd58..6d8319fbdd3 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -107,6 +107,7 @@ typedef enum eGPUBuiltin {
GPU_VOLUME_TEMPERATURE = (1 << 18),
GPU_BARYCENTRIC_TEXCO = (1 << 19),
GPU_BARYCENTRIC_DIST = (1 << 20),
+ GPU_INVERSE_NORMAL_MATRIX = (1 << 21),
} eGPUBuiltin;
typedef enum eGPUMatFlag {
diff --git a/source/blender/gpu/GPU_select.h b/source/blender/gpu/GPU_select.h
index e1396b49c15..b9dbeeccf30 100644
--- a/source/blender/gpu/GPU_select.h
+++ b/source/blender/gpu/GPU_select.h
@@ -52,5 +52,6 @@ void GPU_select_cache_end(void);
/* utilities */
const uint *GPU_select_buffer_near(const uint *buffer, int hits);
+void GPU_select_buffer_stride_realign(const struct rcti *src, const struct rcti *dst, uint *r_buf);
#endif
diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h
index 34b607bcb5d..ee2091c7cec 100644
--- a/source/blender/gpu/GPU_shader_interface.h
+++ b/source/blender/gpu/GPU_shader_interface.h
@@ -45,6 +45,7 @@ typedef enum {
GPU_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */
GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */
+ GPU_UNIFORM_NORMAL_INV, /* mat3 NormalMatrixInverse */
GPU_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */
GPU_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */
GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index c43a1711528..eb273608a3f 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -45,7 +45,6 @@ void GPU_depth_range(float near, float far);
void GPU_depth_test(bool enable);
bool GPU_depth_test_enabled(void);
void GPU_line_smooth(bool enable);
-void GPU_line_stipple(bool enable);
void GPU_line_width(float width);
void GPU_point_size(float size);
void GPU_polygon_smooth(bool enable);
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 5732bad81a9..bd7ac508163 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -34,6 +34,7 @@ struct GPUVertBuf;
struct Image;
struct ImageUser;
struct PreviewImage;
+struct rcti;
struct GPUFrameBuffer;
typedef struct GPUTexture GPUTexture;
@@ -153,17 +154,17 @@ GPUTexture *GPU_texture_create_nD(
eGPUTextureFormat tex_format, eGPUDataFormat gpu_data_format, int samples,
const bool can_rescale, char err_out[256]);
-GPUTexture *GPU_texture_create_1D(
+GPUTexture *GPU_texture_create_1d(
int w, eGPUTextureFormat data_type, const float *pixels, char err_out[256]);
-GPUTexture *GPU_texture_create_1D_array(
+GPUTexture *GPU_texture_create_1d_array(
int w, int h, eGPUTextureFormat data_type, const float *pixels, char err_out[256]);
-GPUTexture *GPU_texture_create_2D(
+GPUTexture *GPU_texture_create_2d(
int w, int h, eGPUTextureFormat data_type, const float *pixels, char err_out[256]);
-GPUTexture *GPU_texture_create_2D_multisample(
+GPUTexture *GPU_texture_create_2d_multisample(
int w, int h, eGPUTextureFormat data_type, const float *pixels, int samples, char err_out[256]);
-GPUTexture *GPU_texture_create_2D_array(
+GPUTexture *GPU_texture_create_2d_array(
int w, int h, int d, eGPUTextureFormat data_type, const float *pixels, char err_out[256]);
-GPUTexture *GPU_texture_create_3D(
+GPUTexture *GPU_texture_create_3d(
int w, int h, int d, eGPUTextureFormat data_type, const float *pixels, char err_out[256]);
GPUTexture *GPU_texture_create_cube(
int w, eGPUTextureFormat data_type, const float *pixels, char err_out[256]);
@@ -185,6 +186,9 @@ void GPU_texture_update_sub(
int offset_x, int offset_y, int offset_z, int width, int height, int depth);
void *GPU_texture_read(GPUTexture *tex, eGPUDataFormat gpu_data_format, int miplvl);
+void GPU_texture_read_rect(
+ GPUTexture *tex, eGPUDataFormat gpu_data_format,
+ const struct rcti *rect, void *r_buf);
void GPU_invalid_tex_init(void);
void GPU_invalid_tex_bind(int mode);
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h
index 64d06a0219c..63ff430033b 100644
--- a/source/blender/gpu/GPU_vertex_format.h
+++ b/source/blender/gpu/GPU_vertex_format.h
@@ -29,7 +29,7 @@
#include "GPU_common.h"
#define GPU_VERT_ATTR_MAX_LEN 16
-#define GPU_VERT_ATTR_MAX_NAMES 3
+#define GPU_VERT_ATTR_MAX_NAMES 4
#define GPU_VERT_ATTR_NAME_AVERAGE_LEN 11
#define GPU_VERT_ATTR_NAMES_BUF_LEN ((GPU_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GPU_VERT_ATTR_MAX_LEN)
@@ -97,7 +97,7 @@ int GPU_vertformat_attr_id_get(const GPUVertFormat *, const char *name);
* 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.
- **/
+ */
void GPU_vertformat_triple_load(GPUVertFormat *format);
/* format conversion */
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 63d875b07fd..355ca083274 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -64,7 +64,7 @@ static char *glsl_material_library = NULL;
* Internal shader cache: This prevent the shader recompilation / stall when
* using undo/redo AND also allows for GPUPass reuse if the Shader code is the
* same for 2 different Materials. Unused GPUPasses are free by Garbage collection.
- **/
+ */
/* Only use one linklist that contains the GPUPasses grouped by hash. */
static GPUPass *pass_cache = NULL;
@@ -467,6 +467,8 @@ const char *GPU_builtin_name(eGPUBuiltin builtin)
return "unfinvviewmat";
else if (builtin == GPU_INVERSE_OBJECT_MATRIX)
return "unfinvobmat";
+ else if (builtin == GPU_INVERSE_NORMAL_MATRIX)
+ return "unfinvnormat";
else if (builtin == GPU_LOC_TO_VIEW_MATRIX)
return "unflocaltoviewmat";
else if (builtin == GPU_INVERSE_LOC_TO_VIEW_MATRIX)
@@ -719,6 +721,8 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
BLI_dynstr_append(ds, "objmat");
else if (input->builtin == GPU_INVERSE_OBJECT_MATRIX)
BLI_dynstr_append(ds, "objinv");
+ else if (input->builtin == GPU_INVERSE_NORMAL_MATRIX)
+ BLI_dynstr_append(ds, "norinv");
else if (input->builtin == GPU_VIEW_POSITION)
BLI_dynstr_append(ds, "viewposition");
else if (input->builtin == GPU_VIEW_NORMAL)
@@ -795,6 +799,8 @@ static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUO
BLI_dynstr_append(ds, "\t#define objmat ModelMatrix\n");
if (builtins & GPU_INVERSE_OBJECT_MATRIX)
BLI_dynstr_append(ds, "\t#define objinv ModelMatrixInverse\n");
+ if (builtins & GPU_INVERSE_NORMAL_MATRIX)
+ BLI_dynstr_append(ds, "\t#define norinv NormalMatrixInverse\n");
if (builtins & GPU_INVERSE_VIEW_MATRIX)
BLI_dynstr_append(ds, "\t#define viewinv ViewMatrixInverse\n");
if (builtins & GPU_LOC_TO_VIEW_MATRIX)
@@ -872,8 +878,9 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
/* XXX FIXME : see notes in mesh_render_data_create() */
/* NOTE : Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.c */
if (input->attr_type == CD_ORCO) {
- /* orco is computed from local positions, see below */
- BLI_dynstr_appendf(ds, "uniform vec3 OrcoTexCoFactors[2];\n");
+ /* OPTI : orco is computed from local positions, but only if no modifier is present. */
+ BLI_dynstr_append(ds, "uniform vec3 OrcoTexCoFactors[2];\n");
+ BLI_dynstr_append(ds, "DEFINE_ATTR(vec4, orco);\n");
}
else if (input->attr_name[0] == '\0') {
BLI_dynstr_appendf(ds, "DEFINE_ATTR(%s, %s);\n", GPU_DATATYPE_STR[input->type], attr_prefix_get(input->attr_type));
@@ -910,7 +917,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
}
if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_appendf(ds, "out vec3 barycentricPosg;\n");
+ BLI_dynstr_append(ds, "out vec3 barycentricPosg;\n");
}
@@ -949,7 +956,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
/* To match cycles without breaking into individual segment we encode if we need to invert
* the first component into the second component. We invert if the barycentricTexCo.y
* is NOT 0.0 or 1.0. */
- BLI_dynstr_appendf(
+ BLI_dynstr_append(
ds, "\tint _base_id = hair_get_base_id();\n");
BLI_dynstr_appendf(
ds, "\tbarycentricTexCo%s.x = float((_base_id %% 2) == 1);\n",
@@ -960,7 +967,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
}
if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_appendf(ds, "\tbarycentricPosg = position;\n");
+ BLI_dynstr_append(ds, "\tbarycentricPosg = position;\n");
}
for (node = nodes->first; node; node = node->next) {
@@ -976,6 +983,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
BLI_dynstr_appendf(
ds, "\tvar%d%s = OrcoTexCoFactors[0] + (ModelMatrixInverse * vec4(hair_get_strand_pos(), 1.0)).xyz * OrcoTexCoFactors[1];\n",
input->attr_id, use_geom ? "g" : "");
+ /* TODO: fix ORCO with modifiers. */
}
else {
BLI_dynstr_appendf(
@@ -993,7 +1001,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
* geometry shader is needed. */
if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_appendf(ds, "\tbarycentricPosg = (ModelMatrix * vec4(position, 1.0)).xyz;\n");
+ BLI_dynstr_append(ds, "\tbarycentricPosg = (ModelMatrix * vec4(position, 1.0)).xyz;\n");
}
for (node = nodes->first; node; node = node->next) {
@@ -1001,16 +1009,27 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
if (input->source == GPU_SOURCE_ATTR && input->attr_first) {
if (input->attr_type == CD_TANGENT) { /* silly exception */
BLI_dynstr_appendf(
- ds, "\tvar%d%s.xyz = normalize(NormalMatrix * att%d.xyz);\n",
+ ds, "\tvar%d%s.xyz = NormalMatrix * att%d.xyz;\n",
input->attr_id, use_geom ? "g" : "", input->attr_id);
BLI_dynstr_appendf(
ds, "\tvar%d%s.w = att%d.w;\n",
input->attr_id, use_geom ? "g" : "", input->attr_id);
+ /* Normalize only if vector is not null. */
+ BLI_dynstr_appendf(
+ ds, "\tfloat lvar%d = dot(var%d%s.xyz, var%d%s.xyz);\n",
+ input->attr_id, input->attr_id, use_geom ? "g" : "", input->attr_id, use_geom ? "g" : "");
+ BLI_dynstr_appendf(
+ ds, "\tvar%d%s.xyz *= (lvar%d > 0.0) ? inversesqrt(lvar%d) : 1.0;\n",
+ input->attr_id, use_geom ? "g" : "", input->attr_id, input->attr_id);
}
else if (input->attr_type == CD_ORCO) {
BLI_dynstr_appendf(
ds, "\tvar%d%s = OrcoTexCoFactors[0] + position * OrcoTexCoFactors[1];\n",
input->attr_id, use_geom ? "g" : "");
+ /* See mesh_create_loop_orco() for explanation. */
+ BLI_dynstr_appendf(
+ ds, "\tif (orco.w == 0.0) { var%d%s = orco.xyz * 0.5 + 0.5; }\n",
+ input->attr_id, use_geom ? "g" : "");
}
else if (input->attr_type == CD_MCOL) {
BLI_dynstr_appendf(
@@ -1080,8 +1099,8 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code, cons
bool is_hair_shader = (strstr(defines, "HAIR_SHADER") != NULL);
/* Create prototype because attributes cannot be declared before layout. */
- BLI_dynstr_appendf(ds, "void pass_attr(in int vert);\n");
- BLI_dynstr_appendf(ds, "void calc_barycentric_distances(vec3 pos0, vec3 pos1, vec3 pos2);\n");
+ BLI_dynstr_append(ds, "void pass_attr(in int vert);\n");
+ BLI_dynstr_append(ds, "void calc_barycentric_distances(vec3 pos0, vec3 pos1, vec3 pos2);\n");
BLI_dynstr_append(ds, "#define USE_ATTR\n");
/* Generate varying declarations. */
@@ -1104,16 +1123,16 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code, cons
}
if (builtins & GPU_BARYCENTRIC_TEXCO) {
- BLI_dynstr_appendf(ds, "#ifdef HAIR_SHADER\n");
- BLI_dynstr_appendf(ds, "in vec2 barycentricTexCog[];\n");
- BLI_dynstr_appendf(ds, "#endif\n");
+ BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
+ BLI_dynstr_append(ds, "in vec2 barycentricTexCog[];\n");
+ BLI_dynstr_append(ds, "#endif\n");
- BLI_dynstr_appendf(ds, "out vec2 barycentricTexCo;\n");
+ BLI_dynstr_append(ds, "out vec2 barycentricTexCo;\n");
}
if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_appendf(ds, "in vec3 barycentricPosg[];\n");
- BLI_dynstr_appendf(ds, "flat out vec3 barycentricDist;\n");
+ BLI_dynstr_append(ds, "in vec3 barycentricPosg[];\n");
+ BLI_dynstr_append(ds, "flat out vec3 barycentricDist;\n");
}
if (geom_code == NULL) {
@@ -1127,37 +1146,37 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code, cons
else {
/* Force geom shader usage */
/* TODO put in external file. */
- BLI_dynstr_appendf(ds, "layout(triangles) in;\n");
- BLI_dynstr_appendf(ds, "layout(triangle_strip, max_vertices=3) out;\n");
+ BLI_dynstr_append(ds, "layout(triangles) in;\n");
+ BLI_dynstr_append(ds, "layout(triangle_strip, max_vertices=3) out;\n");
- BLI_dynstr_appendf(ds, "in vec3 worldPositiong[];\n");
- BLI_dynstr_appendf(ds, "in vec3 viewPositiong[];\n");
- BLI_dynstr_appendf(ds, "in vec3 worldNormalg[];\n");
- BLI_dynstr_appendf(ds, "in vec3 viewNormalg[];\n");
+ BLI_dynstr_append(ds, "in vec3 worldPositiong[];\n");
+ BLI_dynstr_append(ds, "in vec3 viewPositiong[];\n");
+ BLI_dynstr_append(ds, "in vec3 worldNormalg[];\n");
+ BLI_dynstr_append(ds, "in vec3 viewNormalg[];\n");
- BLI_dynstr_appendf(ds, "out vec3 worldPosition;\n");
- BLI_dynstr_appendf(ds, "out vec3 viewPosition;\n");
- BLI_dynstr_appendf(ds, "out vec3 worldNormal;\n");
- BLI_dynstr_appendf(ds, "out vec3 viewNormal;\n");
+ BLI_dynstr_append(ds, "out vec3 worldPosition;\n");
+ BLI_dynstr_append(ds, "out vec3 viewPosition;\n");
+ BLI_dynstr_append(ds, "out vec3 worldNormal;\n");
+ BLI_dynstr_append(ds, "out vec3 viewNormal;\n");
- BLI_dynstr_appendf(ds, "void main(){\n");
+ BLI_dynstr_append(ds, "void main(){\n");
if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_appendf(ds, "\tcalc_barycentric_distances(barycentricPosg[0], barycentricPosg[1], barycentricPosg[2]);\n");
+ BLI_dynstr_append(ds, "\tcalc_barycentric_distances(barycentricPosg[0], barycentricPosg[1], barycentricPosg[2]);\n");
}
- BLI_dynstr_appendf(ds, "\tgl_Position = gl_in[0].gl_Position;\n");
- BLI_dynstr_appendf(ds, "\tpass_attr(0);\n");
- BLI_dynstr_appendf(ds, "\tEmitVertex();\n");
+ BLI_dynstr_append(ds, "\tgl_Position = gl_in[0].gl_Position;\n");
+ BLI_dynstr_append(ds, "\tpass_attr(0);\n");
+ BLI_dynstr_append(ds, "\tEmitVertex();\n");
- BLI_dynstr_appendf(ds, "\tgl_Position = gl_in[1].gl_Position;\n");
- BLI_dynstr_appendf(ds, "\tpass_attr(1);\n");
- BLI_dynstr_appendf(ds, "\tEmitVertex();\n");
+ BLI_dynstr_append(ds, "\tgl_Position = gl_in[1].gl_Position;\n");
+ BLI_dynstr_append(ds, "\tpass_attr(1);\n");
+ BLI_dynstr_append(ds, "\tEmitVertex();\n");
- BLI_dynstr_appendf(ds, "\tgl_Position = gl_in[2].gl_Position;\n");
- BLI_dynstr_appendf(ds, "\tpass_attr(2);\n");
- BLI_dynstr_appendf(ds, "\tEmitVertex();\n");
- BLI_dynstr_appendf(ds, "};\n");
+ BLI_dynstr_append(ds, "\tgl_Position = gl_in[2].gl_Position;\n");
+ BLI_dynstr_append(ds, "\tpass_attr(2);\n");
+ BLI_dynstr_append(ds, "\tEmitVertex();\n");
+ BLI_dynstr_append(ds, "};\n");
}
}
else {
@@ -1165,41 +1184,41 @@ static char *code_generate_geometry(ListBase *nodes, const char *geom_code, cons
}
if (builtins & GPU_BARYCENTRIC_DIST) {
- BLI_dynstr_appendf(ds, "void calc_barycentric_distances(vec3 pos0, vec3 pos1, vec3 pos2) {\n");
- BLI_dynstr_appendf(ds, "\tvec3 edge21 = pos2 - pos1;\n");
- BLI_dynstr_appendf(ds, "\tvec3 edge10 = pos1 - pos0;\n");
- BLI_dynstr_appendf(ds, "\tvec3 edge02 = pos0 - pos2;\n");
- BLI_dynstr_appendf(ds, "\tvec3 d21 = normalize(edge21);\n");
- BLI_dynstr_appendf(ds, "\tvec3 d10 = normalize(edge10);\n");
- BLI_dynstr_appendf(ds, "\tvec3 d02 = normalize(edge02);\n");
-
- BLI_dynstr_appendf(ds, "\tfloat d = dot(d21, edge02);\n");
- BLI_dynstr_appendf(ds, "\tbarycentricDist.x = sqrt(dot(edge02, edge02) - d * d);\n");
- BLI_dynstr_appendf(ds, "\td = dot(d02, edge10);\n");
- BLI_dynstr_appendf(ds, "\tbarycentricDist.y = sqrt(dot(edge10, edge10) - d * d);\n");
- BLI_dynstr_appendf(ds, "\td = dot(d10, edge21);\n");
- BLI_dynstr_appendf(ds, "\tbarycentricDist.z = sqrt(dot(edge21, edge21) - d * d);\n");
+ BLI_dynstr_append(ds, "void calc_barycentric_distances(vec3 pos0, vec3 pos1, vec3 pos2) {\n");
+ BLI_dynstr_append(ds, "\tvec3 edge21 = pos2 - pos1;\n");
+ BLI_dynstr_append(ds, "\tvec3 edge10 = pos1 - pos0;\n");
+ BLI_dynstr_append(ds, "\tvec3 edge02 = pos0 - pos2;\n");
+ BLI_dynstr_append(ds, "\tvec3 d21 = normalize(edge21);\n");
+ BLI_dynstr_append(ds, "\tvec3 d10 = normalize(edge10);\n");
+ BLI_dynstr_append(ds, "\tvec3 d02 = normalize(edge02);\n");
+
+ BLI_dynstr_append(ds, "\tfloat d = dot(d21, edge02);\n");
+ BLI_dynstr_append(ds, "\tbarycentricDist.x = sqrt(dot(edge02, edge02) - d * d);\n");
+ BLI_dynstr_append(ds, "\td = dot(d02, edge10);\n");
+ BLI_dynstr_append(ds, "\tbarycentricDist.y = sqrt(dot(edge10, edge10) - d * d);\n");
+ BLI_dynstr_append(ds, "\td = dot(d10, edge21);\n");
+ BLI_dynstr_append(ds, "\tbarycentricDist.z = sqrt(dot(edge21, edge21) - d * d);\n");
BLI_dynstr_append(ds, "}\n");
}
/* Generate varying assignments. */
- BLI_dynstr_appendf(ds, "void pass_attr(in int vert) {\n");
+ BLI_dynstr_append(ds, "void pass_attr(in int vert) {\n");
/* XXX HACK: Eevee specific. */
if (geom_code == NULL) {
- BLI_dynstr_appendf(ds, "\tworldPosition = worldPositiong[vert];\n");
- BLI_dynstr_appendf(ds, "\tviewPosition = viewPositiong[vert];\n");
- BLI_dynstr_appendf(ds, "\tworldNormal = worldNormalg[vert];\n");
- BLI_dynstr_appendf(ds, "\tviewNormal = viewNormalg[vert];\n");
+ BLI_dynstr_append(ds, "\tworldPosition = worldPositiong[vert];\n");
+ BLI_dynstr_append(ds, "\tviewPosition = viewPositiong[vert];\n");
+ BLI_dynstr_append(ds, "\tworldNormal = worldNormalg[vert];\n");
+ BLI_dynstr_append(ds, "\tviewNormal = viewNormalg[vert];\n");
}
if (builtins & GPU_BARYCENTRIC_TEXCO) {
- BLI_dynstr_appendf(ds, "#ifdef HAIR_SHADER\n");
- BLI_dynstr_appendf(ds, "\tbarycentricTexCo = barycentricTexCog[vert];\n");
- BLI_dynstr_appendf(ds, "#else\n");
- BLI_dynstr_appendf(ds, "\tbarycentricTexCo.x = float((vert %% 3) == 0);\n");
- BLI_dynstr_appendf(ds, "\tbarycentricTexCo.y = float((vert %% 3) == 1);\n");
- BLI_dynstr_appendf(ds, "#endif\n");
+ BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
+ BLI_dynstr_append(ds, "\tbarycentricTexCo = barycentricTexCog[vert];\n");
+ BLI_dynstr_append(ds, "#else\n");
+ BLI_dynstr_append(ds, "\tbarycentricTexCo.x = float((vert % 3) == 0);\n");
+ BLI_dynstr_append(ds, "\tbarycentricTexCo.y = float((vert % 3) == 1);\n");
+ BLI_dynstr_append(ds, "#endif\n");
}
for (node = nodes->first; node; node = node->next) {
@@ -1254,8 +1273,6 @@ void GPU_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListB
if (!shader)
return;
- GPU_shader_bind(shader);
-
for (node = nodes->first; node; node = node->next) {
int z = 0;
for (input = node->inputs.first; input; input = next, z++) {
@@ -1284,8 +1301,6 @@ void GPU_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListB
}
}
}
-
- GPU_shader_unbind();
}
/* Node Link Functions */
@@ -1398,6 +1413,8 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
static const char *gpu_uniform_set_function_from_type(eNodeSocketDatatype type)
{
switch (type) {
+ /* For now INT is supported as float. */
+ case SOCK_INT:
case SOCK_FLOAT:
return "set_value";
case SOCK_VECTOR:
@@ -1982,6 +1999,13 @@ void GPU_pass_compile(GPUPass *pass, const char *shname)
}
pass->shader = NULL;
}
+ else if (!BLI_thread_is_main()) {
+ /* For some Intel drivers, you must use the program at least once
+ * in the rendering context that it is linked. */
+ glUseProgram(GPU_shader_get_program(pass->shader));
+ glUseProgram(0);
+ }
+
pass->compiled = true;
}
}
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 62dcbb94d1c..c9989703d5b 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -429,6 +429,28 @@ void GPU_create_gl_tex(
{
ImBuf *ibuf = NULL;
+ if (textarget == GL_TEXTURE_2D &&
+ is_over_resolution_limit(textarget, rectw, recth))
+ {
+ int tpx = rectw;
+ int tpy = recth;
+ rectw = smaller_power_of_2_limit(rectw);
+ recth = smaller_power_of_2_limit(recth);
+
+ if (use_high_bit_depth) {
+ ibuf = IMB_allocFromBuffer(NULL, frect, tpx, tpy);
+ IMB_scaleImBuf(ibuf, rectw, recth);
+
+ frect = ibuf->rect_float;
+ }
+ else {
+ ibuf = IMB_allocFromBuffer(rect, NULL, tpx, tpy);
+ IMB_scaleImBuf(ibuf, rectw, recth);
+
+ rect = ibuf->rect;
+ }
+ }
+
/* create image */
glGenTextures(1, (GLuint *)bind);
glBindTexture(textarget, *bind);
@@ -855,7 +877,7 @@ static GPUTexture *create_transfer_function(int type, const ColorBand *coba)
break;
}
- GPUTexture *tex = GPU_texture_create_1D(TFUNC_WIDTH, GPU_RGBA8, data, NULL);
+ GPUTexture *tex = GPU_texture_create_1d(TFUNC_WIDTH, GPU_RGBA8, data, NULL);
MEM_freeN(data);
@@ -1067,9 +1089,9 @@ void GPU_create_smoke_velocity(SmokeModifierData *smd)
}
if (!sds->tex_velocity_x) {
- sds->tex_velocity_x = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_x, NULL);
- sds->tex_velocity_y = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_y, NULL);
- sds->tex_velocity_z = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_z, NULL);
+ sds->tex_velocity_x = GPU_texture_create_3d(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_x, NULL);
+ sds->tex_velocity_y = GPU_texture_create_3d(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_y, NULL);
+ sds->tex_velocity_z = GPU_texture_create_3d(sds->res[0], sds->res[1], sds->res[2], GPU_R16F, vel_z, NULL);
}
}
#else // WITH_SMOKE
@@ -1275,148 +1297,6 @@ void GPU_disable_program_point_size(void)
/** \name Framebuffer color depth, for selection codes
* \{ */
-#ifdef __APPLE__
-
-/* apple seems to round colors to below and up on some configs */
-
-static uint index_to_framebuffer(int index)
-{
- uint i = index;
-
- switch (GPU_color_depth()) {
- case 12:
- i = ((i & 0xF00) << 12) + ((i & 0xF0) << 8) + ((i & 0xF) << 4);
- /* sometimes dithering subtracts! */
- i |= 0x070707;
- break;
- case 15:
- case 16:
- i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3);
- i |= 0x030303;
- break;
- case 24:
- break;
- default: /* 18 bits... */
- i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2);
- i |= 0x010101;
- break;
- }
-
- return i;
-}
-
-#else
-
-/* this is the old method as being in use for ages.... seems to work? colors are rounded to lower values */
-
-static uint index_to_framebuffer(int index)
-{
- uint i = index;
-
- switch (GPU_color_depth()) {
- case 8:
- i = ((i & 48) << 18) + ((i & 12) << 12) + ((i & 3) << 6);
- i |= 0x3F3F3F;
- break;
- case 12:
- i = ((i & 0xF00) << 12) + ((i & 0xF0) << 8) + ((i & 0xF) << 4);
- /* sometimes dithering subtracts! */
- i |= 0x0F0F0F;
- break;
- case 15:
- case 16:
- i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3);
- i |= 0x070707;
- break;
- case 24:
- break;
- default: /* 18 bits... */
- i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2);
- i |= 0x030303;
- break;
- }
-
- return i;
-}
-
-#endif
-
-
-void GPU_select_index_set(int index)
-{
- const int col = index_to_framebuffer(index);
- glColor3ub(( (col) & 0xFF),
- (((col) >> 8) & 0xFF),
- (((col) >> 16) & 0xFF));
-}
-
-void GPU_select_index_get(int index, int *r_col)
-{
- const int col = index_to_framebuffer(index);
- char *c_col = (char *)r_col;
- c_col[0] = (col & 0xFF); /* red */
- c_col[1] = ((col >> 8) & 0xFF); /* green */
- c_col[2] = ((col >> 16) & 0xFF); /* blue */
- c_col[3] = 0xFF; /* alpha */
-}
-
-
-#define INDEX_FROM_BUF_8(col) ((((col) & 0xC00000) >> 18) + (((col) & 0xC000) >> 12) + (((col) & 0xC0) >> 6))
-#define INDEX_FROM_BUF_12(col) ((((col) & 0xF00000) >> 12) + (((col) & 0xF000) >> 8) + (((col) & 0xF0) >> 4))
-#define INDEX_FROM_BUF_15_16(col) ((((col) & 0xF80000) >> 9) + (((col) & 0xF800) >> 6) + (((col) & 0xF8) >> 3))
-#define INDEX_FROM_BUF_18(col) ((((col) & 0xFC0000) >> 6) + (((col) & 0xFC00) >> 4) + (((col) & 0xFC) >> 2))
-#define INDEX_FROM_BUF_24(col) ((col) & 0xFFFFFF)
-
-int GPU_select_to_index(uint col)
-{
- if (col == 0) {
- return 0;
- }
-
- switch (GPU_color_depth()) {
- case 8: return INDEX_FROM_BUF_8(col);
- case 12: return INDEX_FROM_BUF_12(col);
- case 15:
- case 16: return INDEX_FROM_BUF_15_16(col);
- case 24: return INDEX_FROM_BUF_24(col);
- default: return INDEX_FROM_BUF_18(col);
- }
-}
-
-void GPU_select_to_index_array(uint *col, const uint size)
-{
-#define INDEX_BUF_ARRAY(INDEX_FROM_BUF_BITS) \
- for (i = size; i--; col++) { \
- if ((c = *col)) { \
- *col = INDEX_FROM_BUF_BITS(c); \
- } \
- } ((void)0)
-
- if (size > 0) {
- uint i, c;
-
- switch (GPU_color_depth()) {
- case 8:
- INDEX_BUF_ARRAY(INDEX_FROM_BUF_8);
- break;
- case 12:
- INDEX_BUF_ARRAY(INDEX_FROM_BUF_12);
- break;
- case 15:
- case 16:
- INDEX_BUF_ARRAY(INDEX_FROM_BUF_15_16);
- break;
- case 24:
- INDEX_BUF_ARRAY(INDEX_FROM_BUF_24);
- break;
- default:
- INDEX_BUF_ARRAY(INDEX_FROM_BUF_18);
- break;
- }
- }
-
-#undef INDEX_BUF_ARRAY
-}
#define STATE_STACK_DEPTH 16
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 6fb40b06177..282b9dfc388 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -67,7 +67,6 @@ static struct GPUGlobal {
GLint maxtexturesvert;
GLint maxubosize;
GLint maxubobinds;
- int colordepth;
int samples_color_texture_max;
eGPUDeviceType device;
eGPUOSType os;
@@ -252,12 +251,6 @@ void gpu_extensions_init(void)
BLI_assert(ret == GL_FRAMEBUFFER_DEFAULT);
#endif
- GLint r, g, b;
- glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &r);
- glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, &g);
- glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, &b);
- GG.colordepth = r + g + b; /* Assumes same depth for RGB. */
-
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &GG.samples_color_texture_max);
const char *vendor = (const char *)glGetString(GL_VENDOR);
@@ -402,11 +395,6 @@ void gpu_extensions_exit(void)
GPU_invalid_tex_free();
}
-int GPU_color_depth(void)
-{
- return GG.colordepth;
-}
-
bool GPU_mem_stats_supported(void)
{
return (GLEW_NVX_gpu_memory_info || GLEW_ATI_meminfo) && (G.debug & G_DEBUG_GPU_MEM);
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index 1c631a23cea..83acdf6a756 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -306,7 +306,7 @@ void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, GPUTexture *tex)
* Following GPUAttachments are color buffers.
* Setting GPUAttachment.mip to -1 will leave the texture in this slot.
* Setting GPUAttachment.tex to NULL will detach the texture in this slot.
- **/
+ */
void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len)
{
if (config[0].tex) {
@@ -414,7 +414,7 @@ static void gpu_framebuffer_update_attachments(GPUFrameBuffer *fb)
* Hack to solve the problem of some bugged AMD GPUs (see `GPU_unused_fb_slot_workaround`).
* If there is an empty color slot between the color slots,
* all textures after this slot are apparently skipped/discarded.
- **/
+ */
static void gpu_framebuffer_update_attachments_and_fill_empty_slots(GPUFrameBuffer *fb)
{
GLenum gl_attachments[GPU_FB_MAX_COLOR_ATTACHMENT];
@@ -702,7 +702,7 @@ void GPU_framebuffer_blit(
/**
* 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.
- **/
+ */
void GPU_framebuffer_recursive_downsample(
GPUFrameBuffer *fb, int max_lvl,
void (*callback)(void *userData, int level), void *userData)
@@ -791,12 +791,12 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
height = max_ii(1, height);
width = max_ii(1, width);
- ofs->color = GPU_texture_create_2D_multisample(
+ ofs->color = GPU_texture_create_2d_multisample(
width, height,
(high_bitdepth) ? GPU_RGBA16F : GPU_RGBA8, NULL, samples, err_out);
if (depth) {
- ofs->depth = GPU_texture_create_2D_multisample(width, height, GPU_DEPTH24_STENCIL8, NULL, samples, err_out);
+ ofs->depth = GPU_texture_create_2d_multisample(width, height, GPU_DEPTH24_STENCIL8, NULL, samples, err_out);
}
if ((depth && !ofs->depth) || !ofs->color) {
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 302b3b4ef1c..af8fcf6164e 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -165,7 +165,7 @@ static void gpu_material_ramp_texture_build(GPUMaterial *mat)
GPUColorBandBuilder *builder = mat->coba_builder;
- mat->coba_tex = GPU_texture_create_1D_array(CM_TABLE + 1, builder->current_layer, GPU_RGBA16F,
+ mat->coba_tex = GPU_texture_create_1d_array(CM_TABLE + 1, builder->current_layer, GPU_RGBA16F,
(float *)builder->pixels, NULL);
MEM_freeN(builder);
@@ -539,7 +539,7 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int
GPU_texture_free(material->sss_tex_profile);
}
- material->sss_tex_profile = GPU_texture_create_1D(64, GPU_RGBA16F, translucence_profile, NULL);
+ material->sss_tex_profile = GPU_texture_create_1d(64, GPU_RGBA16F, translucence_profile, NULL);
MEM_freeN(translucence_profile);
diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c
index b5bee35350e..9f0a5851390 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.c
@@ -451,41 +451,62 @@ void GPU_matrix_project(const float world[3], const float model[4][4], const flo
win[2] = (v[2] + 1) * 0.5f;
}
-bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3])
+/**
+ * The same result could be obtained as follows:
+ *
+ * \code{.c}
+ * float projinv[4][4];
+ * invert_m4_m4(projinv, projmat);
+ * co[0] = 2 * co[0] - 1;
+ * co[1] = 2 * co[1] - 1;
+ * co[2] = 2 * co[2] - 1;
+ * mul_project_m4_v3(projinv, co);
+ * \endcode
+ *
+ * But that solution loses much precision.
+ * Therefore, get the same result without inverting the matrix.
+ */
+static void gpu_mul_invert_projmat_m4_unmapped_v3(const float projmat[4][4], float co[3])
{
- float pm[4][4];
- float in[4];
- float out[4];
+ float left, right, bottom, top, near, far;
+ bool is_persp = projmat[3][3] == 0.0f;
+
+ projmat_dimensions(
+ projmat, &left, &right, &bottom, &top, &near, &far);
- mul_m4_m4m4(pm, proj, model);
+ co[0] = left + co[0] * (right - left);
+ co[1] = bottom + co[1] * (top - bottom);
- if (!invert_m4(pm)) {
+ if (is_persp) {
+ co[2] = far * near / (far + co[2] * (near - far));
+ co[0] *= co[2];
+ co[1] *= co[2];
+ }
+ else {
+ co[2] = near + co[2] * (far - near);
+ }
+ co[2] *= -1;
+}
+
+bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3])
+{
+ float in[3];
+ float viewinv[4][4];
+
+ if (!invert_m4_m4(viewinv, model)) {
zero_v3(world);
return false;
}
- in[0] = win[0];
- in[1] = win[1];
- in[2] = win[2];
- in[3] = 1;
+ copy_v3_v3(in, win);
/* Map x and y from window coordinates */
in[0] = (in[0] - view[0]) / view[2];
in[1] = (in[1] - view[1]) / view[3];
- /* Map to range -1 to +1 */
- in[0] = 2 * in[0] - 1;
- in[1] = 2 * in[1] - 1;
- in[2] = 2 * in[2] - 1;
-
- mul_v4_m4v3(out, pm, in);
-
- if (out[3] == 0.0f) {
- copy_v3_v3(world, out);
- return false;
- }
+ gpu_mul_invert_projmat_m4_unmapped_v3(proj, in);
+ mul_v3_m4v3(world, viewinv, in);
- mul_v3_v3fl(world, out, 1.0f / out[3]);
return true;
}
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c
index adc5f5a9864..875bcdcc674 100644
--- a/source/blender/gpu/intern/gpu_select.c
+++ b/source/blender/gpu/intern/gpu_select.c
@@ -23,6 +23,7 @@
* Interface for accessing gpu-related methods for selection. The semantics are
* similar to glRenderMode(GL_SELECT) from older OpenGL versions.
*/
+#include <string.h>
#include <stdlib.h>
#include "GPU_select.h"
@@ -31,6 +32,8 @@
#include "MEM_guardedalloc.h"
+#include "BLI_rect.h"
+
#include "DNA_userdef_types.h"
#include "BLI_utildefines.h"
@@ -211,3 +214,38 @@ const uint *GPU_select_buffer_near(const uint *buffer, int hits)
}
return buffer_near;
}
+
+/* Part of the solution copied from `rect_subregion_stride_calc`. */
+void GPU_select_buffer_stride_realign(
+ const rcti *src, const rcti *dst, uint *r_buf)
+{
+ const int x = dst->xmin - src->xmin;
+ const int y = dst->ymin - src->ymin;
+
+ BLI_assert(src->xmin <= dst->xmin && src->ymin <= dst->ymin &&
+ src->xmax >= dst->xmax && src->ymax >= dst->ymax);
+ BLI_assert(x >= 0 && y >= 0);
+
+ const int src_x = BLI_rcti_size_x(src);
+ const int src_y = BLI_rcti_size_y(src);
+ const int dst_x = BLI_rcti_size_x(dst);
+ const int dst_y = BLI_rcti_size_y(dst);
+
+ int last_px_written = dst_x * dst_y - 1;
+ int last_px_id = src_x * (y + dst_y - 1) + (x + dst_x - 1);
+ const int skip = src_x - dst_x;
+
+ memset(&r_buf[last_px_id + 1], 0, (src_x * src_y - (last_px_id + 1)) * sizeof(*r_buf));
+
+ while (true) {
+ for (int i = dst_x; i--;) {
+ r_buf[last_px_id--] = r_buf[last_px_written--];
+ }
+ if (last_px_written < 0) {
+ break;
+ }
+ last_px_id -= skip;
+ memset(&r_buf[last_px_id + 1], 0, skip * sizeof(*r_buf));
+ }
+ memset(r_buf, 0, (last_px_id + 1) * sizeof(*r_buf));
+}
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index e9ca3257a8f..21807e07643 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -184,7 +184,7 @@ const struct GPUShaderConfigData GPU_shader_cfg_data[GPU_SHADER_CFG_LEN] = {
};
/* cache of built-in shaders (each is created on first use) */
-static GPUShader *builtin_shaders[GPU_SHADER_CFG_LEN][GPU_SHADER_BUILTIN_LEN] = {NULL};
+static GPUShader *builtin_shaders[GPU_SHADER_CFG_LEN][GPU_SHADER_BUILTIN_LEN] = {{NULL}};
#ifndef NDEBUG
static uint g_shaderid = 0;
@@ -271,6 +271,14 @@ static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH])
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))
+ strcat(defines, "#define OS_WIN\n");
+ 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))
+ strcat(defines, "#define OS_UNIX\n");
+
return;
}
@@ -562,7 +570,7 @@ static const char *string_join_array_maybe_alloc(const char **str_arr, bool *r_i
struct GPUShader *GPU_shader_create_from_arrays_impl(
const struct GPU_ShaderCreateFromArray_Params *params)
{
- struct { const char *str; bool is_alloc;} str_dst[4] = {0};
+ struct { const char *str; bool is_alloc;} str_dst[4] = {{0}};
const char **str_src[4] = {params->vert, params->frag, params->geom, params->defs};
for (int i = 0; i < ARRAY_SIZE(str_src); i++) {
@@ -1234,7 +1242,8 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(
GPU_SHADER_3D_FLAT_SELECT_ID,
GPU_SHADER_3D_UNIFORM_SELECT_ID) ||
ELEM(shader,
- GPU_SHADER_3D_FLAT_COLOR));
+ GPU_SHADER_3D_FLAT_COLOR,
+ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR));
const char *world_clip_lib = datatoc_gpu_shader_cfg_world_clip_lib_glsl;
const char *world_clip_def = "#define USE_WORLD_CLIP_PLANES\n";
/* In rare cases geometry shaders calculate clipping themselves. */
diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c
index 72f19b3fc6b..21e2be03eb9 100644
--- a/source/blender/gpu/intern/gpu_shader_interface.c
+++ b/source/blender/gpu/intern/gpu_shader_interface.c
@@ -61,6 +61,7 @@ static const char *BuiltinUniform_name(GPUUniformBuiltin u)
[GPU_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse",
[GPU_UNIFORM_NORMAL] = "NormalMatrix",
+ [GPU_UNIFORM_NORMAL_INV] = "NormalMatrixInverse",
[GPU_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix",
[GPU_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors",
[GPU_UNIFORM_ORCO] = "OrcoTexCoFactors",
diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c
index 98f905cd051..765bbd5e751 100644
--- a/source/blender/gpu/intern/gpu_state.c
+++ b/source/blender/gpu/intern/gpu_state.c
@@ -20,6 +20,8 @@
#include "DNA_userdef_types.h"
+#include "BKE_global.h"
+
#include "GPU_glew.h"
#include "GPU_state.h"
#include "GPU_extensions.h"
@@ -92,7 +94,7 @@ bool GPU_depth_test_enabled()
void GPU_line_smooth(bool enable)
{
- if (enable) {
+ if (enable && ((G.debug & G_DEBUG_GPU) == 0)) {
glEnable(GL_LINE_SMOOTH);
}
else {
@@ -100,16 +102,6 @@ void GPU_line_smooth(bool enable)
}
}
-void GPU_line_stipple(bool enable)
-{
- if (enable) {
- glEnable(GL_LINE_STIPPLE);
- }
- else {
- glDisable(GL_LINE_STIPPLE);
- }
-}
-
void GPU_line_width(float width)
{
float max_size = GPU_max_line_width();
@@ -126,7 +118,7 @@ void GPU_point_size(float size)
void GPU_polygon_smooth(bool enable)
{
- if (enable) {
+ if (enable && ((G.debug & G_DEBUG_GPU) == 0)) {
glEnable(GL_POLYGON_SMOOTH);
}
else {
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 61db44d786d..8aafe349be8 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -405,9 +405,9 @@ static GLenum gpu_get_gl_internalformat(eGPUTextureFormat format)
case GPU_DEPTH24_STENCIL8: return GL_DEPTH24_STENCIL8;
case GPU_DEPTH32F_STENCIL8: return GL_DEPTH32F_STENCIL8;
/* Texture only format */
- /* ** Add Format here **/
+ /* ** Add Format here */
/* Special formats texture only */
- /* ** Add Format here **/
+ /* ** Add Format here */
/* Depth Formats */
case GPU_DEPTH_COMPONENT32F: return GL_DEPTH_COMPONENT32F;
case GPU_DEPTH_COMPONENT24: return GL_DEPTH_COMPONENT24;
@@ -439,7 +439,7 @@ static GLenum gpu_get_gl_datatype(eGPUDataFormat format)
}
}
-static float *GPU_texture_3D_rescale(GPUTexture *tex, int w, int h, int d, int channels, const float *fpixels)
+static float *GPU_texture_rescale_3d(GPUTexture *tex, int w, int h, int d, int channels, const float *fpixels)
{
const uint xf = w / tex->w, yf = h / tex->h, zf = d / tex->d;
float *nfpixels = MEM_mallocN(channels * sizeof(float) * tex->w * tex->h * tex->d, "GPUTexture Rescaled 3Dtex");
@@ -575,7 +575,7 @@ static bool gpu_texture_try_alloc(
return false;
case GL_PROXY_TEXTURE_3D:
BLI_assert(data_type == GL_FLOAT);
- *rescaled_fpixels = GPU_texture_3D_rescale(tex, w, h, d, channels, fpixels);
+ *rescaled_fpixels = GPU_texture_rescale_3d(tex, w, h, d, channels, fpixels);
return (bool)*rescaled_fpixels;
}
}
@@ -645,10 +645,12 @@ GPUTexture *GPU_texture_create_nD(
tex->bindcode = GPU_tex_alloc();
if (!tex->bindcode) {
- if (err_out)
- BLI_snprintf(err_out, 256, "GPUTexture: texture create failed\n");
- else
+ if (err_out) {
+ BLI_strncpy(err_out, "GPUTexture: texture create failed\n", 256);
+ }
+ else {
fprintf(stderr, "GPUTexture: texture create failed\n");
+ }
GPU_texture_free(tex);
return NULL;
}
@@ -685,7 +687,7 @@ GPUTexture *GPU_texture_create_nD(
if (!valid) {
if (err_out) {
- BLI_snprintf(err_out, 256, "GPUTexture: texture alloc failed\n");
+ BLI_strncpy(err_out, "GPUTexture: texture alloc failed\n", 256);
}
else {
fprintf(stderr, "GPUTexture: texture alloc failed. Likely not enough Video Memory.\n");
@@ -790,10 +792,12 @@ static GPUTexture *GPU_texture_cube_create(
tex->bindcode = GPU_tex_alloc();
if (!tex->bindcode) {
- if (err_out)
- BLI_snprintf(err_out, 256, "GPUTexture: texture create failed\n");
- else
+ if (err_out) {
+ BLI_strncpy(err_out, "GPUTexture: texture create failed\n", 256);
+ }
+ else {
fprintf(stderr, "GPUTexture: texture create failed\n");
+ }
GPU_texture_free(tex);
return NULL;
}
@@ -985,7 +989,7 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap)
}
-GPUTexture *GPU_texture_create_1D(
+GPUTexture *GPU_texture_create_1d(
int w, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
{
BLI_assert(w > 0);
@@ -993,7 +997,7 @@ GPUTexture *GPU_texture_create_1D(
return GPU_texture_create_nD(w, 0, 0, 1, pixels, tex_format, data_format, 0, false, err_out);
}
-GPUTexture *GPU_texture_create_1D_array(
+GPUTexture *GPU_texture_create_1d_array(
int w, int h, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
{
BLI_assert(w > 0 && h > 0);
@@ -1001,7 +1005,7 @@ GPUTexture *GPU_texture_create_1D_array(
return GPU_texture_create_nD(w, h, 0, 1, pixels, tex_format, data_format, 0, false, err_out);
}
-GPUTexture *GPU_texture_create_2D(
+GPUTexture *GPU_texture_create_2d(
int w, int h, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
{
BLI_assert(w > 0 && h > 0);
@@ -1009,7 +1013,7 @@ GPUTexture *GPU_texture_create_2D(
return GPU_texture_create_nD(w, h, 0, 2, pixels, tex_format, data_format, 0, false, err_out);
}
-GPUTexture *GPU_texture_create_2D_multisample(
+GPUTexture *GPU_texture_create_2d_multisample(
int w, int h, eGPUTextureFormat tex_format, const float *pixels, int samples, char err_out[256])
{
BLI_assert(w > 0 && h > 0);
@@ -1017,7 +1021,7 @@ GPUTexture *GPU_texture_create_2D_multisample(
return GPU_texture_create_nD(w, h, 0, 2, pixels, tex_format, data_format, samples, false, err_out);
}
-GPUTexture *GPU_texture_create_2D_array(
+GPUTexture *GPU_texture_create_2d_array(
int w, int h, int d, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
{
BLI_assert(w > 0 && h > 0 && d > 0);
@@ -1025,7 +1029,7 @@ GPUTexture *GPU_texture_create_2D_array(
return GPU_texture_create_nD(w, h, d, 2, pixels, tex_format, data_format, 0, false, err_out);
}
-GPUTexture *GPU_texture_create_3D(
+GPUTexture *GPU_texture_create_3d(
int w, int h, int d, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
{
BLI_assert(w > 0 && h > 0 && d > 0);
@@ -1266,6 +1270,35 @@ void *GPU_texture_read(GPUTexture *tex, eGPUDataFormat gpu_data_format, int mipl
return buf;
}
+void GPU_texture_read_rect(
+ GPUTexture *tex, eGPUDataFormat gpu_data_format,
+ const rcti *rect, void *r_buf)
+{
+ gpu_validate_data_format(tex->format, gpu_data_format);
+
+ GPUFrameBuffer *cur_fb = GPU_framebuffer_active_get();
+ GPUFrameBuffer *tmp_fb = GPU_framebuffer_create();
+ GPU_framebuffer_texture_attach(tmp_fb, tex, 0, 0);
+
+ GPU_framebuffer_bind(tmp_fb);
+ glReadBuffer(GL_COLOR_ATTACHMENT0);
+
+ GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag);
+ GLenum data_type = gpu_get_gl_datatype(gpu_data_format);
+
+ glReadPixels(rect->xmin, rect->ymin,
+ BLI_rcti_size_x(rect), BLI_rcti_size_y(rect),
+ data_format, data_type, r_buf);
+
+ if (cur_fb) {
+ GPU_framebuffer_bind(cur_fb);
+ }
+ else {
+ GPU_framebuffer_restore();
+ }
+ GPU_framebuffer_free(tmp_fb);
+}
+
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *pixels)
{
GPU_texture_update_sub(tex, data_format, pixels, 0, 0, 0, tex->w, tex->h, tex->d);
@@ -1275,9 +1308,9 @@ void GPU_invalid_tex_init(void)
{
memory_usage = 0;
const float color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
- GG.invalid_tex_1D = GPU_texture_create_1D(1, GPU_RGBA8, color, NULL);
- GG.invalid_tex_2D = GPU_texture_create_2D(1, 1, GPU_RGBA8, color, NULL);
- GG.invalid_tex_3D = GPU_texture_create_3D(1, 1, 1, GPU_RGBA8, color, NULL);
+ GG.invalid_tex_1D = GPU_texture_create_1d(1, GPU_RGBA8, color, NULL);
+ GG.invalid_tex_2D = GPU_texture_create_2d(1, 1, GPU_RGBA8, color, NULL);
+ GG.invalid_tex_3D = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, color, NULL);
}
void GPU_invalid_tex_bind(int mode)
@@ -1352,13 +1385,13 @@ int GPU_texture_bound_number(GPUTexture *tex)
return tex->number;
}
-#define WARN_NOT_BOUND(_tex) do { \
+#define WARN_NOT_BOUND(_tex) { \
if (_tex->number == -1) { \
fprintf(stderr, "Warning : Trying to set parameter on a texture not bound.\n"); \
BLI_assert(0); \
return; \
} \
-} while (0);
+} ((void)0)
void GPU_texture_generate_mipmap(GPUTexture *tex)
{
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c
index fea23c1ac0f..47539724a26 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.c
@@ -84,15 +84,17 @@ GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_
ubo->bindcode = GPU_buf_alloc();
if (!ubo->bindcode) {
- if (err_out)
- BLI_snprintf(err_out, 256, "GPUUniformBuffer: UBO create failed");
+ if (err_out) {
+ BLI_strncpy(err_out, "GPUUniformBuffer: UBO create failed", 256);
+ }
GPU_uniformbuffer_free(ubo);
return NULL;
}
if (ubo->size > GPU_max_ubo_size()) {
- if (err_out)
- BLI_snprintf(err_out, 256, "GPUUniformBuffer: UBO too big");
+ if (err_out) {
+ BLI_strncpy(err_out, "GPUUniformBuffer: UBO too big", 256);
+ }
GPU_uniformbuffer_free(ubo);
return NULL;
}
@@ -123,15 +125,17 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou
ubo->buffer.bindcode = GPU_buf_alloc();
if (!ubo->buffer.bindcode) {
- if (err_out)
- BLI_snprintf(err_out, 256, "GPUUniformBuffer: UBO create failed");
+ if (err_out) {
+ BLI_strncpy(err_out, "GPUUniformBuffer: UBO create failed", 256);
+ }
GPU_uniformbuffer_free(&ubo->buffer);
return NULL;
}
if (ubo->buffer.size > GPU_max_ubo_size()) {
- if (err_out)
- BLI_snprintf(err_out, 256, "GPUUniformBuffer: UBO too big");
+ if (err_out) {
+ BLI_strncpy(err_out, "GPUUniformBuffer: UBO too big", 256);
+ }
GPU_uniformbuffer_free(&ubo->buffer);
return NULL;
}
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 7688b113547..9a39b724b6a 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -304,7 +304,7 @@ GPUTexture *GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine,
}
}
- tex = GPU_texture_create_2D(width, height, format, NULL, NULL);
+ tex = GPU_texture_create_2d(width, height, format, NULL, NULL);
GPU_texture_bind(tex, 0);
/* Doing filtering for depth does not make sense when not doing shadow mapping,
* and enabling texture filtering on integer texture make them unreadable. */
@@ -381,8 +381,8 @@ static void gpu_viewport_default_fb_create(GPUViewport *viewport)
int *size = viewport->size;
bool ok = true;
- dtxl->color = GPU_texture_create_2D(size[0], size[1], GPU_RGBA8, NULL, NULL);
- dtxl->depth = GPU_texture_create_2D(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL);
+ dtxl->color = GPU_texture_create_2d(size[0], size[1], GPU_RGBA8, NULL, NULL);
+ dtxl->depth = GPU_texture_create_2d(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL);
if (!(dtxl->depth && dtxl->color)) {
ok = false;
@@ -426,8 +426,8 @@ static void gpu_viewport_default_multisample_fb_create(GPUViewport *viewport)
int samples = viewport->samples;
bool ok = true;
- dtxl->multisample_color = GPU_texture_create_2D_multisample(size[0], size[1], GPU_RGBA8, NULL, samples, NULL);
- dtxl->multisample_depth = GPU_texture_create_2D_multisample(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, samples, NULL);
+ dtxl->multisample_color = GPU_texture_create_2d_multisample(size[0], size[1], GPU_RGBA8, NULL, samples, NULL);
+ dtxl->multisample_depth = GPU_texture_create_2d_multisample(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, samples, NULL);
if (!(dtxl->multisample_depth && dtxl->multisample_color)) {
ok = false;
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl
index 9fdf8ececc5..a64f9c375c0 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl
@@ -1,7 +1,7 @@
/**
* Simple shader that just draw multiple icons at the specified locations
* does not need any vertex input (producing less call to immBegin/End)
- **/
+ */
/* Same as ICON_DRAW_CACHE_SIZE */
#define MAX_CALLS 16
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
index 118f4e3b187..015082186b5 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
@@ -1,7 +1,7 @@
/**
* Simple shader that just draw one icon at the specified location
* does not need any vertex input (producing less call to immBegin/End)
- **/
+ */
uniform mat4 ModelViewProjectionMatrix;
uniform vec4 rect_icon;
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 8fa19f94b39..1e5a75c37b8 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
@@ -30,6 +30,10 @@ void main()
gl_Position = v1;
color_geom = color_vert[0];
distance_along_line = 0.0f;
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_set_clip_distance(gl_in[0].gl_ClipDistance);
+#endif
EmitVertex();
gl_Position = v2;
@@ -47,6 +51,10 @@ void main()
distance_along_line = distance(p1, p2);
}
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_set_clip_distance(gl_in[1].gl_ClipDistance);
+#endif
EmitVertex();
EndPrimitive();
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
index ea8d57b5eea..220adba817a 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
@@ -1,6 +1,6 @@
/**
* 2D Quadratic Bezier thick line drawing
- **/
+ */
#define MID_VERTEX 57
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 2fe08896585..791f634c6cd 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
@@ -8,6 +8,10 @@
uniform mat4 ModelViewProjectionMatrix;
+#ifdef USE_WORLD_CLIP_PLANES
+uniform mat4 ModelMatrix;
+#endif
+
uniform vec4 color;
in vec3 pos;
@@ -16,6 +20,10 @@ out vec4 color_vert;
void main()
{
- gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ vec4 pos_4d = vec4(pos, 1.0);
+ gl_Position = ModelViewProjectionMatrix * pos_4d;
color_vert = color;
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance((ModelMatrix * pos_4d).xyz);
+#endif
}
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl
index b2d186efa91..bdb26981399 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl
@@ -7,17 +7,13 @@ in vec3 pos;
uniform uint offset;
in uint color;
-flat out vec4 id;
+flat out uint id;
#endif
void main()
{
#ifndef UNIFORM_ID
- id = vec4(
- (((color + offset) ) & 0xFFu) * (1.0f / 255.0f),
- (((color + offset) >> 8u) & 0xFFu) * (1.0f / 255.0f),
- (((color + offset) >> 16u) & 0xFFu) * (1.0f / 255.0f),
- (((color + offset) >> 24u) ) * (1.0f / 255.0f));
+ id = offset + color;
#endif
vec4 pos_4d = vec4(pos, 1.0);
diff --git a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
index 3de1bd838b3..6c7e2d17e06 100644
--- a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_geom.glsl
@@ -1,6 +1,9 @@
uniform mat4 ModelViewProjectionMatrix;
uniform vec2 Viewport;
uniform int xraymode;
+uniform int caps_start;
+uniform int caps_end;
+uniform int fill_stroke;
layout(lines_adjacency) in;
layout(triangle_strip, max_vertices = 13) out;
@@ -15,6 +18,8 @@ out vec2 mTexCoord;
#define GP_XRAY_3DSPACE 1
#define GP_XRAY_BACK 2
+#define GPENCIL_FLATCAP 1
+
/* project 3d point to 2d on screen space */
vec2 toScreenSpace(vec4 vertex)
{
@@ -37,6 +42,22 @@ float getZdepth(vec4 point)
/* in front by default */
return 0.0;
}
+
+/* check equality but with a small tolerance */
+bool is_equal(vec4 p1, vec4 p2)
+{
+ float limit = 0.0001;
+ float x = abs(p1.x - p2.x);
+ float y = abs(p1.y - p2.y);
+ float z = abs(p1.z - p2.z);
+
+ if ((x < limit) && (y < limit) && (z < limit)) {
+ return true;
+ }
+
+ return false;
+}
+
void main(void)
{
float MiterLimit = 0.75;
@@ -134,10 +155,11 @@ void main(void)
}
/* generate the start endcap (alpha < 0 used as endcap flag)*/
- if (P0 == P2) {
+ float extend = (fill_stroke > 0) ? 2 : 1 ;
+ if ((caps_start != GPENCIL_FLATCAP) && is_equal(P0,P2)) {
mTexCoord = vec2(1, 0.5);
mColor = vec4(finalColor[1].rgb, finalColor[1].a * -1.0) ;
- vec2 svn1 = normalize(sp1 - sp2) * length_a * 4.0;
+ vec2 svn1 = normalize(sp1 - sp2) * length_a * 4.0 * extend;
gl_Position = vec4((sp1 + svn1) / Viewport, getZdepth(P1), 1.0);
EmitVertex();
@@ -174,7 +196,7 @@ void main(void)
EmitVertex();
/* generate the end endcap (alpha < 0 used as endcap flag)*/
- if (P1 == P3) {
+ if ((caps_end != GPENCIL_FLATCAP) && is_equal(P1,P3)) {
mTexCoord = vec2(0, 1);
mColor = vec4(finalColor[2].rgb, finalColor[2].a * -1.0) ;
gl_Position = vec4((sp2 + (length_b * 2.0) * miter_b) / Viewport, getZdepth(P2), 1.0);
@@ -187,7 +209,7 @@ void main(void)
mTexCoord = vec2(1, 0.5);
mColor = vec4(finalColor[2].rgb, finalColor[2].a * -1.0) ;
- vec2 svn2 = normalize(sp2 - sp1) * length_b * 4.0;
+ vec2 svn2 = normalize(sp2 - sp1) * length_b * 4.0 * extend;
gl_Position = vec4((sp2 + svn2) / Viewport, getZdepth(P2), 1.0);
EmitVertex();
}
diff --git a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl
index 5cbe2f60ebd..968f913d4e4 100644
--- a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl
@@ -4,7 +4,7 @@ uniform mat4 ProjectionMatrix;
uniform float pixsize; /* rv3d->pixsize */
uniform int keep_size;
uniform float objscale;
-uniform int pixfactor;
+uniform float pixfactor;
in vec3 pos;
in vec4 color;
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 422487d075d..5f54b53987e 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -2,6 +2,7 @@
uniform mat4 ModelViewMatrix;
uniform mat4 ModelViewMatrixInverse;
uniform mat3 NormalMatrix;
+uniform mat3 NormalMatrixInverse;
#ifndef USE_ATTR
uniform mat4 ModelMatrix;
@@ -187,6 +188,11 @@ void direction_transform_m4v3(vec3 vin, mat4 mat, out vec3 vout)
vout = (mat * vec4(vin, 0.0)).xyz;
}
+void mat3_mul(vec3 vin, mat3 mat, out vec3 vout)
+{
+ vout = mat * vin;
+}
+
void point_transform_m4v3(vec3 vin, mat4 mat, out vec3 vout)
{
vout = (mat * vec4(vin, 1.0)).xyz;
@@ -525,6 +531,25 @@ void curves_rgb(
outcol = mix(col, outcol, fac);
}
+void curves_rgb_opti(
+ float fac, vec4 col, sampler1DArray curvemap, float layer,
+ vec4 range, vec4 ext_a,
+ out vec4 outcol)
+{
+ vec4 co = vec4(RANGE_RESCALE(col.rgb, ext_a.x, range.a), layer);
+ vec3 samp;
+ samp.r = texture(curvemap, co.xw).a;
+ samp.g = texture(curvemap, co.yw).a;
+ samp.b = texture(curvemap, co.zw).a;
+
+ outcol.r = curve_extrapolate(co.x, samp.r, ext_a);
+ outcol.g = curve_extrapolate(co.y, samp.g, ext_a);
+ outcol.b = curve_extrapolate(co.z, samp.b, ext_a);
+ outcol.a = col.a;
+
+ outcol = mix(col, outcol, fac);
+}
+
void set_value(float val, out float outval)
{
outval = val;
@@ -1585,11 +1610,11 @@ void node_volume_principled(
/* Compute density. */
density = max(density, 0.0);
- if(density > 1e-5) {
+ if (density > 1e-5) {
density = max(density * density_attribute, 0.0);
}
- if(density > 1e-5) {
+ if (density > 1e-5) {
/* Compute scattering and absorption coefficients. */
vec3 scatter_color = color.rgb * color_attribute.rgb;
@@ -1601,20 +1626,21 @@ void node_volume_principled(
/* Compute emission. */
emission_strength = max(emission_strength, 0.0);
- if(emission_strength > 1e-5) {
+ if (emission_strength > 1e-5) {
emission_coeff += emission_strength * emission_color.rgb;
}
- if(blackbody_intensity > 1e-3) {
+ if (blackbody_intensity > 1e-3) {
/* Add temperature from attribute. */
float T = max(temperature * max(temperature_attribute, 0.0), 0.0);
/* Stefan-Boltzman law. */
- float T4 = (T * T) * (T * T);
+ float T2 = T * T;
+ float T4 = T2 * T2;
float sigma = 5.670373e-8 * 1e-6 / M_PI;
float intensity = sigma * mix(1.0, T4, blackbody_intensity);
- if(intensity > 1e-5) {
+ if (intensity > 1e-5) {
vec4 bb;
node_blackbody(T, spectrummap, layer, bb);
emission_coeff += bb.rgb * blackbody_tint.rgb * intensity;
@@ -1701,6 +1727,8 @@ void node_attribute_volume_density(sampler3D tex, out vec4 outcol, out vec3 outv
outf = dot(vec3(1.0 / 3.0), outvec);
}
+uniform vec3 volumeColor = vec3(1.0);
+
void node_attribute_volume_color(sampler3D tex, out vec4 outcol, out vec3 outvec, out float outf)
{
#if defined(MESH_SHADER) && defined(VOLUMETRICS)
@@ -1714,7 +1742,7 @@ void node_attribute_volume_color(sampler3D tex, out vec4 outcol, out vec3 outvec
if (value.a > 1e-8)
value.rgb /= value.a;
- outvec = value.rgb;
+ outvec = value.rgb * volumeColor;
outcol = vec4(outvec, 1.0);
outf = dot(vec3(1.0 / 3.0), outvec);
}
@@ -1774,13 +1802,13 @@ void tangent_orco_z(vec3 orco_in, out vec3 orco_out)
void node_tangentmap(vec4 attr_tangent, mat4 toworld, out vec3 tangent)
{
- tangent = (toworld * vec4(attr_tangent.xyz, 0.0)).xyz;
+ tangent = normalize((toworld * vec4(attr_tangent.xyz, 0.0)).xyz);
}
void node_tangent(vec3 N, vec3 orco, mat4 objmat, mat4 toworld, out vec3 T)
{
#ifndef VOLUMETRICS
- N = normalize(worldNormal);
+ N = normalize(gl_FrontFacing ? worldNormal : -worldNormal);
#else
N = (toworld * vec4(N, 0.0)).xyz;
#endif
@@ -1809,8 +1837,7 @@ void node_geometry(
position = worldPosition;
# ifndef VOLUMETRICS
- normal = normalize(worldNormal);
-
+ normal = normalize(gl_FrontFacing ? worldNormal : -worldNormal);
vec3 B = dFdx(worldPosition);
vec3 T = dFdy(worldPosition);
true_normal = normalize(cross(B, T));
@@ -1847,7 +1874,7 @@ void node_tex_coord(
out vec3 camera, out vec3 window, out vec3 reflection)
{
generated = attr_orco;
- normal = normalize((obinvmat * (viewinvmat * vec4(N, 0.0))).xyz);
+ normal = normalize(NormalMatrixInverse * N);
uv = attr_uv;
object = (obinvmat * (viewinvmat * vec4(I, 1.0))).xyz;
camera = vec3(I.xy, -I.z);
@@ -1884,9 +1911,7 @@ void node_tex_coord_background(
object = coords;
camera = vec3(co.xy, -co.z);
- window = (ProjectionMatrix[3][3] == 0.0) ?
- vec3(mtex_2d_mapping(I).xy * camerafac.xy + camerafac.zw, 0.0) :
- vec3(vec2(0.5) * camerafac.xy + camerafac.zw, 0.0);
+ window = vec3(mtex_2d_mapping(I).xy * camerafac.xy + camerafac.zw, 0.0);
reflection = -coords;
}
@@ -2300,7 +2325,7 @@ void node_tex_image_box(vec3 texco,
}
else {
/* last case, we have a mix between three */
- weight = ((2.0 - limit) * N + (limit - 1.0)) / max(1e-8, 2.0 * limit - 1.0);
+ weight = ((2.0 - limit) * N + (limit - 1.0)) / max(1e-8, blend);
}
color = weight.x * color1 + weight.y * color2 + weight.z * color3;
@@ -2770,18 +2795,13 @@ void node_tex_voronoi(vec3 co, float scale, float exponent, float coloring, floa
{
vec3 p = co * scale;
int xx, yy, zz, xi, yi, zi;
- float da[4];
- vec3 pa[4];
+ vec4 da = vec4(1e10);
+ vec3 pa[4] = vec3[4](vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));
xi = floor_to_int(p[0]);
yi = floor_to_int(p[1]);
zi = floor_to_int(p[2]);
- da[0] = 1e+10;
- da[1] = 1e+10;
- da[2] = 1e+10;
- da[3] = 1e+10;
-
for (xx = xi - 1; xx <= xi + 1; xx++) {
for (yy = yi - 1; yy <= yi + 1; yy++) {
for (zz = zi - 1; zz <= zi + 1; zz++) {
@@ -2805,18 +2825,16 @@ void node_tex_voronoi(vec3 co, float scale, float exponent, float coloring, floa
vp += vec3(xx, yy, zz);
if (d < da[0]) {
- da[3] = da[2];
- da[2] = da[1];
- da[1] = da[0];
+ da.yzw = da.xyz;
da[0] = d;
+
pa[3] = pa[2];
pa[2] = pa[1];
pa[1] = pa[0];
pa[0] = vp;
}
else if (d < da[1]) {
- da[3] = da[2];
- da[2] = da[1];
+ da.zw = da.yz;
da[1] = d;
pa[3] = pa[2];
@@ -2956,7 +2974,7 @@ void node_light_falloff(float strength, float tsmooth, out float quadratic, out
constant = strength;
}
-void node_object_info(mat4 obmat, vec3 info, out vec3 location, out float object_index, out float material_index, out float random)
+void node_object_info(mat4 obmat, vec4 info, out vec3 location, out float object_index, out float material_index, out float random)
{
location = obmat[3].xyz;
object_index = info.x;
@@ -2964,9 +2982,14 @@ void node_object_info(mat4 obmat, vec3 info, out vec3 location, out float object
random = info.z;
}
-void node_normal_map(vec4 tangent, vec3 normal, vec3 texnormal, out vec3 outnormal)
+void node_normal_map(vec4 info, vec4 tangent, vec3 normal, vec3 texnormal, out vec3 outnormal)
{
- vec3 B = tangent.w * cross(normal, tangent.xyz);
+ if (all(equal(tangent, vec4(0.0, 0.0, 0.0, 1.0)))) {
+ outnormal = normal;
+ return;
+ }
+ tangent *= (gl_FrontFacing ? 1.0 : -1.0);
+ vec3 B = tangent.w * cross(normal, tangent.xyz) * info.w;
outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * normal;
outnormal = normalize(outnormal);
@@ -3071,7 +3094,7 @@ uniform float backgroundAlpha;
void node_output_world(Closure surface, Closure volume, out Closure result)
{
#ifndef VOLUMETRICS
- result.radiance = surface.radiance;
+ result.radiance = surface.radiance * backgroundAlpha;
result.opacity = backgroundAlpha;
#else
result = volume;
diff --git a/source/blender/gpu/shaders/gpu_shader_selection_id_frag.glsl b/source/blender/gpu/shaders/gpu_shader_selection_id_frag.glsl
index a38113fad87..45ba6cf4d08 100644
--- a/source/blender/gpu/shaders/gpu_shader_selection_id_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_selection_id_frag.glsl
@@ -2,20 +2,12 @@
#ifdef UNIFORM_ID
uniform uint id;
#else
-flat in vec4 id;
+flat in uint id;
#endif
-out vec4 fragColor;
+out uint fragColor;
void main()
{
-#ifdef UNIFORM_ID
- fragColor = vec4(
- ((id ) & 0xFFu) * (1.0f / 255.0f),
- ((id >> 8u) & 0xFFu) * (1.0f / 255.0f),
- ((id >> 16u) & 0xFFu) * (1.0f / 255.0f),
- ((id >> 24u) ) * (1.0f / 255.0f));
-#else
fragColor = id;
-#endif
}
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 81050841550..03d07844ec8 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -95,7 +95,9 @@ void IMB_exit(void);
*
* \attention Defined in readimage.c
*/
-struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr);
+struct ImBuf *IMB_ibImageFromMemory(
+ const unsigned char *mem, size_t size, int flags,
+ char colorspace[IM_MAX_SPACE], const char *descr);
/**
*
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index ec22b8d8a2a..43d91dc0d8e 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -425,7 +425,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
if (anim->pgf) {
lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo]));
if (lpbi) {
- ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
+ ibuf = IMB_ibImageFromMemory((const unsigned char *) lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
//Oh brother...
}
}
@@ -787,8 +787,7 @@ static void ffmpeg_postprocess(struct anim *anim)
int *dstStride = anim->pFrameRGB->linesize;
uint8_t **dst = anim->pFrameRGB->data;
int dstStride2[4] = { -dstStride[0], 0, 0, 0 };
- uint8_t *dst2[4] = { dst[0] + (anim->y - 1) * dstStride[0],
- 0, 0, 0 };
+ uint8_t *dst2[4] = { dst[0] + (anim->y - 1) * dstStride[0], 0, 0, 0 };
sws_scale(anim->img_convert_ctx,
(const uint8_t *const *)input->data,
@@ -885,13 +884,13 @@ static int ffmpeg_decode_video_frame(struct anim *anim)
anim->pFrameComplete = 0;
avcodec_decode_video2(
- anim->pCodecCtx,
- anim->pFrame, &anim->pFrameComplete,
- &anim->next_packet);
+ anim->pCodecCtx,
+ anim->pFrame, &anim->pFrameComplete,
+ &anim->next_packet);
if (anim->pFrameComplete) {
anim->next_pts = av_get_pts_from_frame(
- anim->pFormatCtx, anim->pFrame);
+ anim->pFormatCtx, anim->pFrame);
av_log(anim->pFormatCtx,
AV_LOG_DEBUG,
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index d9f1c92fdde..14389a566fd 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -182,8 +182,10 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
if (verbose) printf("Cineon: File is LSB.\n");
}
else {
- if (verbose) printf("Cineon: Bad magic number %lu in \"%s\".\n",
- (unsigned long)header.fileHeader.magic_num, byteStuff);
+ if (verbose) {
+ printf("Cineon: Bad magic number %lu in \"%s\".\n",
+ (unsigned long)header.fileHeader.magic_num, byteStuff);
+ }
logImageClose(cineon);
return NULL;
}
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index d9b061089f7..16a7525bb80 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -1132,7 +1132,7 @@ void DirectDrawSurface::mipmap(Image *img, uint face, uint mipmap)
// It was easier to copy this function from upstream than to resync.
// This should be removed if a resync ever occurs.
-void* DirectDrawSurface::readData(uint &rsize)
+void *DirectDrawSurface::readData(uint &rsize)
{
uint header_size = 128; // sizeof(DDSHeader);
if (header.hasDX10Header())
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index 5d88acd782a..6de3cabf5bd 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -879,11 +879,11 @@ static void index_rebuild_ffmpeg_proc_decoded_frame(
tc_frameno = context->frameno_gapless;
IMB_index_builder_proc_frame(
- context->indexer[i],
- curr_packet->data,
- curr_packet->size,
- tc_frameno,
- s_pos, s_dts, pts);
+ context->indexer[i],
+ curr_packet->data,
+ curr_packet->size,
+ tc_frameno,
+ s_pos, s_dts, pts);
}
}
@@ -937,7 +937,7 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
if (frame_finished) {
index_rebuild_ffmpeg_proc_decoded_frame(
- context, &next_packet, in_frame);
+ context, &next_packet, in_frame);
}
av_free_packet(&next_packet);
}
@@ -957,12 +957,12 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
frame_finished = 0;
avcodec_decode_video2(
- context->iCodecCtx, in_frame, &frame_finished,
- &next_packet);
+ context->iCodecCtx, in_frame, &frame_finished,
+ &next_packet);
if (frame_finished) {
index_rebuild_ffmpeg_proc_decoded_frame(
- context, &next_packet, in_frame);
+ context, &next_packet, in_frame);
}
} while (frame_finished);
}
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index cc6d99e2a90..5bed5b28b14 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -602,10 +602,10 @@ static int expandrow2(
float pixel_f;
#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next) \
- if (UNLIKELY(iptr_next > iptr_end)) { goto fail; }
+ if (UNLIKELY(iptr_next > iptr_end)) { goto fail; } ((void)0)
#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next) \
- if (UNLIKELY(optr_next > optr_end)) { goto fail; }
+ if (UNLIKELY(optr_next > optr_end)) { goto fail; } ((void)0)
optr += z;
optr_end += z;
@@ -683,10 +683,10 @@ static int expandrow(
uchar pixel, count;
#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next) \
- if (UNLIKELY(iptr_next > iptr_end)) { goto fail; }
+ if (UNLIKELY(iptr_next > iptr_end)) { goto fail; } ((void)0)
#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next) \
- if (UNLIKELY(optr_next > optr_end)) { goto fail; }
+ if (UNLIKELY(optr_next > optr_end)) { goto fail; } ((void)0)
optr += z;
optr_end += z;
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index c3690bcf643..aaeb4e4c2ad 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -138,7 +138,7 @@ static void info_callback(const char *msg, void *client_data)
struct BufInfo {
const unsigned char *buf;
const unsigned char *cur;
- off_t len;
+ OPJ_OFF_T len;
};
static void opj_read_from_buffer_free(void *UNUSED(p_user_data))
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index feb75bed831..ad4e07030d1 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -92,7 +92,9 @@ static void imb_handle_alpha(ImBuf *ibuf, int flags, char colorspace[IM_MAX_SPAC
colormanage_imbuf_make_linear(ibuf, effective_colorspace);
}
-ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
+ImBuf *IMB_ibImageFromMemory(
+ const unsigned char *mem, size_t size, int flags,
+ char colorspace[IM_MAX_SPACE], const char *descr)
{
ImBuf *ibuf;
const ImFileType *type;
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index cd29a3c5bc4..a2bd50b6ade 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -340,8 +340,7 @@ typedef struct PreviewImage {
*
* The tags represent types! This is a dirty way of enabling RTTI. The
* sig_byte end endian defines aren't really used much.
- *
- **/
+ */
#ifdef __BIG_ENDIAN__
/* big endian */
@@ -527,7 +526,8 @@ enum {
/* Tag given ID for an update in all the dependency graphs. */
typedef enum IDRecalcFlag {
- /* Individual update tags, this is what ID gets tagged for update with. */
+ /***************************************************************************
+ * Individual update tags, this is what ID gets tagged for update with. */
/* ** Object transformation changed. ** */
ID_RECALC_TRANSFORM = (1 << 0),
@@ -585,7 +585,16 @@ typedef enum IDRecalcFlag {
*/
ID_RECALC_COPY_ON_WRITE = (1 << 13),
- /* Aggregate flags, use only for checks on runtime.
+ /***************************************************************************
+ * Pseudonyms, to have more semantic meaning in the actual code without
+ * using too much low-level and implementation specific tags. */
+
+ /* Update animation datablock itself, without doing full re-evaluation of
+ * all dependent objects. */
+ ID_RECALC_ANIMATION_NO_FLUSH = ID_RECALC_COPY_ON_WRITE,
+
+ /***************************************************************************
+ * Aggregate flags, use only for checks on runtime.
* Do NOT use those for tagging. */
/* Identifies that SOMETHING has been changed in this ID. */
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index ddea6f64dba..b17a746f11c 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -699,7 +699,7 @@ typedef struct bDopeSheet {
/** Standard flags. */
int flag;
- /** Index+1 of channel to rename - only gets set by renaming operator. */
+ /** `index + 1` of channel to rename - only gets set by renaming operator. */
int renameIndex;
} bDopeSheet;
@@ -833,11 +833,11 @@ typedef enum eSAction_Flag {
/* draw time in seconds instead of time in frames */
SACTION_DRAWTIME = (1 << 2),
/* don't filter action channels according to visibility */
- //SACTION_NOHIDE = (1<<3), // XXX deprecated... old animation system
+ //SACTION_NOHIDE = (1 << 3), // XXX deprecated... old animation system
/* don't kill overlapping keyframes after transform */
SACTION_NOTRANSKEYCULL = (1 << 4),
/* don't include keyframes that are out of view */
- //SACTION_HORIZOPTIMISEON = (1<<5), // XXX deprecated... old irrelevant trick
+ //SACTION_HORIZOPTIMISEON = (1 << 5), // XXX deprecated... old irrelevant trick
/* show pose-markers (local to action) in Action Editor mode */
SACTION_POSEMARKERS_SHOW = (1 << 6),
/* don't draw action channels using group colors (where applicable) */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 14708632eb6..ccc0b2e4fcb 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -83,7 +83,7 @@ typedef enum eFModifier_Types {
FMODIFIER_TYPE_ENVELOPE = 3,
FMODIFIER_TYPE_CYCLES = 4,
FMODIFIER_TYPE_NOISE = 5,
- /** unimplemented - for applying: fft, high/low pass filters, etc. */
+ /** Unimplemented - for applying: fft, high/low pass filters, etc. */
FMODIFIER_TYPE_FILTER = 6,
FMODIFIER_TYPE_PYTHON = 7,
FMODIFIER_TYPE_LIMITS = 8,
@@ -93,27 +93,27 @@ typedef enum eFModifier_Types {
FMODIFIER_NUM_TYPES
} eFModifier_Types;
-/* F-Curve Modifier Settings */
+/** F-Curve Modifier Settings. */
typedef enum eFModifier_Flags {
- /* modifier is not able to be evaluated for some reason, and should be skipped (internal) */
- FMODIFIER_FLAG_DISABLED = (1<<0),
- /* modifier's data is expanded (in UI) */
- FMODIFIER_FLAG_EXPANDED = (1<<1),
- /* modifier is active one (in UI) for editing purposes */
- FMODIFIER_FLAG_ACTIVE = (1<<2),
- /* user wants modifier to be skipped */
- FMODIFIER_FLAG_MUTED = (1<<3),
- /* restrict range that F-Modifier can be considered over */
- FMODIFIER_FLAG_RANGERESTRICT = (1<<4),
- /* use influence control */
- FMODIFIER_FLAG_USEINFLUENCE = (1<<5),
+ /** Modifier is not able to be evaluated for some reason, and should be skipped (internal). */
+ FMODIFIER_FLAG_DISABLED = (1 << 0),
+ /** Modifier's data is expanded (in UI). */
+ FMODIFIER_FLAG_EXPANDED = (1 << 1),
+ /** Modifier is active one (in UI) for editing purposes. */
+ FMODIFIER_FLAG_ACTIVE = (1 << 2),
+ /** User wants modifier to be skipped. */
+ FMODIFIER_FLAG_MUTED = (1 << 3),
+ /** Restrict range that F-Modifier can be considered over. */
+ FMODIFIER_FLAG_RANGERESTRICT = (1 << 4),
+ /** Use influence control. */
+ FMODIFIER_FLAG_USEINFLUENCE = (1 << 5),
} eFModifier_Flags;
/* --- */
/* Generator modifier data */
typedef struct FMod_Generator {
- /* general generator information */
+ /* general generator information */
/** Coefficients array. */
float *coefficients;
/** Size of the coefficients array. */
@@ -124,7 +124,6 @@ typedef struct FMod_Generator {
/** Which 'generator' to use eFMod_Generator_Modes. */
int mode;
- /* settings */
/** Settings. */
int flag;
} FMod_Generator;
@@ -141,7 +140,7 @@ typedef enum eFMod_Generator_Modes {
*/
typedef enum eFMod_Generator_Flags {
/* generator works in conjunction with other modifiers (i.e. doesn't replace those before it) */
- FCM_GENERATOR_ADDITIVE = (1<<0),
+ FCM_GENERATOR_ADDITIVE = (1 << 0),
} eFMod_Generator_Flags;
@@ -252,10 +251,10 @@ typedef struct FMod_Limits {
/* limiting flags */
typedef enum eFMod_Limit_Flags {
- FCM_LIMIT_XMIN = (1<<0),
- FCM_LIMIT_XMAX = (1<<1),
- FCM_LIMIT_YMIN = (1<<2),
- FCM_LIMIT_YMAX = (1<<3),
+ FCM_LIMIT_XMIN = (1 << 0),
+ FCM_LIMIT_XMAX = (1 << 1),
+ FCM_LIMIT_YMIN = (1 << 2),
+ FCM_LIMIT_YMAX = (1 << 3),
} eFMod_Limit_Flags;
@@ -272,10 +271,14 @@ typedef struct FMod_Noise {
/* modification modes */
typedef enum eFMod_Noise_Modifications {
- FCM_NOISE_MODIF_REPLACE = 0, /* Modify existing curve, matching it's shape */
- FCM_NOISE_MODIF_ADD, /* Add noise to the curve */
- FCM_NOISE_MODIF_SUBTRACT, /* Subtract noise from the curve */
- FCM_NOISE_MODIF_MULTIPLY /* Multiply the curve by noise */
+ /** Modify existing curve, matching it's shape. */
+ FCM_NOISE_MODIF_REPLACE = 0,
+ /** Add noise to the curve. */
+ FCM_NOISE_MODIF_ADD,
+ /** Subtract noise from the curve. */
+ FCM_NOISE_MODIF_SUBTRACT,
+ /** Multiply the curve by noise. */
+ FCM_NOISE_MODIF_MULTIPLY
} eFMod_Noise_Modifications;
@@ -297,8 +300,10 @@ typedef struct FMod_Stepped {
/* stepped modifier range flags */
typedef enum eFMod_Stepped_Flags {
- FCM_STEPPED_NO_BEFORE = (1<<0), /* don't affect frames before the start frame */
- FCM_STEPPED_NO_AFTER = (1<<1), /* don't affect frames after the end frame */
+ /** Don't affect frames before the start frame. */
+ FCM_STEPPED_NO_BEFORE = (1 << 0),
+ /** Don't affect frames after the end frame. */
+ FCM_STEPPED_NO_AFTER = (1 << 1),
} eFMod_Stepped_Flags;
/* Drivers -------------------------------------- */
@@ -331,22 +336,21 @@ typedef struct DriverTarget {
int idtype;
} DriverTarget;
-/* Driver Target flags */
+/** Driver Target flags. */
typedef enum eDriverTarget_Flag {
- /* used for targets that use the pchan_name instead of RNA path
- * (i.e. rotation difference)
- */
+ /** used for targets that use the pchan_name instead of RNA path
+ * (i.e. rotation difference) */
DTAR_FLAG_STRUCT_REF = (1 << 0),
- /* idtype can only be 'Object' */
+ /** idtype can only be 'Object' */
DTAR_FLAG_ID_OB_ONLY = (1 << 1),
/* "localspace" flags */
- /* base flag - basically "pre parent+constraints" */
+ /** base flag - basically "pre parent+constraints" */
DTAR_FLAG_LOCALSPACE = (1 << 2),
- /* include constraints transformed to space including parents */
+ /** include constraints transformed to space including parents */
DTAR_FLAG_LOCAL_CONSTS = (1 << 3),
- /* error flags */
+ /** error flags */
DTAR_FLAG_INVALID = (1 << 4),
} eDriverTarget_Flag;
@@ -371,7 +375,8 @@ typedef enum eDriverTarget_TransformChannels {
#define MAX_DRIVER_TARGETS 8
-/* Driver Variable (dvar)
+/**
+ * Driver Variable (dvar)
*
* A 'variable' for use as an input for the driver evaluation.
* Defines a way of accessing some channel to use, that can be
@@ -401,20 +406,21 @@ typedef struct DriverVar {
float curval;
} DriverVar;
-/* Driver Variable Types */
+/** Driver Variable Types.* */
typedef enum eDriverVar_Types {
- /* single RNA property */
+ /** single RNA property */
DVAR_TYPE_SINGLE_PROP = 0,
- /* rotation difference (between 2 bones) */
+ /** rotation difference (between 2 bones) */
DVAR_TYPE_ROT_DIFF,
- /* distance between objects/bones */
+ /** distance between objects/bones */
DVAR_TYPE_LOC_DIFF,
- /* 'final' transform for object/bones */
+ /** 'final' transform for object/bones */
DVAR_TYPE_TRANSFORM_CHAN,
- /* maximum number of variable types
- * NOTE: this must always be th last item in this list,
- * so add new types above this line.
+ /** Maximum number of variable types.
+ *
+ * \note This must always be th last item in this list,
+ * so add new types above this line.
*/
MAX_DVAR_TYPES
} eDriverVar_Types;
@@ -456,7 +462,8 @@ typedef enum eDriverVar_Flags {
/* --- */
-/* Channel Driver (i.e. Drivers / Expressions) (driver)
+/**
+ * Channel Driver (i.e. Drivers / Expressions) (driver)
*
* Channel Drivers are part of the dependency system, and are executed in addition to
* normal user-defined animation. They take the animation result of some channel(s), and
@@ -495,40 +502,41 @@ typedef struct ChannelDriver {
int flag;
} ChannelDriver;
-/* driver type */
+/** Driver type. */
typedef enum eDriver_Types {
- /* target values are averaged together */
+ /** target values are averaged together. */
DRIVER_TYPE_AVERAGE = 0,
- /* python expression/function relates targets */
+ /** python expression/function relates targets. */
DRIVER_TYPE_PYTHON,
- /* sum of all values */
+ /** sum of all values. */
DRIVER_TYPE_SUM,
- /* smallest value */
+ /** smallest value. */
DRIVER_TYPE_MIN,
- /* largest value */
+ /** largest value. */
DRIVER_TYPE_MAX
} eDriver_Types;
-/* driver flags */
-/* note: (1<<5) is deprecated; was "DRIVER_FLAG_SHOWDEBUG" */
+/** Driver flags. */
typedef enum eDriver_Flags {
- /* driver has invalid settings (internal flag) */
- DRIVER_FLAG_INVALID = (1<<0),
- DRIVER_FLAG_DEPRECATED = (1<<1),
- /* driver does replace value, but overrides (for layering of animation over driver) */
- // TODO: this needs to be implemented at some stage or left out...
- //DRIVER_FLAG_LAYERING = (1<<2),
- /* use when the expression needs to be recompiled */
- DRIVER_FLAG_RECOMPILE = (1<<3),
- /* the names are cached so they don't need have python unicode versions created each time */
- DRIVER_FLAG_RENAMEVAR = (1<<4),
- /* include 'self' in the drivers namespace. */
- DRIVER_FLAG_USE_SELF = (1<<6),
+ /** Driver has invalid settings (internal flag) */
+ DRIVER_FLAG_INVALID = (1 << 0),
+ DRIVER_FLAG_DEPRECATED = (1 << 1),
+ /** Driver does replace value, but overrides (for layering of animation over driver) */
+ // TODO: this needs to be implemented at some stage or left out...
+ //DRIVER_FLAG_LAYERING = (1 << 2),
+ /** Use when the expression needs to be recompiled. */
+ DRIVER_FLAG_RECOMPILE = (1 << 3),
+ /** The names are cached so they don't need have python unicode versions created each time */
+ DRIVER_FLAG_RENAMEVAR = (1 << 4),
+ // DRIVER_FLAG_UNUSED_5 = (1 << 5),
+ /** Include 'self' in the drivers namespace. */
+ DRIVER_FLAG_USE_SELF = (1 << 6),
} eDriver_Flags;
/* F-Curves -------------------------------------- */
-/* FPoint (fpt)
+/**
+ * FPoint (fpt)
*
* This is the bare-minimum data required storing motion samples. Should be more efficient
* than using BPoints, which contain a lot of other unnecessary data...
@@ -596,31 +604,31 @@ typedef struct FCurve {
/* user-editable flags/settings */
typedef enum eFCurve_Flags {
/** curve/keyframes are visible in editor */
- FCURVE_VISIBLE = (1<<0),
+ FCURVE_VISIBLE = (1 << 0),
/** curve is selected for editing */
- FCURVE_SELECTED = (1<<1),
+ FCURVE_SELECTED = (1 << 1),
/** curve is active one */
- FCURVE_ACTIVE = (1<<2),
+ FCURVE_ACTIVE = (1 << 2),
/** keyframes (beztriples) cannot be edited */
- FCURVE_PROTECTED = (1<<3),
+ FCURVE_PROTECTED = (1 << 3),
/** fcurve will not be evaluated for the next round */
- FCURVE_MUTED = (1<<4),
+ FCURVE_MUTED = (1 << 4),
/** fcurve uses 'auto-handles', which stay horizontal... */
// DEPRECATED
- FCURVE_AUTO_HANDLES = (1<<5),
- FCURVE_MOD_OFF = (1<<6),
+ FCURVE_AUTO_HANDLES = (1 << 5),
+ FCURVE_MOD_OFF = (1 << 6),
/** skip evaluation, as RNA-path cannot be resolved
* (similar to muting, but cannot be set by user) */
- FCURVE_DISABLED = (1<<10),
+ FCURVE_DISABLED = (1 << 10),
/** curve can only have whole-number values (integer types) */
- FCURVE_INT_VALUES = (1<<11),
+ FCURVE_INT_VALUES = (1 << 11),
/** curve can only have certain discrete-number values
* (no interpolation at all, for enums/booleans) */
- FCURVE_DISCRETE_VALUES = (1<<12),
+ FCURVE_DISCRETE_VALUES = (1 << 12),
/** temporary tag for editing */
- FCURVE_TAGGED = (1<<15),
+ FCURVE_TAGGED = (1 << 15),
} eFCurve_Flags;
/* extrapolation modes (only simple value 'extending') */
@@ -664,7 +672,8 @@ typedef enum eFCurve_Smoothing {
/* NLA Strips ------------------------------------- */
-/* NLA Strip (strip)
+/**
+ * NLA Strip (strip)
*
* A NLA Strip is a container for the reuse of Action data, defining parameters
* to control the remapping of the Action data to some destination.
@@ -729,7 +738,7 @@ typedef enum eNlaStrip_Blend_Mode {
NLASTRIP_MODE_COMBINE,
} eNlaStrip_Blend_Mode;
-/* NLA Strip Extrpolation Mode */
+/** NLA Strip Extrpolation Mode. */
typedef enum eNlaStrip_Extrapolate_Mode {
/* extend before first frame if no previous strips in track,
* and always hold+extend last frame */
@@ -740,63 +749,64 @@ typedef enum eNlaStrip_Extrapolate_Mode {
NLASTRIP_EXTEND_NOTHING = 2,
} eNlaStrip_Extrapolate_Mode;
-/* NLA Strip Settings */
+/** NLA Strip Settings. */
typedef enum eNlaStrip_Flag {
/* UI selection flags */
- /* NLA strip is the active one in the track (also indicates if strip is being tweaked) */
- NLASTRIP_FLAG_ACTIVE = (1<<0),
- /* NLA strip is selected for editing */
- NLASTRIP_FLAG_SELECT = (1<<1),
-// NLASTRIP_FLAG_SELECT_L = (1<<2), // left handle selected
-// NLASTRIP_FLAG_SELECT_R = (1<<3), // right handle selected
-
- /* NLA strip uses the same action that the action being tweaked uses
+ /** NLA strip is the active one in the track (also indicates if strip is being tweaked) */
+ NLASTRIP_FLAG_ACTIVE = (1 << 0),
+ /* NLA strip is selected for editing */
+ NLASTRIP_FLAG_SELECT = (1 << 1),
+ // NLASTRIP_FLAG_SELECT_L = (1 << 2), // left handle selected
+ // NLASTRIP_FLAG_SELECT_R = (1 << 3), // right handle selected
+
+ /** NLA strip uses the same action that the action being tweaked uses
* (not set for the tweaking one though). */
- NLASTRIP_FLAG_TWEAKUSER = (1<<4),
+ NLASTRIP_FLAG_TWEAKUSER = (1 << 4),
/* controls driven by local F-Curves */
- /* strip influence is controlled by local F-Curve */
- NLASTRIP_FLAG_USR_INFLUENCE = (1<<5),
- NLASTRIP_FLAG_USR_TIME = (1<<6),
- NLASTRIP_FLAG_USR_TIME_CYCLIC = (1<<7),
+ /** strip influence is controlled by local F-Curve */
+ NLASTRIP_FLAG_USR_INFLUENCE = (1 << 5),
+ NLASTRIP_FLAG_USR_TIME = (1 << 6),
+ NLASTRIP_FLAG_USR_TIME_CYCLIC = (1 << 7),
- /* NLA strip length is synced to the length of the referenced action */
- NLASTRIP_FLAG_SYNC_LENGTH = (1<<9),
+ /** NLA strip length is synced to the length of the referenced action */
+ NLASTRIP_FLAG_SYNC_LENGTH = (1 << 9),
/* playback flags (may be overridden by F-Curves) */
- /* NLA strip blendin/out values are set automatically based on overlaps */
- NLASTRIP_FLAG_AUTO_BLENDS = (1<<10),
- /* NLA strip is played back in reverse order */
- NLASTRIP_FLAG_REVERSE = (1<<11),
- /* NLA strip is muted (i.e. doesn't contribute in any way) */
- NLASTRIP_FLAG_MUTED = (1<<12),
- /* NLA Strip is played back in 'ping-pong' style */
- NLASTRIP_FLAG_MIRROR = (1<<13),
+ /** NLA strip blendin/out values are set automatically based on overlaps */
+ NLASTRIP_FLAG_AUTO_BLENDS = (1 << 10),
+ /** NLA strip is played back in reverse order */
+ NLASTRIP_FLAG_REVERSE = (1 << 11),
+ /** NLA strip is muted (i.e. doesn't contribute in any way) */
+ NLASTRIP_FLAG_MUTED = (1 << 12),
+ /** NLA Strip is played back in 'ping-pong' style */
+ NLASTRIP_FLAG_MIRROR = (1 << 13),
/* temporary editing flags */
- /* NLA strip should ignore frame range and hold settings, and evaluate at global time. */
- NLASTRIP_FLAG_NO_TIME_MAP = (1<<29),
- /* NLA-Strip is really just a temporary meta used to facilitate easier transform code */
- NLASTRIP_FLAG_TEMP_META = (1<<30),
+ /** NLA strip should ignore frame range and hold settings, and evaluate at global time. */
+ NLASTRIP_FLAG_NO_TIME_MAP = (1 << 29),
+ /** NLA-Strip is really just a temporary meta used to facilitate easier transform code */
+ NLASTRIP_FLAG_TEMP_META = (1 << 30),
NLASTRIP_FLAG_EDIT_TOUCHED = (1u << 31),
} eNlaStrip_Flag;
/* NLA Strip Type */
typedef enum eNlaStrip_Type {
- /* 'clip' - references an Action */
+ /* 'clip' - references an Action */
NLASTRIP_TYPE_CLIP = 0,
- /* 'transition' - blends between the adjacent strips */
+ /* 'transition' - blends between the adjacent strips */
NLASTRIP_TYPE_TRANSITION,
- /* 'meta' - a strip which acts as a container for a few others */
+ /* 'meta' - a strip which acts as a container for a few others */
NLASTRIP_TYPE_META,
- /* 'emit sound' - a strip which is used for timing when speaker emits sounds */
+ /* 'emit sound' - a strip which is used for timing when speaker emits sounds */
NLASTRIP_TYPE_SOUND
} eNlaStrip_Type;
/* NLA Tracks ------------------------------------- */
-/* NLA Track (nlt)
+/**
+ * NLA Track (nlt)
*
* A track groups a bunch of 'strips', which should form a continuous set of
* motion, on top of which other such groups can be layered. This should allow
@@ -823,26 +833,27 @@ typedef struct NlaTrack {
typedef enum eNlaTrack_Flag {
/** track is the one that settings can be modified on,
* also indicates if track is being 'tweaked' */
- NLATRACK_ACTIVE = (1<<0),
+ NLATRACK_ACTIVE = (1 << 0),
/** track is selected in UI for relevant editing operations */
- NLATRACK_SELECTED = (1<<1),
+ NLATRACK_SELECTED = (1 << 1),
/** track is not evaluated */
- NLATRACK_MUTED = (1<<2),
+ NLATRACK_MUTED = (1 << 2),
/** track is the only one evaluated (must be used in conjunction with adt->flag) */
- NLATRACK_SOLO = (1<<3),
+ NLATRACK_SOLO = (1 << 3),
/** track's settings (and strips) cannot be edited (to guard against unwanted changes) */
- NLATRACK_PROTECTED = (1<<4),
+ NLATRACK_PROTECTED = (1 << 4),
/** track is not allowed to execute,
* usually as result of tweaking being enabled (internal flag) */
- NLATRACK_DISABLED = (1<<10),
+ NLATRACK_DISABLED = (1 << 10),
} eNlaTrack_Flag;
/* ************************************ */
/* KeyingSet Datatypes */
-/* Path for use in KeyingSet definitions (ksp)
+/**
+ * Path for use in KeyingSet definitions (ksp)
*
* Paths may be either specific (specifying the exact sub-ID
* dynamic data-block - such as PoseChannels - to act upon, ala
@@ -880,26 +891,26 @@ typedef struct KS_Path {
/* KS_Path->flag */
typedef enum eKSP_Settings {
/* entire array (not just the specified index) gets keyframed */
- KSP_FLAG_WHOLE_ARRAY = (1<<0),
+ KSP_FLAG_WHOLE_ARRAY = (1 << 0),
} eKSP_Settings;
/* KS_Path->groupmode */
typedef enum eKSP_Grouping {
- /* path should be grouped using group name stored in path */
+ /** Path should be grouped using group name stored in path. */
KSP_GROUP_NAMED = 0,
- /* path should not be grouped at all */
+ /** Path should not be grouped at all. */
KSP_GROUP_NONE,
- /* path should be grouped using KeyingSet's name */
+ /** Path should be grouped using KeyingSet's name. */
KSP_GROUP_KSNAME,
- /* path should be grouped using name of inner-most context item from templates
- * - this is most useful for relative KeyingSets only
- */
+ /** Path should be grouped using name of inner-most context item from templates
+ * - this is most useful for relative KeyingSets only. */
KSP_GROUP_TEMPLATE_ITEM
} eKSP_Grouping;
/* ---------------- */
-/* KeyingSet definition (ks)
+/**
+ * KeyingSet definition (ks)
*
* A KeyingSet defines a group of properties that should
* be keyframed together, providing a convenient way for animators
@@ -940,37 +951,37 @@ typedef struct KeyingSet {
/* KeyingSet settings */
typedef enum eKS_Settings {
- /* keyingset cannot be removed (and doesn't need to be freed) */
- KEYINGSET_BUILTIN = (1<<0),
- /* keyingset does not depend on context info (i.e. paths are absolute) */
- KEYINGSET_ABSOLUTE = (1<<1),
+ /** Keyingset cannot be removed (and doesn't need to be freed). */
+ KEYINGSET_BUILTIN = (1 << 0),
+ /** Keyingset does not depend on context info (i.e. paths are absolute). */
+ KEYINGSET_ABSOLUTE = (1 << 1),
} eKS_Settings;
/* Flags for use by keyframe creation/deletion calls */
typedef enum eInsertKeyFlags {
INSERTKEY_NOFLAGS = 0,
/** only insert keyframes where they're needed */
- INSERTKEY_NEEDED = (1<<0),
+ INSERTKEY_NEEDED = (1 << 0),
/** insert 'visual' keyframes where possible/needed */
- INSERTKEY_MATRIX = (1<<1),
+ INSERTKEY_MATRIX = (1 << 1),
/** don't recalculate handles,etc. after adding key */
- INSERTKEY_FAST = (1<<2),
+ INSERTKEY_FAST = (1 << 2),
/** don't realloc mem (or increase count, as array has already been set out) */
- INSERTKEY_FASTR = (1<<3),
+ INSERTKEY_FASTR = (1 << 3),
/** only replace an existing keyframe (this overrides INSERTKEY_NEEDED) */
- INSERTKEY_REPLACE = (1<<4),
+ INSERTKEY_REPLACE = (1 << 4),
/** transform F-Curves should have XYZ->RGB color mode */
- INSERTKEY_XYZ2RGB = (1<<5),
+ INSERTKEY_XYZ2RGB = (1 << 5),
/** ignore user-prefs (needed for predictable API use) */
- INSERTKEY_NO_USERPREF = (1<<6),
+ INSERTKEY_NO_USERPREF = (1 << 6),
/** Allow to make a full copy of new key into existing one, if any,
* instead of 'reusing' existing handles.
* Used by copy/paste code. */
- INSERTKEY_OVERWRITE_FULL = (1<<7),
+ INSERTKEY_OVERWRITE_FULL = (1 << 7),
/** for driver FCurves, use driver's "input" value - for easier corrective driver setup */
- INSERTKEY_DRIVER = (1<<8),
+ INSERTKEY_DRIVER = (1 << 8),
/** for cyclic FCurves, adjust key timing to preserve the cycle period and flow */
- INSERTKEY_CYCLE_AWARE = (1<<9),
+ INSERTKEY_CYCLE_AWARE = (1 << 9),
} eInsertKeyFlags;
/* ************************************************ */
@@ -978,7 +989,8 @@ typedef enum eInsertKeyFlags {
/* AnimOverride ------------------------------------- */
-/* Animation Override (aor)
+/**
+ * Animation Override (aor)
*
* This is used to as temporary storage of values which have been changed by the user, but not
* yet keyframed (thus, would get overwritten by the animation system before the user had a chance
@@ -1001,7 +1013,8 @@ typedef struct AnimOverride {
/* AnimData ------------------------------------- */
-/* Animation data for some ID block (adt)
+/**
+ * Animation data for some ID block (adt)
*
* This block of data is used to provide all of the necessary animation data for a datablock.
* Currently, this data will not be reusable, as there shouldn't be any need to do so.
@@ -1063,37 +1076,38 @@ typedef struct AnimData {
/* Animation Data settings (mostly for NLA) */
typedef enum eAnimData_Flag {
- /* only evaluate a single track in the NLA */
- ADT_NLA_SOLO_TRACK = (1<<0),
- /* don't use NLA */
- ADT_NLA_EVAL_OFF = (1<<1),
- /* NLA is being 'tweaked' (i.e. in EditMode) */
- ADT_NLA_EDIT_ON = (1<<2),
- /* active Action for 'tweaking' does not have mapping applied for editing */
- ADT_NLA_EDIT_NOMAP = (1<<3),
- /* NLA-Strip F-Curves are expanded in UI */
- ADT_NLA_SKEYS_COLLAPSED = (1<<4),
-
- /* drivers expanded in UI */
- ADT_DRIVERS_COLLAPSED = (1<<10),
- /* don't execute drivers */
- ADT_DRIVERS_DISABLED = (1<<11),
-
- /* AnimData block is selected in UI */
- ADT_UI_SELECTED = (1<<14),
- /* AnimData block is active in UI */
- ADT_UI_ACTIVE = (1<<15),
-
- /* F-Curves from this AnimData block are not visible in the Graph Editor */
- ADT_CURVES_NOT_VISIBLE = (1<<16),
-
- /* F-Curves from this AnimData block are always visible */
- ADT_CURVES_ALWAYS_VISIBLE = (1<<17),
+ /** Only evaluate a single track in the NLA. */
+ ADT_NLA_SOLO_TRACK = (1 << 0),
+ /** Don't use NLA */
+ ADT_NLA_EVAL_OFF = (1 << 1),
+ /** NLA is being 'tweaked' (i.e. in EditMode). */
+ ADT_NLA_EDIT_ON = (1 << 2),
+ /** Active Action for 'tweaking' does not have mapping applied for editing. */
+ ADT_NLA_EDIT_NOMAP = (1 << 3),
+ /** NLA-Strip F-Curves are expanded in UI. */
+ ADT_NLA_SKEYS_COLLAPSED = (1 << 4),
+
+ /** Drivers expanded in UI. */
+ ADT_DRIVERS_COLLAPSED = (1 << 10),
+ /** Don't execute drivers. */
+ ADT_DRIVERS_DISABLED = (1 << 11),
+
+ /** AnimData block is selected in UI. */
+ ADT_UI_SELECTED = (1 << 14),
+ /** AnimData block is active in UI. */
+ ADT_UI_ACTIVE = (1 << 15),
+
+ /** F-Curves from this AnimData block are not visible in the Graph Editor. */
+ ADT_CURVES_NOT_VISIBLE = (1 << 16),
+
+ /** F-Curves from this AnimData block are always visible. */
+ ADT_CURVES_ALWAYS_VISIBLE = (1 << 17),
} eAnimData_Flag;
/* Base Struct for Anim ------------------------------------- */
-/* Used for BKE_animdata_from_id()
+/**
+ * Used for BKE_animdata_from_id()
* All ID-datablocks which have their own 'local' AnimData
* should have the same arrangement in their structs.
*/
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 9aec322520d..3e725d131f2 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -135,27 +135,27 @@ typedef struct bArmature {
/* armature->flag */
/* don't use bit 7, was saved in files to disable stuff */
typedef enum eArmature_Flag {
- ARM_RESTPOS = (1<<0),
+ ARM_RESTPOS = (1 << 0),
/** XRAY is here only for backwards converting */
- ARM_FLAG_DEPRECATED_1 = (1 << 1), /* cleared */
- ARM_DRAWAXES = (1<<2),
- ARM_DRAWNAMES = (1<<3),
- ARM_POSEMODE = (1<<4),
- ARM_FLAG_DEPRECATED_5 = (1<<5), /* cleared */
- ARM_DELAYDEFORM = (1<<6),
- ARM_FLAG_DEPRECATED_7 = (1 << 7), /* cleared */
- ARM_MIRROR_EDIT = (1<<8),
- ARM_AUTO_IK = (1<<9),
+ ARM_FLAG_UNUSED_1 = (1 << 1), /* cleared */
+ ARM_DRAWAXES = (1 << 2),
+ ARM_DRAWNAMES = (1 << 3),
+ ARM_POSEMODE = (1 << 4),
+ ARM_FLAG_UNUSED_5 = (1 << 5), /* cleared */
+ ARM_DELAYDEFORM = (1 << 6),
+ ARM_FLAG_UNUSED_7 = (1 << 7), /* cleared */
+ ARM_MIRROR_EDIT = (1 << 8),
+ ARM_AUTO_IK = (1 << 9),
/** made option negative, for backwards compat */
- ARM_NO_CUSTOM = (1<<10),
+ ARM_NO_CUSTOM = (1 << 10),
/** draw custom colors */
- ARM_COL_CUSTOM = (1<<11),
+ ARM_COL_CUSTOM = (1 << 11),
/** when ghosting, only show selected bones (this should belong to ghostflag instead) */
- ARM_FLAG_DEPRECATED_12 = (1 << 12), /* cleared */
+ ARM_FLAG_UNUSED_12 = (1 << 12), /* cleared */
/** dopesheet channel is expanded */
- ARM_DS_EXPAND = (1<<13),
+ ARM_DS_EXPAND = (1 << 13),
/** other objects are used for visualizing various states (hack for efficient updates) */
- ARM_HAS_VIZ_DEPS = (1<<14),
+ ARM_HAS_VIZ_DEPS = (1 << 14),
} eArmature_Flag;
/* armature->drawtype */
@@ -175,24 +175,24 @@ typedef enum eArmature_VertDeformer {
/* armature->deformflag */
typedef enum eArmature_DeformFlag {
- ARM_DEF_VGROUP = (1<<0),
- ARM_DEF_ENVELOPE = (1<<1),
- ARM_DEF_QUATERNION = (1<<2),
+ ARM_DEF_VGROUP = (1 << 0),
+ ARM_DEF_ENVELOPE = (1 << 1),
+ ARM_DEF_QUATERNION = (1 << 2),
#ifdef DNA_DEPRECATED
- ARM_DEF_B_BONE_REST = (1<<3), /* deprecated */
+ ARM_DEF_B_BONE_REST = (1 << 3), /* deprecated */
#endif
- ARM_DEF_INVERT_VGROUP = (1<<4),
+ ARM_DEF_INVERT_VGROUP = (1 << 4),
} eArmature_DeformFlag;
/* armature->pathflag */
// XXX deprecated... old animation system (armature only viz)
#ifdef DNA_DEPRECATED
typedef enum eArmature_PathFlag {
- ARM_PATH_FNUMS = (1<<0),
- ARM_PATH_KFRAS = (1<<1),
- ARM_PATH_HEADS = (1<<2),
- ARM_PATH_ACFRA = (1<<3),
- ARM_PATH_KFNOS = (1<<4),
+ ARM_PATH_FNUMS = (1 << 0),
+ ARM_PATH_KFRAS = (1 << 1),
+ ARM_PATH_HEADS = (1 << 2),
+ ARM_PATH_ACFRA = (1 << 3),
+ ARM_PATH_KFNOS = (1 << 4),
} eArmature_PathFlag;
#endif
diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h
index 6a0a19fa44c..6c68ca69363 100644
--- a/source/blender/makesdna/DNA_boid_types.h
+++ b/source/blender/makesdna/DNA_boid_types.h
@@ -186,7 +186,7 @@ typedef struct BoidState {
//typedef struct BoidSimulationData {
// ListBase signal_defines;/* list of defined signals */
// ListBase signals[20]; /* gathers signals from all channels */
-// struct KDTree *signaltrees[20];
+// struct KDTree_3d *signaltrees[20];
// char channel_names[20][32];
// int last_signal_id; /* used for incrementing signal ids */
// int flag; /* switches for drawing stuff */
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index b367c141581..4bfbb3655af 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -83,23 +83,25 @@ typedef struct BrushGpencilSettings {
float fill_threshold;
/** Number of pixel to consider the leak is too small (x 2). */
short fill_leak;
- char _pad1[6];
+ /** Fill zoom factor */
+ short fill_factor;
+ char _pad_1[4];
/** Number of simplify steps. */
- int fill_simplylvl;
+ int fill_simplylvl;
/** Type of control lines drawing mode. */
- int fill_draw_mode;
+ int fill_draw_mode;
/** Icon identifier. */
- int icon_id;
+ int icon_id;
/** Maximum distance before generate new point for very fast mouse movements. */
- int input_samples;
+ int input_samples;
/** Random factor for UV rotation. */
float uv_random;
/** Moved to 'Brush.gpencil_tool'. */
- int brush_type DNA_DEPRECATED;
+ int brush_type DNA_DEPRECATED;
/** Soft, hard or stroke. */
- int eraser_mode;
+ int eraser_mode;
/** Smooth while drawing factor. */
float active_smooth;
/** Factor to apply to strength for soft eraser. */
@@ -356,13 +358,13 @@ typedef enum eBrushGradientSourceFill {
/* Brush.flag */
typedef enum eBrushFlags {
BRUSH_AIRBRUSH = (1 << 0),
- BRUSH_FLAG_DEPRECATED_1 = (1 << 1), /* cleared */
+ BRUSH_FLAG_UNUSED_1 = (1 << 1), /* cleared */
BRUSH_ALPHA_PRESSURE = (1 << 2),
BRUSH_SIZE_PRESSURE = (1 << 3),
BRUSH_JITTER_PRESSURE = (1 << 4),
BRUSH_SPACING_PRESSURE = (1 << 5),
- BRUSH_FLAG_DEPRECATED_6 = (1 << 6), /* cleared */
- BRUSH_FLAG_DEPRECATED_7 = (1 << 7), /* cleared */
+ BRUSH_FLAG_UNUSED_6 = (1 << 6), /* cleared */
+ BRUSH_FLAG_UNUSED_7 = (1 << 7), /* cleared */
BRUSH_ANCHORED = (1 << 8),
BRUSH_DIR_IN = (1 << 9),
BRUSH_SPACE = (1 << 10),
@@ -372,7 +374,7 @@ typedef enum eBrushFlags {
BRUSH_LOCK_ALPHA = (1 << 14),
BRUSH_ORIGINAL_NORMAL = (1 << 15),
BRUSH_OFFSET_PRESSURE = (1 << 16),
- BRUSH_FLAG_DEPRECATED_17 = (1 << 17), /* cleared */
+ BRUSH_FLAG_UNUSED_17 = (1 << 17), /* cleared */
BRUSH_SPACE_ATTEN = (1 << 18),
BRUSH_ADAPTIVE_SPACE = (1 << 19),
BRUSH_LOCK_SIZE = (1 << 20),
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index b6fd57d1663..51ff301abf2 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -114,7 +114,7 @@ typedef struct bConstraintTarget {
/* bConstraintTarget -> flag */
typedef enum eConstraintTargetFlag {
/** temporary target-struct that needs to be freed after use */
- CONSTRAINT_TAR_TEMP = (1<<0),
+ CONSTRAINT_TAR_TEMP = (1 << 0),
} eConstraintTargetFlag;
/* bConstraintTarget/bConstraintOb -> type */
@@ -666,26 +666,26 @@ typedef enum eBConstraint_Types {
} eBConstraint_Types;
/* bConstraint->flag */
-/* flags 0x2 (1<<1) and 0x8 (1<<3) were used in past */
-/* flag 0x20 (1<<5) was used to indicate that a constraint was evaluated
+/* flags 0x2 (1 << 1) and 0x8 (1 << 3) were used in past */
+/* flag 0x20 (1 << 5) was used to indicate that a constraint was evaluated
* using a 'local' hack for posebones only. */
typedef enum eBConstraint_Flags {
/* expand for UI */
- CONSTRAINT_EXPAND = (1<<0),
+ CONSTRAINT_EXPAND = (1 << 0),
/* pre-check for illegal object name or bone name */
- CONSTRAINT_DISABLE = (1<<2),
+ CONSTRAINT_DISABLE = (1 << 2),
/* to indicate which Ipo should be shown, maybe for 3d access later too */
- CONSTRAINT_ACTIVE = (1<<4),
+ CONSTRAINT_ACTIVE = (1 << 4),
/* to indicate that the owner's space should only be changed into ownspace, but not out of it */
- CONSTRAINT_SPACEONCE = (1<<6),
+ CONSTRAINT_SPACEONCE = (1 << 6),
/* influence ipo is on constraint itself, not in action channel */
- CONSTRAINT_OWN_IPO = (1<<7),
+ CONSTRAINT_OWN_IPO = (1 << 7),
/* indicates that constraint was added locally (i.e. didn't come from the proxy-lib) */
- CONSTRAINT_PROXY_LOCAL = (1<<8),
+ CONSTRAINT_PROXY_LOCAL = (1 << 8),
/* indicates that constraint is temporarily disabled (only used in GE) */
- CONSTRAINT_OFF = (1<<9),
+ CONSTRAINT_OFF = (1 << 9),
/* use bbone curve shape when calculating headtail values (also used by dependency graph!) */
- CONSTRAINT_BBONE_SHAPE = (1<<10),
+ CONSTRAINT_BBONE_SHAPE = (1 << 10),
/* That constraint has been inserted in local override (i.e. it can be fully edited!). */
CONSTRAINT_STATICOVERRIDE_LOCAL = (1 << 11),
/* use full transformation (not just segment locations) - only set at runtime */
@@ -694,60 +694,59 @@ typedef enum eBConstraint_Flags {
/* bConstraint->ownspace/tarspace */
typedef enum eBConstraint_SpaceTypes {
- /* default for all - worldspace */
+ /** Default for all - worldspace. */
CONSTRAINT_SPACE_WORLD = 0,
- /* for objects (relative to parent/without parent influence),
- * for bones (along normals of bone, without parent/restpositions)
- */
+ /** For objects (relative to parent/without parent influence),
+ * for bones (along normals of bone, without parent/restpositions). */
CONSTRAINT_SPACE_LOCAL = 1,
- /* for posechannels - pose space */
+ /** For posechannels - pose space. */
CONSTRAINT_SPACE_POSE = 2,
- /* for posechannels - local with parent */
+ /** For posechannels - local with parent. */
CONSTRAINT_SPACE_PARLOCAL = 3,
- /* for files from between 2.43-2.46 (should have been parlocal) */
+ /** For files from between 2.43-2.46 (should have been parlocal). */
CONSTRAINT_SPACE_INVALID = 4 /* do not exchange for anything! */
} eBConstraint_SpaceTypes;
/* bConstraintChannel.flag */
// XXX deprecated... old AnimSys
typedef enum eConstraintChannel_Flags {
- CONSTRAINT_CHANNEL_SELECT = (1<<0),
- CONSTRAINT_CHANNEL_PROTECTED = (1<<1),
+ CONSTRAINT_CHANNEL_SELECT = (1 << 0),
+ CONSTRAINT_CHANNEL_PROTECTED = (1 << 1),
} eConstraintChannel_Flags;
/* -------------------------------------- */
/* bRotateLikeConstraint.flag */
typedef enum eCopyRotation_Flags {
- ROTLIKE_X = (1<<0),
- ROTLIKE_Y = (1<<1),
- ROTLIKE_Z = (1<<2),
- ROTLIKE_X_INVERT = (1<<4),
- ROTLIKE_Y_INVERT = (1<<5),
- ROTLIKE_Z_INVERT = (1<<6),
- ROTLIKE_OFFSET = (1<<7),
+ ROTLIKE_X = (1 << 0),
+ ROTLIKE_Y = (1 << 1),
+ ROTLIKE_Z = (1 << 2),
+ ROTLIKE_X_INVERT = (1 << 4),
+ ROTLIKE_Y_INVERT = (1 << 5),
+ ROTLIKE_Z_INVERT = (1 << 6),
+ ROTLIKE_OFFSET = (1 << 7),
} eCopyRotation_Flags;
/* bLocateLikeConstraint.flag */
typedef enum eCopyLocation_Flags {
- LOCLIKE_X = (1<<0),
- LOCLIKE_Y = (1<<1),
- LOCLIKE_Z = (1<<2),
- /* LOCLIKE_TIP is a deprecated option... use headtail=1.0f instead */
- LOCLIKE_TIP = (1<<3),
- LOCLIKE_X_INVERT = (1<<4),
- LOCLIKE_Y_INVERT = (1<<5),
- LOCLIKE_Z_INVERT = (1<<6),
- LOCLIKE_OFFSET = (1<<7),
+ LOCLIKE_X = (1 << 0),
+ LOCLIKE_Y = (1 << 1),
+ LOCLIKE_Z = (1 << 2),
+ /** LOCLIKE_TIP is a deprecated option... use headtail=1.0f instead */
+ LOCLIKE_TIP = (1 << 3),
+ LOCLIKE_X_INVERT = (1 << 4),
+ LOCLIKE_Y_INVERT = (1 << 5),
+ LOCLIKE_Z_INVERT = (1 << 6),
+ LOCLIKE_OFFSET = (1 << 7),
} eCopyLocation_Flags;
/* bSizeLikeConstraint.flag */
typedef enum eCopyScale_Flags {
- SIZELIKE_X = (1<<0),
- SIZELIKE_Y = (1<<1),
- SIZELIKE_Z = (1<<2),
- SIZELIKE_OFFSET = (1<<3),
- SIZELIKE_MULTIPLY = (1<<4),
+ SIZELIKE_X = (1 << 0),
+ SIZELIKE_Y = (1 << 1),
+ SIZELIKE_Z = (1 << 2),
+ SIZELIKE_OFFSET = (1 << 3),
+ SIZELIKE_MULTIPLY = (1 << 4),
} eCopyScale_Flags;
/* bTransformConstraint.to/from */
@@ -813,14 +812,14 @@ typedef enum eShrinkwrap_Flags {
/* FollowPath flags */
typedef enum eFollowPath_Flags {
- FOLLOWPATH_FOLLOW = (1<<0),
- FOLLOWPATH_STATIC = (1<<1),
- FOLLOWPATH_RADIUS = (1<<2),
+ FOLLOWPATH_FOLLOW = (1 << 0),
+ FOLLOWPATH_STATIC = (1 << 1),
+ FOLLOWPATH_RADIUS = (1 << 2),
} eFollowPath_Flags;
/* bTrackToConstraint->flags */
typedef enum eTrackTo_Flags {
- TARGET_Z_UP = (1<<0),
+ TARGET_Z_UP = (1 << 0),
} eTrackTo_Flags;
/* Stretch To Constraint -> volmode */
@@ -848,30 +847,30 @@ typedef enum eClampTo_Modes {
/* ClampTo Constraint ->flag2 */
typedef enum eClampTo_Flags {
- CLAMPTO_CYCLIC = (1<<0),
+ CLAMPTO_CYCLIC = (1 << 0),
} eClampTo_Flags;
/* bKinematicConstraint->flag */
typedef enum eKinematic_Flags {
- CONSTRAINT_IK_TIP = (1<<0),
- CONSTRAINT_IK_ROT = (1<<1),
+ CONSTRAINT_IK_TIP = (1 << 0),
+ CONSTRAINT_IK_ROT = (1 << 1),
/* targetless */
- CONSTRAINT_IK_AUTO = (1<<2),
+ CONSTRAINT_IK_AUTO = (1 << 2),
/* autoik */
- CONSTRAINT_IK_TEMP = (1<<3),
- CONSTRAINT_IK_STRETCH = (1<<4),
- CONSTRAINT_IK_POS = (1<<5),
- CONSTRAINT_IK_SETANGLE = (1<<6),
- CONSTRAINT_IK_GETANGLE = (1<<7),
+ CONSTRAINT_IK_TEMP = (1 << 3),
+ CONSTRAINT_IK_STRETCH = (1 << 4),
+ CONSTRAINT_IK_POS = (1 << 5),
+ CONSTRAINT_IK_SETANGLE = (1 << 6),
+ CONSTRAINT_IK_GETANGLE = (1 << 7),
/* limit axis */
- CONSTRAINT_IK_NO_POS_X = (1<<8),
- CONSTRAINT_IK_NO_POS_Y = (1<<9),
- CONSTRAINT_IK_NO_POS_Z = (1<<10),
- CONSTRAINT_IK_NO_ROT_X = (1<<11),
- CONSTRAINT_IK_NO_ROT_Y = (1<<12),
- CONSTRAINT_IK_NO_ROT_Z = (1<<13),
+ CONSTRAINT_IK_NO_POS_X = (1 << 8),
+ CONSTRAINT_IK_NO_POS_Y = (1 << 9),
+ CONSTRAINT_IK_NO_POS_Z = (1 << 10),
+ CONSTRAINT_IK_NO_ROT_X = (1 << 11),
+ CONSTRAINT_IK_NO_ROT_Y = (1 << 12),
+ CONSTRAINT_IK_NO_ROT_Z = (1 << 13),
/* axis relative to target */
- CONSTRAINT_IK_TARGETAXIS = (1<<14),
+ CONSTRAINT_IK_TARGETAXIS = (1 << 14),
} eKinematic_Flags;
/* bSplineIKConstraint->flag */
@@ -907,52 +906,52 @@ typedef enum eSplineIK_XZScaleModes {
/* bArmatureConstraint -> flag */
typedef enum eArmature_Flags {
/** use dual quaternion blending */
- CONSTRAINT_ARMATURE_QUATERNION = (1<<0),
+ CONSTRAINT_ARMATURE_QUATERNION = (1 << 0),
/** use envelopes */
- CONSTRAINT_ARMATURE_ENVELOPE = (1<<1),
+ CONSTRAINT_ARMATURE_ENVELOPE = (1 << 1),
/** use current bone location */
- CONSTRAINT_ARMATURE_CUR_LOCATION = (1<<2),
+ CONSTRAINT_ARMATURE_CUR_LOCATION = (1 << 2),
} eArmature_Flags;
/* MinMax (floor) flags */
typedef enum eFloor_Flags {
- MINMAX_STICKY = (1<<0),
- MINMAX_STUCK = (1<<1),
- MINMAX_USEROT = (1<<2),
+ MINMAX_STICKY = (1 << 0),
+ MINMAX_STUCK = (1 << 1),
+ MINMAX_USEROT = (1 << 2),
} eFloor_Flags;
/* transform limiting constraints -> flag2 */
typedef enum eTransformLimits_Flags2 {
/* not used anymore - for older Limit Location constraints only */
- LIMIT_NOPARENT = (1<<0),
+ LIMIT_NOPARENT = (1 << 0),
/* for all Limit constraints - allow to be used during transform? */
- LIMIT_TRANSFORM = (1<<1),
+ LIMIT_TRANSFORM = (1 << 1),
} eTransformLimits_Flags2;
/* transform limiting constraints -> flag (own flags) */
typedef enum eTransformLimits_Flags {
- LIMIT_XMIN = (1<<0),
- LIMIT_XMAX = (1<<1),
- LIMIT_YMIN = (1<<2),
- LIMIT_YMAX = (1<<3),
- LIMIT_ZMIN = (1<<4),
- LIMIT_ZMAX = (1<<5),
+ LIMIT_XMIN = (1 << 0),
+ LIMIT_XMAX = (1 << 1),
+ LIMIT_YMIN = (1 << 2),
+ LIMIT_YMAX = (1 << 3),
+ LIMIT_ZMIN = (1 << 4),
+ LIMIT_ZMAX = (1 << 5),
} eTransformLimits_Flags;
/* limit rotation constraint -> flag (own flags) */
typedef enum eRotLimit_Flags {
- LIMIT_XROT = (1<<0),
- LIMIT_YROT = (1<<1),
- LIMIT_ZROT = (1<<2),
+ LIMIT_XROT = (1 << 0),
+ LIMIT_YROT = (1 << 1),
+ LIMIT_ZROT = (1 << 2),
} eRotLimit_Flags;
/* distance limit constraint */
/* bDistLimitConstraint->flag */
typedef enum eDistLimit_Flag {
/* "soft" cushion effect when reaching the limit sphere */ // NOT IMPLEMENTED!
- LIMITDIST_USESOFT = (1<<0),
+ LIMITDIST_USESOFT = (1 << 0),
/* as for all Limit constraints - allow to be used during transform? */
- LIMITDIST_TRANSFORM = (1<<1),
+ LIMITDIST_TRANSFORM = (1 << 1),
} eDistLimit_Flag;
/* bDistLimitConstraint->mode */
@@ -964,21 +963,21 @@ typedef enum eDistLimit_Modes {
/* python constraint -> flag */
typedef enum ePyConstraint_Flags {
- PYCON_USETARGETS = (1<<0),
- PYCON_SCRIPTERROR = (1<<1),
+ PYCON_USETARGETS = (1 << 0),
+ PYCON_SCRIPTERROR = (1 << 1),
} ePyConstraint_Flags;
/* ChildOf Constraint -> flag */
typedef enum eChildOf_Flags {
- CHILDOF_LOCX = (1<<0),
- CHILDOF_LOCY = (1<<1),
- CHILDOF_LOCZ = (1<<2),
- CHILDOF_ROTX = (1<<3),
- CHILDOF_ROTY = (1<<4),
- CHILDOF_ROTZ = (1<<5),
- CHILDOF_SIZEX = (1<<6),
- CHILDOF_SIZEY = (1<<7),
- CHILDOF_SIZEZ = (1<<8),
+ CHILDOF_LOCX = (1 << 0),
+ CHILDOF_LOCY = (1 << 1),
+ CHILDOF_LOCZ = (1 << 2),
+ CHILDOF_ROTX = (1 << 3),
+ CHILDOF_ROTY = (1 << 4),
+ CHILDOF_ROTZ = (1 << 5),
+ CHILDOF_SIZEX = (1 << 6),
+ CHILDOF_SIZEY = (1 << 7),
+ CHILDOF_SIZEZ = (1 << 8),
CHILDOF_ALL = 511,
} eChildOf_Flags;
@@ -1006,15 +1005,15 @@ typedef enum ePivotConstraint_Axis {
/* settings for Pivot Constraint in general */
typedef enum ePivotConstraint_Flag {
/* offset is to be interpreted as being a fixed-point in space */
- PIVOTCON_FLAG_OFFSET_ABS = (1<<0),
+ PIVOTCON_FLAG_OFFSET_ABS = (1 << 0),
/* rotation-based activation uses negative rotation to drive result */
- PIVOTCON_FLAG_ROTACT_NEG = (1<<1),
+ PIVOTCON_FLAG_ROTACT_NEG = (1 << 1),
} ePivotConstraint_Flag;
typedef enum eFollowTrack_Flags {
- FOLLOWTRACK_ACTIVECLIP = (1<<0),
- FOLLOWTRACK_USE_3D_POSITION = (1<<1),
- FOLLOWTRACK_USE_UNDISTORTION = (1<<2),
+ FOLLOWTRACK_ACTIVECLIP = (1 << 0),
+ FOLLOWTRACK_USE_3D_POSITION = (1 << 1),
+ FOLLOWTRACK_USE_UNDISTORTION = (1 << 2),
} eFollowTrack_Flags;
typedef enum eFollowTrack_FrameMethod {
@@ -1025,12 +1024,12 @@ typedef enum eFollowTrack_FrameMethod {
/* CameraSolver Constraint -> flag */
typedef enum eCameraSolver_Flags {
- CAMERASOLVER_ACTIVECLIP = (1<<0),
+ CAMERASOLVER_ACTIVECLIP = (1 << 0),
} eCameraSolver_Flags;
/* ObjectSolver Constraint -> flag */
typedef enum eObjectSolver_Flags {
- OBJECTSOLVER_ACTIVECLIP = (1<<0),
+ OBJECTSOLVER_ACTIVECLIP = (1 << 0),
} eObjectSolver_Flags;
/* ObjectSolver Constraint -> flag */
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index d432209575b..1ee81b56636 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -490,6 +490,10 @@ typedef enum eBezTriple_KeyframeType {
/* checks if the given BezTriple is selected */
#define BEZT_ISSEL_ANY(bezt) \
(((bezt)->f2 & SELECT) || ((bezt)->f1 & SELECT) || ((bezt)->f3 & SELECT))
+#define BEZT_ISSEL_ALL(bezt) \
+ (((bezt)->f2 & SELECT) && ((bezt)->f1 & SELECT) && ((bezt)->f3 & SELECT))
+#define BEZT_ISSEL_ALL_HIDDENHANDLES(v3d, bezt) \
+ ((((v3d) != NULL) && ((v3d)->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0) ? (bezt)->f2 & SELECT : BEZT_ISSEL_ALL(bezt))
#define BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt) \
((((v3d) != NULL) && ((v3d)->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0) ? (bezt)->f2 & SELECT : BEZT_ISSEL_ANY(bezt))
diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h
index 91412044e0e..10d18684413 100644
--- a/source/blender/makesdna/DNA_customdata_types.h
+++ b/source/blender/makesdna/DNA_customdata_types.h
@@ -108,7 +108,7 @@ typedef enum CustomDataType {
CD_PROP_INT = 11,
CD_PROP_STR = 12,
CD_ORIGSPACE = 13, /* for modifier stack face location mapping */
- CD_ORCO = 14,
+ CD_ORCO = 14, /* undeformed vertex coordinates, normalized to 0..1 range */
/* CD_MTEXPOLY = 15, */ /* deprecated */
CD_MLOOPUV = 16,
CD_MLOOPCOL = 17,
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index 9f585ac21af..15b270538ef 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -91,6 +91,14 @@ enum {
MOD_DPAINT_INITIAL_VERTEXCOLOR = 3,
};
+/* Is stored in ModifierData.runtime. */
+#
+#
+typedef struct DynamicPaintRuntime {
+ struct Mesh *canvas_mesh;
+ struct Mesh *brush_mesh;
+} DynamicPaintRuntime;
+
typedef struct DynamicPaintSurface {
struct DynamicPaintSurface *next, *prev;
@@ -169,7 +177,6 @@ enum {
typedef struct DynamicPaintCanvasSettings {
/** For fast RNA access. */
struct DynamicPaintModifierData *pmd;
- struct Mesh *mesh;
struct ListBase surfaces;
short active_sur, flags;
@@ -248,7 +255,6 @@ enum {
typedef struct DynamicPaintBrushSettings {
/** For fast RNA access. */
struct DynamicPaintModifierData *pmd;
- struct Mesh *mesh;
struct ParticleSystem *psys;
int flags;
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index bd17d4e57dc..56e17fe9149 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -201,6 +201,7 @@ typedef struct bGPDstroke {
/** Vertex weight data. */
struct MDeformVert *dvert;
+ void *_pad3;
bGPDstroke_Runtime runtime;
char _pad2[4];
diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h
index bd0916c9b7e..e411e5f304e 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -90,8 +90,8 @@ typedef struct RenderSlot {
/* iuser->flag */
#define IMA_ANIM_ALWAYS (1 << 0)
-/* #define IMA_DEPRECATED_1 (1 << 1) */
-/* #define IMA_DEPRECATED_2 (1 << 2) */
+/* #define IMA_UNUSED_1 (1 << 1) */
+/* #define IMA_UNUSED_2 (1 << 2) */
#define IMA_NEED_FRAME_RECALC (1 << 3)
#define IMA_SHOW_STEREO (1 << 4)
@@ -165,16 +165,16 @@ typedef struct Image {
/* Image.flag */
enum {
- IMA_FLAG_DEPRECATED_0 = (1 << 0), /* cleared */
- IMA_FLAG_DEPRECATED_1 = (1 << 1), /* cleared */
+ IMA_FLAG_UNUSED_0 = (1 << 0), /* cleared */
+ IMA_FLAG_UNUSED_1 = (1 << 1), /* cleared */
#ifdef DNA_DEPRECATED
IMA_DO_PREMUL = (1 << 2),
#endif
- IMA_FLAG_DEPRECATED_4 = (1 << 4), /* cleared */
+ IMA_FLAG_UNUSED_4 = (1 << 4), /* cleared */
IMA_NOCOLLECT = (1 << 5),
- IMA_FLAG_DEPRECATED_6 = (1 << 6), /* cleared */
+ IMA_FLAG_UNUSED_6 = (1 << 6), /* cleared */
IMA_OLD_PREMUL = (1 << 7),
- IMA_FLAG_DEPRECATED_8 = (1 << 8), /* cleared */
+ IMA_FLAG_UNUSED_8 = (1 << 8), /* cleared */
IMA_USED_FOR_RENDER = (1 << 9),
/** For image user, but these flags are mixed. */
IMA_USER_FRAME_IN_RANGE = (1 << 10),
@@ -182,8 +182,8 @@ enum {
IMA_IGNORE_ALPHA = (1 << 12),
IMA_DEINTERLACE = (1 << 13),
IMA_USE_VIEWS = (1 << 14),
- IMA_FLAG_DEPRECATED_15 = (1 << 15), /* cleared */
- IMA_FLAG_DEPRECATED_16 = (1 << 16), /* cleared */
+ IMA_FLAG_UNUSED_15 = (1 << 15), /* cleared */
+ IMA_FLAG_UNUSED_16 = (1 << 16), /* cleared */
};
/* Image.gpuflag */
diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h
index b728e5081ba..9be5448a327 100644
--- a/source/blender/makesdna/DNA_ipo_types.h
+++ b/source/blender/makesdna/DNA_ipo_types.h
@@ -200,24 +200,24 @@ typedef struct Ipo {
#define MA_FRESTRAI 25
#define MA_ADD 26
-#define MA_MAP1 (1<<5)
-#define MA_MAP2 (1<<6)
-#define MA_MAP3 (1<<7)
-#define MA_MAP4 (1<<8)
-#define MA_MAP5 (1<<9)
-#define MA_MAP6 (1<<10)
-#define MA_MAP7 (1<<11)
-#define MA_MAP8 (1<<12)
-#define MA_MAP9 (1<<13)
-#define MA_MAP10 (1<<14)
-#define MA_MAP11 (1<<15)
-#define MA_MAP12 (1<<16)
-#define MA_MAP13 (1<<17)
-#define MA_MAP14 (1<<18)
-#define MA_MAP15 (1<<19)
-#define MA_MAP16 (1<<20)
-#define MA_MAP17 (1<<21)
-#define MA_MAP18 (1<<22)
+#define MA_MAP1 (1 << 5)
+#define MA_MAP2 (1 << 6)
+#define MA_MAP3 (1 << 7)
+#define MA_MAP4 (1 << 8)
+#define MA_MAP5 (1 << 9)
+#define MA_MAP6 (1 << 10)
+#define MA_MAP7 (1 << 11)
+#define MA_MAP8 (1 << 12)
+#define MA_MAP9 (1 << 13)
+#define MA_MAP10 (1 << 14)
+#define MA_MAP11 (1 << 15)
+#define MA_MAP12 (1 << 16)
+#define MA_MAP13 (1 << 17)
+#define MA_MAP14 (1 << 18)
+#define MA_MAP15 (1 << 19)
+#define MA_MAP16 (1 << 20)
+#define MA_MAP17 (1 << 21)
+#define MA_MAP18 (1 << 22)
/* ********** Texture Slots (MTex) ********** */
@@ -518,6 +518,6 @@ typedef struct Ipo {
/* driver->flag */
/* invalid flag: currently only used for buggy pydriver expressions */
-#define IPO_DRIVER_FLAG_INVALID (1<<0)
+#define IPO_DRIVER_FLAG_INVALID (1 << 0)
#endif
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 10834768c3f..718ca4f3b7d 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -301,7 +301,7 @@ enum {
enum {
MA_BL_HIDE_BACKFACE = (1 << 0),
MA_BL_SS_REFRACTION = (1 << 1),
- MA_BL_FLAG_DEPRECATED_2 = (1 << 2), /* cleared */
+ MA_BL_FLAG_UNUSED_2 = (1 << 2), /* cleared */
MA_BL_TRANSLUCENCY = (1 << 3),
};
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index 956fee97d40..0d43b14e252 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -189,6 +189,7 @@ typedef struct Mesh {
/** Deprecated multiresolution modeling data, only keep for loading old files. */
struct Multires *mr DNA_DEPRECATED;
+ void *_pad1;
Mesh_Runtime runtime;
} Mesh;
@@ -233,15 +234,15 @@ enum {
/* me->flag */
enum {
- ME_FLAG_DEPRECATED_0 = 1 << 0, /* cleared */
- ME_FLAG_DEPRECATED_1 = 1 << 1, /* cleared */
+ ME_FLAG_UNUSED_0 = 1 << 0, /* cleared */
+ ME_FLAG_UNUSED_1 = 1 << 1, /* cleared */
ME_TWOSIDED = 1 << 2,
- ME_FLAG_DEPRECATED_3 = 1 << 3, /* cleared */
- ME_FLAG_DEPRECATED_4 = 1 << 4, /* cleared */
+ ME_FLAG_UNUSED_3 = 1 << 3, /* cleared */
+ ME_FLAG_UNUSED_4 = 1 << 4, /* cleared */
ME_AUTOSMOOTH = 1 << 5,
- ME_FLAG_DEPRECATED_6 = 1 << 6, /* cleared */
- ME_FLAG_DEPRECATED_7 = 1 << 7, /* cleared */
- ME_FLAG_DEPRECATED_8 = 1 << 8, /* cleared */
+ ME_FLAG_UNUSED_6 = 1 << 6, /* cleared */
+ ME_FLAG_UNUSED_7 = 1 << 7, /* cleared */
+ ME_FLAG_UNUSED_8 = 1 << 8, /* cleared */
ME_DS_EXPAND = 1 << 9,
ME_SCULPT_DYNAMIC_TOPOLOGY = 1 << 10,
};
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 9ed879d10c5..5f86ee562f9 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -277,7 +277,7 @@ typedef struct MDisps {
unsigned int *hidden;
} MDisps;
-/** Multires structs kept for compatibility with old files **/
+/** Multires structs kept for compatibility with old files. */
typedef struct MultiresCol {
float a, r, g, b;
} MultiresCol;
@@ -326,7 +326,7 @@ typedef struct Multires {
char *edge_creases;
} Multires;
-/** End Multires **/
+/* End Multires */
typedef struct MRecast {
int i;
diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h
index f5bc9ef383a..92b6c6e3c5b 100644
--- a/source/blender/makesdna/DNA_meta_types.h
+++ b/source/blender/makesdna/DNA_meta_types.h
@@ -116,7 +116,7 @@ typedef struct MetaBall {
#define MB_UPDATE_NEVER 3
/* mb->flag2 */
-#define MB_DS_EXPAND (1<<0)
+#define MB_DS_EXPAND (1 << 0)
/* ml->type */
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index a2c19b198ef..8d198e06a23 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -114,6 +114,10 @@ typedef struct ModifierData {
char name[64];
char *error;
+
+ /* Pointer to a ModifierData in the original domain. */
+ struct ModifierData *orig_modifier_data;
+ void *runtime;
} ModifierData;
typedef enum {
@@ -167,8 +171,6 @@ typedef struct SubsurfModifierData {
/* TODO(sergey): Get rid of those with the old CCG subdivision code. */
void *emCache, *mCache;
- /* Cached subdivision surface descriptor, with topology and settings. */
- struct Subdiv *subdiv;
} SubsurfModifierData;
typedef struct LatticeModifierData {
@@ -953,8 +955,6 @@ typedef struct MultiresModifierData {
short quality;
short uv_smooth;
char _pad2[4];
- struct Subdiv *subdiv;
- void *_pad3;
} MultiresModifierData;
typedef enum {
@@ -1550,7 +1550,7 @@ typedef struct TriangulateModifierData {
int flag;
int quad_method;
int ngon_method;
- char _pad[4];
+ int min_vertices;
} TriangulateModifierData;
/* TriangulateModifierData.flag */
diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h
index fb3b3f994b4..342bad4e067 100644
--- a/source/blender/makesdna/DNA_movieclip_types.h
+++ b/source/blender/makesdna/DNA_movieclip_types.h
@@ -172,7 +172,7 @@ enum {
enum {
MCLIP_USE_PROXY = (1 << 0),
MCLIP_USE_PROXY_CUSTOM_DIR = (1 << 1),
- /* MCLIP_CUSTOM_START_FRAME = (1<<2), */ /* UNUSED */
+ /* MCLIP_CUSTOM_START_FRAME = (1 << 2), */ /* UNUSED */
MCLIP_DATA_EXPAND = (1 << 3),
MCLIP_TIMECODE_FLAGS = (MCLIP_USE_PROXY | MCLIP_USE_PROXY_CUSTOM_DIR),
@@ -190,6 +190,8 @@ enum {
/* MovieClip->render_flag */
enum {
MCLIP_PROXY_RENDER_UNDISTORT = 1,
+ /** Use original, if proxy is not found. */
+ MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER = 2,
};
#endif
diff --git a/source/blender/makesdna/DNA_nla_types.h b/source/blender/makesdna/DNA_nla_types.h
index f1b1ab21116..4095a5dc99b 100644
--- a/source/blender/makesdna/DNA_nla_types.h
+++ b/source/blender/makesdna/DNA_nla_types.h
@@ -94,20 +94,20 @@ typedef struct bActionStrip {
/* strip->flag */
typedef enum eActStrip_Flag {
- ACTSTRIP_SELECT = (1<<0),
- ACTSTRIP_USESTRIDE = (1<<1),
+ ACTSTRIP_SELECT = (1 << 0),
+ ACTSTRIP_USESTRIDE = (1 << 1),
/* Not implemented. Is not used anywhere */
- ACTSTRIP_BLENDTONEXT = (1<<2),
- ACTSTRIP_HOLDLASTFRAME = (1<<3),
- ACTSTRIP_ACTIVE = (1<<4),
- ACTSTRIP_LOCK_ACTION = (1<<5),
- ACTSTRIP_MUTE = (1<<6),
+ ACTSTRIP_BLENDTONEXT = (1 << 2),
+ ACTSTRIP_HOLDLASTFRAME = (1 << 3),
+ ACTSTRIP_ACTIVE = (1 << 4),
+ ACTSTRIP_LOCK_ACTION = (1 << 5),
+ ACTSTRIP_MUTE = (1 << 6),
/* This has yet to be implemented. To indicate that a strip should be played backwards */
- ACTSTRIP_REVERSE = (1<<7),
- ACTSTRIP_CYCLIC_USEX = (1<<8),
- ACTSTRIP_CYCLIC_USEY = (1<<9),
- ACTSTRIP_CYCLIC_USEZ = (1<<10),
- ACTSTRIP_AUTO_BLENDS = (1<<11),
+ ACTSTRIP_REVERSE = (1 << 7),
+ ACTSTRIP_CYCLIC_USEX = (1 << 8),
+ ACTSTRIP_CYCLIC_USEY = (1 << 9),
+ ACTSTRIP_CYCLIC_USEZ = (1 << 10),
+ ACTSTRIP_AUTO_BLENDS = (1 << 11),
} eActStrip_Flag;
#endif
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index a255646b734..0f06aed8bca 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -307,31 +307,31 @@ typedef struct bNode {
#define NODE_MUTED 512
// #define NODE_CUSTOM_NAME 1024 /* deprecated! */
/* group node types: use const outputs by default */
-#define NODE_CONST_OUTPUT (1<<11)
+#define NODE_CONST_OUTPUT (1 << 11)
/* node is always behind others */
-#define NODE_BACKGROUND (1<<12)
+#define NODE_BACKGROUND (1 << 12)
/* automatic flag for nodes included in transforms */
-#define NODE_TRANSFORM (1<<13)
+#define NODE_TRANSFORM (1 << 13)
/* node is active texture */
/* note: take care with this flag since its possible it gets
* `stuck` inside/outside the active group - which makes buttons
* window texture not update, we try to avoid it by clearing the
* flag when toggling group editing - Campbell */
-#define NODE_ACTIVE_TEXTURE (1<<14)
+#define NODE_ACTIVE_TEXTURE (1 << 14)
/* use a custom color for the node */
-#define NODE_CUSTOM_COLOR (1<<15)
+#define NODE_CUSTOM_COLOR (1 << 15)
/* Node has been initialized
* This flag indicates the node->typeinfo->init function has been called.
* In case of undefined type at creation time this can be delayed until
* until the node type is registered.
*/
-#define NODE_INIT (1<<16)
+#define NODE_INIT (1 << 16)
/* do recalc of output, used to skip recalculation of unwanted
* composite out nodes when editing tree
*/
-#define NODE_DO_OUTPUT_RECALC (1<<17)
+#define NODE_DO_OUTPUT_RECALC (1 << 17)
/* node->update */
/* XXX NODE_UPDATE is a generic update flag. More fine-grained updates
diff --git a/source/blender/makesdna/DNA_object_fluidsim_types.h b/source/blender/makesdna/DNA_object_fluidsim_types.h
index 534eaf3c780..843a9ae5c5b 100644
--- a/source/blender/makesdna/DNA_object_fluidsim_types.h
+++ b/source/blender/makesdna/DNA_object_fluidsim_types.h
@@ -152,25 +152,25 @@ typedef struct FluidsimSettings {
#define OB_FLUIDSIM_CONTROL 128
#define OB_TYPEFLAG_START 7
-#define OB_FSGEO_THIN (1<<(OB_TYPEFLAG_START+1))
-#define OB_FSBND_NOSLIP (1<<(OB_TYPEFLAG_START+2))
-#define OB_FSBND_PARTSLIP (1<<(OB_TYPEFLAG_START+3))
-#define OB_FSBND_FREESLIP (1<<(OB_TYPEFLAG_START+4))
-#define OB_FSINFLOW_LOCALCOORD (1<<(OB_TYPEFLAG_START+5))
+#define OB_FSGEO_THIN (1 << (OB_TYPEFLAG_START + 1))
+#define OB_FSBND_NOSLIP (1 << (OB_TYPEFLAG_START + 2))
+#define OB_FSBND_PARTSLIP (1 << (OB_TYPEFLAG_START + 3))
+#define OB_FSBND_FREESLIP (1 << (OB_TYPEFLAG_START + 4))
+#define OB_FSINFLOW_LOCALCOORD (1 << (OB_TYPEFLAG_START + 5))
/* surface generation flag (part of enabling chapter 6 of
* "Free Surface Flows with Moving and Deforming Objects for LBM") */
-#define OB_FSSG_NOOBS (1<<(OB_TYPEFLAG_START+6))
+#define OB_FSSG_NOOBS (1 << (OB_TYPEFLAG_START + 6))
// guiDisplayMode particle flags
#define OB_FSDOM_GEOM 1
#define OB_FSDOM_PREVIEW 2
#define OB_FSDOM_FINAL 3
-#define OB_FSPART_BUBBLE (1<<1)
-#define OB_FSPART_DROP (1<<2)
-#define OB_FSPART_NEWPART (1<<3)
-#define OB_FSPART_FLOAT (1<<4)
-#define OB_FSPART_TRACER (1<<5)
+#define OB_FSPART_BUBBLE (1 << 1)
+#define OB_FSPART_DROP (1 << 2)
+#define OB_FSPART_NEWPART (1 << 3)
+#define OB_FSPART_FLOAT (1 << 4)
+#define OB_FSPART_TRACER (1 << 5)
// new fluid bit flags for fss->flags
#define OB_FLUIDSIM_REVERSE (1 << 0)
diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h
index c7bb3dad809..4b276a0aa85 100644
--- a/source/blender/makesdna/DNA_object_force_types.h
+++ b/source/blender/makesdna/DNA_object_force_types.h
@@ -186,7 +186,7 @@ typedef struct EffectorWeights {
#define EFF_WEIGHT_DO_HAIR 1
/* Point cache file data types:
- * - used as (1<<flag) so poke jahka if you reach the limit of 15
+ * - used as (1 << flag) so poke jahka if you reach the limit of 15
* - to add new data types update:
* - BKE_ptcache_data_size()
* - ptcache_file_init_pointers()
@@ -272,11 +272,15 @@ typedef struct PointCache {
char info[64];
/** File path, 1024 = FILE_MAX. */
char path[1024];
+
/**
- * Array of length endframe-startframe+1 with flags to indicate cached frames.
+ * Array of length `endframe - startframe + 1` with flags to indicate cached frames.
* Can be later used for other per frame flags too if needed.
*/
char *cached_frames;
+ int cached_frames_len;
+ char _pad1[4];
+
struct ListBase mem_cache;
struct PTCacheEdit *edit;
@@ -378,18 +382,18 @@ typedef struct SoftBody {
/* self collision*/
/** Fixed collision ball size if > 0. */
float colball;
- /** Cooling down collision response . */
+ /** Cooling down collision response. */
float balldamp;
- /** Pressure the ball is loaded with . */
+ /** Pressure the ball is loaded with. */
float ballstiff;
short sbc_mode;
- short aeroedge,
- minloops,
- maxloops,
- choke,
- solver_ID,
- plastic, springpreload
- ;
+ short aeroedge;
+ short minloops;
+ short maxloops;
+ short choke;
+ short solver_ID;
+ short plastic;
+ short springpreload;
/** Scratchpad/cache on live time not saved in file. */
struct SBScratch *scratch;
@@ -446,7 +450,7 @@ typedef struct SoftBody {
/** used for (simple) force */
#define PFIELD_GRAVITATION (1 << 18)
/** Enable cloth collision side detection based on normal. */
-#define PFIELD_CLOTH_USE_CULLING (1<< 19)
+#define PFIELD_CLOTH_USE_CULLING (1 << 19)
/** Replace collision direction with collider normal. */
#define PFIELD_CLOTH_USE_NORMAL (1 << 20)
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 3b09801b4b7..9f2118d9cc0 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -170,6 +170,7 @@ typedef struct Object_Runtime {
struct ObjectBBoneDeform *cached_bbone_deformation;
+ void *_pad1;
} Object_Runtime;
typedef struct Object {
@@ -372,7 +373,8 @@ typedef struct Object {
ImageUser *iuser;
char empty_image_visibility_flag;
char empty_image_depth;
- char _pad8[2];
+ char empty_image_flag;
+ char _pad8[1];
int select_id;
@@ -475,20 +477,20 @@ enum {
/* (short) transflag */
enum {
- OB_TRANSFLAG_DEPRECATED_0 = 1 << 0, /* cleared */
- OB_TRANSFLAG_DEPRECATED_1 = 1 << 1, /* cleared */
+ OB_TRANSFLAG_UNUSED_0 = 1 << 0, /* cleared */
+ OB_TRANSFLAG_UNUSED_1 = 1 << 1, /* cleared */
OB_NEG_SCALE = 1 << 2,
- OB_TRANSFLAG_DEPRECATED_3 = 1 << 3, /* cleared */
+ OB_TRANSFLAG_UNUSED_3 = 1 << 3, /* cleared */
OB_DUPLIVERTS = 1 << 4,
OB_DUPLIROT = 1 << 5,
- OB_TRANSFLAG_DEPRECATED_6 = 1 << 6, /* cleared */
+ OB_TRANSFLAG_UNUSED_6 = 1 << 6, /* cleared */
/* runtime, calculate derivedmesh for dupli before it's used */
OB_DUPLICALCDERIVED = 1 << 7,
OB_DUPLICOLLECTION = 1 << 8,
OB_DUPLIFACES = 1 << 9,
OB_DUPLIFACES_SCALE = 1 << 10,
OB_DUPLIPARTS = 1 << 11,
- OB_TRANSFLAG_DEPRECATED_12 = 1 << 12, /* cleared */
+ OB_TRANSFLAG_UNUSED_12 = 1 << 12, /* cleared */
/* runtime constraints disable */
OB_NO_CONSTRAINTS = 1 << 13,
/* hack to work around particle issue */
@@ -597,8 +599,8 @@ enum {
#define OB_FROMDUPLI (1 << 9)
#define OB_DONE (1 << 10) /* unknown state, clear before use */
#ifdef DNA_DEPRECATED_ALLOW
-# define OB_FLAG_DEPRECATED_11 (1 << 11) /* cleared */
-# define OB_FLAG_DEPRECATED_12 (1 << 12) /* cleared */
+# define OB_FLAG_UNUSED_11 (1 << 11) /* cleared */
+# define OB_FLAG_UNUSED_12 (1 << 12) /* cleared */
#endif
/* ob->restrictflag */
@@ -612,15 +614,15 @@ enum {
enum {
OB_SHAPE_LOCK = 1 << 0,
#ifdef DNA_DEPRECATED_ALLOW
- OB_SHAPE_FLAG_DEPRECATED_1 = 1 << 1, /* cleared */
+ OB_SHAPE_FLAG_UNUSED_1 = 1 << 1, /* cleared */
#endif
OB_SHAPE_EDIT_MODE = 1 << 2,
};
/* ob->nlaflag */
enum {
- OB_ADS_DEPRECATED_1 = 1 << 0, /* cleared */
- OB_ADS_DEPRECATED_2 = 1 << 1, /* cleared */
+ OB_ADS_UNUSED_1 = 1 << 0, /* cleared */
+ OB_ADS_UNUSED_2 = 1 << 1, /* cleared */
/* object-channel expanded status */
OB_ADS_COLLAPSED = 1 << 10,
/* object's ipo-block */
@@ -670,6 +672,11 @@ enum {
OB_EMPTY_IMAGE_HIDE_FRONT = 1 << 3,
};
+/** #Object.empty_image_flag */
+enum {
+ OB_EMPTY_IMAGE_USE_ALPHA_BLEND = 1 << 0,
+};
+
#define MAX_DUPLI_RECUR 8
#ifdef __cplusplus
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index dc6e9dd05a1..ae677a93c43 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -206,8 +206,8 @@ typedef struct ParticleSettings {
short kink, kink_axis;
/* billboards */
- short bb_align, bb_uv_split, bb_anim, bb_split_offset;
- float bb_tilt, bb_rand_tilt, bb_offset[2], bb_size[2], bb_vel_head, bb_vel_tail;
+ short bb_align, bb_uv_split, bb_anim, bb_split_offset DNA_DEPRECATED;
+ float bb_tilt, bb_rand_tilt, bb_offset[2], bb_size[2], bb_vel_head, bb_vel_tail DNA_DEPRECATED;
/* draw color */
float color_vec_max;
@@ -362,7 +362,7 @@ typedef struct ParticleSystem {
char _pad1[6];
/** Billboard uv name, MAX_CUSTOMDATA_LAYER_NAME. */
- char bb_uvname[3][64];
+ char bb_uvname[3][64] DNA_DEPRECATED;
/* if you change these remember to update array lengths to PSYS_TOT_VG! */
/** Vertex groups, 0==disable, 1==starting index. */
@@ -379,7 +379,7 @@ typedef struct ParticleSystem {
int tot_fluidsprings, alloc_fluidsprings;
/** Used for interactions with self and other systems. */
- struct KDTree *tree;
+ struct KDTree_3d *tree;
/** Used for interactions with self and other systems. */
struct BVHTree *bvhtree;
@@ -412,7 +412,7 @@ typedef enum eParticleDrawFlag {
PART_DRAW_HEALTH = (1 << 4),
PART_ABS_PATH_TIME = (1 << 5),
PART_DRAW_COUNT_GR = (1 << 6),
- PART_DRAW_BB_LOCK = (1 << 7), /* used with billboards */
+ PART_DRAW_BB_LOCK = (1 << 7), /* used with billboards */ /* DEPRECATED */
PART_DRAW_ROTATE_OB = (1 << 7), /* used with instance object/collection */
PART_DRAW_PARENT = (1 << 8),
PART_DRAW_NUM = (1 << 9),
@@ -452,32 +452,32 @@ typedef enum eParticleDrawFlag {
#define PART_EDISTR 256 /* particle/face from face areas */
#define PART_ROTATIONS 512 /* calculate particle rotations (and store them in pointcache) */
-#define PART_DIE_ON_COL (1<<12)
-#define PART_SIZE_DEFL (1<<13) /* swept sphere deflections */
-#define PART_ROT_DYN (1<<14) /* dynamic rotation */
-#define PART_SIZEMASS (1<<16)
+#define PART_DIE_ON_COL (1 << 12)
+#define PART_SIZE_DEFL (1 << 13) /* swept sphere deflections */
+#define PART_ROT_DYN (1 << 14) /* dynamic rotation */
+#define PART_SIZEMASS (1 << 16)
-#define PART_HIDE_ADVANCED_HAIR (1<<15)
+#define PART_HIDE_ADVANCED_HAIR (1 << 15)
-//#define PART_ABS_TIME (1<<17)
-//#define PART_GLOB_TIME (1<<18)
+//#define PART_ABS_TIME (1 << 17)
+//#define PART_GLOB_TIME (1 << 18)
-#define PART_BOIDS_2D (1<<19)
+#define PART_BOIDS_2D (1 << 19)
-//#define PART_BRANCHING (1<<20)
-//#define PART_ANIM_BRANCHING (1<<21)
+//#define PART_BRANCHING (1 << 20)
+//#define PART_ANIM_BRANCHING (1 << 21)
#define PART_HAIR_BSPLINE 1024
-#define PART_GRID_HEXAGONAL (1<<24)
-#define PART_GRID_INVERT (1<<26)
+#define PART_GRID_HEXAGONAL (1 << 24)
+#define PART_GRID_INVERT (1 << 26)
-#define PART_CHILD_EFFECT (1<<27)
-#define PART_CHILD_LONG_HAIR (1<<28)
-/* #define PART_CHILD_RENDER (1<<29) */ /*UNUSED*/
-#define PART_CHILD_GUIDE (1<<30)
+#define PART_CHILD_EFFECT (1 << 27)
+#define PART_CHILD_LONG_HAIR (1 << 28)
+/* #define PART_CHILD_RENDER (1 << 29) */ /*UNUSED*/
+#define PART_CHILD_GUIDE (1 << 30)
-#define PART_SELF_EFFECT (1<<22)
+#define PART_SELF_EFFECT (1 << 22)
/* part->from */
#define PART_FROM_VERT 0
@@ -510,15 +510,15 @@ typedef enum eParticleKink {
/* part->child_flag */
typedef enum eParticleChildFlag {
- PART_CHILD_USE_CLUMP_NOISE = (1<<0),
- PART_CHILD_USE_CLUMP_CURVE = (1<<1),
- PART_CHILD_USE_ROUGH_CURVE = (1<<2),
- PART_CHILD_USE_TWIST_CURVE = (1<<3),
+ PART_CHILD_USE_CLUMP_NOISE = (1 << 0),
+ PART_CHILD_USE_CLUMP_CURVE = (1 << 1),
+ PART_CHILD_USE_ROUGH_CURVE = (1 << 2),
+ PART_CHILD_USE_TWIST_CURVE = (1 << 3),
} eParticleChildFlag;
/* part->shape_flag */
typedef enum eParticleShapeFlag {
- PART_SHAPE_CLOSE_TIP = (1<<0),
+ PART_SHAPE_CLOSE_TIP = (1 << 0),
} eParticleShapeFlag;
/* part->draw_col */
@@ -530,24 +530,6 @@ typedef enum eParticleShapeFlag {
/* part->time_flag */
#define PART_TIME_AUTOSF 1 /* Automatic subframes */
-/* part->bb_align */
-#define PART_BB_X 0
-#define PART_BB_Y 1
-#define PART_BB_Z 2
-#define PART_BB_VIEW 3
-#define PART_BB_VEL 4
-
-/* part->bb_anim */
-#define PART_BB_ANIM_NONE 0
-#define PART_BB_ANIM_AGE 1
-#define PART_BB_ANIM_ANGLE 2
-#define PART_BB_ANIM_FRAME 3
-
-/* part->bb_split_offset */
-#define PART_BB_OFF_NONE 0
-#define PART_BB_OFF_LINEAR 1
-#define PART_BB_OFF_RANDOM 2
-
/* part->draw_as */
/* part->ren_as*/
#define PART_DRAW_NOT 0
@@ -560,7 +542,7 @@ typedef enum eParticleShapeFlag {
#define PART_DRAW_PATH 6
#define PART_DRAW_OB 7
#define PART_DRAW_GR 8
-#define PART_DRAW_BB 9
+#define PART_DRAW_BB 9 /* deprecated */
#define PART_DRAW_REND 10
/* part->integrator */
@@ -661,25 +643,25 @@ typedef enum eParticleShapeFlag {
/* mapto */
typedef enum eParticleTextureInfluence {
/* init */
- PAMAP_TIME = (1<<0), /* emission time */
- PAMAP_LIFE = (1<<1), /* life time */
- PAMAP_DENS = (1<<2), /* density */
- PAMAP_SIZE = (1<<3), /* physical size */
+ PAMAP_TIME = (1 << 0), /* emission time */
+ PAMAP_LIFE = (1 << 1), /* life time */
+ PAMAP_DENS = (1 << 2), /* density */
+ PAMAP_SIZE = (1 << 3), /* physical size */
PAMAP_INIT = (PAMAP_TIME | PAMAP_LIFE | PAMAP_DENS | PAMAP_SIZE),
/* reset */
- PAMAP_IVEL = (1<<5), /* initial velocity */
+ PAMAP_IVEL = (1 << 5), /* initial velocity */
/* physics */
- PAMAP_FIELD = (1<<6), /* force fields */
- PAMAP_GRAVITY = (1<<10),
- PAMAP_DAMP = (1<<11),
+ PAMAP_FIELD = (1 << 6), /* force fields */
+ PAMAP_GRAVITY = (1 << 10),
+ PAMAP_DAMP = (1 << 11),
PAMAP_PHYSICS = (PAMAP_FIELD | PAMAP_GRAVITY | PAMAP_DAMP),
/* children */
- PAMAP_CLUMP = (1<<7),
- PAMAP_KINK_FREQ = (1<<8),
- PAMAP_KINK_AMP = (1<<12),
- PAMAP_ROUGH = (1<<9),
- PAMAP_LENGTH = (1<<4),
- PAMAP_TWIST = (1<<13),
+ PAMAP_CLUMP = (1 << 7),
+ PAMAP_KINK_FREQ = (1 << 8),
+ PAMAP_KINK_AMP = (1 << 12),
+ PAMAP_ROUGH = (1 << 9),
+ PAMAP_LENGTH = (1 << 4),
+ PAMAP_TWIST = (1 << 13),
PAMAP_CHILD = (PAMAP_CLUMP | PAMAP_KINK_FREQ | PAMAP_KINK_AMP | PAMAP_ROUGH | PAMAP_LENGTH | PAMAP_TWIST),
} eParticleTextureInfluence;
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index 9985236aeb1..a3a2a0e0124 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -197,23 +197,23 @@ typedef enum eRigidBodyOb_Flag {
/* RigidBody Collision Shape */
typedef enum eRigidBody_Shape {
- /* simple box (i.e. bounding box) */
+ /** Simple box (i.e. bounding box). */
RB_SHAPE_BOX = 0,
- /* sphere */
+ /** Sphere. */
RB_SHAPE_SPHERE,
- /* rounded "pill" shape (i.e. calcium tablets) */
+ /** Rounded "pill" shape (i.e. calcium tablets). */
RB_SHAPE_CAPSULE,
- /* cylinder (i.e. pringles can) */
+ /** Cylinder (i.e. pringles can). */
RB_SHAPE_CYLINDER,
- /* cone (i.e. party hat) */
+ /** Cone (i.e. party hat). */
RB_SHAPE_CONE,
- /* convex hull (minimal shrinkwrap encompassing all verts) */
+ /** Convex hull (minimal shrinkwrap encompassing all verts). */
RB_SHAPE_CONVEXH,
- /* triangulated mesh */
+ /** Triangulated mesh. */
RB_SHAPE_TRIMESH,
- /* concave mesh approximated using primitives */
+ /* concave mesh approximated using primitives */
//RB_SHAPE_COMPOUND,
} eRigidBody_Shape;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 48301202778..e7e147b0934 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -255,18 +255,18 @@ typedef struct SceneRenderLayer {
typedef enum eScenePassType {
SCE_PASS_COMBINED = (1 << 0),
SCE_PASS_Z = (1 << 1),
- SCE_PASS_DEPRECATED_1 = (1 << 2), /* RGBA */
- SCE_PASS_DEPRECATED_2 = (1 << 3), /* DIFFUSE */
- SCE_PASS_DEPRECATED_3 = (1 << 4), /* SPEC */
+ SCE_PASS_UNUSED_1 = (1 << 2), /* RGBA */
+ SCE_PASS_UNUSED_2 = (1 << 3), /* DIFFUSE */
+ SCE_PASS_UNUSED_3 = (1 << 4), /* SPEC */
SCE_PASS_SHADOW = (1 << 5),
SCE_PASS_AO = (1 << 6),
- SCE_PASS_DEPRECATED_4 = (1 << 7), /* REFLECT */
+ SCE_PASS_UNUSED_4 = (1 << 7), /* REFLECT */
SCE_PASS_NORMAL = (1 << 8),
SCE_PASS_VECTOR = (1 << 9),
- SCE_PASS_DEPRECATED_5 = (1 << 10), /* REFRACT */
+ SCE_PASS_UNUSED_5 = (1 << 10), /* REFRACT */
SCE_PASS_INDEXOB = (1 << 11),
SCE_PASS_UV = (1 << 12),
- SCE_PASS_DEPRECATED_6 = (1 << 13), /* INDIRECT */
+ SCE_PASS_UNUSED_6 = (1 << 13), /* INDIRECT */
SCE_PASS_MIST = (1 << 14),
SCE_PASS_RAYHITS = (1 << 15),
SCE_PASS_EMIT = (1 << 16),
@@ -334,7 +334,7 @@ typedef struct SceneRenderView {
} SceneRenderView;
/* SceneRenderView.viewflag */
-#define SCE_VIEW_DISABLE (1 << 0)
+#define SCE_VIEW_DISABLE (1 << 0)
/* RenderData.views_format */
enum {
@@ -1053,6 +1053,7 @@ typedef enum eGP_Lockaxis_Types {
GP_LOCKAXIS_X = 1,
GP_LOCKAXIS_Y = 2,
GP_LOCKAXIS_Z = 3,
+ GP_LOCKAXIS_CURSOR = 4
} eGP_Lockaxis_Types;
/* Settings for a GPencil Stroke Sculpting Brush */
@@ -1852,50 +1853,50 @@ typedef struct Scene {
/* **************** RENDERDATA ********************* */
/* RenderData.flag */
-/* use preview range */
-#define SCER_PRV_RANGE (1 << 0)
-#define SCER_LOCK_FRAME_SELECTION (1 << 1)
-/* show/use subframes (for checking motion blur) */
-#define SCER_SHOW_SUBFRAME (1 << 3)
+ /* use preview range */
+#define SCER_PRV_RANGE (1 << 0)
+#define SCER_LOCK_FRAME_SELECTION (1 << 1)
+ /* show/use subframes (for checking motion blur) */
+#define SCER_SHOW_SUBFRAME (1 << 3)
/* RenderData.mode */
#define R_OSA (1 << 0)
-#define R_MODE_DEPRECATED_1 (1 << 1) /* cleared */
-#define R_MODE_DEPRECATED_2 (1 << 2) /* cleared */
-#define R_MODE_DEPRECATED_3 (1 << 3) /* cleared */
-#define R_MODE_DEPRECATED_4 (1 << 4) /* cleared */
-#define R_MODE_DEPRECATED_5 (1 << 5) /* cleared */
-#define R_MODE_DEPRECATED_6 (1 << 6) /* cleared */
-#define R_MODE_DEPRECATED_7 (1 << 7) /* cleared */
-#define R_MODE_DEPRECATED_8 (1 << 8) /* cleared */
+#define R_MODE_UNUSED_1 (1 << 1) /* cleared */
+#define R_MODE_UNUSED_2 (1 << 2) /* cleared */
+#define R_MODE_UNUSED_3 (1 << 3) /* cleared */
+#define R_MODE_UNUSED_4 (1 << 4) /* cleared */
+#define R_MODE_UNUSED_5 (1 << 5) /* cleared */
+#define R_MODE_UNUSED_6 (1 << 6) /* cleared */
+#define R_MODE_UNUSED_7 (1 << 7) /* cleared */
+#define R_MODE_UNUSED_8 (1 << 8) /* cleared */
#define R_BORDER (1 << 9)
-#define R_MODE_DEPRECATED_10 (1 << 10) /* cleared */
+#define R_MODE_UNUSED_10 (1 << 10) /* cleared */
#define R_CROP (1 << 11)
/* Disable camera switching: runtime (DURIAN_CAMERA_SWITCH) */
#define R_NO_CAMERA_SWITCH (1 << 12)
-#define R_MODE_DEPRECATED_13 (1 << 13) /* cleared */
+#define R_MODE_UNUSED_13 (1 << 13) /* cleared */
#define R_MBLUR (1 << 14)
/* unified was here */
-#define R_MODE_DEPRECATED_16 (1 << 16) /* cleared */
-#define R_MODE_DEPRECATED_17 (1 << 17) /* cleared */
-#define R_MODE_DEPRECATED_18 (1 << 18) /* cleared */
-#define R_MODE_DEPRECATED_19 (1 << 19) /* cleared */
+#define R_MODE_UNUSED_16 (1 << 16) /* cleared */
+#define R_MODE_UNUSED_17 (1 << 17) /* cleared */
+#define R_MODE_UNUSED_18 (1 << 18) /* cleared */
+#define R_MODE_UNUSED_19 (1 << 19) /* cleared */
#define R_FIXED_THREADS (1 << 19)
-#define R_MODE_DEPRECATED_20 (1 << 20) /* cleared */
-#define R_MODE_DEPRECATED_21 (1 << 21) /* cleared */
+#define R_MODE_UNUSED_20 (1 << 20) /* cleared */
+#define R_MODE_UNUSED_21 (1 << 21) /* cleared */
#define R_NO_OVERWRITE (1 << 22) /* skip existing files */
#define R_TOUCH (1 << 23) /* touch files before rendering */
#define R_SIMPLIFY (1 << 24)
#define R_EDGE_FRS (1 << 25) /* R_EDGE reserved for Freestyle */
#define R_PERSISTENT_DATA (1 << 26) /* keep data around for re-render */
-#define R_MODE_DEPRECATED_27 (1 << 27) /* cleared */
+#define R_MODE_UNUSED_27 (1 << 27) /* cleared */
/* RenderData.seq_flag */
enum {
- R_SEQ_DEPRECATED_0 = (1 << 0), /* cleared */
- R_SEQ_DEPRECATED_1 = (1 << 1), /* cleared */
- R_SEQ_DEPRECATED_2 = (1 << 2), /* cleared */
+ R_SEQ_UNUSED_0 = (1 << 0), /* cleared */
+ R_SEQ_UNUSED_1 = (1 << 1), /* cleared */
+ R_SEQ_UNUSED_2 = (1 << 2), /* cleared */
R_SEQ_SOLID_TEX = (1 << 3),
R_SEQ_CAMERA_DOF = (1 << 4),
};
@@ -1927,18 +1928,18 @@ enum {
#define R_MATNODE_PREVIEW (1 << 5)
#define R_DOCOMP (1 << 6)
#define R_COMP_CROP (1 << 7)
-#define R_SCEMODE_DEPRECATED_8 (1 << 8) /* cleared */
+#define R_SCEMODE_UNUSED_8 (1 << 8) /* cleared */
#define R_SINGLE_LAYER (1 << 9)
#define R_EXR_TILE_FILE (1 << 10)
-#define R_SCEMODE_DEPRECATED_11 (1 << 11) /* cleared */
+#define R_SCEMODE_UNUSED_11 (1 << 11) /* cleared */
#define R_NO_IMAGE_LOAD (1 << 12)
-#define R_SCEMODE_DEPRECATED_13 (1 << 13) /* cleared */
+#define R_SCEMODE_UNUSED_13 (1 << 13) /* cleared */
#define R_NO_FRAME_UPDATE (1 << 14)
#define R_FULL_SAMPLE (1 << 15)
-#define R_SCEMODE_DEPRECATED_16 (1 << 16) /* cleared */
-#define R_SCEMODE_DEPRECATED_17 (1 << 17) /* cleared */
+#define R_SCEMODE_UNUSED_16 (1 << 16) /* cleared */
+#define R_SCEMODE_UNUSED_17 (1 << 17) /* cleared */
#define R_TEXNODE_PREVIEW (1 << 18)
-#define R_SCEMODE_DEPRECATED_19 (1 << 19) /* cleared */
+#define R_SCEMODE_UNUSED_19 (1 << 19) /* cleared */
#define R_EXR_CACHE_FILE (1 << 20)
#define R_MULTIVIEW (1 << 21)
@@ -1973,7 +1974,7 @@ enum {
enum {
/** deprecated, should only be used in versioning code only */
R_COLOR_MANAGEMENT = (1 << 0),
- R_COLOR_MANAGEMENT_DEPRECATED_1 = (1 << 1),
+ R_COLOR_MANAGEMENT_UNUSED_1 = (1 << 1),
};
#ifdef DNA_DEPRECATED
@@ -2196,11 +2197,11 @@ typedef enum eVGroupSelect {
/* Scene.flag */
-#define SCE_DS_SELECTED (1 << 0)
-#define SCE_DS_COLLAPSED (1 << 1)
-#define SCE_NLA_EDIT_ON (1 << 2)
-#define SCE_FRAME_DROP (1 << 3)
-#define SCE_KEYS_NO_SELONLY (1 << 4)
+#define SCE_DS_SELECTED (1 << 0)
+#define SCE_DS_COLLAPSED (1 << 1)
+#define SCE_NLA_EDIT_ON (1 << 2)
+#define SCE_FRAME_DROP (1 << 3)
+#define SCE_KEYS_NO_SELONLY (1 << 4)
/* return flag BKE_scene_base_iter_next functions */
/* #define F_ERROR -1 */ /* UNUSED */
@@ -2211,7 +2212,7 @@ typedef enum eVGroupSelect {
/* AudioData.flag */
#define AUDIO_MUTE (1 << 0)
#define AUDIO_SYNC (1 << 1)
-#define AUDIO_SCRUB (1 << 2)
+#define AUDIO_SCRUB (1 << 2)
#define AUDIO_VOLUME_ANIMATED (1 << 3)
/* FFMpegCodecData.flags */
@@ -2249,15 +2250,15 @@ typedef enum ePaintSymmetryFlags {
/* Sculpt.flags */
/* These can eventually be moved to paint flags? */
typedef enum eSculptFlags {
- SCULPT_FLAG_DEPRECATED_0 = (1 << 0), /* cleared */
- SCULPT_FLAG_DEPRECATED_1 = (1 << 1), /* cleared */
- SCULPT_FLAG_DEPRECATED_2 = (1 << 2), /* cleared */
+ SCULPT_FLAG_UNUSED_0 = (1 << 0), /* cleared */
+ SCULPT_FLAG_UNUSED_1 = (1 << 1), /* cleared */
+ SCULPT_FLAG_UNUSED_2 = (1 << 2), /* cleared */
SCULPT_LOCK_X = (1 << 3),
SCULPT_LOCK_Y = (1 << 4),
SCULPT_LOCK_Z = (1 << 5),
- SCULPT_FLAG_DEPRECATED_6 = (1 << 6), /* cleared */
+ SCULPT_FLAG_UNUSED_6 = (1 << 6), /* cleared */
SCULPT_USE_OPENMP = (1 << 7),
SCULPT_ONLY_DEFORM = (1 << 8),
@@ -2423,7 +2424,7 @@ typedef enum eGPencil_Guide_Reference {
#define PE_DEFLECT_EMITTER (1 << 2)
#define PE_INTERPOLATE_ADDED (1 << 3)
#define PE_DRAW_PART (1 << 4)
-#define PE_DEPRECATED_6 (1 << 6) /* cleared */
+#define PE_UNUSED_6 (1 << 6) /* cleared */
#define PE_FADE_TIME (1 << 7)
#define PE_AUTO_VELOCITY (1 << 8)
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 3dc44ac9416..fb111fad335 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -286,8 +286,7 @@ typedef struct ScrGlobalAreaData {
* and winx/winy don't) */
short cur_fixed_height;
/* For global areas, this is the min and max size they can use depending on
- * if they are 'collapsed' or not. Value is set on area creation and not
- * touched afterwards. */
+ * if they are 'collapsed' or not. */
short size_min, size_max;
/** GlobalAreaAlign. */
short align;
@@ -403,9 +402,8 @@ typedef struct ARegion {
/** Hide, .... */
short flag;
- /** Current split size in float (unused). */
- float fsize;
- /** Current split size in pixels (if zero it uses regiontype). */
+ /** Current split size in unscaled pixels (if zero it uses regiontype).
+ * To convert to pixels use: `UI_DPI_FAC * ar->sizex + 0.5f`. */
short sizex, sizey;
/** Private, cached notifier events. */
@@ -416,7 +414,6 @@ typedef struct ARegion {
short overlap;
/** Temporary copy of flag settings for clean fullscreen. */
short flagfullscreen;
- char _pad[4];
/** Callbacks for this region type. */
struct ARegionType *type;
@@ -453,15 +450,15 @@ typedef struct ARegion {
/** #ScrArea.flag */
enum {
HEADER_NO_PULLDOWN = (1 << 0),
-// AREA_FLAG_DEPRECATED_1 = (1 << 1),
-// AREA_FLAG_DEPRECATED_2 = (1 << 2),
+// AREA_FLAG_UNUSED_1 = (1 << 1),
+// AREA_FLAG_UNUSED_2 = (1 << 2),
#ifdef DNA_DEPRECATED_ALLOW
AREA_TEMP_INFO = (1 << 3), /* versioned to make slot reusable */
#endif
/* update size of regions within the area */
AREA_FLAG_REGION_SIZE_UPDATE = (1 << 3),
AREA_FLAG_ACTIVE_TOOL_UPDATE = (1 << 4),
-// AREA_FLAG_DEPRECATED_5 = (1 << 5),
+// AREA_FLAG_UNUSED_5 = (1 << 5),
/* used to check if we should switch back to prevspace (of a different type) */
AREA_FLAG_TEMP_TYPE = (1 << 6),
/* for temporary fullscreens (file browser, image editor render)
@@ -612,6 +609,7 @@ enum {
#define RGN_ALIGN_VSPLIT 6
#define RGN_ALIGN_FLOAT 7
#define RGN_ALIGN_QSPLIT 8
+#define RGN_ALIGN_ENUM_MASK 0x0F
#define RGN_SPLIT_PREV 32
@@ -627,6 +625,9 @@ enum {
RGN_FLAG_TEMP_REGIONDATA = (1 << 3),
/* The region must either use its prefsizex/y or be hidden. */
RGN_FLAG_PREFSIZE_OR_HIDDEN = (1 << 4),
+ /** Size has been clamped (floating regions only). */
+ RGN_FLAG_SIZE_CLAMP_X = (1 << 5),
+ RGN_FLAG_SIZE_CLAMP_Y = (1 << 6),
};
/** #ARegion.do_draw */
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 629bfffb696..1593ceb9063 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -446,7 +446,7 @@ typedef struct SequencerScopes {
/* SpeedControlVars->flags */
#define SEQ_SPEED_INTEGRATE (1 << 0)
-#define SEQ_SPEED_DEPRECATED_1 (1 << 1) /* cleared */
+#define SEQ_SPEED_UNUSED_1 (1 << 1) /* cleared */
#define SEQ_SPEED_COMPRESS_IPO_Y (1 << 2)
/* ***************** SEQUENCE ****************** */
@@ -460,7 +460,7 @@ enum {
SEQ_OVERLAP = (1 << 3),
SEQ_FILTERY = (1 << 4),
SEQ_MUTE = (1 << 5),
- SEQ_FLAG_DEPRECATED_6 = (1 << 6), /* cleared */
+ SEQ_FLAG_UNUSED_6 = (1 << 6), /* cleared */
SEQ_REVERSE_FRAMES = (1 << 7),
SEQ_IPO_FRAME_LOCKED = (1 << 8),
SEQ_EFFECT_NOT_LOADED = (1 << 9),
@@ -472,9 +472,9 @@ enum {
SEQ_USE_PROXY = (1 << 15),
SEQ_USE_TRANSFORM = (1 << 16),
SEQ_USE_CROP = (1 << 17),
- SEQ_FLAG_DEPRECATED_18 = (1 << 18), /* cleared */
- SEQ_FLAG_DEPRECATED_19 = (1 << 19), /* cleared */
- SEQ_FLAG_DEPRECATED_21 = (1 << 21), /* cleared */
+ SEQ_FLAG_UNUSED_18 = (1 << 18), /* cleared */
+ SEQ_FLAG_UNUSED_19 = (1 << 19), /* cleared */
+ SEQ_FLAG_UNUSED_21 = (1 << 21), /* cleared */
SEQ_USE_EFFECT_DEFAULT_FADE = (1 << 22),
SEQ_USE_LINEAR_MODIFIERS = (1 << 23),
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index 9f8d3449d39..e4f4db0be78 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -38,11 +38,11 @@ enum {
};
/* noise */
-#define MOD_SMOKE_NOISEWAVE (1<<0)
-#define MOD_SMOKE_NOISEFFT (1<<1)
-#define MOD_SMOKE_NOISECURL (1<<2)
+#define MOD_SMOKE_NOISEWAVE (1 << 0)
+#define MOD_SMOKE_NOISEFFT (1 << 1)
+#define MOD_SMOKE_NOISECURL (1 << 2)
/* viewsettings */
-#define MOD_SMOKE_VIEW_SHOW_HIGHRES (1<<0)
+#define MOD_SMOKE_VIEW_SHOW_HIGHRES (1 << 0)
/* slice method */
enum {
@@ -112,10 +112,10 @@ enum {
#define SM_HRES_FULLSAMPLE 2
/* smoke data fields (active_fields) */
-#define SM_ACTIVE_HEAT (1<<0)
-#define SM_ACTIVE_FIRE (1<<1)
-#define SM_ACTIVE_COLORS (1<<2)
-#define SM_ACTIVE_COLOR_SET (1<<3)
+#define SM_ACTIVE_HEAT (1 << 0)
+#define SM_ACTIVE_FIRE (1 << 1)
+#define SM_ACTIVE_COLORS (1 << 2)
+#define SM_ACTIVE_COLOR_SET (1 << 3)
enum {
VDB_COMPRESSION_BLOSC = 0,
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index afe80edfdd3..21e945a084a 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -205,8 +205,8 @@ typedef enum eSpaceButtons_Context {
typedef enum eSpaceButtons_Flag {
SB_PRV_OSA = (1 << 0),
SB_PIN_CONTEXT = (1 << 1),
- SB_FLAG_DEPRECATED_2 = (1 << 2),
- SB_FLAG_DEPRECATED_3 = (1 << 3),
+ SB_FLAG_UNUSED_2 = (1 << 2),
+ SB_FLAG_UNUSED_3 = (1 << 3),
/** Do not add materials, particles, etc. in TemplateTextureUser list. */
SB_TEX_USER_LIMITED = (1 << 3),
SB_SHADING_CONTEXT = (1 << 4),
@@ -270,12 +270,12 @@ typedef enum eSpaceOutliner_Flag {
/* SpaceOutliner.filter */
typedef enum eSpaceOutliner_Filter {
SO_FILTER_SEARCH = (1 << 0), /* Run-time flag. */
- SO_FILTER_DEPRECATED_1 = (1 << 1), /* cleared */
+ SO_FILTER_UNUSED_1 = (1 << 1), /* cleared */
SO_FILTER_NO_OBJECT = (1 << 2),
SO_FILTER_NO_OB_CONTENT = (1 << 3), /* Not only mesh, but modifiers, constraints, ... */
SO_FILTER_NO_CHILDREN = (1 << 4),
- SO_FILTER_DEPRECATED_5 = (1 << 5), /* cleared */
+ SO_FILTER_UNUSED_5 = (1 << 5), /* cleared */
SO_FILTER_NO_OB_MESH = (1 << 6),
SO_FILTER_NO_OB_ARMATURE = (1 << 7),
SO_FILTER_NO_OB_EMPTY = (1 << 8),
@@ -283,7 +283,7 @@ typedef enum eSpaceOutliner_Filter {
SO_FILTER_NO_OB_CAMERA = (1 << 10),
SO_FILTER_NO_OB_OTHERS = (1 << 11),
- SO_FILTER_DEPRECATED_12 = (1 << 12), /* cleared */
+ SO_FILTER_UNUSED_12 = (1 << 12), /* cleared */
SO_FILTER_OB_STATE_VISIBLE = (1 << 13), /* Not set via DNA. */
SO_FILTER_OB_STATE_SELECTED = (1 << 14), /* Not set via DNA. */
SO_FILTER_OB_STATE_ACTIVE = (1 << 15), /* Not set via DNA. */
@@ -341,7 +341,7 @@ typedef enum eSpaceOutliner_Mode {
typedef enum eSpaceOutliner_StoreFlag {
/* cleanup tree */
SO_TREESTORE_CLEANUP = (1 << 0),
- SO_TREESTORE_DEPRECATED_1 = (1 << 1), /* cleared */
+ SO_TREESTORE_UNUSED_1 = (1 << 1), /* cleared */
/* rebuild the tree, similar to cleanup,
* but defer a call to BKE_outliner_treehash_rebuild_from_treestore instead */
SO_TREESTORE_REBUILD = (1 << 2),
@@ -487,11 +487,11 @@ typedef struct SpaceNla {
/* SpaceNla.flag */
typedef enum eSpaceNla_Flag {
- SNLA_FLAG_DEPRECATED_0 = (1 << 0),
- SNLA_FLAG_DEPRECATED_1 = (1 << 1),
+ SNLA_FLAG_UNUSED_0 = (1 << 0),
+ SNLA_FLAG_UNUSED_1 = (1 << 1),
/* draw timing in seconds instead of frames */
SNLA_DRAWTIME = (1 << 2),
- SNLA_FLAG_DEPRECATED_3 = (1 << 3),
+ SNLA_FLAG_UNUSED_3 = (1 << 3),
/* don't draw frame number beside frame indicator */
SNLA_NODRAWCFRANUM = (1 << 4),
/* don't draw influence curves on strips */
@@ -767,16 +767,16 @@ typedef enum eFileSel_Action {
/* Note: short flag, also used as 16 lower bits of flags in link/append code
* (WM and BLO code area, see BLO_LibLinkFlags in BLO_readfile.h). */
typedef enum eFileSel_Params_Flag {
- FILE_PARAMS_FLAG_DEPRECATED_1 = (1 << 0), /* cleared */
+ FILE_PARAMS_FLAG_UNUSED_1 = (1 << 0), /* cleared */
FILE_RELPATH = (1 << 1),
FILE_LINK = (1 << 2),
FILE_HIDE_DOT = (1 << 3),
FILE_AUTOSELECT = (1 << 4),
FILE_ACTIVE_COLLECTION = (1 << 5),
- FILE_PARAMS_FLAG_DEPRECATED_6 = (1 << 6), /* cleared */
+ FILE_PARAMS_FLAG_UNUSED_6 = (1 << 6), /* cleared */
FILE_DIRSEL_ONLY = (1 << 7),
FILE_FILTER = (1 << 8),
- FILE_PARAMS_FLAG_DEPRECATED_9 = (1 << 9), /* cleared */
+ FILE_PARAMS_FLAG_UNUSED_9 = (1 << 9), /* cleared */
FILE_GROUP_INSTANCE = (1 << 10),
} eFileSel_Params_Flag;
@@ -1062,17 +1062,17 @@ typedef enum eSpaceImage_Sticky {
/* SpaceImage.flag */
typedef enum eSpaceImage_Flag {
- SI_FLAG_DEPRECATED_0 = (1 << 0), /* cleared */
- SI_FLAG_DEPRECATED_1 = (1 << 1), /* cleared */
+ SI_FLAG_UNUSED_0 = (1 << 0), /* cleared */
+ SI_FLAG_UNUSED_1 = (1 << 1), /* cleared */
SI_CLIP_UV = (1 << 2),
- SI_FLAG_DEPRECATED_3 = (1 << 3), /* cleared */
+ SI_FLAG_UNUSED_3 = (1 << 3), /* cleared */
SI_NO_DRAWFACES = (1 << 4),
SI_DRAWSHADOW = (1 << 5),
- SI_FLAG_DEPRECATED_6 = (1 << 6), /* cleared */
- SI_FLAG_DEPRECATED_7 = (1 << 7), /* cleared */
- SI_FLAG_DEPRECATED_8 = (1 << 8), /* cleared */
+ SI_FLAG_UNUSED_6 = (1 << 6), /* cleared */
+ SI_FLAG_UNUSED_7 = (1 << 7), /* cleared */
+ SI_FLAG_UNUSED_8 = (1 << 8), /* cleared */
SI_COORDFLOATS = (1 << 9),
- SI_FLAG_DEPRECATED_10 = (1 << 10),
+ SI_FLAG_UNUSED_10 = (1 << 10),
SI_LIVE_UNWRAP = (1 << 11),
SI_USE_ALPHA = (1 << 12),
SI_SHOW_ALPHA = (1 << 13),
@@ -1082,8 +1082,8 @@ typedef enum eSpaceImage_Flag {
SI_PREVSPACE = (1 << 15),
SI_FULLWINDOW = (1 << 16),
- SI_FLAG_DEPRECATED_17 = (1 << 17), /* cleared */
- SI_FLAG_DEPRECATED_18 = (1 << 18), /* cleared */
+ SI_FLAG_UNUSED_17 = (1 << 17), /* cleared */
+ SI_FLAG_UNUSED_18 = (1 << 18), /* cleared */
/* this means that the image is drawn until it reaches the view edge,
* in the image view, it's unrelated to the 'tile' mode for texface
@@ -1092,9 +1092,9 @@ typedef enum eSpaceImage_Flag {
SI_SMOOTH_UV = (1 << 20),
SI_DRAW_STRETCH = (1 << 21),
SI_SHOW_GPENCIL = (1 << 22),
- SI_FLAG_DEPRECATED_23 = (1 << 23), /* cleared */
+ SI_FLAG_UNUSED_23 = (1 << 23), /* cleared */
- SI_FLAG_DEPRECATED_24 = (1 << 24),
+ SI_FLAG_UNUSED_24 = (1 << 24),
SI_NO_DRAW_TEXPAINT = (1 << 25),
SI_DRAW_METADATA = (1 << 26),
@@ -1103,7 +1103,7 @@ typedef enum eSpaceImage_Flag {
SI_SHOW_G = (1 << 28),
SI_SHOW_B = (1 << 29),
- SI_NO_DRAWEDGES = (1 << 30),
+ SI_NO_DRAWEDGES = (1 << 30),
} eSpaceImage_Flag;
/* SpaceImage.other_uv_filter */
@@ -1332,9 +1332,9 @@ typedef enum eSpaceNode_Flag {
SNODE_SHOW_G = (1 << 8),
SNODE_SHOW_B = (1 << 9),
SNODE_AUTO_RENDER = (1 << 5),
- SNODE_FLAG_DEPRECATED_6 = (1 << 6), /* cleared */
- SNODE_FLAG_DEPRECATED_10 = (1 << 10), /* cleared */
- SNODE_FLAG_DEPRECATED_11 = (1 << 11), /* cleared */
+ SNODE_FLAG_UNUSED_6 = (1 << 6), /* cleared */
+ SNODE_FLAG_UNUSED_10 = (1 << 10), /* cleared */
+ SNODE_FLAG_UNUSED_11 = (1 << 11), /* cleared */
SNODE_PIN = (1 << 12),
/** automatically offset following nodes in a chain on insertion */
SNODE_SKIP_INSOFFSET = (1 << 13),
diff --git a/source/blender/makesdna/DNA_speaker_types.h b/source/blender/makesdna/DNA_speaker_types.h
index 6d40f8bff72..786c549d074 100644
--- a/source/blender/makesdna/DNA_speaker_types.h
+++ b/source/blender/makesdna/DNA_speaker_types.h
@@ -55,8 +55,8 @@ typedef struct Speaker {
/* **************** SPEAKER ********************* */
/* flag */
-#define SPK_DS_EXPAND (1<<0)
-#define SPK_MUTED (1<<1)
-// #define SPK_RELATIVE (1<<2) /* UNUSED */
+#define SPK_DS_EXPAND (1 << 0)
+#define SPK_MUTED (1 << 1)
+// #define SPK_RELATIVE (1 << 2) /* UNUSED */
#endif /* __DNA_SPEAKER_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_text_types.h b/source/blender/makesdna/DNA_text_types.h
index 34b49e29b38..856e17214a2 100644
--- a/source/blender/makesdna/DNA_text_types.h
+++ b/source/blender/makesdna/DNA_text_types.h
@@ -59,10 +59,18 @@ typedef struct Text {
#define TXT_MAX_UNDO (TXT_INIT_UNDO*TXT_INIT_UNDO)
/* text flags */
-#define TXT_ISDIRTY (1 << 0)
-#define TXT_ISMEM (1 << 2)
-#define TXT_ISEXT (1 << 3)
-#define TXT_ISSCRIPT (1 << 4) /* used by space handler scriptlinks */
-#define TXT_TABSTOSPACES (1 << 10) /* use space instead of tabs */
+enum {
+ TXT_ISDIRTY = 1 << 0,
+ TXT_ISMEM = 1 << 2,
+ TXT_ISEXT = 1 << 3,
+ /** Used by space handler scriptlinks. */
+ TXT_ISSCRIPT = 1 << 4,
+
+ TXT_FLAG_UNUSED_8 = 1 << 8, /* cleared */
+ TXT_FLAG_UNUSED_9 = 1 << 9, /* cleared */
+
+ /** Use space instead of tabs. */
+ TXT_TABSTOSPACES = 1 << 10,
+};
#endif /* __DNA_TEXT_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 3db9f2d7131..96745b40382 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -128,7 +128,7 @@ typedef struct PointDensity {
/** for 'Object' or 'Particle system' type - source object */
struct Object *object;
- /** index+1 in ob.particlesystem, non-ID pointer not allowed */
+ /** `index + 1` in ob.particlesystem, non-ID pointer not allowed */
int psys;
/** cache points in worldspace, object space, ... ? */
short psys_cache_space;
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index 6afabe20800..c7da64b14f8 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -274,8 +274,8 @@ typedef struct MovieTrackingSettings {
/* two keyframes for reconstruction initialization
* were moved to per-tracking object settings
*/
- int keyframe1 DNA_DEPRECATED,
- keyframe2 DNA_DEPRECATED;
+ int keyframe1 DNA_DEPRECATED;
+ int keyframe2 DNA_DEPRECATED;
int reconstruction_flag;
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 048b7e60d57..d44b149d3fd 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -573,7 +573,9 @@ typedef struct UserDef {
/** #eUserpref_UI_Flag. */
int uiflag;
/** #eUserpref_UI_Flag2. */
- int uiflag2;
+ char uiflag2;
+ char gpu_flag;
+ char _pad8[2];
/* Experimental flag for app-templates to make changes to behavior
* which are outside the scope of typical preferences. */
short app_flag;
@@ -664,8 +666,7 @@ typedef struct UserDef {
char ipo_new;
/** Handle types for newly added keyframes. */
char keyhandles_new;
- char gpu_select_pick_deph;
- char _pad11[2];
+ char _pad11[3];
/** #eZoomFrame_Mode. */
char view_frame_type;
@@ -722,8 +723,8 @@ typedef struct UserDef {
float gpencil_new_layer_col[4];
short tweak_threshold;
+ char move_threshold;
char navigation_mode;
- char _pad10;
char font_path_ui[1024];
char font_path_ui_mono[1024];
@@ -757,7 +758,9 @@ typedef struct UserDef {
/** #eMultiSample_Type, amount of samples for Grease Pencil. */
short gpencil_multisamples;
- char _pad5[4];
+ char factor_display_type;
+
+ char _pad5[3];
} UserDef;
/* from blenkernel blender.c */
@@ -798,32 +801,32 @@ typedef enum eUserPref_SectionFlag {
/** #UserDef.flag */
typedef enum eUserPref_Flag {
- USER_AUTOSAVE = (1 << 0),
+ USER_AUTOSAVE = (1 << 0),
USER_FLAG_NUMINPUT_ADVANCED = (1 << 1),
- USER_FLAG_DEPRECATED_2 = (1 << 2), /* cleared */
- USER_FLAG_DEPRECATED_3 = (1 << 3), /* cleared */
- USER_FLAG_DEPRECATED_4 = (1 << 4), /* cleared */
- USER_TRACKBALL = (1 << 5),
- USER_FLAG_DEPRECATED_6 = (1 << 6), /* cleared */
- USER_FLAG_DEPRECATED_7 = (1 << 7), /* cleared */
- USER_MAT_ON_OB = (1 << 8),
- USER_FLAG_DEPRECATED_9 = (1 << 9), /* cleared */
- USER_DEVELOPER_UI = (1 << 10),
- USER_TOOLTIPS = (1 << 11),
- USER_TWOBUTTONMOUSE = (1 << 12),
- USER_NONUMPAD = (1 << 13),
- USER_FLAG_DEPRECATED_14 = (1 << 14), /* cleared */
- USER_FILECOMPRESS = (1 << 15),
- USER_SAVE_PREVIEWS = (1 << 16),
- USER_CUSTOM_RANGE = (1 << 17),
- USER_ADD_EDITMODE = (1 << 18),
- USER_ADD_VIEWALIGNED = (1 << 19),
- USER_RELPATHS = (1 << 20),
- USER_RELEASECONFIRM = (1 << 21),
- USER_SCRIPT_AUTOEXEC_DISABLE = (1 << 22),
- USER_FILENOUI = (1 << 23),
- USER_NONEGFRAMES = (1 << 24),
- USER_TXT_TABSTOSPACES_DISABLE = (1 << 25),
+ USER_FLAG_UNUSED_2 = (1 << 2), /* cleared */
+ USER_FLAG_UNUSED_3 = (1 << 3), /* cleared */
+ USER_FLAG_UNUSED_4 = (1 << 4), /* cleared */
+ USER_TRACKBALL = (1 << 5),
+ USER_FLAG_UNUSED_6 = (1 << 6), /* cleared */
+ USER_FLAG_UNUSED_7 = (1 << 7), /* cleared */
+ USER_MAT_ON_OB = (1 << 8),
+ USER_FLAG_UNUSED_9 = (1 << 9), /* cleared */
+ USER_DEVELOPER_UI = (1 << 10),
+ USER_TOOLTIPS = (1 << 11),
+ USER_TWOBUTTONMOUSE = (1 << 12),
+ USER_NONUMPAD = (1 << 13),
+ USER_FLAG_UNUSED_14 = (1 << 14), /* cleared */
+ USER_FILECOMPRESS = (1 << 15),
+ USER_SAVE_PREVIEWS = (1 << 16),
+ USER_CUSTOM_RANGE = (1 << 17),
+ USER_ADD_EDITMODE = (1 << 18),
+ USER_ADD_VIEWALIGNED = (1 << 19),
+ USER_RELPATHS = (1 << 20),
+ USER_RELEASECONFIRM = (1 << 21),
+ USER_SCRIPT_AUTOEXEC_DISABLE = (1 << 22),
+ USER_FILENOUI = (1 << 23),
+ USER_NONEGFRAMES = (1 << 24),
+ USER_TXT_TABSTOSPACES_DISABLE = (1 << 25),
USER_TOOLTIPS_PYTHON = (1 << 26),
} eUserPref_Flag;
@@ -859,8 +862,8 @@ typedef enum eWalkNavigation_Flag {
/** #UserDef.uiflag */
typedef enum eUserpref_UI_Flag {
- USER_UIFLAG_DEPRECATED_0 = (1 << 0), /* cleared */
- USER_UIFLAG_DEPRECATED_1 = (1 << 1), /* cleared */
+ USER_UIFLAG_UNUSED_0 = (1 << 0), /* cleared */
+ USER_UIFLAG_UNUSED_1 = (1 << 1), /* cleared */
USER_WHEELZOOMDIR = (1 << 2),
USER_FILTERFILEEXTS = (1 << 3),
USER_DRAWVIEWINFO = (1 << 4),
@@ -872,7 +875,7 @@ typedef enum eUserpref_UI_Flag {
USER_MENUOPENAUTO = (1 << 9),
USER_DEPTH_CURSOR = (1 << 10),
USER_AUTOPERSP = (1 << 11),
- USER_UIFLAG_DEPRECATED_12 = (1 << 12), /* cleared */
+ USER_UIFLAG_UNUSED_12 = (1 << 12), /* cleared */
USER_GLOBALUNDO = (1 << 13),
USER_ORBIT_SELECTION = (1 << 14),
USER_DEPTH_NAVIGATE = (1 << 15),
@@ -882,7 +885,7 @@ typedef enum eUserpref_UI_Flag {
USER_CAM_LOCK_NO_PARENT = (1 << 19),
USER_ZOOM_TO_MOUSEPOS = (1 << 20),
USER_SHOW_FPS = (1 << 21),
- USER_UIFLAG_DEPRECATED_22 = (1 << 22), /* cleared */
+ USER_UIFLAG_UNUSED_22 = (1 << 22), /* cleared */
USER_MENUFIXEDORDER = (1 << 23),
USER_CONTINUOUS_MOUSE = (1 << 24),
USER_ZOOM_INVERT = (1 << 25),
@@ -894,14 +897,21 @@ typedef enum eUserpref_UI_Flag {
USER_HIDE_SYSTEM_BOOKMARKS = (1u << 31),
} eUserpref_UI_Flag;
-/** #UserDef.uiflag2 */
+/** #UserDef.uiflag2
+ *
+ * \note don't add new flags here, use 'uiflag' which has flags free. */
typedef enum eUserpref_UI_Flag2 {
- USER_UIFLAG2_DEPRECATED_0 = (1 << 0),
- USER_REGION_OVERLAP = (1 << 1),
- USER_TRACKPAD_NATURAL = (1 << 2),
- USER_EDIT_MODE_SMOOTH_WIRE = (1 << 3),
+ USER_UIFLAG2_UNUSED_0 = (1 << 0), /* cleared */
+ USER_REGION_OVERLAP = (1 << 1),
+ USER_TRACKPAD_NATURAL = (1 << 2),
+ USER_UIFLAG2_UNUSED_3 = (1 << 3), /* dirty */
} eUserpref_UI_Flag2;
+typedef enum eUserpref_GPU_Flag {
+ USER_GPU_FLAG_NO_DEPT_PICK = (1 << 0),
+ USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE = (1 << 1),
+} eUserpref_GPU_Flag;
+
/** #UserDef.tablet_api */
typedef enum eUserpref_TableAPI {
USER_TABLET_AUTOMATIC = 0,
@@ -953,15 +963,15 @@ typedef enum eAutokey_Flag {
/** #UserDef.transopts */
typedef enum eUserpref_Translation_Flags {
- USER_TR_TOOLTIPS = (1 << 0),
- USER_TR_IFACE = (1 << 1),
- USER_TR_DEPRECATED_2 = (1 << 2), /* cleared */
- USER_TR_DEPRECATED_3 = (1 << 3), /* cleared */
- USER_TR_DEPRECATED_4 = (1 << 4), /* cleared */
- USER_DOTRANSLATE = (1 << 5),
- USER_TR_DEPRECATED_6 = (1 << 6), /* cleared */
- USER_TR_DEPRECATED_7 = (1 << 7), /* cleared */
- USER_TR_NEWDATANAME = (1 << 8),
+ USER_TR_TOOLTIPS = (1 << 0),
+ USER_TR_IFACE = (1 << 1),
+ USER_TR_UNUSED_2 = (1 << 2), /* cleared */
+ USER_TR_UNUSED_3 = (1 << 3), /* cleared */
+ USER_TR_UNUSED_4 = (1 << 4), /* cleared */
+ USER_DOTRANSLATE = (1 << 5),
+ USER_TR_UNUSED_6 = (1 << 6), /* cleared */
+ USER_TR_UNUSED_7 = (1 << 7), /* cleared */
+ USER_TR_NEWDATANAME = (1 << 8),
} eUserpref_Translation_Flags;
/** #UserDef.dupflag */
@@ -1001,8 +1011,8 @@ typedef enum eText_Draw_Options {
/** Grease Pencil Settings.
* #UserDef.gp_settings */
typedef enum eGP_UserdefSettings {
- GP_PAINT_DEPRECATED_0 = (1 << 0),
- GP_PAINT_DOSIMPLIFY = (1 << 1),
+ GP_PAINT_UNUSED_0 = (1 << 0),
+ GP_PAINT_DOSIMPLIFY = (1 << 1),
} eGP_UserdefSettings;
enum {
@@ -1111,6 +1121,12 @@ typedef enum eOpensubdiv_Computee_Type {
USER_OPENSUBDIV_COMPUTE_GLSL_COMPUTE = 6,
} eOpensubdiv_Computee_Type;
+/** #UserDef.factor_display_type */
+typedef enum eUserpref_FactorDisplay {
+ USER_FACTOR_AS_FACTOR = 0,
+ USER_FACTOR_AS_PERCENTAGE = 1,
+} eUserpref_FactorDisplay;
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 3259587f4cb..075ea50c13b 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -75,7 +75,6 @@ typedef struct RegionView3D {
struct RegionView3D *localvd;
struct RenderEngine *render_engine;
struct ViewDepths *depths;
- void *gpuoffscreen;
/** Animated smooth view. */
struct SmoothView3DStore *sms;
@@ -326,14 +325,14 @@ typedef struct View3D {
#define V3D_S3D_DISPVOLUME (1 << 2)
/* View3D->flag (short) */
-#define V3D_FLAG_DEPRECATED_0 (1 << 0) /* cleared */
-#define V3D_FLAG_DEPRECATED_1 (1 << 1) /* cleared */
+#define V3D_FLAG_UNUSED_0 (1 << 0) /* cleared */
+#define V3D_FLAG_UNUSED_1 (1 << 1) /* cleared */
#define V3D_HIDE_HELPLINES (1 << 2)
#define V3D_INVALID_BACKBUF (1 << 3)
-#define V3D_FLAG_DEPRECATED_10 (1 << 10) /* cleared */
+#define V3D_FLAG_UNUSED_10 (1 << 10) /* cleared */
#define V3D_SELECT_OUTLINE (1 << 11)
-#define V3D_FLAG_DEPRECATED_12 (1 << 12) /* cleared */
+#define V3D_FLAG_UNUSED_12 (1 << 12) /* cleared */
#define V3D_GLOBAL_STATS (1 << 13)
#define V3D_DRAW_CENTERS (1 << 15)
@@ -375,19 +374,19 @@ typedef struct View3D {
/* View3d->flag2 (int) */
#define V3D_HIDE_OVERLAYS (1 << 2)
-#define V3D_FLAG2_DEPRECATED_3 (1 << 3) /* cleared */
+#define V3D_FLAG2_UNUSED_3 (1 << 3) /* cleared */
#define V3D_SHOW_ANNOTATION (1 << 4)
#define V3D_LOCK_CAMERA (1 << 5)
-#define V3D_FLAG2_DEPRECATED_6 (1 << 6) /* cleared */
+#define V3D_FLAG2_UNUSED_6 (1 << 6) /* cleared */
#define V3D_SHOW_RECONSTRUCTION (1 << 7)
#define V3D_SHOW_CAMERAPATH (1 << 8)
#define V3D_SHOW_BUNDLENAME (1 << 9)
-#define V3D_FLAG2_DEPRECATED_10 (1 << 10) /* cleared */
+#define V3D_FLAG2_UNUSED_10 (1 << 10) /* cleared */
#define V3D_RENDER_BORDER (1 << 11)
-#define V3D_FLAG2_DEPRECATED_12 (1 << 12) /* cleared */
-#define V3D_FLAG2_DEPRECATED_13 (1 << 13) /* cleared */
-#define V3D_FLAG2_DEPRECATED_14 (1 << 14) /* cleared */
-#define V3D_FLAG2_DEPRECATED_15 (1 << 15) /* cleared */
+#define V3D_FLAG2_UNUSED_12 (1 << 12) /* cleared */
+#define V3D_FLAG2_UNUSED_13 (1 << 13) /* cleared */
+#define V3D_FLAG2_UNUSED_14 (1 << 14) /* cleared */
+#define V3D_FLAG2_UNUSED_15 (1 << 15) /* cleared */
/* View3d->gp_flag (short) */
#define V3D_GP_SHOW_PAPER (1 << 0) /* Activate paper to cover all viewport */
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 753c9378797..420573c74e2 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -182,14 +182,14 @@ typedef struct wmWindowManager {
/* wmWindowManager.initialized */
enum {
- WM_WINDOW_IS_INITIALIZED = (1<<0),
- WM_KEYCONFIG_IS_INITIALIZED = (1<<1),
+ WM_WINDOW_IS_INITIALIZED = (1 << 0),
+ WM_KEYCONFIG_IS_INITIALIZED = (1 << 1),
};
#define WM_KEYCONFIG_STR_DEFAULT "blender"
/* IME is win32 only! */
-#ifndef WIN32
+#if !defined(WIN32) && !defined(DNA_DEPRECATED)
# ifdef __GNUC__
# define ime_data ime_data __attribute__ ((deprecated))
# endif
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index daf6bb01ee9..37277d7df8e 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -17,9 +17,7 @@
/** \file
* \ingroup DNA
*
- * Use API in BKE_workspace.h!
- * Struct members marked with DNA_PRIVATE_WORKSPACE will throw a
- * warning saying it's deprecated when used outside of workspace.c.
+ * Use API in BKE_workspace.h to edit these.
*/
#ifndef __DNA_WORKSPACE_TYPES_H__
@@ -27,25 +25,6 @@
#include "DNA_scene_types.h"
-/* Same logic as DNA_DEPRECATED_ALLOW, but throws 'deprecated'
- * warnings if DNA_PRIVATE_WORKSPACE_ALLOW is not defined */
-#ifdef DNA_PRIVATE_WORKSPACE_ALLOW
- /* allow use of private items */
-# define DNA_PRIVATE_WORKSPACE
-#else
-# ifndef DNA_PRIVATE_WORKSPACE
-# define DNA_PRIVATE_WORKSPACE DNA_PRIVATE_ATTR
-# endif
-#endif
-
-#ifdef DNA_PRIVATE_READ_WRITE_ALLOW
-# define DNA_PRIVATE_WORKSPACE_READ_WRITE
-#else
-# ifndef DNA_PRIVATE_WORKSPACE_READ_WRITE
-# define DNA_PRIVATE_WORKSPACE_READ_WRITE DNA_PRIVATE_WORKSPACE
-# endif
-#endif
-
/* Currently testing, allow to disable. */
#define USE_WORKSPACE_TOOL
@@ -111,29 +90,29 @@ typedef struct WorkSpaceLayout {
/* The name of this layout, we override the RNA name of the screen with this
* (but not ID name itself) */
/** MAX_NAME. */
- char name[64] DNA_PRIVATE_WORKSPACE;
+ char name[64];
} WorkSpaceLayout;
/** Optional tags, which features to use, aligned with #bAddon names by convention. */
typedef struct wmOwnerID {
struct wmOwnerID *next, *prev;
/** MAX_NAME. */
- char name[64] DNA_PRIVATE_WORKSPACE;
+ char name[64];
} wmOwnerID;
typedef struct WorkSpace {
ID id;
/** WorkSpaceLayout. */
- ListBase layouts DNA_PRIVATE_WORKSPACE;
+ ListBase layouts;
/* Store for each hook (so for each window) which layout has
* been activated the last time this workspace was visible. */
/** WorkSpaceDataRelation. */
- ListBase hook_layout_relations DNA_PRIVATE_WORKSPACE_READ_WRITE;
+ ListBase hook_layout_relations;
/* Feature tagging (use for addons) */
/** #wmOwnerID. */
- ListBase owner_ids DNA_PRIVATE_WORKSPACE_READ_WRITE;
+ ListBase owner_ids;
/* should be: '#ifdef USE_WORKSPACE_TOOL'. */
@@ -151,7 +130,7 @@ typedef struct WorkSpace {
int object_mode;
/** Enum eWorkSpaceFlags. */
- int flags DNA_PRIVATE_WORKSPACE;
+ int flags;
/* Number for workspace tab reordering in the UI. */
int order;
@@ -160,9 +139,6 @@ typedef struct WorkSpace {
char *status_text;
} WorkSpace;
-/* internal struct, but exported for read/write */
-#if defined(DNA_PRIVATE_READ_WRITE_ALLOW) || defined(DNA_PRIVATE_WORKSPACE_ALLOW)
-
/**
* Generic (and simple/primitive) struct for storing a history of assignments/relations
* of workspace data to non-workspace data in a listbase inside the workspace.
@@ -196,15 +172,13 @@ typedef struct WorkSpaceDataRelation {
void *value;
} WorkSpaceDataRelation;
-#endif /* DNA_PRIVATE_WORKSPACE_READ_WRITE */
-
/**
* Little wrapper to store data that is going to be per window, but coming from the workspace.
* It allows us to keep workspace and window data completely separate.
*/
typedef struct WorkSpaceInstanceHook {
- WorkSpace *active DNA_PRIVATE_WORKSPACE;
- struct WorkSpaceLayout *act_layout DNA_PRIVATE_WORKSPACE;
+ WorkSpace *active;
+ struct WorkSpaceLayout *act_layout;
/* Needed because we can't change workspaces/layouts in running handler loop,
* it would break context. */
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index 161109cdf2d..ca7b22d5ec3 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -98,13 +98,13 @@ typedef struct World {
/* mode */
#define WO_MIST (1 << 0)
-#define WO_MODE_DEPRECATED_1 (1 << 1) /* cleared */
-#define WO_MODE_DEPRECATED_2 (1 << 2) /* cleared */
-#define WO_MODE_DEPRECATED_3 (1 << 3) /* cleared */
-#define WO_MODE_DEPRECATED_4 (1 << 4) /* cleared */
-#define WO_MODE_DEPRECATED_5 (1 << 5) /* cleared */
+#define WO_MODE_UNUSED_1 (1 << 1) /* cleared */
+#define WO_MODE_UNUSED_2 (1 << 2) /* cleared */
+#define WO_MODE_UNUSED_3 (1 << 3) /* cleared */
+#define WO_MODE_UNUSED_4 (1 << 4) /* cleared */
+#define WO_MODE_UNUSED_5 (1 << 5) /* cleared */
#define WO_AMB_OCC (1 << 6)
-#define WO_MODE_DEPRECATED_7 (1 << 7) /* cleared */
+#define WO_MODE_UNUSED_7 (1 << 7) /* cleared */
enum {
WO_MIST_QUADRATIC = 0,
@@ -113,10 +113,10 @@ enum {
};
/* flag */
-#define WO_DS_EXPAND (1<<0)
+#define WO_DS_EXPAND (1 << 0)
/* NOTE: this must have the same value as MA_DS_SHOW_TEXS,
* otherwise anim-editors will not read correctly
*/
-#define WO_DS_SHOW_TEXS (1<<2)
+#define WO_DS_SHOW_TEXS (1 << 2)
#endif
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index 294fb861912..09f95d50f17 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -63,10 +63,12 @@ add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/dna.c
${CMAKE_CURRENT_BINARY_DIR}/dna_type_offsets.h
+ ${CMAKE_CURRENT_BINARY_DIR}/dna_verify.c
COMMAND
"$<TARGET_FILE:makesdna>"
${CMAKE_CURRENT_BINARY_DIR}/dna.c
${CMAKE_CURRENT_BINARY_DIR}/dna_type_offsets.h
+ ${CMAKE_CURRENT_BINARY_DIR}/dna_verify.c
${CMAKE_SOURCE_DIR}/source/blender/makesdna/
DEPENDS makesdna
)
@@ -86,6 +88,7 @@ set(SRC
dna_utils.c
dna_genfile.c
${CMAKE_CURRENT_BINARY_DIR}/dna.c
+ ${CMAKE_CURRENT_BINARY_DIR}/dna_verify.c
${SRC_DNA_INC}
dna_utils.h
@@ -93,6 +96,7 @@ set(SRC
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/dna.c
+ ${CMAKE_CURRENT_BINARY_DIR}/dna_verify.c
${CMAKE_CURRENT_BINARY_DIR}/dna_type_offsets.h
PROPERTIES GENERATED TRUE
)
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index f53651621c2..38e1d0986fd 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -122,6 +122,7 @@
* - 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.
*/
@@ -345,7 +346,9 @@ static bool init_structDNA(
gravity_fix = nr;
}
}
- while (*cp) cp++;
+ while (*cp) {
+ cp++;
+ }
cp++;
}
@@ -373,7 +376,9 @@ static bool init_structDNA(
for (int nr = 0; nr < sdna->nr_types; nr++) {
/* WARNING! See: DNA_struct_rename_legacy_hack_static_from_alias docs. */
sdna->types[nr] = DNA_struct_rename_legacy_hack_static_from_alias(cp);
- while (*cp) cp++;
+ while (*cp) {
+ cp++;
+ }
cp++;
}
@@ -396,7 +401,10 @@ static bool init_structDNA(
*r_error_message = "TLEN error in SDNA file";
return false;
}
- if (sdna->nr_types & 1) sp++; /* prevent BUS error */
+ /* prevent BUS error */
+ if (sdna->nr_types & 1) {
+ sp++;
+ }
/* Struct array ('STRC') */
data = (int *)sp;
@@ -445,8 +453,9 @@ static bool init_structDNA(
if (gravity_fix > -1) {
for (int nr = 0; nr < sdna->nr_structs; nr++) {
sp = sdna->structs[nr];
- if (strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0)
+ if (strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0) {
sp[10] = SDNA_TYPE_VOID;
+ }
}
}
}
@@ -646,15 +655,21 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna
while (b > 0) {
str1 = newsdna->types[sp_new[0]];
str2 = oldsdna->types[sp_old[0]];
- if (strcmp(str1, str2) != 0) break;
+ if (strcmp(str1, str2) != 0) {
+ break;
+ }
str1 = newsdna->names[sp_new[1]];
str2 = oldsdna->names[sp_old[1]];
- if (strcmp(str1, str2) != 0) break;
+ if (strcmp(str1, str2) != 0) {
+ break;
+ }
/* same type and same name, now pointersize */
if (ispointer(str1)) {
- if (oldsdna->pointer_size != newsdna->pointer_size) break;
+ if (oldsdna->pointer_size != newsdna->pointer_size) {
+ break;
+ }
}
b--;
@@ -703,17 +718,17 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna
*/
static eSDNA_Type sdna_type_nr(const char *dna_type)
{
- if ((strcmp(dna_type, "char") == 0) || (strcmp(dna_type, "const char") == 0)) return SDNA_TYPE_CHAR;
- else if ((strcmp(dna_type, "uchar") == 0) || (strcmp(dna_type, "unsigned char") == 0)) return SDNA_TYPE_UCHAR;
- else if ( strcmp(dna_type, "short") == 0) return SDNA_TYPE_SHORT;
- else if ((strcmp(dna_type, "ushort") == 0) || (strcmp(dna_type, "unsigned short") == 0)) return SDNA_TYPE_USHORT;
- else if ( strcmp(dna_type, "int") == 0) return SDNA_TYPE_INT;
- else if ( strcmp(dna_type, "float") == 0) return SDNA_TYPE_FLOAT;
- else if ( strcmp(dna_type, "double") == 0) return SDNA_TYPE_DOUBLE;
- else if ( strcmp(dna_type, "int64_t") == 0) return SDNA_TYPE_INT64;
- else if ( strcmp(dna_type, "uint64_t") == 0) return SDNA_TYPE_UINT64;
+ if ((strcmp(dna_type, "char") == 0) || (strcmp(dna_type, "const char") == 0)) { return SDNA_TYPE_CHAR; }
+ else if ((strcmp(dna_type, "uchar") == 0) || (strcmp(dna_type, "unsigned char") == 0)) { return SDNA_TYPE_UCHAR; }
+ else if ( strcmp(dna_type, "short") == 0) { return SDNA_TYPE_SHORT; }
+ else if ((strcmp(dna_type, "ushort") == 0) || (strcmp(dna_type, "unsigned short") == 0)) { return SDNA_TYPE_USHORT; }
+ else if ( strcmp(dna_type, "int") == 0) { return SDNA_TYPE_INT; }
+ else if ( strcmp(dna_type, "float") == 0) { return SDNA_TYPE_FLOAT; }
+ else if ( strcmp(dna_type, "double") == 0) { return SDNA_TYPE_DOUBLE; }
+ else if ( strcmp(dna_type, "int64_t") == 0) { return SDNA_TYPE_INT64; }
+ else if ( strcmp(dna_type, "uint64_t") == 0) { return SDNA_TYPE_UINT64; }
/* invalid! */
- else return -1;
+ else { return -1; }
}
/**
@@ -780,10 +795,14 @@ static void cast_elem(
case SDNA_TYPE_INT:
*( (int *)curdata) = val; break;
case SDNA_TYPE_FLOAT:
- if (otypenr < 2) val /= 255;
+ if (otypenr < 2) {
+ val /= 255;
+ }
*( (float *)curdata) = val; break;
case SDNA_TYPE_DOUBLE:
- if (otypenr < 2) val /= 255;
+ if (otypenr < 2) {
+ val /= 255;
+ }
*( (double *)curdata) = val; break;
case SDNA_TYPE_INT64:
*( (int64_t *)curdata) = val; break;
@@ -848,9 +867,15 @@ static int elem_strcmp(const char *name, const char *oname)
int a = 0;
while (1) {
- if (name[a] != oname[a]) return 1;
- if (name[a] == '[' || oname[a] == '[') break;
- if (name[a] == 0 || oname[a] == 0) break;
+ if (name[a] != oname[a]) {
+ return 1;
+ }
+ if (name[a] == '[' || oname[a] == '[') {
+ break;
+ }
+ if (name[a] == 0 || oname[a] == 0) {
+ break;
+ }
a++;
}
return 0;
@@ -931,7 +956,9 @@ static const char *find_elem(
if (elem_strcmp(name, oname) == 0) { /* name equal */
if (strcmp(type, otype) == 0) { /* type equal */
- if (sppo) *sppo = old;
+ if (sppo) {
+ *sppo = old;
+ }
return olddata;
}
@@ -983,7 +1010,9 @@ static void reconstruct_elem(
while (*cp && *cp != '[') {
cp++; countpos++;
}
- if (*cp != '[') countpos = 0;
+ if (*cp != '[') {
+ countpos = 0;
+ }
/* in old is the old struct */
elemcount = old[1];
@@ -1087,8 +1116,12 @@ static void reconstruct_struct(
unsigned int cursdna_index_last = UINT_MAX;
- if (oldSDNAnr == -1) return;
- if (curSDNAnr == -1) return;
+ if (oldSDNAnr == -1) {
+ return;
+ }
+ if (curSDNAnr == -1) {
+ return;
+ }
if (compflags[oldSDNAnr] == SDNA_CMP_EQUAL) {
/* if recursive: test for equal */
@@ -1146,7 +1179,9 @@ static void reconstruct_struct(
/* new struct array larger than old */
mulo--;
- if (mulo <= 0) break;
+ if (mulo <= 0) {
+ break;
+ }
}
}
else {
@@ -1179,7 +1214,9 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data)
const char *type, *name;
unsigned int oldsdna_index_last = UINT_MAX;
- if (oldSDNAnr == -1) return;
+ if (oldSDNAnr == -1) {
+ return;
+ }
firststructtypenr = *(oldsdna->structs[0]);
spo = spc = oldsdna->structs[oldSDNAnr];
@@ -1227,7 +1264,9 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data)
/* exception: variable called blocktype: derived from ID_ */
bool skip = false;
if (name[0] == 'b' && name[1] == 'l') {
- if (strcmp(name, "blocktype") == 0) skip = true;
+ if (strcmp(name, "blocktype") == 0) {
+ skip = true;
+ }
}
if (skip == false) {
diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h
index e1fa1e29f96..3ae572f40cf 100644
--- a/source/blender/makesdna/intern/dna_rename_defs.h
+++ b/source/blender/makesdna/intern/dna_rename_defs.h
@@ -87,7 +87,3 @@ DNA_STRUCT_RENAME_ELEM(bTheme, tstatusbar, space_statusbar)
DNA_STRUCT_RENAME_ELEM(bTheme, ttopbar, space_topbar)
DNA_STRUCT_RENAME_ELEM(bTheme, tuserpref, space_preferences)
DNA_STRUCT_RENAME_ELEM(bTheme, tv3d, space_view3d)
-
-#if 0
-DNA_STRUCT_RENAME(Light, Light)
-#endif
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index aee98d8ffa5..3a17aeeae96 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -169,6 +169,7 @@ static short **structs, *structdata;
static struct {
GHash *struct_map_alias_from_static;
GHash *struct_map_static_from_alias;
+ GHash *elem_map_alias_from_static;
GHash *elem_map_static_from_alias;
} g_version_data = {NULL};
@@ -236,7 +237,7 @@ static int convert_include(const char *filename);
/**
* Determine how many bytes are needed for each struct.
*/
-static int calculate_struct_sizes(int);
+static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char *base_directory);
/**
* Construct the DNA.c file
@@ -401,7 +402,9 @@ static int add_name(const char *str)
additional_slen_offset = 0;
- if (str[0] == 0 /* || (str[1] == 0) */) return -1;
+ if (str[0] == 0 /* || (str[1] == 0) */) {
+ return -1;
+ }
if (str[0] == '(' && str[1] == '*') {
/* we handle function pointer and special array cases here, e.g.
@@ -438,8 +441,9 @@ static int add_name(const char *str)
if (str[j] == 0) {
DEBUG_PRINTF(3, "offsetting for multidim array pointer\n");
}
- else
+ else {
printf("Error during tokening multidim array pointer\n");
+ }
}
else if (str[j] == 0) {
DEBUG_PRINTF(3, "offsetting for space\n");
@@ -615,17 +619,6 @@ static int preprocess_include(char *maindata, const int maindata_len)
a -= 13;
cp += 13;
}
- else if (strncmp("DNA_PRIVATE_WORKSPACE", cp, 21) == 0) {
- /* Check for DNA_PRIVATE_WORKSPACE_READ_WRITE */
- if (strncmp("_READ_WRITE", cp + 21, 11) == 0) {
- a -= 31;
- cp += 31;
- }
- else {
- a -= 20;
- cp += 20;
- }
- }
else {
md[0] = cp[0];
md++;
@@ -714,9 +707,14 @@ static int convert_include(const char *filename)
skip_struct = false;
}
else {
- if (md[-1] == ' ') md[-1] = 0;
+ if (md[-1] == ' ') {
+ md[-1] = 0;
+ }
md1 = md - 2;
- while (*md1 != 32) md1--; /* to beginning of word */
+ while (*md1 != 32) {
+ /* to beginning of word */
+ md1--;
+ }
md1++;
/* we've got a struct name when... */
@@ -736,22 +734,28 @@ static int convert_include(const char *filename)
/* first lets make it all nice strings */
md1 = md + 1;
while (*md1 != '}') {
- if (md1 > mainend) break;
+ if (md1 > mainend) {
+ break;
+ }
- if (*md1 == ',' || *md1 == ' ') *md1 = 0;
+ if (*md1 == ',' || *md1 == ' ') {
+ *md1 = 0;
+ }
md1++;
}
/* read types and names until first character that is not '}' */
md1 = md + 1;
while (*md1 != '}') {
- if (md1 > mainend) break;
+ if (md1 > mainend) {
+ break;
+ }
/* skip when it says 'struct' or 'unsigned' or 'const' */
if (*md1) {
- if (strncmp(md1, "struct", 6) == 0) md1 += 7;
- if (strncmp(md1, "unsigned", 8) == 0) md1 += 9;
- if (strncmp(md1, "const", 5) == 0) md1 += 6;
+ if (strncmp(md1, "struct", 6) == 0) { md1 += 7; }
+ if (strncmp(md1, "unsigned", 8) == 0) { md1 += 9; }
+ if (strncmp(md1, "const", 5) == 0) { md1 += 6; }
/* we've got a type! */
type = add_type(md1, 0);
@@ -767,7 +771,9 @@ static int convert_include(const char *filename)
/* read until ';' */
while (*md1 != ';') {
- if (md1 > mainend) break;
+ if (md1 > mainend) {
+ break;
+ }
if (*md1) {
/* We've got a name. slen needs
@@ -857,11 +863,21 @@ static bool check_field_alignment(int firststruct, int structtype, int type, int
return result;
}
-static int calculate_struct_sizes(int firststruct)
+static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char *base_directory)
{
int unknown = nr_structs, lastunknown;
bool dna_error = false;
+ /* Write test to verify sizes are accurate. */
+ fprintf(file_verify, "/* Verify struct sizes and member offsets are as expected by DNA. */\n");
+ fprintf(file_verify, "#include \"BLI_assert.h\"\n\n");
+ fprintf(file_verify, "#define DNA_DEPRECATED\n");
+ for (int i = 0; *(includefiles[i]) != '\0'; i++) {
+ fprintf(file_verify, "#include \"%s%s\"\n", base_directory, includefiles[i]);
+ }
+ fprintf(file_verify, "\n");
+
+ /* Multiple iterations to handle nested structs. */
while (unknown) {
lastunknown = unknown;
unknown = 0;
@@ -870,6 +886,7 @@ static int calculate_struct_sizes(int firststruct)
for (int a = 0; a < nr_structs; a++) {
const short *structpoin = structs[a];
const int structtype = structpoin[0];
+ const char *structname = version_struct_alias_from_static(types[structtype]);
/* when length is not known... */
if (types_size_native[structtype] == 0) {
@@ -884,8 +901,18 @@ static int calculate_struct_sizes(int firststruct)
for (int b = 0; b < structpoin[1]; b++, sp += 2) {
int type = sp[0];
const char *cp = names[sp[1]];
-
int namelen = (int)strlen(cp);
+
+ /* Write size verification to file. */
+ {
+ char *name_static = alloca(namelen + 1);
+ DNA_elem_id_strip_copy(name_static, cp);
+ const char *str_pair[2] = {types[structtype], name_static};
+ const char *name_alias = BLI_ghash_lookup(g_version_data.elem_map_alias_from_static, str_pair);
+ fprintf(file_verify, "BLI_STATIC_ASSERT(offsetof(struct %s, %s) == %d, \"DNA member offset verify\");\n",
+ structname, name_alias ? name_alias : name_static, size_native);
+ }
+
/* is it a pointer or function pointer? */
if (cp[0] == '*' || cp[1] == '*') {
has_pointer = 1;
@@ -1001,11 +1028,15 @@ static int calculate_struct_sizes(int firststruct)
dna_error = 1;
}
+ /* Write size verification to file. */
+ fprintf(file_verify, "BLI_STATIC_ASSERT(sizeof(struct %s) == %d, \"DNA struct size verify\");\n\n", structname, size_native);
}
}
}
- if (unknown == lastunknown) break;
+ if (unknown == lastunknown) {
+ break;
+ }
}
if (unknown) {
@@ -1088,7 +1119,7 @@ void print_struct_sizes(void)
}
-static int make_structDNA(const char *baseDirectory, FILE *file, FILE *file_offsets)
+static int make_structDNA(const char *base_directory, FILE *file, FILE *file_offsets, FILE *file_verify)
{
int i;
const short *sp;
@@ -1119,7 +1150,7 @@ static int make_structDNA(const char *baseDirectory, FILE *file, FILE *file_offs
DNA_alias_maps(
DNA_RENAME_ALIAS_FROM_STATIC,
&g_version_data.struct_map_alias_from_static,
- NULL);
+ &g_version_data.elem_map_alias_from_static);
DNA_alias_maps(
DNA_RENAME_STATIC_FROM_ALIAS,
&g_version_data.struct_map_static_from_alias,
@@ -1158,7 +1189,7 @@ static int make_structDNA(const char *baseDirectory, FILE *file, FILE *file_offs
/* Mind the breaking condition here! */
DEBUG_PRINTF(0, "\tStart of header scan:\n");
for (i = 0; *(includefiles[i]) != '\0'; i++) {
- sprintf(str, "%s%s", baseDirectory, includefiles[i]);
+ sprintf(str, "%s%s", base_directory, includefiles[i]);
DEBUG_PRINTF(0, "\t|-- Converting %s\n", str);
if (convert_include(str)) {
return 1;
@@ -1166,7 +1197,7 @@ static int make_structDNA(const char *baseDirectory, FILE *file, FILE *file_offs
}
DEBUG_PRINTF(0, "\tFinished scanning %d headers.\n", i);
- if (calculate_struct_sizes(firststruct)) {
+ if (calculate_struct_sizes(firststruct, file_verify, base_directory)) {
/* error */
return 1;
}
@@ -1250,7 +1281,9 @@ static int make_structDNA(const char *baseDirectory, FILE *file, FILE *file_offs
dna_write(file, "TLEN", 4);
len = 2 * nr_types;
- if (nr_types & 1) len += 2;
+ if (nr_types & 1) {
+ len += 2;
+ }
dna_write(file, types_size_native, len);
/* WRITE STRUCTS */
@@ -1266,37 +1299,6 @@ static int make_structDNA(const char *baseDirectory, FILE *file, FILE *file_offs
dna_write(file, structs[0], len);
- /* a simple dna padding test */
- if (0) {
- FILE *fp;
- int a;
-
- fp = fopen("padding.c", "w");
- if (fp == NULL) {
- /* pass */
- }
- else {
-
- /* add all include files defined in the global array */
- for (i = 0; *(includefiles[i]) != '\0'; i++) {
- fprintf(fp, "#include \"%s%s\"\n", baseDirectory, includefiles[i]);
- }
-
- fprintf(fp, "main() {\n");
- sp = types_size_native;
- sp += firststruct;
- for (a = firststruct; a < nr_types; a++, sp++) {
- if (*sp) {
- fprintf(fp, "\tif (sizeof(struct %s) - %d) printf(\"ALIGN ERROR:", types[a], *sp);
- fprintf(fp, "%%d %s %d ", types[a], *sp);
- fprintf(fp, "\\n\", sizeof(struct %s) - %d);\n", types[a], *sp);
- }
- }
- fprintf(fp, "}\n");
- fclose(fp);
- }
- }
- /* end end padding test */
}
/* write a simple enum with all structs offsets,
@@ -1310,7 +1312,7 @@ static int make_structDNA(const char *baseDirectory, FILE *file, FILE *file_offs
fprintf(file_offsets, "\t_SDNA_TYPE_%s = %d,\n", version_struct_alias_from_static(types[structtype]), i);
}
fprintf(file_offsets, "\tSDNA_TYPE_MAX = %d,\n", nr_structs);
- fprintf(file_offsets, "};\n");
+ fprintf(file_offsets, "};\n\n");
}
/* Check versioning errors which could cause duplicate names,
@@ -1350,6 +1352,7 @@ static int make_structDNA(const char *baseDirectory, FILE *file, FILE *file_offs
BLI_ghash_free(g_version_data.struct_map_alias_from_static, NULL, NULL);
BLI_ghash_free(g_version_data.struct_map_static_from_alias, NULL, NULL);
BLI_ghash_free(g_version_data.elem_map_static_from_alias, MEM_freeN, NULL);
+ BLI_ghash_free(g_version_data.elem_map_alias_from_static, MEM_freeN, NULL);
DEBUG_PRINTF(0, "done.\n");
@@ -1381,13 +1384,14 @@ int main(int argc, char **argv)
{
int return_status = 0;
- if (argc != 3 && argc != 4) {
+ if (argc != 4 && argc != 5) {
printf("Usage: %s dna.c dna_struct_offsets.h [base directory]\n", argv[0]);
return_status = 1;
}
else {
FILE *file_dna = fopen(argv[1], "w");
FILE *file_dna_offsets = fopen(argv[2], "w");
+ FILE *file_dna_verify = fopen(argv[3], "w");
if (!file_dna) {
printf("Unable to open file: %s\n", argv[1]);
return_status = 1;
@@ -1396,19 +1400,23 @@ int main(int argc, char **argv)
printf("Unable to open file: %s\n", argv[2]);
return_status = 1;
}
+ else if (!file_dna_verify) {
+ printf("Unable to open file: %s\n", argv[3]);
+ return_status = 1;
+ }
else {
- const char *baseDirectory;
+ const char *base_directory;
- if (argc == 4) {
- baseDirectory = argv[3];
+ if (argc == 5) {
+ base_directory = argv[4];
}
else {
- baseDirectory = BASE_HEADER;
+ base_directory = BASE_HEADER;
}
fprintf(file_dna, "extern const unsigned char DNAstr[];\n");
fprintf(file_dna, "const unsigned char DNAstr[] = {\n");
- if (make_structDNA(baseDirectory, file_dna, file_dna_offsets)) {
+ if (make_structDNA(base_directory, file_dna, file_dna_offsets, file_dna_verify)) {
/* error */
fclose(file_dna);
file_dna = NULL;
@@ -1428,6 +1436,9 @@ int main(int argc, char **argv)
if (file_dna_offsets) {
fclose(file_dna_offsets);
}
+ if (file_dna_verify) {
+ fclose(file_dna_verify);
+ }
}
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 638e088c7b2..e976e39a28f 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1159,7 +1159,7 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name);
#define RNA_PROP_END \
} \
RNA_property_collection_end(&rna_macro_iter); \
- }
+ } ((void)0)
#define RNA_STRUCT_BEGIN(sptr, prop) \
{ \
@@ -1176,7 +1176,7 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name);
#define RNA_STRUCT_END \
} \
RNA_property_collection_end(&rna_macro_iter); \
- }
+ } ((void)0)
/* check if the idproperty exists, for operators */
bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost);
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index e713007cc03..49e1444d6ef 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -239,6 +239,11 @@ typedef enum PropertyFlag {
PROP_DYNAMIC = (1 << 17), /* for dynamic arrays, and retvals of type string */
PROP_ENUM_NO_CONTEXT = (1 << 24), /* for enum that shouldn't be contextual */
PROP_ENUM_NO_TRANSLATE = (1 << 29), /* for enums not to be translated (e.g. viewlayers' names in nodes) */
+
+ /* Don't do dependency graph tag from a property update callback.
+ * Use this for properties which defines interface state, for example,
+ * properties which denotes whether modifier panel is collapsed or not. */
+ PROP_NO_DEG_UPDATE = (1 << 30),
} PropertyFlag;
/* Flags related to comparing and overriding RNA properties. Make sure enums are updated with these */
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index b19a5109589..444f051c818 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -31,6 +31,7 @@
#include "RNA_define.h"
#include "RNA_types.h"
+#include "RNA_enum_types.h"
#include "rna_internal.h"
@@ -2957,7 +2958,9 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
}
}
else {
- if (!defaultfound) {
+ if (!defaultfound &&
+ !(eprop->itemf && eprop->item == DummyRNA_NULL_items))
+ {
CLOG_ERROR(&LOG, "%s%s.%s, enum default is not in items.",
srna->identifier, errnest, prop->identifier);
DefRNA.error = 1;
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index fac3864d089..70c342f4665 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -1339,7 +1339,7 @@ static void rna_def_library(BlenderRNA *brna)
/**
* \attention This is separate from the above. It allows for RNA functions to
* return an IDProperty *. See MovieClip.metadata for a usage example.
- **/
+ */
static void rna_def_idproperty_wrap_ptr(BlenderRNA *brna)
{
StructRNA *srna;
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 8282ed04520..1d391988cbd 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -219,7 +219,6 @@ PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *da
}
}
-/**/
void RNA_pointer_recast(PointerRNA *ptr, PointerRNA *r_ptr)
{
#if 0 /* works but this case if covered by more general code below. */
@@ -2188,7 +2187,7 @@ static void rna_property_update(bContext *C, Main *bmain, Scene *scene, PointerR
/* we could add NULL check, for now don't */
WM_msg_publish_rna(mbus, ptr, prop);
}
- if (ptr->id.data != NULL) {
+ if (ptr->id.data != NULL && ((prop->flag & PROP_NO_DEG_UPDATE) == 0)) {
const short id_type = GS(((ID *)ptr->id.data)->name);
if (ID_TYPE_IS_COW(id_type)) {
DEG_id_tag_update(ptr->id.data, ID_RECALC_COPY_ON_WRITE);
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index fd45a9a9048..7d86c42c561 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -47,8 +47,11 @@
#include "BKE_fcurve.h"
+#include "DEG_depsgraph.h"
+
#include "ED_keyframing.h"
+#include "WM_api.h"
static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter)
{
@@ -94,6 +97,9 @@ static void rna_Action_groups_remove(bAction *act, ReportList *reports, PointerR
MEM_freeN(agrp);
RNA_POINTER_INVALIDATE(agrp_ptr);
+
+ DEG_id_tag_update(&act->id, ID_RECALC_ANIMATION_NO_FLUSH);
+ WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
static FCurve *rna_Action_fcurve_new(bAction *act, Main *bmain, ReportList *reports, const char *data_path,
@@ -150,6 +156,9 @@ static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, PointerR
free_fcurve(fcu);
RNA_POINTER_INVALIDATE(fcu_ptr);
}
+
+ DEG_id_tag_update(&act->id, ID_RECALC_ANIMATION_NO_FLUSH);
+ WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
static TimeMarker *rna_Action_pose_markers_new(bAction *act, const char name[])
@@ -545,6 +554,7 @@ static void rna_def_action_group(BlenderRNA *brna)
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
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_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 1c16abcd12f..4440cd2313c 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -580,7 +580,7 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); \
else \
RNA_def_property_update(prop, 0, "rna_Armature_update_data"); \
- } (void)0;
+ } ((void)0)
PropertyRNA *prop;
diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c
index 9906fa49dcb..9ffc53d2ad9 100644
--- a/source/blender/makesrna/intern/rna_boid.c
+++ b/source/blender/makesrna/intern/rna_boid.c
@@ -207,8 +207,9 @@ static char *rna_BoidSettings_path(PointerRNA *ptr)
if (particle_id_check(ptr)) {
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
- if (part->boids == boids)
- return BLI_sprintfN("boids");
+ if (part->boids == boids) {
+ return BLI_strdup("boids");
+ }
}
return NULL;
}
@@ -441,6 +442,7 @@ static void rna_def_boidrule(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Boids_reset");
/*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, "mode", eModifierMode_Expanded); */
/*RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface"); */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index aba1f08ed6b..a5f43a580c5 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -80,7 +80,7 @@ const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = {
{SCULPT_TOOL_ROTATE, "ROTATE", ICON_BRUSH_ROTATE, "Rotate", ""},
{0, "", 0, NULL, NULL},
{SCULPT_TOOL_MASK, "MASK", ICON_BRUSH_MASK, "Mask", ""},
- {SCULPT_TOOL_SIMPLIFY, "SIMPLIFY", ICON_BRUSH_SUBTRACT /* icon TODO */, "Simplify", ""},
+ {SCULPT_TOOL_SIMPLIFY, "SIMPLIFY", ICON_BRUSH_DATA /* icon TODO */, "Simplify", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -126,10 +126,10 @@ static EnumPropertyItem rna_enum_gpencil_brush_eraser_modes_items[] = {
};
static EnumPropertyItem rna_enum_gpencil_fill_draw_modes_items[] = {
+ {GP_FILL_DMODE_BOTH, "BOTH", 0, "Default", "Use both visible strokes and edit lines as fill boundary limits"},
{GP_FILL_DMODE_STROKE, "STROKE", 0, "Strokes", "Use visible strokes as fill boundary limits"},
- {GP_FILL_DMODE_CONTROL, "CONTROL", 0, "Control", "Use internal control lines as fill boundary limits"},
- {GP_FILL_DMODE_BOTH, "BOTH", 0, "Both", "Use visible strokes and control lines as fill boundary limits"},
- {0, NULL, 0, NULL, NULL},
+ {GP_FILL_DMODE_CONTROL, "CONTROL", 0, "Edit Lines", "Use edit lines as fill boundary limits"},
+ {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem rna_enum_gpencil_brush_icons_items[] = {
@@ -159,6 +159,7 @@ static EnumPropertyItem rna_enum_gpencil_brush_icons_items[] = {
#include "BKE_icons.h"
#include "BKE_gpencil.h"
#include "BKE_paint.h"
+#include "BKE_material.h"
#include "WM_api.h"
@@ -346,6 +347,16 @@ static bool rna_TextureCapabilities_has_texture_angle_get(PointerRNA *ptr)
return mtex->brush_map_mode != MTEX_MAP_MODE_3D;
}
+static bool rna_BrushCapabilitiesSculpt_has_direction_get(PointerRNA *ptr)
+{
+ Brush *br = (Brush *)ptr->data;
+ return !ELEM(br->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_CLAY,
+ SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE,
+ SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE, SCULPT_TOOL_FLATTEN,
+ SCULPT_TOOL_FILL, SCULPT_TOOL_SCRAPE, SCULPT_TOOL_CLAY,
+ SCULPT_TOOL_PINCH, SCULPT_TOOL_MASK);
+}
+
static bool rna_BrushCapabilitiesSculpt_has_gravity_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
@@ -432,29 +443,10 @@ static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
/*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */
}
-static void rna_Brush_material_update(bContext *C, PointerRNA *ptr)
+static void rna_Brush_material_update(bContext *UNUSED(C), PointerRNA *UNUSED(ptr))
{
- Main *bmain = CTX_data_main(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- Object *ob = OBACT(view_layer);
- Brush *br = (Brush *)ptr->id.data;
- int index;
-
- /* set material slot to same material */
- if ((ob) && (ob->type == OB_GPENCIL) && (br->gpencil_settings != NULL)) {
- BrushGpencilSettings *gpencil_settings = br->gpencil_settings;
- if (gpencil_settings->material != NULL) {
-
- index = BKE_gpencil_get_material_index(ob, gpencil_settings->material);
- if ((index > 0) && (ob->actcol != index)) {
- ob->actcol = index;
- /* update other brushes to keep all synchro */
- BKE_brush_update_material(bmain, gpencil_settings->material, br);
- }
-
- }
- WM_main_add_notifier(NC_SPACE | ND_SPACE_PROPERTIES, NULL);
- }
+ /* number of material users changed */
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_PROPERTIES, NULL);
}
static void rna_Brush_main_tex_update(bContext *C, PointerRNA *ptr)
@@ -713,6 +705,24 @@ static void rna_BrushGpencilSettings_default_eraser_update(Main *bmain, Scene *s
}
}
+static void rna_BrushGpencilSettings_use_material_pin_update(bContext *C, PointerRNA *ptr)
+{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ Object *ob = OBACT(view_layer);
+ Brush *brush = ptr->id.data;
+
+ if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
+ Material *material = give_current_material(ob, ob->actcol);
+ BKE_gpencil_brush_set_material(brush, material);
+ }
+ else {
+ BKE_gpencil_brush_set_material(brush, NULL);
+ }
+
+ /* number of material users changed */
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_PROPERTIES, NULL);
+}
+
static void rna_BrushGpencilSettings_eraser_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
ToolSettings *ts = scene->toolsettings;
@@ -880,6 +890,7 @@ static void rna_def_sculpt_capabilities(BlenderRNA *brna)
SCULPT_TOOL_CAPABILITY(has_smooth_stroke, "Has Smooth Stroke");
SCULPT_TOOL_CAPABILITY(has_space_attenuation, "Has Space Attenuation");
SCULPT_TOOL_CAPABILITY(has_strength_pressure, "Has Strength Pressure");
+ SCULPT_TOOL_CAPABILITY(has_direction, "Has Direction");
SCULPT_TOOL_CAPABILITY(has_gravity, "Has Gravity");
#undef SCULPT_CAPABILITY
@@ -1003,7 +1014,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "draw_sensitivity");
RNA_def_property_range(prop, 0.1f, 3.0f);
RNA_def_property_ui_text(prop, "Sensitivity", "Pressure sensitivity factor for new strokes");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Strength factor for new strokes */
@@ -1012,7 +1023,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
RNA_def_property_ui_text(prop, "Strength", "Color strength for new strokes (affect alpha factor of color)");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Jitter factor for new strokes */
@@ -1020,7 +1031,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "draw_jitter");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Jitter", "Jitter factor for new strokes");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Randomnes factor for pressure */
@@ -1028,7 +1039,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "draw_random_press");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Pressure Randomness", "Randomness factor for pressure in new strokes");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Randomnes factor for strength */
@@ -1036,7 +1047,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "draw_random_strength");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Strength Randomness", "Randomness factor strength in new strokes");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Randomnes factor for subdivision */
@@ -1044,71 +1055,78 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "draw_random_sub");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Random Subdivision", "Randomness factor for new strokes after subdivision");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Angle when brush is full size */
prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "draw_angle");
RNA_def_property_range(prop, -M_PI_2, M_PI_2);
- RNA_def_property_ui_text(prop, "Angle",
- "Direction of the stroke at which brush gives maximal thickness "
- "(0° for horizontal)");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Angle",
+ "Direction of the stroke at which brush gives maximal thickness "
+ "(0° for horizontal)");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Factor to change brush size depending of angle */
prop = RNA_def_property(srna, "angle_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "draw_angle_factor");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Angle Factor",
- "Reduce brush thickness by this factor when stroke is perpendicular to 'Angle' direction");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Angle Factor",
+ "Reduce brush thickness by this factor when stroke is perpendicular to 'Angle' direction");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Smoothing factor for new strokes */
prop = RNA_def_property(srna, "pen_smooth_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "draw_smoothfac");
RNA_def_property_range(prop, 0.0, 2.0f);
- RNA_def_property_ui_text(prop, "Smooth",
- "Amount of smoothing to apply after finish newly created strokes, to reduce jitter/noise");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Smooth",
+ "Amount of smoothing to apply after finish newly created strokes, to reduce jitter/noise");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Iterations of the Smoothing factor */
prop = RNA_def_property(srna, "pen_smooth_steps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "draw_smoothlvl");
RNA_def_property_range(prop, 1, 3);
- RNA_def_property_ui_text(prop, "Iterations",
- "Number of times to smooth newly created strokes");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Iterations",
+ "Number of times to smooth newly created strokes");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Thickness smoothing factor for new strokes */
prop = RNA_def_property(srna, "pen_thick_smooth_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "thick_smoothfac");
RNA_def_property_range(prop, 0.0, 2.0f);
- RNA_def_property_ui_text(prop, "Smooth Thickness",
- "Amount of thickness smoothing to apply after finish newly created strokes, to reduce jitter/noise");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Smooth Thickness",
+ "Amount of thickness smoothing to apply after finish newly created strokes, to reduce jitter/noise");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Thickness iterations of the Smoothing factor */
prop = RNA_def_property(srna, "pen_thick_smooth_steps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "thick_smoothlvl");
RNA_def_property_range(prop, 1, 3);
- RNA_def_property_ui_text(prop, "Iterations Thickness",
- "Number of times to smooth thickness for newly created strokes");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Iterations Thickness",
+ "Number of times to smooth thickness for newly created strokes");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Subdivision level for new strokes */
prop = RNA_def_property(srna, "pen_subdivision_steps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "draw_subdivide");
RNA_def_property_range(prop, 0, 3);
- RNA_def_property_ui_text(prop, "Subdivision Steps",
- "Number of times to subdivide newly created strokes, for less jagged strokes");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Subdivision Steps",
+ "Number of times to subdivide newly created strokes, for less jagged strokes");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Curves for pressure */
@@ -1116,96 +1134,111 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "curve_sensitivity");
RNA_def_property_struct_type(prop, "CurveMapping");
RNA_def_property_ui_text(prop, "Curve Sensitivity", "Curve used for the sensitivity");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "curve_strength", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "curve_strength");
RNA_def_property_struct_type(prop, "CurveMapping");
RNA_def_property_ui_text(prop, "Curve Strength", "Curve used for the strength");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "curve_jitter", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "curve_jitter");
RNA_def_property_struct_type(prop, "CurveMapping");
RNA_def_property_ui_text(prop, "Curve Jitter", "Curve used for the jitter effect");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* fill threshold for transparence */
prop = RNA_def_property(srna, "fill_threshold", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "fill_threshold");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Threshold",
- "Threshold to consider color transparent for filling");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Threshold",
+ "Threshold to consider color transparent for filling");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* fill leak size */
prop = RNA_def_property(srna, "fill_leak", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "fill_leak");
RNA_def_property_range(prop, 0, 100);
- RNA_def_property_ui_text(prop, "Leak Size",
- "Size in pixels to consider the leak closed");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Leak Size",
+ "Size in pixels to consider the leak closed");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+ /* fill factor size */
+ prop = RNA_def_property(srna, "fill_factor", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "fill_factor");
+ RNA_def_property_range(prop, 1, 8);
+ RNA_def_property_ui_text(prop, "Resolution",
+ "Multiplier for fill resolution, higher resolution is more accurate but slower");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* fill simplify steps */
prop = RNA_def_property(srna, "fill_simplify_level", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "fill_simplylvl");
RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "Simplify",
- "Number of simplify steps (large values reduce fill accuracy)");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Simplify",
+ "Number of simplify steps (large values reduce fill accuracy)");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "uv_random", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "uv_random");
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "UV Random", "Random factor for autogenerated UV rotation");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "input_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "input_samples");
RNA_def_property_range(prop, 0, GP_MAX_INPUT_SAMPLES);
RNA_def_property_ui_text(prop, "Input Samples", "Generate intermediate points for very fast mouse movements. Set to 0 to disable");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* active smooth factor while drawing */
prop = RNA_def_property(srna, "active_smooth_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "active_smooth");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Active Smooth",
- "Amount of smoothing while drawing ");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Active Smooth",
+ "Amount of smoothing while drawing ");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "eraser_strength_factor", PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_sdna(prop, NULL, "era_strength_f");
RNA_def_property_range(prop, 0.0, 100.0);
RNA_def_property_ui_range(prop, 0.0, 100.0, 10, 1);
- RNA_def_property_ui_text(prop, "Affect Stroke Strength",
- "Amount of erasing for strength ");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Affect Stroke Strength",
+ "Amount of erasing for strength ");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "eraser_thickness_factor", PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_sdna(prop, NULL, "era_thickness_f");
RNA_def_property_range(prop, 0.0, 100.0);
RNA_def_property_ui_range(prop, 0.0, 100.0, 10, 1);
- RNA_def_property_ui_text(prop, "Affect Stroke Thickness",
- "Amount of erasing for thickness ");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Affect Stroke Thickness",
+ "Amount of erasing for thickness ");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* brush standard icon */
prop = RNA_def_property(srna, "gp_icon", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "icon_id");
RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_icons_items);
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Grease Pencil Icon", "");
/* Flags */
@@ -1213,54 +1246,55 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_PRESSURE);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(prop, "Use Pressure", "Use tablet pressure");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "use_strength_pressure", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_STENGTH_PRESSURE);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(prop, "Use Pressure Strength", "Use tablet pressure for color strength");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "use_jitter_pressure", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_JITTER_PRESSURE);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(prop, "Use Pressure Jitter", "Use tablet pressure for jitter");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "use_settings_stabilizer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_STABILIZE_MOUSE);
RNA_def_property_boolean_default(prop, true);
- RNA_def_property_ui_text(prop, "Use Stabilizer",
- "Draw lines with a delay to allow smooth strokes. Press Shift key to override while drawing");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Use Stabilizer",
+ "Draw lines with a delay to allow smooth strokes. Press Shift key to override while drawing");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "use_cursor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_ENABLE_CURSOR);
RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_text(prop, "Enable Cursor", "Enable cursor on screen");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "eraser_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "eraser_mode");
RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_eraser_modes_items);
RNA_def_property_ui_text(prop, "Mode", "Eraser Mode");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_BrushGpencilSettings_eraser_mode_update");
prop = RNA_def_property(srna, "fill_draw_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "fill_draw_mode");
RNA_def_property_enum_items(prop, rna_enum_gpencil_fill_draw_modes_items);
RNA_def_property_ui_text(prop, "Mode", "Mode to draw boundary limits");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "trim", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_TRIM_STROKE);
RNA_def_property_boolean_default(prop, false);
RNA_def_property_ui_text(prop, "Trim Stroke Ends", "Trim intersecting stroke ends");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
/* Material */
prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
@@ -1268,55 +1302,58 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_BrushGpencilSettings_material_poll");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK | PROP_CONTEXT_UPDATE);
RNA_def_property_ui_text(prop, "Material", "Material used for strokes drawn using this brush");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_Brush_material_update");
prop = RNA_def_property(srna, "show_fill_boundary", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_FILL_SHOW_HELPLINES);
RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_text(prop, "Show Lines", "Show help lines for filling to see boundaries");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "show_fill", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_BRUSH_FILL_HIDE);
RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_text(prop, "Show Fill", "Show transparent lines to use as boundary for filling");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "use_default_eraser", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_DEFAULT_ERASER);
RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
RNA_def_property_ui_text(prop, "Default Eraser", "Use this brush when enable eraser with fast switch key");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_BrushGpencilSettings_default_eraser_update");
prop = RNA_def_property(srna, "use_settings_postprocess", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_GROUP_SETTINGS);
RNA_def_property_ui_text(prop, "Use Post-Process Settings", "Additional post processing options for new strokes");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "use_settings_random", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_GROUP_RANDOM);
RNA_def_property_ui_text(prop, "Random Settings", "Random brush settings");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "use_material_pin", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_MATERIAL_PINNED);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
RNA_def_property_ui_text(prop, "Pin Material", "Keep material assigned to brush");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_BrushGpencilSettings_use_material_pin_update");
prop = RNA_def_property(srna, "show_lasso", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_BRUSH_DISSABLE_LASSO);
RNA_def_property_ui_text(prop, "Show Lasso", "Do not draw fill color while drawing the stroke");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "use_occlude_eraser", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_BRUSH_OCCLUDE_ERASER);
- RNA_def_property_ui_text(prop, "Occlude Eraser",
- "Erase only strokes visible and not occluded");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Occlude Eraser",
+ "Erase only strokes visible and not occluded");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
static void rna_def_brush(BlenderRNA *brna)
@@ -1399,6 +1436,12 @@ static void rna_def_brush(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem brush_size_unit_items[] = {
+ {0, "VIEW", 0, "View", "Measure brush size relateve to the view"},
+ {BRUSH_LOCK_SIZE, "SCENE", 0, "Scene", "Measure brush size relateve to the scene"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
srna = RNA_def_struct(brna, "Brush", "ID");
RNA_def_struct_ui_text(srna, "Brush", "Brush data-block for storing brush settings for painting and sculpting");
RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA);
@@ -1442,7 +1485,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "gpencil_tool");
RNA_def_property_enum_items(prop, rna_enum_brush_gpencil_types_items);
RNA_def_property_ui_text(prop, "Type", "Category of the brush");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
/** End per mode tool properties. */
@@ -1505,7 +1548,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush daubs as a percentage of brush diameter");
RNA_def_property_update(prop, 0, "rna_Brush_update");
- prop = RNA_def_property(srna, "grad_spacing", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "grad_spacing", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "gradient_spacing");
RNA_def_property_range(prop, 1, 10000);
RNA_def_property_ui_range(prop, 1, 10000, 5, -1);
@@ -1699,7 +1742,6 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_original_normal", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ORIGINAL_NORMAL);
- RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
RNA_def_property_ui_text(prop, "Original Normal",
"When locked keep using normal of surface where stroke was initiated");
RNA_def_property_update(prop, 0, "rna_Brush_update");
@@ -1810,8 +1852,7 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_space_attenuation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACE_ATTEN);
- RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
- RNA_def_property_ui_text(prop, "Use Automatic Strength Adjustment",
+ RNA_def_property_ui_text(prop, "Adjust Strength for Spacing",
"Automatically adjust strength to give consistent results for different spacings");
RNA_def_property_update(prop, 0, "rna_Brush_update");
@@ -1822,12 +1863,10 @@ static void rna_def_brush(BlenderRNA *brna)
"Space daubs according to surface orientation instead of screen space");
RNA_def_property_update(prop, 0, "rna_Brush_update");
- prop = RNA_def_property(srna, "use_locked_size", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_LOCK_SIZE);
- RNA_def_property_ui_text(prop, "Use Blender Units",
- "When locked brush stays same size relative to object; when unlocked brush size is "
- "given in pixels");
- RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
+ prop = RNA_def_property(srna, "use_locked_size", PROP_ENUM, PROP_NONE); /* as an enum */
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_items(prop, brush_size_unit_items);
+ RNA_def_property_ui_text(prop, "Radius Unit", "Measure brush size relative to the view or the scene");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "use_edge_to_edge", PROP_BOOLEAN, PROP_NONE);
@@ -1843,7 +1882,7 @@ static void rna_def_brush(BlenderRNA *brna)
/* only for projection paint & vertex paint, TODO, other paint modes */
prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BRUSH_LOCK_ALPHA);
- RNA_def_property_ui_text(prop, "Alpha", "When this is disabled, lock alpha while painting");
+ RNA_def_property_ui_text(prop, "Affect Alpha", "When this is disabled, lock alpha while painting");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c
index 0912c9bdc6e..5f930c178a2 100644
--- a/source/blender/makesrna/intern/rna_camera.c
+++ b/source/blender/makesrna/intern/rna_camera.c
@@ -225,6 +225,7 @@ static void rna_def_camera_background_image(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
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", CAM_BGIMG_FLAG_EXPANDED);
RNA_def_property_ui_text(prop, "Show Expanded", "Show the expanded in the user interface");
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
@@ -372,17 +373,6 @@ void RNA_def_camera(BlenderRNA *brna)
{CAM_PANO, "PANO", 0, "Panoramic", ""},
{0, NULL, 0, NULL, NULL},
};
- static const EnumPropertyItem prop_display_type_extra_items[] = {
- {CAM_DTX_CENTER, "CENTER", 0, "Center", ""},
- {CAM_DTX_CENTER_DIAG, "CENTER_DIAGONAL", 0, "Center Diagonal", ""},
- {CAM_DTX_THIRDS, "THIRDS", 0, "Thirds", ""},
- {CAM_DTX_GOLDEN, "GOLDEN", 0, "Golden", ""},
- {CAM_DTX_GOLDEN_TRI_A, "GOLDEN_TRIANGLE_A", 0, "Golden Triangle A", ""},
- {CAM_DTX_GOLDEN_TRI_B, "GOLDEN_TRIANGLE_B", 0, "Golden Triangle B", ""},
- {CAM_DTX_HARMONY_TRI_A, "HARMONY_TRIANGLE_A", 0, "Harmonious Triangle A", ""},
- {CAM_DTX_HARMONY_TRI_B, "HARMONY_TRIANGLE_B", 0, "Harmonious Triangle B", ""},
- {0, NULL, 0, NULL, NULL},
- };
static const EnumPropertyItem prop_lens_unit_items[] = {
{0, "MILLIMETERS", 0, "Millimeters", "Specify the lens in millimeters"},
{CAM_ANGLETOGGLE, "FOV", 0, "Field of View", "Specify the lens as the field of view's angle"},
@@ -405,13 +395,6 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Type", "Camera types");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
- prop = RNA_def_property(srna, "show_guide", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "dtx");
- RNA_def_property_enum_items(prop, prop_display_type_extra_items);
- RNA_def_property_flag(prop, PROP_ENUM_FLAG);
- RNA_def_property_ui_text(prop, "Composition Guides", "Display overlay");
- RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
-
prop = RNA_def_property(srna, "sensor_fit", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "sensor_fit");
RNA_def_property_enum_items(prop, sensor_fit_items);
@@ -465,7 +448,7 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "lens");
RNA_def_property_float_default(prop, 50.0f);
RNA_def_property_range(prop, 1.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 1.0f, 5000.0f, 1, 2);
+ RNA_def_property_ui_range(prop, 1.0f, 5000.0f, 100, 4);
RNA_def_property_ui_text(prop, "Focal Length", "Perspective Camera lens value in millimeters");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
@@ -473,7 +456,7 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "sensor_x");
RNA_def_property_float_default(prop, 36.0f);
RNA_def_property_range(prop, 1.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 1.0f, 100.f, 1, 2);
+ RNA_def_property_ui_range(prop, 1.0f, 100.f, 100, 4);
RNA_def_property_ui_text(prop, "Sensor Width", "Horizontal size of the image sensor area in millimeters");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
@@ -481,7 +464,7 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "sensor_y");
RNA_def_property_float_default(prop, 34.0f);
RNA_def_property_range(prop, 1.0f, FLT_MAX);
- RNA_def_property_ui_range(prop, 1.0f, 100.f, 1, 2);
+ RNA_def_property_ui_range(prop, 1.0f, 100.f, 100, 4);
RNA_def_property_ui_text(prop, "Sensor Height", "Vertical size of the image sensor area in millimeters");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
@@ -578,6 +561,47 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_enum_items(prop, prop_lens_unit_items);
RNA_def_property_ui_text(prop, "Lens Unit", "Unit to edit lens in for the user interface");
+ /* dtx */
+ prop = RNA_def_property(srna, "show_composition_center", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dtx", CAM_DTX_CENTER);
+ RNA_def_property_ui_text(prop, "Center", "Display center composition guide inside the camera view");
+ RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
+
+ prop = RNA_def_property(srna, "show_composition_center_diagonal", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dtx", CAM_DTX_CENTER_DIAG);
+ RNA_def_property_ui_text(prop, "Center Diagonal", "Display diagonal center composition guide inside the camera view");
+ RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
+
+ prop = RNA_def_property(srna, "show_composition_thirds", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dtx", CAM_DTX_THIRDS);
+ RNA_def_property_ui_text(prop, "Thirds", "Display rule of thirds composition guide inside the camera view");
+ RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
+
+ prop = RNA_def_property(srna, "show_composition_golden", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dtx", CAM_DTX_GOLDEN);
+ RNA_def_property_ui_text(prop, "Golden Ratio", "Display golden ratio composition guide inside the camera view");
+ RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
+
+ prop = RNA_def_property(srna, "show_composition_golden_tria_a", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dtx", CAM_DTX_GOLDEN_TRI_A);
+ RNA_def_property_ui_text(prop, "Golden Triangle A", "Display golden triangle A composition guide inside the camera view");
+ RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
+
+ prop = RNA_def_property(srna, "show_composition_golden_tria_b", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dtx", CAM_DTX_GOLDEN_TRI_B);
+ RNA_def_property_ui_text(prop, "Golden Triangle B", "Display golden triangle B composition guide inside the camera view");
+ RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
+
+ prop = RNA_def_property(srna, "show_composition_harmony_tri_a", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dtx", CAM_DTX_HARMONY_TRI_A);
+ RNA_def_property_ui_text(prop, "Harmonious Triangle A", "Display harmony A composition guide inside the camera view");
+ RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
+
+ prop = RNA_def_property(srna, "show_composition_harmony_tri_b", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dtx", CAM_DTX_HARMONY_TRI_B);
+ RNA_def_property_ui_text(prop, "Harmonious Triangle B", "Display harmony B composition guide inside the camera view");
+ RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL);
+
/* pointers */
prop = RNA_def_property(srna, "dof_object", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 61c2600a021..faf9a99ace1 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -432,7 +432,7 @@ static void rna_ColorManagedDisplaySettings_display_device_update(Main *bmain, S
static char *rna_ColorManagedDisplaySettings_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("display_settings");
+ return BLI_strdup("display_settings");
}
static int rna_ColorManagedViewSettings_view_transform_get(PointerRNA *ptr)
@@ -518,7 +518,7 @@ static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, bool va
static char *rna_ColorManagedViewSettings_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("view_settings");
+ return BLI_strdup("view_settings");
}
@@ -627,12 +627,12 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain, Scene
static char *rna_ColorManagedSequencerColorspaceSettings_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("sequencer_colorspace_settings");
+ return BLI_strdup("sequencer_colorspace_settings");
}
static char *rna_ColorManagedInputColorspaceSettings_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("colorspace_settings");
+ return BLI_strdup("colorspace_settings");
}
static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index c08a1e0128c..4c6c7740ff8 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -88,6 +88,8 @@ const EnumPropertyItem rna_enum_constraint_type_items[] = {
{0, "", 0, N_("Relationship"), ""},
{CONSTRAINT_TYPE_ACTION, "ACTION", ICON_CONSTRAINT, "Action",
"Use transform property of target to look up pose for owner from an Action"},
+ {CONSTRAINT_TYPE_ARMATURE, "ARMATURE", ICON_CONSTRAINT, "Armature",
+ "Apply weight-blended transformation from multiple bones like the Armature modifier"},
{CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", ICON_CONSTRAINT, "Child Of",
"Make target the 'detachable' parent of owner"},
{CONSTRAINT_TYPE_MINMAX, "FLOOR", ICON_CONSTRAINT, "Floor",
@@ -102,8 +104,6 @@ const EnumPropertyItem rna_enum_constraint_type_items[] = {
"Custom constraint(s) written in Python (Not yet implemented)"}, */
{CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT, "Shrinkwrap",
"Restrict movements to surface of target mesh"},
- {CONSTRAINT_TYPE_ARMATURE, "ARMATURE", ICON_CONSTRAINT, "Armature",
- "Apply weight-blended transformation from multiple bones like the Armature modifier"},
{0, NULL, 0, NULL, NULL},
};
@@ -449,7 +449,7 @@ static void rna_ArmatureConstraint_target_remove(
bConstraintTarget *tgt = target_ptr->data;
if (BLI_findindex(&acon->targets, tgt) < 0) {
- BKE_reportf(reports, RPT_ERROR, "Target is not in the constraint target list");
+ BKE_report(reports, RPT_ERROR, "Target is not in the constraint target list");
return;
}
@@ -2624,20 +2624,24 @@ void RNA_def_constraint(BlenderRNA *brna)
RNA_def_property_enum_items(prop, owner_space_pchan_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf");
RNA_def_property_ui_text(prop, "Owner Space", "Space that owner is evaluated in");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
prop = RNA_def_property(srna, "target_space", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "tarspace");
RNA_def_property_enum_items(prop, target_space_pchan_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_target_space_itemf");
RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
/* flags */
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_OFF);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Disable", "Enable/Disable Constraint");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
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", CONSTRAINT_EXPAND);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Expanded", "Constraint's panel is expanded in UI");
@@ -2652,9 +2656,10 @@ void RNA_def_constraint(BlenderRNA *brna)
/* TODO: setting this to true must ensure that all others in stack are turned off too... */
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_ACTIVE);
- RNA_def_property_ui_text(prop, "Active", "Constraint is the one being edited ");
+ RNA_def_property_ui_text(prop, "Active", "Constraint is the one being edited");
prop = RNA_def_property(srna, "is_proxy_local", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_PROXY_LOCAL);
RNA_def_property_ui_text(prop, "Proxy Local",
"Constraint was added in this proxy instance (i.e. did not belong to source Armature)");
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index ae3b8304d7b..050ae632a4b 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -1221,6 +1221,11 @@ static void rna_def_charinfo(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Material Index", "");
RNA_def_property_int_funcs(prop, "rna_ChariInfo_material_index_get", "rna_ChariInfo_material_index_set", "rna_Curve_material_index_range");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
+ prop = RNA_def_property(srna, "kerning", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "kern");
+ RNA_def_property_ui_text(prop, "Kerning", "Spacing between characters");
+ RNA_def_property_update(prop, 0, "rna_Curve_update_data");
}
static void rna_def_surface(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index b6cae3de386..4d981fe6e9c 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -495,7 +495,7 @@ static void rna_FCurve_update_eval(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
IdAdtTemplate *iat = (IdAdtTemplate *)ptr->id.data;
if (iat && iat->adt && iat->adt->action) {
/* action is separate datablock, needs separate tag */
- DEG_id_tag_update(&iat->adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&iat->adt->action->id, ID_RECALC_ANIMATION);
}
}
@@ -618,7 +618,7 @@ static void rna_FModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin
if (adt != NULL) {
if (adt->action != NULL) {
/* action is separate datablock, needs separate tag */
- DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION);
}
}
@@ -955,7 +955,7 @@ static void rna_Keyframe_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point
if (adt != NULL) {
if (adt->action != NULL) {
/* action is separate datablock, needs separate tag */
- DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION);
}
}
}
@@ -1405,6 +1405,7 @@ static void rna_def_fmodifier(BlenderRNA *brna)
/* settings */
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", FMODIFIER_FLAG_EXPANDED);
RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI");
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 6203d06c7d5..73203beb3e2 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -505,12 +505,14 @@ static void rna_GPencil_stroke_point_add(ID *id, bGPDstroke *stroke, int count,
if (count > 0) {
/* create space at the end of the array for extra points */
- stroke->points = MEM_recallocN_id(stroke->points,
- sizeof(bGPDspoint) * (stroke->totpoints + count),
- "gp_stroke_points");
- stroke->dvert = MEM_recallocN_id(stroke->dvert,
- sizeof(MDeformVert) * (stroke->totpoints + count),
- "gp_stroke_weight");
+ stroke->points = MEM_recallocN_id(
+ stroke->points,
+ sizeof(bGPDspoint) * (stroke->totpoints + count),
+ "gp_stroke_points");
+ stroke->dvert = MEM_recallocN_id(
+ stroke->dvert,
+ sizeof(MDeformVert) * (stroke->totpoints + count),
+ "gp_stroke_weight");
/* init the pressure and strength values so that old scripts won't need to
* be modified to give these initial values...
@@ -754,7 +756,7 @@ static void rna_GpencilVertex_groups_begin(CollectionPropertyIterator *iter, Poi
static char *rna_GreasePencilGrid_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("grid");
+ return BLI_strdup("grid");
}
#else
@@ -931,8 +933,9 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
/* vertex groups */
prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_funcs(prop, "rna_GpencilVertex_groups_begin", "rna_iterator_array_next",
- "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
+ RNA_def_property_collection_funcs(
+ prop, "rna_GpencilVertex_groups_begin", "rna_iterator_array_next",
+ "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
RNA_def_property_struct_type(prop, "GpencilVertexGroupElement");
RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this vertex is member of");
@@ -1077,8 +1080,9 @@ static void rna_def_gpencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "new", "rna_GPencil_frame_new");
RNA_def_function_ui_description(func, "Add a new grease pencil frame");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm = RNA_def_int(func, "frame_number", 1, MINAFRAME, MAXFRAME, "Frame Number",
- "The frame on which this sketch appears", MINAFRAME, MAXFRAME);
+ parm = RNA_def_int(
+ func, "frame_number", 1, MINAFRAME, MAXFRAME, "Frame Number",
+ "The frame on which this sketch appears", MINAFRAME, MAXFRAME);
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_pointer(func, "frame", "GPencilFrame", "", "The newly created frame");
RNA_def_function_return(func, parm);
@@ -1141,11 +1145,21 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ /* layer channel color (grease pencil) */
+ prop = RNA_def_property(srna, "channel_color", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "color");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Custom Channel Color",
+ "Custom color for animation channel in Dopesheet");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* Stroke Drawing Color (Annotations) */
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Color", "Color for all strokes in this layer");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
@@ -1153,10 +1167,10 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "thickness");
RNA_def_property_range(prop, 1, 10);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Thickness", "Thickness of annotation strokes");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
-
+
/* Tint Color */
prop = RNA_def_property(srna, "tint_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "tintcolor");
@@ -1189,22 +1203,28 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_annotation_onion_skinning", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_LAYER_ONIONSKIN);
- RNA_def_property_ui_text(prop, "Onion Skinning",
- "Display annotation onion skins before and after the current frame");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(
+ prop, "Onion Skinning",
+ "Display annotation onion skins before and after the current frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "annotation_onion_before_range", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gstep");
RNA_def_property_range(prop, -1, 120);
- RNA_def_property_ui_text(prop, "Frames Before",
- "Maximum number of frames to show before current frame");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(
+ prop, "Frames Before",
+ "Maximum number of frames to show before current frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "annotation_onion_after_range", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gstep_next");
RNA_def_property_range(prop, -1, 120);
- RNA_def_property_ui_text(prop, "Frames After",
- "Maximum number of frames to show after current frame");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(
+ prop, "Frames After",
+ "Maximum number of frames to show after current frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "annotation_onion_before_color", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -1212,6 +1232,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_array_default(prop, default_onion_color_b);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
@@ -1220,6 +1241,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_array_default(prop, default_onion_color_a);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
@@ -1231,8 +1253,9 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
prop = RNA_def_property(srna, "viewlayer_render", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "viewlayername");
- RNA_def_property_ui_text(prop, "ViewLayer",
- "Only include Layer in this View Layer render output (leave blank to include always)");
+ RNA_def_property_ui_text(
+ prop, "ViewLayer",
+ "Only include Layer in this View Layer render output (leave blank to include always)");
/* blend mode */
prop = RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE);
@@ -1248,6 +1271,13 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Hide", "Set layer Visibility");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "annotation_hide", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE);
+ RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Hide", "Set annotation Visibility");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_LOCKED);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
@@ -1257,6 +1287,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
prop = RNA_def_property(srna, "lock_frame", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_FRAMELOCK);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Frame Locked", "Lock current frame displayed by layer");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
@@ -1269,15 +1300,17 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
prop = RNA_def_property(srna, "clamp_layer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_USE_MASK);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Clamp Layer",
- "Clamp any pixel outside underlying layers drawing");
+ RNA_def_property_ui_text(
+ prop, "Clamp Layer",
+ "Clamp any pixel outside underlying layers drawing");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* solo mode: Only display frames with keyframe */
prop = RNA_def_property(srna, "use_solo_mode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_SOLO_MODE);
- RNA_def_property_ui_text(prop, "Solo Mode",
- "In Paint mode display only layers with keyframe in current frame");
+ RNA_def_property_ui_text(
+ prop, "Solo Mode",
+ "In Paint mode display only layers with keyframe in current frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* exposed as layers.active */
@@ -1392,20 +1425,20 @@ static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_funcs(
- prop,
- "rna_GPencil_active_layer_index_get",
- "rna_GPencil_active_layer_index_set",
- "rna_GPencil_active_layer_index_range");
+ prop,
+ "rna_GPencil_active_layer_index_get",
+ "rna_GPencil_active_layer_index_set",
+ "rna_GPencil_active_layer_index_range");
RNA_def_property_ui_text(prop, "Active Layer Index", "Index of active grease pencil layer");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
/* Active Layer - As an enum (for selecting active layer for annotations) */
prop = RNA_def_property(srna, "active_note", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_funcs(
- prop,
- "rna_GPencil_active_layer_index_get",
- "rna_GPencil_active_layer_index_set",
- "rna_GPencil_active_layer_itemf");
+ prop,
+ "rna_GPencil_active_layer_index_get",
+ "rna_GPencil_active_layer_index_set",
+ "rna_GPencil_active_layer_itemf");
RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); /* purely dynamic, as it maps to user-data */
RNA_def_property_ui_text(prop, "Active Note", "Note/Layer to add annotation strokes to");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
@@ -1423,8 +1456,9 @@ static void rna_def_gpencil_grid(BlenderRNA *brna)
RNA_def_struct_nested(brna, srna, "GreasePencil");
RNA_def_struct_path_func(srna, "rna_GreasePencilGrid_path");
- RNA_def_struct_ui_text(srna, "Grid and Canvas Settings",
- "Settings for grid and canvas in 3D viewport");
+ RNA_def_struct_ui_text(
+ srna, "Grid and Canvas Settings",
+ "Settings for grid and canvas in 3D viewport");
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "scale");
@@ -1499,8 +1533,9 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "stroke_depth_order", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "draw_mode");
RNA_def_property_enum_items(prop, rna_enum_gpencil_stroke_depth_order_items);
- RNA_def_property_ui_text(prop, "Stroke Depth Order",
- "Defines how the strokes are ordered in 3D space");
+ RNA_def_property_ui_text(
+ prop, "Stroke Depth Order",
+ "Defines how the strokes are ordered in 3D space");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* Flags */
@@ -1569,8 +1604,9 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_autolock_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_AUTOLOCK_LAYERS);
- RNA_def_property_ui_text(prop, "Autolock Layers",
- "Lock automatically all layers except active one to avoid accidental changes");
+ RNA_def_property_ui_text(
+ prop, "Autolock Layers",
+ "Lock automatically all layers except active one to avoid accidental changes");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_autolock");
prop = RNA_def_property(srna, "edit_line_color", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -1586,18 +1622,20 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "gstep");
RNA_def_property_range(prop, 0, 120);
RNA_def_property_int_default(prop, 1);
- RNA_def_property_ui_text(prop, "Frames Before",
- "Maximum number of frames to show before current frame "
- "(0 = don't show any frames before current)");
+ RNA_def_property_ui_text(
+ prop, "Frames Before",
+ "Maximum number of frames to show before current frame "
+ "(0 = don't show any frames before current)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gstep_next");
RNA_def_property_range(prop, 0, 120);
RNA_def_property_int_default(prop, 1);
- RNA_def_property_ui_text(prop, "Frames After",
- "Maximum number of frames to show after current frame "
- "(0 = don't show any frames after current)");
+ RNA_def_property_ui_text(
+ prop, "Frames After",
+ "Maximum number of frames to show after current frame "
+ "(0 = don't show any frames after current)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "use_ghost_custom_colors", PROP_BOOLEAN, PROP_NONE);
@@ -1623,8 +1661,9 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_ghosts_always", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_GHOST_ALWAYS);
- RNA_def_property_ui_text(prop, "Always Show Ghosts",
- "Ghosts are shown in renders and animation playback. Useful for special effects (e.g. motion blur)");
+ RNA_def_property_ui_text(
+ prop, "Always Show Ghosts",
+ "Ghosts are shown in renders and animation playback. Useful for special effects (e.g. motion blur)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "onion_mode", PROP_ENUM, PROP_NONE);
@@ -1635,14 +1674,16 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_onion_fade", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_FADE);
- RNA_def_property_ui_text(prop, "Fade",
- "Display onion keyframes with a fade in color transparency");
+ RNA_def_property_ui_text(
+ prop, "Fade",
+ "Display onion keyframes with a fade in color transparency");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "use_onion_loop", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "onion_flag", GP_ONION_LOOP);
- RNA_def_property_ui_text(prop, "Loop",
- "Display first onion keyframes using next frame color to show indication of loop start frame");
+ RNA_def_property_ui_text(
+ prop, "Loop",
+ "Display first onion keyframes using next frame color to show indication of loop start frame");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "onion_factor", PROP_FLOAT, PROP_NONE);
@@ -1656,8 +1697,9 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "zdepth_offset");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 5);
- RNA_def_property_ui_text(prop, "Surface Offset",
- "Offset amount when drawing in surface mode");
+ RNA_def_property_ui_text(
+ prop, "Surface Offset",
+ "Offset amount when drawing in surface mode");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* Nested Structs */
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 1787642e9c3..23be3bb2980 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -892,8 +892,9 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_custom_frame_range", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TIME_CUSTOM_RANGE);
- RNA_def_property_ui_text(prop, "Custom Range",
- "Define a custom range of frames to use in modifier");
+ RNA_def_property_ui_text(
+ prop, "Custom Range",
+ "Define a custom range of frames to use in modifier");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
}
@@ -1071,9 +1072,10 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna)
/* Offset parameters */
prop = RNA_def_property(srna, "offset_object", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "object");
- RNA_def_property_ui_text(prop, "Object Offset",
- "Use the location and rotation of another object to determine the distance and "
- "rotational change between arrayed items");
+ RNA_def_property_ui_text(
+ prop, "Object Offset",
+ "Use the location and rotation of another object to determine the distance and "
+ "rotational change between arrayed items");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
@@ -1152,8 +1154,9 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna)
prop = RNA_def_property(srna, "keep_on_top", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_KEEP_ONTOP);
- RNA_def_property_ui_text(prop, "Keep On Top",
- "Keep the original stroke in front of new instances (only affect by layer)");
+ RNA_def_property_ui_text(
+ prop, "Keep On Top",
+ "Keep the original stroke in front of new instances (only affect by layer)");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
}
@@ -1431,8 +1434,9 @@ static void rna_def_modifier_gpencilhook(BlenderRNA *brna)
prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "subtarget");
- RNA_def_property_ui_text(prop, "Sub-Target",
- "Name of Parent Bone for hook (if applicable), also recalculates and clears offset");
+ RNA_def_property_ui_text(
+ prop, "Sub-Target",
+ "Name of Parent Bone for hook (if applicable), also recalculates and clears offset");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE);
@@ -1554,15 +1558,17 @@ static void rna_def_modifier_gpencilarmature(BlenderRNA *brna)
#if 0 /* GPXX keep disabled now */
prop = RNA_def_property(srna, "use_multi_modifier", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "multi", 0);
- RNA_def_property_ui_text(prop, "Multi Modifier",
- "Use same input as previous modifier, and mix results using overall vgroup");
+ RNA_def_property_ui_text(
+ prop, "Multi Modifier",
+ "Use same input as previous modifier, and mix results using overall vgroup");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
#endif
prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "vgname");
- RNA_def_property_ui_text(prop, "Vertex Group",
- "Name of Vertex Group which determines influence of modifier per point");
+ RNA_def_property_ui_text(
+ prop, "Vertex Group",
+ "Name of Vertex Group which determines influence of modifier per point");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ArmatureGpencilModifier_vgname_set");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
@@ -1621,6 +1627,7 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
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, "mode", eGpencilModifierMode_Expanded);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface");
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 1528c8b32e0..d1cb3eee54a 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -217,7 +217,7 @@ void rna_def_mtex_common(struct BlenderRNA *brna, struct StructRNA *srna, const
const char *activeset, const char *activeeditable, const char *structname,
const char *structname_slots, const char *update, const char *update_index);
void rna_def_texpaint_slots(struct BlenderRNA *brna, struct StructRNA *srna);
-void rna_def_view_layer_common(struct StructRNA *srna, bool scene);
+void rna_def_view_layer_common(struct StructRNA *srna, const bool scene);
void rna_def_actionbone_group_common(struct StructRNA *srna, int update_flag, const char *update_cb);
void rna_ActionGroup_colorset_set(struct PointerRNA *ptr, int value);
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index 8fe20a1b03f..1d9084bf3f0 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -920,7 +920,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
/* 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, "Compute local space vertices' normals for this shape key");
RNA_def_function_flag(func, FUNC_USE_SELF_ID);
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 4c400b4fb2e..5445db78582 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -91,7 +91,7 @@ static void rna_Material_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point
{
Material *ma = ptr->id.data;
- DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_SHADING);
WM_main_add_notifier(NC_MATERIAL | ND_SHADING, ma);
}
@@ -125,7 +125,7 @@ static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
{
Material *ma = ptr->id.data;
- DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&ma->id, ID_RECALC_SHADING);
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma);
}
@@ -176,7 +176,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *U
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
if (!sima->pin) {
- ED_space_image_set(bmain, sima, obedit, image);
+ ED_space_image_set(bmain, sima, obedit, image, true);
}
}
}
@@ -307,7 +307,7 @@ static void rna_gpcolordata_uv_update(Main *bmain, Scene *scene, PointerRNA *ptr
static char *rna_GpencilColorData_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("grease_pencil");
+ return BLI_strdup("grease_pencil");
}
static int rna_GpencilColorData_is_stroke_visible_get(PointerRNA *ptr)
@@ -677,8 +677,8 @@ void RNA_def_material(BlenderRNA *brna)
static EnumPropertyItem prop_eevee_blend_shadow_items[] = {
{MA_BS_NONE, "NONE", 0, "None", "Material will cast no shadow"},
{MA_BS_SOLID, "OPAQUE", 0, "Opaque", "Material will cast shadows without transparency"},
- {MA_BS_CLIP, "CLIP", 0, "Clip", "Use the alpha threshold to clip the visibility (binary visibility)"},
- {MA_BS_HASHED, "HASHED", 0, "Hashed", "Use noise to dither the binary visibility and use filtering to reduce the noise"},
+ {MA_BS_CLIP, "CLIP", 0, "Alpha Clip", "Use the alpha threshold to clip the visibility (binary visibility)"},
+ {MA_BS_HASHED, "HASHED", 0, "Alpha Hashed", "Use noise to dither the binary visibility and use filtering to reduce the noise"},
{0, NULL, 0, NULL, NULL},
};
@@ -693,10 +693,10 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Blend Mode", "Blend Mode for Transparent Faces");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
- prop = RNA_def_property(srna, "transparent_shadow_method", PROP_ENUM, PROP_NONE);
+ prop = RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "blend_shadow");
RNA_def_property_enum_items(prop, prop_eevee_blend_shadow_items);
- RNA_def_property_ui_text(prop, "Transparent Shadow", "Shadow method for transparent material");
+ RNA_def_property_ui_text(prop, "Shadow Mode", "Shadow mapping method");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
prop = RNA_def_property(srna, "alpha_threshold", PROP_FLOAT, PROP_FACTOR);
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index c9a8da51e40..ce1f4202f16 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -958,7 +958,7 @@ static void rna_Mesh_face_map_remove(struct Mesh *me, ReportList *reports, struc
}
if (BKE_mesh_clear_facemap_customdata(me) == false) {
- BKE_reportf(reports, RPT_ERROR, "Error removing face-map");
+ BKE_report(reports, RPT_ERROR, "Error removing face-map");
}
}
@@ -2642,6 +2642,7 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_int_funcs(prop, "rna_Mesh_uv_layer_stencil_index_get",
"rna_Mesh_uv_layer_stencil_index_set", "rna_Mesh_uv_layer_index_range");
RNA_def_property_ui_text(prop, "Mask UV loop layer Index", "Mask UV loop layer index");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
/* Vertex colors */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 0389410b279..9f1d25c0b3f 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -123,9 +123,9 @@ const EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[] = {
{MOD_TRIANGULATE_QUAD_BEAUTY, "BEAUTY", 0, "Beauty ", "Split the quads in nice triangles, slower method"},
{MOD_TRIANGULATE_QUAD_FIXED, "FIXED", 0, "Fixed", "Split the quads on the first and third vertices"},
{MOD_TRIANGULATE_QUAD_ALTERNATE, "FIXED_ALTERNATE", 0, "Fixed Alternate",
- "Split the quads on the 2nd and 4th vertices"},
+ "Split the quads on the 2nd and 4th vertices"},
{MOD_TRIANGULATE_QUAD_SHORTEDGE, "SHORTEST_DIAGONAL", 0, "Shortest Diagonal",
- "Split the quads based on the distance between the vertices"},
+ "Split the quads based on the distance between the vertices"},
{0, NULL, 0, NULL, NULL},
};
@@ -3046,7 +3046,7 @@ static void rna_def_modifier_bevel(BlenderRNA *brna)
{ MOD_BEVEL_FACE_STRENGTH_NONE, "FSTR_NONE", 0, "None", "Do not set face strength" },
{ MOD_BEVEL_FACE_STRENGTH_NEW, "FSTR_NEW", 0, "New", "Set face strength on new faces only" },
{ MOD_BEVEL_FACE_STRENGTH_AFFECTED, "FSTR_AFFECTED", 0, "Affected",
- "Set face strength on new and affected faces only" },
+ "Set face strength on new and affected faces only" },
{ MOD_BEVEL_FACE_STRENGTH_ALL, "FSTR_ALL", 0, "All", "Set face strength on all faces" },
{ 0, NULL, 0, NULL, NULL },
};
@@ -3147,8 +3147,9 @@ static void rna_def_modifier_bevel(BlenderRNA *brna)
prop = RNA_def_property(srna, "harden_normals", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_BEVEL_HARDEN_NORMALS);
- RNA_def_property_ui_text(prop, "Harden Normals",
- "Match normals of new faces to adjacent faces");
+ RNA_def_property_ui_text(
+ prop, "Harden Normals",
+ "Match normals of new faces to adjacent faces");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "face_strength_mode", PROP_ENUM, PROP_NONE);
@@ -4361,6 +4362,12 @@ static void rna_def_modifier_triangulate(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Polygon Method", "Method for splitting the polygons into triangles");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "min_vertices", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "min_vertices");
+ RNA_def_property_range(prop, 4, INT_MAX);
+ RNA_def_property_ui_text(prop, "Minimum Vertices", "Triangulate only polygons with vertex count greater than or equal to this number");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "keep_custom_normals", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_TRIANGULATE_KEEP_CUSTOMLOOP_NORMALS);
RNA_def_property_ui_text(prop, "Keep Normals",
@@ -5172,6 +5179,7 @@ void RNA_def_modifier(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
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, "mode", eModifierMode_Expanded);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface");
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 69ad550976b..44cf15995f9 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -56,8 +56,6 @@
#include "RE_render_ext.h"
-#include "NOD_composite.h"
-
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -192,6 +190,8 @@ static const EnumPropertyItem prop_shader_output_target_items[] = {
#include "NOD_common.h"
#include "NOD_socket.h"
+#include "NOD_shader.h"
+#include "NOD_composite.h"
#include "RE_engine.h"
#include "RE_pipeline.h"
@@ -451,6 +451,13 @@ static const EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C), P
tmp.icon = ICON_NONE;
RNA_enum_item_add(&item, &totitem, &tmp);
+ tmp.value = NODE_CUSTOM_GROUP;
+ tmp.identifier = "CUSTOM GROUP";
+ tmp.name = "CustomGroup";
+ tmp.description = "Custom Group Node";
+ tmp.icon = ICON_NONE;
+ RNA_enum_item_add(&item, &totitem, &tmp);
+
tmp.value = NODE_UNDEFINED;
tmp.identifier = "UNDEFINED";
tmp.name = "UNDEFINED";
@@ -741,8 +748,8 @@ static void rna_NodeTree_node_remove(bNodeTree *ntree, Main *bmain, ReportList *
return;
}
- id_us_min(node->id);
- nodeDeleteNode(bmain, ntree, node);
+ nodeRemoveNode(bmain, ntree, node, true);
+
RNA_POINTER_INVALIDATE(node_ptr);
ntreeUpdateTree(bmain, ntree); /* update group node socket links */
@@ -759,10 +766,7 @@ static void rna_NodeTree_node_clear(bNodeTree *ntree, Main *bmain, ReportList *r
while (node) {
bNode *next_node = node->next;
- if (node->id)
- id_us_min(node->id);
-
- nodeDeleteNode(bmain, ntree, node);
+ nodeRemoveNode(bmain, ntree, node, true);
node = next_node;
}
@@ -1615,6 +1619,11 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value)
static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, Main *bmain, ReportList *reports, const char *type, const char *name, const char *identifier)
{
+ /* 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);
+ }
+
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
@@ -1633,6 +1642,11 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, Main *bmain, Report
static bNodeSocket *rna_Node_outputs_new(ID *id, bNode *node, Main *bmain, ReportList *reports, const char *type, const char *name, const char *identifier)
{
+ /* 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);
+ }
+
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
@@ -2463,6 +2477,50 @@ static StructRNA *rna_NodeCustomGroup_register(
return nt->ext.srna;
}
+static StructRNA *rna_ShaderNodeCustomGroup_register(
+ Main *bmain, ReportList *reports,
+ void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+{
+ bNodeType * nt = rna_Node_register_base(bmain, reports, &RNA_ShaderNodeCustomGroup, data, identifier, validate, call, free);
+
+ if (!nt)
+ return NULL;
+
+ nt->verifyfunc = node_group_verify;
+ nt->type = NODE_CUSTOM_GROUP;
+
+ register_node_type_sh_custom_group(nt);
+
+ nodeRegisterType(nt);
+
+ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
+
+ return nt->ext.srna;
+}
+
+static StructRNA *rna_CompositorNodeCustomGroup_register(
+ Main *bmain, ReportList *reports,
+ void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+{
+ bNodeType *nt = rna_Node_register_base(bmain, reports, &RNA_CompositorNodeCustomGroup, data, identifier, validate, call, free);
+ if (!nt)
+ return NULL;
+
+ nt->verifyfunc = node_group_verify;
+ nt->type = NODE_CUSTOM_GROUP;
+
+ register_node_type_cmp_custom_group(nt);
+
+ nodeRegisterType(nt);
+
+ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
+
+ return nt->ext.srna;
+}
+
+
static void rna_CompositorNode_tag_need_exec(bNode *node)
{
node->need_exec = true;
@@ -3413,15 +3471,17 @@ static void def_group(StructRNA *srna)
RNA_def_property_ui_text(prop, "Interface", "Interface socket data");
}
-static void def_custom_group(BlenderRNA *brna)
+static void def_custom_group(
+ BlenderRNA *brna, const char *struct_name, const char *base_name,
+ const char *ui_name, const char *ui_desc, const char *reg_func)
{
StructRNA *srna;
- srna = RNA_def_struct(brna, "NodeCustomGroup", "Node");
- RNA_def_struct_ui_text(srna, "Custom Group", "Base node type for custom registered node group types");
+ srna = RNA_def_struct(brna, struct_name, base_name);
+ RNA_def_struct_ui_text(srna, ui_name, ui_desc);
RNA_def_struct_sdna(srna, "bNode");
- RNA_def_struct_register_funcs(srna, "rna_NodeCustomGroup_register", "rna_Node_unregister", NULL);
+ RNA_def_struct_register_funcs(srna, reg_func, "rna_Node_unregister", NULL);
def_group(srna);
}
@@ -4145,19 +4205,19 @@ static void def_sh_tex_pointdensity(StructRNA *srna)
static const EnumPropertyItem particle_color_source_items[] = {
{SHD_POINTDENSITY_COLOR_PARTAGE, "PARTICLE_AGE", 0, "Particle Age",
- "Lifetime mapped as 0.0 - 1.0 intensity"},
+ "Lifetime mapped as 0.0 - 1.0 intensity"},
{SHD_POINTDENSITY_COLOR_PARTSPEED, "PARTICLE_SPEED", 0, "Particle Speed",
- "Particle speed (absolute magnitude of velocity) mapped as 0.0-1.0 intensity"},
+ "Particle speed (absolute magnitude of velocity) mapped as 0.0-1.0 intensity"},
{SHD_POINTDENSITY_COLOR_PARTVEL, "PARTICLE_VELOCITY", 0, "Particle Velocity",
- "XYZ velocity mapped to RGB colors"},
+ "XYZ velocity mapped to RGB colors"},
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem vertex_color_source_items[] = {
- {SHD_POINTDENSITY_COLOR_VERTCOL, "VERTEX_COLOR", 0, "Vertex Color", "Vertex color layer"},
- {SHD_POINTDENSITY_COLOR_VERTWEIGHT, "VERTEX_WEIGHT", 0, "Vertex Weight", "Vertex group weight"},
- {SHD_POINTDENSITY_COLOR_VERTNOR, "VERTEX_NORMAL", 0, "Vertex Normal",
- "XYZ normal vector mapped to RGB colors"},
+ {SHD_POINTDENSITY_COLOR_VERTCOL, "VERTEX_COLOR", 0, "Vertex Color", "Vertex color layer"},
+ {SHD_POINTDENSITY_COLOR_VERTWEIGHT, "VERTEX_WEIGHT", 0, "Vertex Weight", "Vertex group weight"},
+ {SHD_POINTDENSITY_COLOR_VERTNOR, "VERTEX_NORMAL", 0, "Vertex Normal",
+ "XYZ normal vector mapped to RGB colors"},
{0, NULL, 0, NULL, NULL},
};
@@ -7142,6 +7202,7 @@ static void rna_def_node_socket(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Linked", "True if the socket is connected");
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SOCK_COLLAPSED);
RNA_def_property_ui_text(prop, "Expanded", "Socket links are expanded in the user interface");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, NULL);
@@ -8619,7 +8680,9 @@ void RNA_def_nodetree(BlenderRNA *brna)
define_specific_node(brna, "ShaderNodeGroup", "ShaderNode", "Group", "", def_group);
define_specific_node(brna, "CompositorNodeGroup", "CompositorNode", "Group", "", def_group);
define_specific_node(brna, "TextureNodeGroup", "TextureNode", "Group", "", def_group);
- def_custom_group(brna);
+ def_custom_group(brna, "ShaderNodeCustomGroup", "ShaderNode", "Shader Custom Group", "Custom Shader Group Node for Python nodes", "rna_ShaderNodeCustomGroup_register");
+ def_custom_group(brna, "CompositorNodeCustomGroup", "CompositorNode", "Compositor Custom Group", "Custom Compositor Group Node for Python nodes", "rna_CompositorNodeCustomGroup_register");
+ def_custom_group(brna, "NodeCustomGroup", "Node", "Custom Group", "Base node type for custom registered node group types", "rna_NodeCustomGroup_register");
/* special socket types */
rna_def_cmp_output_file_slot_file(brna);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 622a4b7c01b..2d0afcd66f1 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -275,16 +275,12 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id);
}
-static void rna_MaterialIndex_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_MaterialIndex_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- /* update the material of all brushes not pinned */
Object *ob = (Object *)ptr->id.data;
if (ob && ob->type == OB_GPENCIL) {
- Material *ma = give_current_material(ob, ob->actcol);
- if (ma != NULL) {
- BKE_brush_update_material(bmain, ma, NULL);
- WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL);
- }
+ /* notifying material property in topbar */
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL);
}
}
@@ -821,6 +817,11 @@ static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
BLI_assert(BKE_id_is_in_global_main(&ob->id));
BLI_assert(BKE_id_is_in_global_main(value.data));
assign_material(G_MAIN, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING);
+
+ if (ob && ob->type == OB_GPENCIL) {
+ /* notifying material property in topbar */
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ }
}
static int rna_Object_active_material_editable(PointerRNA *ptr, const char **UNUSED(r_info))
@@ -1474,6 +1475,7 @@ static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *re
while (index_len--)
ED_vgroup_vert_add(ob, def, *index++, weight, assignmode); /* XXX, not efficient calling within loop*/
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
}
@@ -1489,6 +1491,7 @@ static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList *
while (index_len--)
ED_vgroup_vert_remove(ob, dg, *index++);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data);
}
@@ -1677,7 +1680,9 @@ static void rna_def_face_map(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+
FunctionRNA *func;
+ PropertyRNA *parm;
srna = RNA_def_struct(brna, "FaceMap", NULL);
RNA_def_struct_sdna(srna, "bFaceMap");
@@ -1705,15 +1710,15 @@ static void rna_def_face_map(BlenderRNA *brna)
RNA_def_function_ui_description(func, "Add vertices to the group");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
/* TODO, see how array size of 0 works, this shouldnt be used */
- prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
- RNA_def_parameter_flags(prop, PROP_DYNAMIC, PARM_REQUIRED);
+ parm = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
+ RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
func = RNA_def_function(srna, "remove", "rna_FaceMap_face_remove");
RNA_def_function_ui_description(func, "Remove a vertex from the group");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
/* TODO, see how array size of 0 works, this shouldnt be used */
- prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
- RNA_def_parameter_flags(prop, PROP_DYNAMIC, PARM_REQUIRED);
+ parm = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0);
+ RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
}
static void rna_def_material_slot(BlenderRNA *brna)
@@ -2503,6 +2508,11 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Display in Orthographic Mode", "Display image in orthographic mode");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+ prop = RNA_def_property(srna, "use_empty_image_alpha", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "empty_image_flag", OB_EMPTY_IMAGE_USE_ALPHA_BLEND);
+ RNA_def_property_ui_text(prop, "Use Alpha", "Use alpha blending instead of alpha test (can produce sorting artifacts)");
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+
static EnumPropertyItem prop_empty_image_side_items[] = {
{0, "DOUBLE_SIDED", 0, "Both", ""},
{OB_EMPTY_IMAGE_HIDE_BACK, "FRONT", 0, "Front", ""},
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 6ec631014d0..5e90f1feddf 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -74,6 +74,7 @@ static const EnumPropertyItem space_items[] = {
#include "BKE_report.h"
#include "ED_object.h"
+#include "ED_screen.h"
#include "DNA_curve_types.h"
#include "DNA_mesh_types.h"
@@ -111,9 +112,11 @@ static void rna_Object_select_set(
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
}
-static bool rna_Object_select_get(Object *ob, bContext *C, ReportList *reports)
+static bool rna_Object_select_get(Object *ob, bContext *C, ReportList *reports, ViewLayer *view_layer)
{
- ViewLayer *view_layer = CTX_data_view_layer(C);
+ if (view_layer == NULL) {
+ view_layer = CTX_data_view_layer(C);
+ }
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (!base) {
@@ -124,10 +127,56 @@ static bool rna_Object_select_get(Object *ob, bContext *C, ReportList *reports)
return ((base->flag & BASE_SELECTED) != 0);
}
-static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports)
+static void rna_Object_hide_set(
+ Object *ob, bContext *C, ReportList *reports,
+ bool hide, ViewLayer *view_layer)
{
- ViewLayer *view_layer = CTX_data_view_layer(C);
- View3D *v3d = CTX_wm_view3d(C);
+ if (view_layer == NULL) {
+ view_layer = CTX_data_view_layer(C);
+ }
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+
+ if (!base) {
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name);
+ return;
+ }
+
+ if (hide) {
+ base->flag |= BASE_HIDDEN;
+ }
+ else {
+ base->flag &= ~BASE_HIDDEN;
+ }
+
+ Scene *scene = CTX_data_scene(C);
+ BKE_layer_collection_sync(scene, view_layer);
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+}
+
+static bool rna_Object_hide_get(Object *ob, bContext *C, ReportList *reports, ViewLayer *view_layer)
+{
+ if (view_layer == NULL) {
+ view_layer = CTX_data_view_layer(C);
+ }
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+
+ if (!base) {
+ BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name);
+ return false;
+ }
+
+ return ((base->flag & BASE_HIDDEN) != 0);
+}
+
+static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports, ViewLayer *view_layer, View3D *v3d)
+{
+ if (view_layer == NULL) {
+ view_layer = CTX_data_view_layer(C);
+ }
+ if (v3d == NULL) {
+ v3d = CTX_wm_view3d(C);
+ }
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (!base) {
@@ -138,8 +187,11 @@ static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports)
return BASE_VISIBLE(v3d, base);
}
-static bool rna_Object_holdout_get(Object *ob, ReportList *reports, ViewLayer *view_layer)
+static bool rna_Object_holdout_get(Object *ob, bContext *C, ReportList *reports, ViewLayer *view_layer)
{
+ if (view_layer == NULL) {
+ view_layer = CTX_data_view_layer(C);
+ }
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (!base) {
@@ -150,8 +202,11 @@ static bool rna_Object_holdout_get(Object *ob, ReportList *reports, ViewLayer *v
return ((base->flag & BASE_HOLDOUT) != 0);
}
-static bool rna_Object_indirect_only_get(Object *ob, ReportList *reports, ViewLayer *view_layer)
+static bool rna_Object_indirect_only_get(Object *ob, bContext *C, ReportList *reports, ViewLayer *view_layer)
{
+ if (view_layer == NULL) {
+ view_layer = CTX_data_view_layer(C);
+ }
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (!base) {
@@ -162,6 +217,61 @@ static bool rna_Object_indirect_only_get(Object *ob, ReportList *reports, ViewLa
return ((base->flag & BASE_INDIRECT_ONLY) != 0);
}
+static Base *rna_Object_local_view_property_helper(bScreen *sc, View3D *v3d, Object *ob, ReportList *reports, Scene **r_scene)
+{
+ if (v3d->localvd == NULL) {
+ BKE_report(reports, RPT_ERROR, "Viewport not in local view");
+ return NULL;
+ }
+
+ wmWindow *win = ED_screen_window_find(sc, G_MAIN->wm.first);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+ if (base == NULL) {
+ BKE_reportf(reports,
+ RPT_WARNING,
+ "Object %s not in view layer %s",
+ ob->id.name + 2,
+ view_layer->name);
+
+ }
+ if (r_scene) {
+ *r_scene = win->scene;
+ }
+ return base;
+}
+
+static bool rna_Object_local_view_get(Object *ob, ReportList *reports, PointerRNA *v3d_ptr)
+{
+ bScreen *sc = v3d_ptr->id.data;
+ View3D *v3d = v3d_ptr->data;
+ Base *base = rna_Object_local_view_property_helper(sc, v3d, ob, reports, NULL);
+ if (base == NULL) {
+ return false; /* Error reported. */
+ }
+ return (base->local_view_bits & v3d->local_view_uuid) != 0;
+}
+
+static void rna_Object_local_view_set(Object *ob, ReportList *reports, PointerRNA *v3d_ptr, bool state)
+{
+ bScreen *sc = v3d_ptr->id.data;
+ View3D *v3d = v3d_ptr->data;
+ Scene *scene;
+ Base *base = rna_Object_local_view_property_helper(sc, v3d, ob, reports, &scene);
+ if (base == NULL) {
+ return; /* Error reported. */
+ }
+ const short local_view_bits_prev = base->local_view_bits;
+ SET_FLAG_FROM_TEST(base->local_view_bits, state, v3d->local_view_uuid);
+ if (local_view_bits_prev != base->local_view_bits) {
+ DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
+ ScrArea *sa = ED_screen_area_find_with_spacedata(sc, (SpaceLink *)v3d, true);
+ if (sa) {
+ ED_area_tag_redraw(sa);
+ }
+ }
+}
+
/* Convert a given matrix from a space to another (using the object and/or a bone as reference). */
static void rna_Object_mat_convert_space(Object *ob, ReportList *reports, bPoseChannel *pchan,
float *mat, float *mat_ret, int from, int to)
@@ -249,12 +359,12 @@ static void rna_Object_shape_key_remove(
Key *key = BKE_key_from_object(ob);
if ((key == NULL) || BLI_findindex(&key->block, kb) == -1) {
- BKE_reportf(reports, RPT_ERROR, "ShapeKey not found");
+ BKE_report(reports, RPT_ERROR, "ShapeKey not found");
return;
}
if (!BKE_object_shapekey_remove(bmain, ob, kb)) {
- BKE_reportf(reports, RPT_ERROR, "Could not remove ShapeKey");
+ BKE_report(reports, RPT_ERROR, "Could not remove ShapeKey");
return;
}
@@ -507,41 +617,73 @@ void RNA_api_object(StructRNA *srna)
#endif
/* Special wrapper to access the base selection value */
+ func = RNA_def_function(srna, "select_get", "rna_Object_select_get");
+ RNA_def_function_ui_description(func, "Test if the object is selected. The selection state is per view layer");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
+ parm = RNA_def_boolean(func, "result", 0, "", "Object selected");
+ RNA_def_function_return(func, parm);
+
func = RNA_def_function(srna, "select_set", "rna_Object_select_set");
- RNA_def_function_ui_description(func, "Select the object (for the active view layer)");
+ RNA_def_function_ui_description(func, "Select or deselect the object. The selection state is per view layer");
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
parm = RNA_def_boolean(func, "state", 0, "", "Selection state to define");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Operate on this view layer instead of the context");
+ parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
- func = RNA_def_function(srna, "select_get", "rna_Object_select_get");
- RNA_def_function_ui_description(func, "Get the object selection for the active view layer");
+ func = RNA_def_function(srna, "hide_get", "rna_Object_hide_get");
+ RNA_def_function_ui_description(func, "Test if the object is hidden for viewport editing. This hiding state is per view layer");
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
- parm = RNA_def_boolean(func, "result", 0, "", "Object selected");
+ parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
+ parm = RNA_def_boolean(func, "result", 0, "", "Object hideed");
RNA_def_function_return(func, parm);
+ func = RNA_def_function(srna, "hide_set", "rna_Object_hide_set");
+ RNA_def_function_ui_description(func, "Hide the object for viewport editing. This hiding state is per view layer");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
+ parm = RNA_def_boolean(func, "state", 0, "", "Hide state to define");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
+
func = RNA_def_function(srna, "visible_get", "rna_Object_visible_get");
- RNA_def_function_ui_description(func, "Get the object visibility for the active view layer and viewport");
+ RNA_def_function_ui_description(func, "Test if the object is visible in the 3D viewport, taking into account all visibility settings");
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
+ parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Use this instead of the active 3D viewport");
parm = RNA_def_boolean(func, "result", 0, "", "Object visible");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "holdout_get", "rna_Object_holdout_get");
RNA_def_function_ui_description(func, "Test if object is masked in the view layer");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "View layer to check against");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
parm = RNA_def_boolean(func, "result", 0, "", "Object holdout");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "indirect_only_get", "rna_Object_indirect_only_get");
RNA_def_function_ui_description(func, "Test if object is set to contribute only indirectly (through shadows and reflections) in the view layer");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "View layer to check against");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
parm = RNA_def_boolean(func, "result", 0, "", "Object indirect only");
RNA_def_function_return(func, parm);
+ /* Local View */
+ func = RNA_def_function(srna, "local_view_get", "rna_Object_local_view_get");
+ RNA_def_function_ui_description(func, "Get the local view state for this object");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view");
+ RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_REQUIRED);
+ parm = RNA_def_boolean(func, "result", 0, "", "Object local view state");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "local_view_set", "rna_Object_local_view_set");
+ RNA_def_function_ui_description(func, "Set the local view state for this object");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view");
+ RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_REQUIRED);
+ parm = RNA_def_boolean(func, "state", 0, "", "Local view state to define");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
/* Matrix space conversion */
func = RNA_def_function(srna, "convert_space", "rna_Object_mat_convert_space");
RNA_def_function_ui_description(func, "Convert (transform) the given matrix from one space to another");
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index a6cfc56706f..337b44a534b 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -532,16 +532,16 @@ static char *rna_FieldSettings_path(PointerRNA *ptr)
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
if (part->pd == pd)
- return BLI_sprintfN("force_field_1");
+ return BLI_strdup("force_field_1");
else if (part->pd2 == pd)
- return BLI_sprintfN("force_field_2");
+ return BLI_strdup("force_field_2");
}
else {
/* object force field */
Object *ob = (Object *)ptr->id.data;
if (ob->pd == pd)
- return BLI_sprintfN("field");
+ return BLI_strdup("field");
}
return NULL;
}
@@ -582,8 +582,9 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
/* particle effector weights */
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
- if (part->effector_weights == ew)
- return BLI_sprintfN("effector_weights");
+ if (part->effector_weights == ew) {
+ return BLI_strdup("effector_weights");
+ }
}
else {
Object *ob = (Object *)ptr->id.data;
@@ -721,7 +722,7 @@ static void rna_def_pointcache_common(StructRNA *srna)
PropertyRNA *prop;
static const EnumPropertyItem point_cache_compress_items[] = {
- {PTCACHE_COMPRESS_NO, "NO", 0, "No", "No compression"},
+ {PTCACHE_COMPRESS_NO, "NO", 0, "None", "No compression"},
{PTCACHE_COMPRESS_LZO, "LIGHT", 0, "Light", "Fast but not so effective compression"},
{PTCACHE_COMPRESS_LZMA, "HEAVY", 0, "Heavy", "Effective but slow compression"},
{0, NULL, 0, NULL, NULL},
@@ -1359,12 +1360,12 @@ static void rna_def_field(BlenderRNA *brna)
prop = RNA_def_property(srna, "apply_to_location", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_DO_LOCATION);
- RNA_def_property_ui_text(prop, "Location", "Effect particles' location");
+ RNA_def_property_ui_text(prop, "Location", "Affect particle's location");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
prop = RNA_def_property(srna, "apply_to_rotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_DO_ROTATION);
- RNA_def_property_ui_text(prop, "Rotation", "Effect particles' dynamic rotation");
+ RNA_def_property_ui_text(prop, "Rotation", "Affect particle's dynamic rotation");
RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
prop = RNA_def_property(srna, "use_absorption", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 4e1a539fe69..635beed74fb 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -108,7 +108,6 @@ static const EnumPropertyItem part_ren_as_items[] = {
{PART_DRAW_PATH, "PATH", 0, "Path", ""},
{PART_DRAW_OB, "OBJECT", 0, "Object", ""},
{PART_DRAW_GR, "COLLECTION", 0, "Collection", ""},
- {PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -1053,8 +1052,9 @@ static char *rna_SPHFluidSettings_path(PointerRNA *ptr)
if (particle_id_check(ptr)) {
ParticleSettings *part = (ParticleSettings *)ptr->id.data;
- if (part->fluid == fluid)
- return BLI_sprintfN("fluid");
+ if (part->fluid == fluid) {
+ return BLI_strdup("fluid");
+ }
}
return NULL;
}
@@ -2062,30 +2062,6 @@ static void rna_def_particle_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- static const EnumPropertyItem bb_align_items[] = {
- {PART_BB_X, "X", 0, "X", ""},
- {PART_BB_Y, "Y", 0, "Y", ""},
- {PART_BB_Z, "Z", 0, "Z", ""},
- {PART_BB_VIEW, "VIEW", 0, "View", ""},
- {PART_BB_VEL, "VEL", 0, "Velocity", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
- static const EnumPropertyItem bb_anim_items[] = {
- {PART_BB_ANIM_NONE, "NONE", 0, "None", ""},
- {PART_BB_ANIM_AGE, "AGE", 0, "Age", ""},
- {PART_BB_ANIM_FRAME, "FRAME", 0, "Frame", ""},
- {PART_BB_ANIM_ANGLE, "ANGLE", 0, "Angle", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
- static const EnumPropertyItem bb_split_offset_items[] = {
- {PART_BB_OFF_NONE, "NONE", 0, "None", ""},
- {PART_BB_OFF_LINEAR, "LINEAR", 0, "Linear", ""},
- {PART_BB_OFF_RANDOM, "RANDOM", 0, "Random", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
static const EnumPropertyItem draw_col_items[] = {
{PART_DRAW_COL_NONE, "NONE", 0, "None", ""},
{PART_DRAW_COL_MAT, "MATERIAL", 0, "Material", ""},
@@ -2481,79 +2457,12 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Axis", "Which axis to use for offset");
RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
- /* billboards */
- prop = RNA_def_property(srna, "lock_billboard", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_BB_LOCK);
- RNA_def_property_ui_text(prop, "Lock Billboard", "Lock the billboards align axis");
- RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
- prop = RNA_def_property(srna, "billboard_align", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "bb_align");
- RNA_def_property_enum_items(prop, bb_align_items);
- RNA_def_property_ui_text(prop, "Align to", "In respect to what the billboards are aligned");
- RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
- prop = RNA_def_property(srna, "billboard_uv_split", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "bb_uv_split");
- RNA_def_property_range(prop, 1, 100);
- RNA_def_property_ui_range(prop, 1, 10, 1, -1);
- RNA_def_property_ui_text(prop, "UV Split", "Number of rows/columns to split UV coordinates for billboards");
-
- prop = RNA_def_property(srna, "billboard_animation", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "bb_anim");
- RNA_def_property_enum_items(prop, bb_anim_items);
- RNA_def_property_ui_text(prop, "Animate", "How to animate billboard textures");
-
- prop = RNA_def_property(srna, "billboard_offset_split", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "bb_split_offset");
- RNA_def_property_enum_items(prop, bb_split_offset_items);
- RNA_def_property_ui_text(prop, "Offset", "How to offset billboard textures");
-
- prop = RNA_def_property(srna, "billboard_tilt", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "bb_tilt");
- RNA_def_property_range(prop, -1.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Tilt", "Tilt of the billboards");
- RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
prop = RNA_def_property(srna, "color_maximum", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "color_vec_max");
RNA_def_property_range(prop, 0.01f, 100.0f);
RNA_def_property_ui_text(prop, "Color Maximum", "Maximum length of the particle color vector");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
- prop = RNA_def_property(srna, "billboard_tilt_random", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "bb_rand_tilt");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Random Tilt", "Random tilt of the billboards");
- RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
- prop = RNA_def_property(srna, "billboard_offset", PROP_FLOAT, PROP_TRANSLATION);
- RNA_def_property_float_sdna(prop, NULL, "bb_offset");
- RNA_def_property_array(prop, 2);
- RNA_def_property_range(prop, -100.0f, 100.0f);
- RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3);
- RNA_def_property_ui_text(prop, "Billboard Offset", "");
- RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
- prop = RNA_def_property(srna, "billboard_size", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "bb_size");
- RNA_def_property_array(prop, 2);
- RNA_def_property_range(prop, 0.001f, 10.0f);
- RNA_def_property_ui_text(prop, "Billboard Scale", "Scale billboards relative to particle size");
- RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
- prop = RNA_def_property(srna, "billboard_velocity_head", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "bb_vel_head");
- RNA_def_property_range(prop, 0.0f, 10.0f);
- RNA_def_property_ui_text(prop, "Billboard Velocity Head", "Scale billboards by velocity");
- RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
- prop = RNA_def_property(srna, "billboard_velocity_tail", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "bb_vel_tail");
- RNA_def_property_range(prop, 0.0f, 10.0f);
- RNA_def_property_ui_text(prop, "Billboard Velocity Tail", "Scale billboards by velocity");
- RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
/* general values */
prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME);
RNA_def_property_float_sdna(prop, NULL, "sta"); /*optional if prop names are the same */
@@ -3097,7 +3006,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "instance_collection");
RNA_def_property_struct_type(prop, "Collection");
- RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_ui_text(prop, "Dupli Collection", "Show Objects in this collection in place of particles");
RNA_def_property_update(prop, 0, "rna_Particle_redo_count");
@@ -3123,13 +3032,6 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Instance Object", "Show this Object in place of particles");
RNA_def_property_update(prop, 0, "rna_Particle_redo_dependency");
- prop = RNA_def_property(srna, "billboard_object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "bb_ob");
- RNA_def_property_struct_type(prop, "Object");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Billboard Object", "Billboards face this object (default is active camera)");
- RNA_def_property_update(prop, 0, "rna_Particle_redo");
-
/* boids */
prop = RNA_def_property(srna, "boids", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "BoidSettings");
@@ -3381,22 +3283,6 @@ static void rna_def_particle_system(BlenderRNA *brna)
"rna_ParticleSystem_active_particle_target_index_range");
RNA_def_property_ui_text(prop, "Active Particle Target Index", "");
- /* billboard */
- prop = RNA_def_property(srna, "billboard_normal_uv", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "bb_uvname[0]");
- RNA_def_property_string_maxlength(prop, 32);
- RNA_def_property_ui_text(prop, "Billboard Normal UV", "UV map to control billboard normals");
-
- prop = RNA_def_property(srna, "billboard_time_index_uv", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "bb_uvname[1]");
- RNA_def_property_string_maxlength(prop, 32);
- RNA_def_property_ui_text(prop, "Billboard Time Index UV", "UV map to control billboard time index (X-Y)");
-
- prop = RNA_def_property(srna, "billboard_split_uv", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "bb_uvname[2]");
- RNA_def_property_string_maxlength(prop, 32);
- RNA_def_property_ui_text(prop, "Billboard Split UV", "UV map to control billboard splitting");
-
/* vertex groups */
/* note, internally store as ints, access as strings */
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index 7f0ee14ef18..169db8cf246 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -119,7 +119,7 @@ static void rna_RigidBodyWorld_reset(Main *UNUSED(bmain), Scene *UNUSED(scene),
static char *rna_RigidBodyWorld_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("rigidbody_world");
+ return BLI_strdup("rigidbody_world");
}
static void rna_RigidBodyWorld_num_solver_iterations_set(PointerRNA *ptr, int value)
@@ -193,7 +193,7 @@ static void rna_RigidBodyOb_shape_reset(Main *UNUSED(bmain), Scene *scene, Point
static char *rna_RigidBodyOb_path(PointerRNA *UNUSED(ptr))
{
/* NOTE: this hardcoded path should work as long as only Objects have this */
- return BLI_sprintfN("rigid_body");
+ return BLI_strdup("rigid_body");
}
static void rna_RigidBodyOb_type_set(PointerRNA *ptr, int value)
@@ -383,7 +383,7 @@ static void rna_RigidBodyOb_angular_damping_set(PointerRNA *ptr, float value)
static char *rna_RigidBodyCon_path(PointerRNA *UNUSED(ptr))
{
/* NOTE: this hardcoded path should work as long as only Objects have this */
- return BLI_sprintfN("rigid_body_constraint");
+ return BLI_strdup("rigid_body_constraint");
}
static void rna_RigidBodyCon_type_set(PointerRNA *ptr, int value)
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 347cb9fc379..4e0bc325d8f 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -473,7 +473,7 @@ const EnumPropertyItem rna_enum_transform_orientation_items[] = {
"(bone Y axis for pose mode)"},
{V3D_ORIENT_GIMBAL, "GIMBAL", ICON_ORIENTATION_GIMBAL, "Gimbal", "Align each axis to the Euler rotation axis as used for input"},
{V3D_ORIENT_VIEW, "VIEW", ICON_ORIENTATION_VIEW, "View", "Align the transformation axes to the window"},
- {V3D_ORIENT_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "Cursor", "Align the transformation axes to the 3D cursor"},
+ {V3D_ORIENT_CURSOR, "CURSOR", ICON_ORIENTATION_CURSOR, "Cursor", "Align the transformation axes to the 3D cursor"},
// {V3D_ORIENT_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"},
{0, NULL, 0, NULL, NULL},
};
@@ -660,12 +660,13 @@ void rna_Scene_set_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
}
}
-static void rna_Scene_view3d_update(Main *bmain, Scene *UNUSED(scene_unused), PointerRNA *ptr)
+static void rna_Scene_camera_update(Main *bmain, Scene *UNUSED(scene_unused), PointerRNA *ptr)
{
wmWindowManager *wm = bmain->wm.first;
Scene *scene = (Scene *)ptr->data;
WM_windows_scene_data_sync(&wm->windows, scene);
+ DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
static void rna_Scene_fps_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
@@ -907,12 +908,12 @@ static void rna_RenderSettings_stereoViews_begin(CollectionPropertyIterator *ite
static char *rna_RenderSettings_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("render");
+ return BLI_strdup("render");
}
static char *rna_BakeSettings_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("render.bake");
+ return BLI_strdup("render.bake");
}
static char *rna_ImageFormatSettings_path(PointerRNA *ptr)
@@ -926,12 +927,12 @@ static char *rna_ImageFormatSettings_path(PointerRNA *ptr)
Scene *scene = (Scene *)id;
if (&scene->r.im_format == imf) {
- return BLI_sprintfN("render.image_settings");
+ return BLI_strdup("render.image_settings");
}
else if (&scene->r.bake.im_format == imf) {
- return BLI_sprintfN("render.bake.image_settings");
+ return BLI_strdup("render.bake.image_settings");
}
- return BLI_sprintfN("..");
+ return BLI_strdup("..");
}
case ID_NT:
{
@@ -955,10 +956,10 @@ static char *rna_ImageFormatSettings_path(PointerRNA *ptr)
}
}
}
- return BLI_sprintfN("..");
+ return BLI_strdup("..");
}
default:
- return BLI_sprintfN("..");
+ return BLI_strdup("..");
}
}
@@ -2124,26 +2125,6 @@ const EnumPropertyItem *rna_TransformOrientation_with_scene_itemf(
#undef V3D_ORIENT_DEFAULT
-void rna_TransformOrientationSlot_ui_info(
- ID *scene_id, TransformOrientationSlot *orient_slot,
- char *r_name, int *r_icon_value)
-{
- Scene *scene = (Scene *)scene_id;
-
- if (orient_slot->type < V3D_ORIENT_CUSTOM) {
- const EnumPropertyItem *items = rna_enum_transform_orientation_items;
- const int i = RNA_enum_from_value(items, orient_slot->type);
- strcpy(r_name, items[i].name);
- *r_icon_value = items[i].icon;
- }
- else {
- TransformOrientation *orientation = BKE_scene_transform_orientation_find(
- scene, orient_slot->index_custom);
- strcpy(r_name, orientation->name);
- *r_icon_value = ICON_OBJECT_ORIGIN;
- }
-}
-
static const EnumPropertyItem *rna_UnitSettings_itemf_wrapper(
const int system, const int type, bool *r_free)
{
@@ -2210,7 +2191,7 @@ static void rna_UnitSettings_system_update(Main *UNUSED(bmain), Scene *scene, Po
static char *rna_UnitSettings_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("unit_settings");
+ return BLI_strdup("unit_settings");
}
/* lanpr */
@@ -2380,20 +2361,6 @@ static void rna_def_transform_orientation_slot(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
RNA_def_property_ui_text(prop, "Use", "Use scene orientation instead of a custom setting");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
-
- FunctionRNA *func;
- PropertyRNA *parm;
-
- /* UI access only (avoid slow RNA introspection). */
- func = RNA_def_function(srna, "ui_info", "rna_TransformOrientationSlot_ui_info");
- RNA_def_function_ui_description(func, "");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID);
- parm = RNA_def_string(func, "name", NULL, sizeof(((TransformOrientation *)NULL)->name), "name", "");
- RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
- RNA_def_function_output(func, parm);
- parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_NONE);
- RNA_def_property_ui_text(parm, "", "");
- RNA_def_function_output(func, parm);
}
static void rna_def_view3d_cursor(BlenderRNA *brna)
@@ -2498,7 +2465,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
};
static const EnumPropertyItem gpencil_stroke_snap_items[] = {
- {0, "NONE", 0, "All points", "No snap"},
+ {0, "NONE", 0, "All points", "Snap to all points"},
{GP_PROJECT_DEPTH_STROKE_ENDPOINTS, "ENDS", 0, "End points", "Snap to first and last points and interpolate" },
{GP_PROJECT_DEPTH_STROKE_FIRST, "FIRST", 0, "First point", "Snap to first point" },
{0, NULL, 0, NULL, NULL},
@@ -2672,7 +2639,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_transform_pivot_point_align", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "transform_flag", SCE_XFORM_AXIS_ALIGN);
- RNA_def_property_ui_text(prop, "Align", "Manipulate center points (object, pose and weight paint mode only)");
+ RNA_def_property_ui_text(prop, "Only Origins", "Manipulate center points (object, pose and weight paint mode only)");
RNA_def_property_ui_icon(prop, ICON_CENTER_ONLY, 0);
RNA_def_property_update(prop, NC_SCENE, NULL);
@@ -2779,21 +2746,24 @@ static void rna_def_tool_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_gpencil_draw_onback", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINT_ONBACK);
- RNA_def_property_ui_text(prop, "Draw Strokes on Back",
- "When draw new strokes, the new stroke is drawn below of all strokes in the layer");
+ RNA_def_property_ui_text(
+ prop, "Draw Strokes on Back",
+ "When draw new strokes, the new stroke is drawn below of all strokes in the layer");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_gpencil_thumbnail_list", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_THUMBNAIL_LIST);
- RNA_def_property_ui_text(prop, "Compact List",
- "Show compact list of color instead of thumbnails");
+ RNA_def_property_ui_text(
+ prop, "Compact List",
+ "Show compact list of color instead of thumbnails");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_gpencil_weight_data_add", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_CREATE_WEIGHTS);
- RNA_def_property_ui_text(prop, "Add weight data for new strokes",
- "When creating new strokes, the weight data is added according to the current vertex group and weight, "
- "if no vertex group selected, weight is not added");
+ RNA_def_property_ui_text(
+ prop, "Add weight data for new strokes",
+ "When creating new strokes, the weight data is added according to the current vertex group and weight, "
+ "if no vertex group selected, weight is not added");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "gpencil_sculpt", PROP_POINTER, PROP_NONE);
@@ -2831,7 +2801,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "gpencil_selectmode");
RNA_def_property_enum_items(prop, gpencil_selectmode_items);
RNA_def_property_ui_text(prop, "Select Mode", "");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
/* Annotations - 2D Views Stroke Placement */
prop = RNA_def_property(srna, "annotation_stroke_placement_view2d", PROP_ENUM, PROP_NONE);
@@ -2859,6 +2829,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "annotation_stroke_placement_view3d", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "annotate_v3d_align");
RNA_def_property_enum_items(prop, annotation_stroke_placement_items);
+ RNA_def_property_enum_default(prop, GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR);
RNA_def_property_ui_text(prop, "Annotation Stroke Placement (3D View)", "How annotation strokes are orientated in 3D space");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
@@ -2977,6 +2948,12 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static const EnumPropertyItem brush_size_unit_items[] = {
+ {0, "VIEW", 0, "View", "Measure brush size relateve to the view"},
+ {UNIFIED_PAINT_BRUSH_LOCK_SIZE, "SCENE", 0, "Scene", "Measure brush size relateve to the scene"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
srna = RNA_def_struct(brna, "UnifiedPaintSettings", NULL);
RNA_def_struct_path_func(srna, "rna_UnifiedPaintSettings_path");
RNA_def_struct_ui_text(srna, "Unified Paint Settings", "Overrides for some of the active brush's settings");
@@ -3062,12 +3039,11 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength");
- prop = RNA_def_property(srna, "use_locked_size", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_BRUSH_LOCK_SIZE);
- RNA_def_property_ui_text(prop, "Use Blender Units",
- "When locked brush stays same size relative to object; "
- "when unlocked brush size is given in pixels");
- RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
+ prop = RNA_def_property(srna, "use_locked_size", PROP_ENUM, PROP_NONE); /* as an enum */
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_items(prop, brush_size_unit_items);
+ RNA_def_property_ui_text(prop, "Radius Unit", "Measure brush size relative to the view or the scene ");
+
}
@@ -5168,7 +5144,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "blurfac");
- RNA_def_property_range(prop, 0.01f, 2.0f);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 2);
RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
@@ -5618,7 +5594,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_simplify_smoke_highres", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "simplify_smoke_ignore_highres", 1);
- RNA_def_property_ui_text(prop, "Use Smoke Highres", "Allow drawing high-res smoke in viewport");
+ RNA_def_property_ui_text(prop, "Use High-resolution Smoke", "Display high-resolution smoke in the viewport");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
/* Grease Pencil - Simplify Options */
@@ -6340,7 +6316,7 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
- RNA_def_property_range(prop, 0.01f, 2.0f);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 2);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
@@ -6697,7 +6673,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll");
RNA_def_property_ui_text(prop, "Camera", "Active camera, used for rendering the scene");
- RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_view3d_update");
+ RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_camera_update");
prop = RNA_def_property(srna, "background_set", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "set");
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 33e3da6d86c..c42bfd55412 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -344,8 +344,8 @@ static void rna_def_area(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Area_type_update");
prop = RNA_def_property(srna, "ui_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); /* infact dummy */
- RNA_def_property_enum_default(prop, 0);
+ RNA_def_property_enum_items(prop, DummyRNA_NULL_items); /* infact dummy */
+ RNA_def_property_enum_default(prop, SPACE_VIEW3D << 16);
RNA_def_property_enum_funcs(prop, "rna_Area_ui_type_get", "rna_Area_ui_type_set", "rna_Area_ui_type_itemf");
RNA_def_property_ui_text(prop, "Editor Type", "Current editor type for this area");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index f372180dd3b..6d805639940 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -82,6 +82,7 @@ static const EnumPropertyItem rna_enum_gpencil_lock_axis_items[] = {
{GP_LOCKAXIS_Y, "AXIS_Y", ICON_AXIS_FRONT, "Front (X-Z)", "Project strokes to plane locked to Y"},
{GP_LOCKAXIS_X, "AXIS_X", ICON_AXIS_SIDE, "Side (Y-Z)", "Project strokes to plane locked to X"},
{GP_LOCKAXIS_Z, "AXIS_Z", ICON_AXIS_TOP, "Top (X-Y)", "Project strokes to plane locked to Z"},
+ {GP_LOCKAXIS_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "Cursor", "Align strokes to current 3D cursor orientation"},
{0, NULL, 0, NULL, NULL},
};
#endif
@@ -490,7 +491,7 @@ static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr))
SpaceImage *sima = (SpaceImage *)slink;
if (!sima->pin)
- ED_space_image_set(bmain, sima, obedit, ima);
+ ED_space_image_set(bmain, sima, obedit, ima, true);
}
}
}
@@ -1063,7 +1064,7 @@ static void rna_def_particle_edit(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_DEFLECT_EMITTER);
RNA_def_property_ui_text(prop, "Deflect Emitter", "Keep paths from intersecting the emitter");
- prop = RNA_def_property(srna, "emitter_distance", PROP_FLOAT, PROP_UNSIGNED);
+ prop = RNA_def_property(srna, "emitter_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "emitterdist");
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 10, 3);
RNA_def_property_ui_text(prop, "Emitter Distance", "Distance to keep particles away from the emitter");
@@ -1081,7 +1082,7 @@ static void rna_def_particle_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_DRAW_PART);
- RNA_def_property_ui_text(prop, "Draw Particles", "Draw actual particles");
+ RNA_def_property_ui_text(prop, "Display Particles", "Display actual particles");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo");
prop = RNA_def_property(srna, "use_default_interpolate", PROP_BOOLEAN, PROP_NONE);
@@ -1218,14 +1219,14 @@ static void rna_def_gpencil_guides(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "use_guide", false);
RNA_def_property_boolean_default(prop, false);
RNA_def_property_ui_text(prop, "Use Guides", "Enable speed guides");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_snapping", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_snapping", false);
RNA_def_property_boolean_default(prop, false);
RNA_def_property_ui_text(prop, "Use Snapping", "Enable snapping to guides angle or spacing options");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "reference_object", PROP_POINTER, PROP_NONE);
@@ -1238,28 +1239,28 @@ static void rna_def_gpencil_guides(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "reference_point");
RNA_def_property_enum_items(prop, prop_gpencil_guide_references);
RNA_def_property_ui_text(prop, "Type", "Type of speed guide");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_viewport_update");
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_gpencil_guidetypes);
RNA_def_property_ui_text(prop, "Type", "Type of speed guide");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "angle");
RNA_def_property_range(prop, -(M_PI * 2.0f), (M_PI * 2.0f));
RNA_def_property_ui_text(prop, "Angle", "Direction of lines");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "angle_snap", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "angle_snap");
RNA_def_property_range(prop, -(M_PI * 2.0f), (M_PI * 2.0f));
RNA_def_property_ui_text(prop, "Angle Snap", "Angle snapping");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "spacing", PROP_FLOAT, PROP_DISTANCE);
@@ -1268,13 +1269,13 @@ static void rna_def_gpencil_guides(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, 3);
RNA_def_property_ui_text(prop, "Spacing", "Guide spacing");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "location");
RNA_def_property_array(prop, 3);
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Location", "Custom reference point for guides");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
@@ -1302,86 +1303,88 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "brushtype");
RNA_def_property_enum_items(prop, rna_enum_gpencil_sculpt_brush_items);
RNA_def_property_ui_text(prop, "Tool", "");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_GPencil_update");
prop = RNA_def_property(srna, "weight_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "weighttype");
RNA_def_property_enum_items(prop, rna_enum_gpencil_weight_brush_items);
RNA_def_property_ui_text(prop, "Tool", "Tool for weight painting");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_GPencil_update");
prop = RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "GPencilSculptBrush");
RNA_def_property_pointer_funcs(prop, "rna_GPencilSculptSettings_brush_get", NULL, NULL, NULL);
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Brush", "");
prop = RNA_def_property(srna, "guide", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "GPencilSculptGuide");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Guide", "");
prop = RNA_def_property(srna, "use_select_mask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_SELECT_MASK);
RNA_def_property_ui_text(prop, "Selection Mask", "Only sculpt selected stroke points");
RNA_def_property_ui_icon(prop, ICON_GP_ONLY_SELECTED, 0);
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_edit_position", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_APPLY_POSITION);
RNA_def_property_ui_text(prop, "Affect Position", "The brush affects the position of the point");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_edit_strength", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_APPLY_STRENGTH);
RNA_def_property_ui_text(prop, "Affect Strength", "The brush affects the color strength of the point");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_edit_thickness", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_APPLY_THICKNESS);
RNA_def_property_ui_text(prop, "Affect Thickness", "The brush affects the thickness of the point");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_edit_uv", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_APPLY_UV);
RNA_def_property_ui_text(prop, "Affect UV", "The brush affects the UV rotation of the point");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_multiframe_falloff", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_FRAME_FALLOFF);
RNA_def_property_ui_text(prop, "Use Falloff", "Use falloff effect when edit in multiframe mode to compute brush effect by frame");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_thickness_curve", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE);
RNA_def_property_ui_text(prop, "Use Curve", "Use curve to define primitive stroke thickness");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
/* custom falloff curve */
prop = RNA_def_property(srna, "multiframe_falloff_curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "cur_falloff");
RNA_def_property_struct_type(prop, "CurveMapping");
- RNA_def_property_ui_text(prop, "Curve",
- "Custom curve to control falloff of brush effect by Grease Pencil frames");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Curve",
+ "Custom curve to control falloff of brush effect by Grease Pencil frames");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
/* custom primitive curve */
prop = RNA_def_property(srna, "thickness_primitive_curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "cur_primitive");
RNA_def_property_struct_type(prop, "CurveMapping");
- RNA_def_property_ui_text(prop, "Curve",
- "Custom curve to control primitive thickness");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_ui_text(
+ prop, "Curve",
+ "Custom curve to control primitive thickness");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
/* lock axis */
@@ -1389,7 +1392,7 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "lock_axis");
RNA_def_property_enum_items(prop, rna_enum_gpencil_lock_axis_items);
RNA_def_property_ui_text(prop, "Lock Axis", "");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* threshold for cutter */
@@ -1398,65 +1401,64 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_float_default(prop, 0.1f);
RNA_def_property_ui_text(prop, "Threshold", "Threshold for stroke intersections");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
/* brush */
srna = RNA_def_struct(brna, "GPencilSculptBrush", NULL);
RNA_def_struct_sdna(srna, "GP_Sculpt_Data");
RNA_def_struct_path_func(srna, "rna_GPencilSculptBrush_path");
RNA_def_struct_ui_text(srna, "GPencil Sculpt Brush", "Stroke editing brush");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, GP_MAX_BRUSH_PIXEL_RADIUS);
RNA_def_property_ui_range(prop, 1, 500, 10, 3);
RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.001, 1.0);
RNA_def_property_ui_text(prop, "Strength", "Brush strength");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "Weight", "Target weight");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_FLAG_USE_PRESSURE);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_pressure_radius", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_FLAG_PRESSURE_RADIUS);
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
RNA_def_property_ui_text(prop, "Radius Pressure", "Enable tablet pressure sensitivity for radius");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_FLAG_USE_FALLOFF);
RNA_def_property_ui_text(prop, "Use Falloff", "Strength of brush decays with distance from cursor");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_edit_pressure", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_FLAG_SMOOTH_PRESSURE);
RNA_def_property_ui_text(prop, "Affect Pressure", "Affect pressure values as well when smoothing strokes");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_direction_items);
RNA_def_property_ui_text(prop, "Direction", "");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
/* Cursor Color */
@@ -1469,7 +1471,7 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_ui_text(prop, "Cursor Add", "Color for the cursor for addition");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "cursor_color_sub", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "curcolor_sub");
@@ -1477,13 +1479,13 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_array_default(prop, default_2);
RNA_def_property_ui_text(prop, "Cursor Sub", "Color for the cursor for subtraction");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "use_cursor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_FLAG_ENABLE_CURSOR);
RNA_def_property_boolean_default(prop, true);
RNA_def_property_ui_text(prop, "Enable Cursor", "Enable cursor on screen");
- RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
void RNA_def_sculpt_paint(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index c01f59582d1..569fbb61ad8 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -2608,6 +2608,7 @@ static void rna_def_modifier(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update");
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", SEQUENCE_MODIFIER_EXPANDED);
RNA_def_property_ui_text(prop, "Expanded", "Mute expanded settings for the modifier");
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c
index 78a21b71fbf..41e87f6d121 100644
--- a/source/blender/makesrna/intern/rna_shader_fx.c
+++ b/source/blender/makesrna/intern/rna_shader_fx.c
@@ -683,6 +683,7 @@ void RNA_def_shader_fx(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
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, "mode", eShaderFxMode_Expanded);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_text(prop, "Expanded", "Set effect expanded in the user interface");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 0592a524b76..97b997c4604 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -643,7 +643,7 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value
ED_view3d_from_m4(mat, rv3d->ofs, rv3d->viewquat, &rv3d->dist);
}
-static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
ID *id = ptr->id.data;
if (GS(id->name) == ID_SCE) {
@@ -661,12 +661,25 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), Poi
DEG_id_tag_update(&ma->id, ID_RECALC_SHADING);
}
+ View3DShading *shading = ptr->data;
+ if (shading->type == OB_MATERIAL ||
+ (shading->type == OB_RENDER && (strcmp(scene->r.engine, RE_engine_id_BLENDER_EEVEE) == 0 ||
+ strcmp(scene->r.engine, RE_engine_id_CYCLES)))) {
+ /* When switching from workbench to render or material mode the geometry of any
+ * active sculpt session needs to be recalculated. */
+ for (Object *ob = bmain->objects.first; ob ; ob = ob->id.next) {
+ if (ob->sculpt) {
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
+ }
+ }
+
bScreen *screen = ptr->id.data;
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;
- if (&v3d->shading == ptr->data) {
+ if (&v3d->shading == shading) {
ED_view3d_shade_update(bmain, v3d, sa);
return;
}
@@ -939,7 +952,7 @@ static int rna_SpaceView3D_icon_from_show_object_viewport_get(PointerRNA *ptr)
static char *rna_View3DShading_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("shading");
+ return BLI_strdup("shading");
}
static PointerRNA rna_SpaceView3D_overlay_get(PointerRNA *ptr)
@@ -949,7 +962,7 @@ static PointerRNA rna_SpaceView3D_overlay_get(PointerRNA *ptr)
static char *rna_View3DOverlay_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("overlay");
+ return BLI_strdup("overlay");
}
/* Space Image Editor */
@@ -1036,7 +1049,7 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
BLI_assert(BKE_id_is_in_global_main(value.data));
- ED_space_image_set(G_MAIN, sima, obedit, (Image *)value.data);
+ ED_space_image_set(G_MAIN, sima, obedit, (Image *)value.data, false);
}
static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value)
@@ -2974,26 +2987,30 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
/* 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);
- RNA_def_property_ui_text(prop, "Show Annotation",
- "Show annotations for this view");
+ RNA_def_property_ui_text(
+ prop, "Show Annotation",
+ "Show annotations for this view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "use_gpencil_paper", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_PAPER);
- RNA_def_property_ui_text(prop, "Use Paper",
- "Cover all viewport with a full color layer to improve visibility while drawing over complex scenes");
+ RNA_def_property_ui_text(
+ prop, "Use Paper",
+ "Cover all viewport with a full color layer to improve visibility while drawing over complex scenes");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "use_gpencil_grid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_SHOW_GRID);
- RNA_def_property_ui_text(prop, "Use Grid",
- "Display a grid over grease pencil paper");
+ RNA_def_property_ui_text(
+ prop, "Use Grid",
+ "Display a grid over grease pencil paper");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "use_gpencil_fade_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", V3D_GP_FADE_NOACTIVE_LAYERS);
- RNA_def_property_ui_text(prop, "Fade Layers",
- "Toggle fading of Grease Pencil layers except the active one");
+ RNA_def_property_ui_text(
+ prop, "Fade Layers",
+ "Toggle fading of Grease Pencil layers except the active one");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
prop = RNA_def_property(srna, "gpencil_grid_opacity", PROP_FLOAT, PROP_NONE);
@@ -3016,8 +3033,9 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_fade_layer");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_default(prop, 0.5f);
- RNA_def_property_ui_text(prop, "Opacity",
- "Fade layer opacity for Grease Pencil layers except the active one");
+ RNA_def_property_ui_text(
+ prop, "Opacity",
+ "Fade layer opacity for Grease Pencil layers except the active one");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
/* show edit lines */
@@ -4421,24 +4439,24 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
};
static const EnumPropertyItem file_filter_idcategories_items[] = {
- {FILTER_ID_SCE,
- "SCENE", ICON_SCENE_DATA, "Scenes", "Show/hide scenes"},
- {FILTER_ID_AC,
- "ANIMATION", ICON_ANIM_DATA, "Animations", "Show/hide animation data"},
+ {FILTER_ID_SCE,
+ "SCENE", ICON_SCENE_DATA, "Scenes", "Show/hide scenes"},
+ {FILTER_ID_AC,
+ "ANIMATION", ICON_ANIM_DATA, "Animations", "Show/hide animation data"},
{FILTER_ID_OB | FILTER_ID_GR,
- "OBJECT", ICON_GROUP, "Objects & Collections", "Show/hide objects and groups"},
+ "OBJECT", ICON_GROUP, "Objects & Collections", "Show/hide objects and groups"},
{FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME,
- "GEOMETRY", ICON_MESH_DATA, "Geometry", "Show/hide meshes, curves, lattice, armatures and metaballs data"},
+ "GEOMETRY", ICON_MESH_DATA, "Geometry", "Show/hide meshes, curves, lattice, armatures and metaballs data"},
{FILTER_ID_LS | FILTER_ID_MA | FILTER_ID_NT | FILTER_ID_TE,
- "SHADING", ICON_MATERIAL_DATA, "Shading",
- "Show/hide materials, nodetrees, textures and Freestyle's linestyles"},
+ "SHADING", ICON_MATERIAL_DATA, "Shading",
+ "Show/hide materials, nodetrees, textures and Freestyle's linestyles"},
{FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO,
- "IMAGE", ICON_IMAGE_DATA, "Images & Sounds", "Show/hide images, movie clips, sounds and masks"},
+ "IMAGE", ICON_IMAGE_DATA, "Images & Sounds", "Show/hide images, movie clips, sounds and masks"},
{FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_SPK | FILTER_ID_WO | FILTER_ID_WS,
- "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lights, cameras and speakers"},
+ "ENVIRONMENT", ICON_WORLD_DATA, "Environment", "Show/hide worlds, lights, cameras and speakers"},
{FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_CF,
- "MISC", ICON_GREASEPENCIL, "Miscellaneous", "Show/hide other data types"},
- {0, NULL, 0, NULL, NULL},
+ "MISC", ICON_GREASEPENCIL, "Miscellaneous", "Show/hide other data types"},
+ {0, NULL, 0, NULL, NULL},
};
srna = RNA_def_struct(brna, "FileSelectParams", NULL);
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 8df1d3115cc..154388e4228 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -55,7 +55,7 @@
static char *rna_tracking_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("tracking");
+ return BLI_strdup("tracking");
}
static void rna_tracking_defaultSettings_patternUpdate(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -307,7 +307,7 @@ static void rna_trackingPlaneTrack_name_set(PointerRNA *ptr, const char *value)
static char *rna_trackingCamera_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("tracking.camera");
+ return BLI_strdup("tracking.camera");
}
static float rna_trackingCamera_focal_mm_get(PointerRNA *ptr)
@@ -336,7 +336,7 @@ static void rna_trackingCamera_focal_mm_set(PointerRNA *ptr, float value)
static char *rna_trackingStabilization_path(PointerRNA *UNUSED(ptr))
{
- return BLI_sprintfN("tracking.stabilization");
+ return BLI_strdup("tracking.stabilization");
}
static int rna_track_2d_stabilization(CollectionPropertyIterator *UNUSED(iter), void *data)
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 5bc647493cc..b6e75cf3507 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -881,6 +881,26 @@ static void rna_UILayout_active_set(PointerRNA *ptr, bool value)
uiLayoutSetActive(ptr->data, value);
}
+static bool rna_UILayout_active_default_get(PointerRNA *ptr)
+{
+ return uiLayoutGetActiveDefault(ptr->data);
+}
+
+static void rna_UILayout_active_default_set(PointerRNA *ptr, bool value)
+{
+ uiLayoutSetActiveDefault(ptr->data, value);
+}
+
+static bool rna_UILayout_activate_init_get(PointerRNA *ptr)
+{
+ return uiLayoutGetActivateInit(ptr->data);
+}
+
+static void rna_UILayout_activate_init_set(PointerRNA *ptr, bool value)
+{
+ uiLayoutSetActivateInit(ptr->data, value);
+}
+
static bool rna_UILayout_alert_get(PointerRNA *ptr)
{
return uiLayoutGetRedAlert(ptr->data);
@@ -1056,6 +1076,20 @@ static void rna_def_ui_layout(BlenderRNA *brna)
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_active_get", "rna_UILayout_active_set");
+ prop = RNA_def_property(srna, "active_default", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_UILayout_active_default_get", "rna_UILayout_active_default_set");
+ RNA_def_property_ui_text(
+ prop, "Active Default",
+ "When true, an operator button defined after this will be activated when pressing return"
+ "(use with popup dialogs)");
+
+ prop = RNA_def_property(srna, "activate_init", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_UILayout_activate_init_get", "rna_UILayout_activate_init_set");
+ RNA_def_property_ui_text(
+ prop, "Activate on Init",
+ "When true, buttons defined in popups will be activated on first display "
+ "(use so you can type into a field without having to click on it first)");
+
prop = RNA_def_property(srna, "operator_context", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_operator_context_items);
RNA_def_property_enum_funcs(prop, "rna_UILayout_op_context_get", "rna_UILayout_op_context_set", NULL);
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 973f92c6575..e6c1038c48d 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -117,6 +117,57 @@ static void rna_uiItemR(
uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon);
}
+static void rna_uiItemR_with_popover(
+ uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
+ const char *text_ctxt, bool translate, int icon,
+ bool icon_only,
+ const char *panel_type)
+{
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
+
+ if (!prop) {
+ RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+ if (RNA_property_type(prop) != PROP_ENUM) {
+ RNA_warning("property is not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+ int flag = 0;
+
+ flag |= (icon_only) ? UI_ITEM_R_ICON_ONLY : 0;
+
+ /* Get translated name (label). */
+ name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
+ uiItemFullR_with_popover(layout, ptr, prop, -1, 0, flag, name, icon, panel_type);
+}
+
+static void rna_uiItemR_with_menu(
+ uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
+ const char *text_ctxt, bool translate, int icon,
+ bool icon_only,
+ const char *menu_type)
+{
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
+
+ if (!prop) {
+ RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+ if (RNA_property_type(prop) != PROP_ENUM) {
+ RNA_warning("property is not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+ int flag = 0;
+
+ flag |= (icon_only) ? UI_ITEM_R_ICON_ONLY : 0;
+
+ /* Get translated name (label). */
+ name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
+ uiItemFullR_with_menu(layout, ptr, prop, -1, 0, flag, name, icon, menu_type);
+}
+
+
static void rna_uiItemMenuEnumR(
uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
const char *text_ctxt, bool translate, int icon)
@@ -452,8 +503,12 @@ static int rna_ui_get_enum_icon(bContext *C, PointerRNA *ptr, const char *propna
static void api_ui_item_common_text(FunctionRNA *func)
{
- RNA_def_string(func, "text", NULL, 0, "", "Override automatic text of the item");
- RNA_def_string(func, "text_ctxt", NULL, 0, "", "Override automatic translation context of the given text");
+ PropertyRNA *prop;
+
+ prop = RNA_def_string(func, "text", NULL, 0, "", "Override automatic text of the item");
+ RNA_def_property_clear_flag(prop, PROP_NEVER_NULL);
+ prop = RNA_def_string(func, "text_ctxt", NULL, 0, "", "Override automatic translation context of the given text");
+ RNA_def_property_clear_flag(prop, PROP_NEVER_NULL);
RNA_def_boolean(func, "translate", true, "", "Translate the given text, when UI translation is enabled");
}
@@ -635,6 +690,20 @@ void RNA_api_ui_layout(StructRNA *srna)
api_ui_item_rna_common(func);
api_ui_item_common(func);
+ func = RNA_def_function(srna, "prop_with_popover", "rna_uiItemR_with_popover");
+ api_ui_item_rna_common(func);
+ api_ui_item_common(func);
+ RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
+ parm = RNA_def_string(func, "panel", NULL, 0, "", "Identifier of the panel");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
+ func = RNA_def_function(srna, "prop_with_menu", "rna_uiItemR_with_menu");
+ api_ui_item_rna_common(func);
+ api_ui_item_common(func);
+ RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
+ parm = RNA_def_string(func, "menu", NULL, 0, "", "Identifier of the menu");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
func = RNA_def_function(srna, "prop_tabs_enum", "rna_uiItemTabsEnumR");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
api_ui_item_rna_common(func);
@@ -766,9 +835,9 @@ void RNA_api_ui_layout(StructRNA *srna)
func = RNA_def_function(srna, "separator", "uiItemS_ex");
RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items");
RNA_def_float(
- func, "factor", 1.0f, 0.0f, FLT_MAX, "Percentage",
- "Percentage of width to space (leave unset for default space)",
- 0.0f, FLT_MAX);
+ func, "factor", 1.0f, 0.0f, FLT_MAX, "Percentage",
+ "Percentage of width to space (leave unset for default space)",
+ 0.0f, FLT_MAX);
func = RNA_def_function(srna, "separator_spacer", "uiItemSpacer");
RNA_def_function_ui_description(func, "Item. Inserts horizontal spacing empty space into the layout between items");
@@ -888,8 +957,9 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX);
RNA_def_float(func, "scale", 1.0f, 0.1f, 1.5f, "Scale of the image thumbnails", "", 0.5f, 1.0f);
- RNA_def_enum(func, "filter", id_template_filter_items, UI_TEMPLATE_ID_FILTER_ALL,
- "", "Optionally limit the items which can be selected");
+ RNA_def_enum(
+ func, "filter", id_template_filter_items, UI_TEMPLATE_ID_FILTER_ALL,
+ "", "Optionally limit the items which can be selected");
func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
RNA_def_function_ui_description(func, "Generates the UI layout for constraints");
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index dda36d89eb1..a2de1712960 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -3775,6 +3775,17 @@ static void rna_def_userdef_view(BlenderRNA *brna)
"Show the frames per second screen refresh rate, while animation is played back");
RNA_def_property_update(prop, 0, "rna_userdef_update");
+ static const EnumPropertyItem factor_display_items[] = {
+ {USER_FACTOR_AS_FACTOR, "FACTOR", 0, "Factor", "Display factors as values between 0 and 1"},
+ {USER_FACTOR_AS_PERCENTAGE, "PERCENTAGE", 0, "Percentage", "Display factors as percentages"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ prop = RNA_def_property(srna, "factor_display_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, factor_display_items);
+ RNA_def_property_ui_text(prop, "Factor Display Type", "How factor values are displayed");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
+
/* Weight Paint */
prop = RNA_def_property(srna, "use_weight_color_range", PROP_BOOLEAN, PROP_NONE);
@@ -4417,7 +4428,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
prop = RNA_def_property(srna, "use_edit_mode_smooth_wire", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_EDIT_MODE_SMOOTH_WIRE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "gpu_flag", USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE);
RNA_def_property_ui_text(prop, "Edit-Mode Smooth Wires",
"Enable Edit-Mode edge smoothing, reducing aliasing, requires restart");
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
@@ -4505,8 +4516,11 @@ static void rna_def_userdef_system(BlenderRNA *brna)
/* Select */
prop = RNA_def_property(srna, "use_select_pick_depth", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "gpu_select_pick_deph", 1);
- RNA_def_property_ui_text(prop, "OpenGL Depth Picking", "Use the depth buffer for picking 3D View selection");
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "gpu_flag", USER_GPU_FLAG_NO_DEPT_PICK);
+ RNA_def_property_ui_text(
+ prop, "OpenGL Depth Picking",
+ "Use the depth buffer for picking 3D View selection "
+ "(without this the front most object may not be selected first)");
/* Audio */
@@ -4699,6 +4713,13 @@ static void rna_def_userdef_input(BlenderRNA *brna)
"Number of pixels you have to drag before a tweak/drag event is triggered "
"(otherwise click events are detected)");
+ prop = RNA_def_property(srna, "move_threshold", PROP_INT, PROP_PIXEL);
+ RNA_def_property_range(prop, 0, 255);
+ RNA_def_property_ui_range(prop, 0, 10, 1, -1);
+ RNA_def_property_ui_text(prop, "Motion Threshold",
+ "Number of pixels you have to before the cursor is considered to have moved "
+ "(used for cycling selected items on successive clicks)");
+
/* tablet pressure curve */
prop = RNA_def_property(srna, "pressure_threshold_max", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0f, 1.0f);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 55a18b40adc..d94349d50de 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -2534,6 +2534,7 @@ static void rna_def_keyconfig(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
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", KMI_EXPANDED);
RNA_def_property_ui_text(prop, "Expanded", "Show key map event and property details in the user interface");
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c
index 2a084cbd526..45d664c4522 100644
--- a/source/blender/makesrna/intern/rna_wm_gizmo.c
+++ b/source/blender/makesrna/intern/rna_wm_gizmo.c
@@ -810,7 +810,7 @@ static StructRNA *rna_GizmoGroup_register(
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&wmap_params);
if (gzmap_type == NULL) {
- BKE_reportf(reports, RPT_ERROR, "Area type does not support gizmos");
+ BKE_report(reports, RPT_ERROR, "Area type does not support gizmos");
return NULL;
}
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index f6691e0fe26..d075439fcee 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -33,8 +33,6 @@
#include "rna_internal.h"
-/* Allow accessing private members of DNA_workspace_types.h */
-#define DNA_PRIVATE_WORKSPACE_ALLOW
#include "DNA_workspace_types.h"
#ifdef RNA_RUNTIME
@@ -148,25 +146,25 @@ const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(
return DummyRNA_DEFAULT_items;
}
-static int rna_WorkspaceTool_index_get(PointerRNA *ptr)
+static int rna_WorkSpaceTool_index_get(PointerRNA *ptr)
{
bToolRef *tref = ptr->data;
return (tref->runtime) ? tref->runtime->index : 0;
}
-static int rna_WorkspaceTool_has_datablock_get(PointerRNA *ptr)
+static int rna_WorkSpaceTool_has_datablock_get(PointerRNA *ptr)
{
bToolRef *tref = ptr->data;
return (tref->runtime) ? (tref->runtime->data_block[0] != '\0') : false;
}
-static void rna_WorkspaceTool_widget_get(PointerRNA *ptr, char *value)
+static void rna_WorkSpaceTool_widget_get(PointerRNA *ptr, char *value)
{
bToolRef *tref = ptr->data;
strcpy(value, tref->runtime ? tref->runtime->gizmo_group : "");
}
-static int rna_WorkspaceTool_widget_length(PointerRNA *ptr)
+static int rna_WorkSpaceTool_widget_length(PointerRNA *ptr)
{
bToolRef *tref = ptr->data;
return tref->runtime ? strlen(tref->runtime->gizmo_group) : 0;
@@ -229,20 +227,19 @@ static void rna_def_workspace_tool(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- srna = RNA_def_struct(brna, "WorkspaceTool", NULL);
+ srna = RNA_def_struct(brna, "WorkSpaceTool", NULL);
RNA_def_struct_sdna(srna, "bToolRef");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Work Space Tool", "");
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "idname");
- RNA_def_property_ui_text(prop, "Name", "");
+ prop = RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Identifier", "");
RNA_def_struct_name_property(srna, prop);
prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Index", "");
- RNA_def_property_int_funcs(prop, "rna_WorkspaceTool_index_get", NULL, NULL);
+ RNA_def_property_int_funcs(prop, "rna_WorkSpaceTool_index_get", NULL, NULL);
prop = RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "space_type");
@@ -261,13 +258,13 @@ static void rna_def_workspace_tool(BlenderRNA *brna)
prop = RNA_def_property(srna, "has_datablock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Has Datablock", "");
- RNA_def_property_boolean_funcs(prop, "rna_WorkspaceTool_has_datablock_get", NULL);
+ RNA_def_property_boolean_funcs(prop, "rna_WorkSpaceTool_has_datablock_get", NULL);
RNA_define_verify_sdna(1);
prop = RNA_def_property(srna, "widget", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Widget", "");
- RNA_def_property_string_funcs(prop, "rna_WorkspaceTool_widget_get", "rna_WorkspaceTool_widget_length", NULL);
+ RNA_def_property_string_funcs(prop, "rna_WorkSpaceTool_widget_get", "rna_WorkSpaceTool_widget_length", NULL);
RNA_define_verify_sdna(1);
RNA_api_workspace_tool(srna);
@@ -292,7 +289,7 @@ static void rna_def_workspace_tools(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_boolean(func, "create", false, "Create", "");
/* return type */
- parm = RNA_def_pointer(func, "result", "WorkspaceTool", "", "");
+ parm = RNA_def_pointer(func, "result", "WorkSpaceTool", "", "");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "from_space_image_mode", "rna_WorkSpace_tools_from_space_image_mode");
@@ -301,14 +298,14 @@ static void rna_def_workspace_tools(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_boolean(func, "create", false, "Create", "");
/* return type */
- parm = RNA_def_pointer(func, "result", "WorkspaceTool", "", "");
+ parm = RNA_def_pointer(func, "result", "WorkSpaceTool", "", "");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "from_space_node", "rna_WorkSpace_tools_from_space_node");
RNA_def_function_ui_description(func, "");
RNA_def_boolean(func, "create", false, "Create", "");
/* return type */
- parm = RNA_def_pointer(func, "result", "WorkspaceTool", "", "");
+ parm = RNA_def_pointer(func, "result", "WorkSpaceTool", "", "");
RNA_def_function_return(func, parm);
}
@@ -337,7 +334,7 @@ static void rna_def_workspace(BlenderRNA *brna)
prop = RNA_def_property(srna, "tools", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "tools", NULL);
- RNA_def_property_struct_type(prop, "WorkspaceTool");
+ RNA_def_property_struct_type(prop, "WorkSpaceTool");
RNA_def_property_ui_text(prop, "Tools", "");
rna_def_workspace_tools(brna, prop);
diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c
index c2e8e9a49a6..f82b1ecda60 100644
--- a/source/blender/makesrna/intern/rna_workspace_api.c
+++ b/source/blender/makesrna/intern/rna_workspace_api.c
@@ -41,7 +41,7 @@
#include "ED_screen.h"
-static void rna_WorkspaceTool_setup(
+static void rna_WorkSpaceTool_setup(
ID *id,
bToolRef *tref,
bContext *C,
@@ -66,7 +66,7 @@ static void rna_WorkspaceTool_setup(
WM_toolsystem_ref_set_from_runtime(C, (WorkSpace *)id, tref, &tref_rt, name);
}
-static void rna_WorkspaceTool_refresh_from_context(
+static void rna_WorkSpaceTool_refresh_from_context(
ID *id,
bToolRef *tref,
Main *bmain)
@@ -74,7 +74,7 @@ static void rna_WorkspaceTool_refresh_from_context(
WM_toolsystem_ref_sync_from_context(bmain, (WorkSpace *)id, tref);
}
-static PointerRNA rna_WorkspaceTool_operator_properties(
+static PointerRNA rna_WorkSpaceTool_operator_properties(
bToolRef *tref,
ReportList *reports,
const char *idname)
@@ -92,7 +92,7 @@ static PointerRNA rna_WorkspaceTool_operator_properties(
return PointerRNA_NULL;
}
-static PointerRNA rna_WorkspaceTool_gizmo_group_properties(
+static PointerRNA rna_WorkSpaceTool_gizmo_group_properties(
bToolRef *tref,
ReportList *reports,
const char *idname)
@@ -129,11 +129,11 @@ void RNA_api_workspace_tool(StructRNA *srna)
PropertyRNA *parm;
FunctionRNA *func;
- func = RNA_def_function(srna, "setup", "rna_WorkspaceTool_setup");
+ func = RNA_def_function(srna, "setup", "rna_WorkSpaceTool_setup");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Set the tool settings");
- parm = RNA_def_string(func, "name", NULL, KMAP_MAX_NAME, "Name", "");
+ parm = RNA_def_string(func, "idname", NULL, MAX_NAME, "Identifier", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* 'bToolRef_Runtime' */
@@ -146,7 +146,7 @@ void RNA_api_workspace_tool(StructRNA *srna)
RNA_def_int(func, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX);
/* Access tool operator options (optionally create). */
- func = RNA_def_function(srna, "operator_properties", "rna_WorkspaceTool_operator_properties");
+ func = RNA_def_function(srna, "operator_properties", "rna_WorkSpaceTool_operator_properties");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_string(func, "operator", NULL, 0, "", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -156,7 +156,7 @@ void RNA_api_workspace_tool(StructRNA *srna)
RNA_def_function_return(func, parm);
/* Access gizmo-group options (optionally create). */
- func = RNA_def_function(srna, "gizmo_group_properties", "rna_WorkspaceTool_gizmo_group_properties");
+ func = RNA_def_function(srna, "gizmo_group_properties", "rna_WorkSpaceTool_gizmo_group_properties");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_string(func, "group", NULL, 0, "", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -165,7 +165,7 @@ void RNA_api_workspace_tool(StructRNA *srna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
RNA_def_function_return(func, parm);
- func = RNA_def_function(srna, "refresh_from_context", "rna_WorkspaceTool_refresh_from_context");
+ func = RNA_def_function(srna, "refresh_from_context", "rna_WorkSpaceTool_refresh_from_context");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
}
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 4a474dde585..4cc780431d0 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -107,7 +107,7 @@ static void deformVerts(
MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */
- armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh, vertexCos, NULL,
+ armature_deform_verts(amd->object, ctx->object, mesh, vertexCos, NULL,
numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name, NULL);
/* free cache */
@@ -126,7 +126,7 @@ static void deformVertsEM(
MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */
- armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh_src, vertexCos, NULL,
+ armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, NULL,
numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name, NULL);
/* free cache */
@@ -148,7 +148,7 @@ static void deformMatricesEM(
ArmatureModifierData *amd = (ArmatureModifierData *) md;
Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false);
- armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh_src, vertexCos, defMats,
+ armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats,
numVerts, amd->deformflag, NULL, amd->defgrp_name, NULL);
if (mesh_src != mesh) {
@@ -163,7 +163,7 @@ static void deformMatrices(
ArmatureModifierData *amd = (ArmatureModifierData *) md;
Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
- armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh_src, vertexCos, defMats,
+ armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats,
numVerts, amd->deformflag, NULL, amd->defgrp_name, NULL);
if (mesh_src != mesh) {
@@ -182,12 +182,6 @@ ModifierTypeInfo modifierType_Armature = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ deformMatrices,
/* deformVertsEM */ deformVertsEM,
@@ -204,4 +198,5 @@ ModifierTypeInfo modifierType_Armature = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 56567c79c6a..542c7665807 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -374,7 +374,7 @@ static Mesh *arrayModifier_doArray(
count = amd->count;
- Object *start_cap_ob = DEG_get_evaluated_object(ctx->depsgraph, amd->start_cap);
+ Object *start_cap_ob = amd->start_cap;
if (start_cap_ob && start_cap_ob != ctx->object && start_cap_ob->type == OB_MESH) {
vgroup_start_cap_remap = BKE_object_defgroup_index_map_create(
start_cap_ob, ctx->object, &vgroup_start_cap_remap_len);
@@ -387,7 +387,7 @@ static Mesh *arrayModifier_doArray(
start_cap_npolys = start_cap_mesh->totpoly;
}
}
- Object *end_cap_ob = DEG_get_evaluated_object(ctx->depsgraph, amd->end_cap);
+ Object *end_cap_ob = amd->end_cap;
if (end_cap_ob && end_cap_ob != ctx->object && end_cap_ob->type == OB_MESH) {
vgroup_end_cap_remap = BKE_object_defgroup_index_map_create(
end_cap_ob, ctx->object, &vgroup_end_cap_remap_len);
@@ -433,7 +433,7 @@ static Mesh *arrayModifier_doArray(
else
unit_m4(obinv);
- mul_m4_series(result_mat, offset, obinv, DEG_get_evaluated_object(ctx->depsgraph, amd->offset_ob)->obmat);
+ mul_m4_series(result_mat, offset, obinv, amd->offset_ob->obmat);
copy_m4_m4(offset, result_mat);
}
@@ -442,7 +442,7 @@ static Mesh *arrayModifier_doArray(
offset_has_scale = !is_one_v3(scale);
if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob != NULL) {
- Object *curve_ob = DEG_get_evaluated_object(ctx->depsgraph, amd->curve_ob);
+ Object *curve_ob = amd->curve_ob;
Curve *cu = curve_ob->data;
if (cu) {
CurveCache *curve_cache = curve_ob->runtime.curve_cache;
@@ -755,12 +755,6 @@ ModifierTypeInfo modifierType_Array = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -777,4 +771,5 @@ ModifierTypeInfo modifierType_Array = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 6e1dd9ed45d..567c74effe0 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -217,12 +217,6 @@ ModifierTypeInfo modifierType_Bevel = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -239,4 +233,5 @@ ModifierTypeInfo modifierType_Bevel = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index a90ddde7946..8e3a19e524a 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -163,7 +163,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
return result;
}
- Object *other = DEG_get_evaluated_object(ctx->depsgraph, bmd->object);
+ Object *other = bmd->object;
mesh_other = BKE_modifier_get_evaluated_mesh_from_evaluated_object(other, false);
if (mesh_other) {
Object *object = ctx->object;
@@ -338,12 +338,6 @@ ModifierTypeInfo modifierType_Boolean = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -360,4 +354,5 @@ ModifierTypeInfo modifierType_Boolean = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index e46c9aca5ce..01478c855bb 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -293,12 +293,6 @@ ModifierTypeInfo modifierType_Build = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -315,4 +309,5 @@ ModifierTypeInfo modifierType_Build = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index f408a22aadf..b8917f58234 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -95,7 +95,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
static void sphere_do(
- CastModifierData *cmd, const ModifierEvalContext *ctx,
+ CastModifierData *cmd, const ModifierEvalContext *UNUSED(ctx),
Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
@@ -119,7 +119,7 @@ static void sphere_do(
if (type == MOD_CAST_TYPE_CYLINDER)
flag &= ~MOD_CAST_Z;
- ctrl_ob = DEG_get_evaluated_object(ctx->depsgraph, cmd->object);
+ ctrl_ob = cmd->object;
/* spherify's center is {0, 0, 0} (the ob's own center in its local
* space), by default, but if the user defined a control object,
@@ -217,7 +217,7 @@ static void sphere_do(
}
static void cuboid_do(
- CastModifierData *cmd, const ModifierEvalContext *ctx,
+ CastModifierData *cmd, const ModifierEvalContext *UNUSED(ctx),
Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
@@ -236,7 +236,7 @@ static void cuboid_do(
flag = cmd->flag;
- ctrl_ob = DEG_get_evaluated_object(ctx->depsgraph, cmd->object);
+ ctrl_ob = cmd->object;
/* now we check which options the user wants */
@@ -474,12 +474,6 @@ ModifierTypeInfo modifierType_Cast = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -496,4 +490,5 @@ ModifierTypeInfo modifierType_Cast = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 41f35faac1b..8bf9d50cda7 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -241,12 +241,6 @@ ModifierTypeInfo modifierType_Cloth = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -263,4 +257,5 @@ ModifierTypeInfo modifierType_Cloth = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index 3e1fa4954fa..2e56da6f100 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -240,6 +240,10 @@ static void deformVerts(
}
}
+static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgraphContext *ctx)
+{
+ DEG_add_modifier_to_transform_relation(ctx->node, "Collision Modifier");
+}
ModifierTypeInfo modifierType_Collision = {
/* name */ "Collision",
@@ -251,12 +255,6 @@ ModifierTypeInfo modifierType_Collision = {
/* copyData */ NULL,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -267,10 +265,11 @@ ModifierTypeInfo modifierType_Collision = {
/* requiredDataMask */ NULL,
/* freeData */ freeData,
/* isDisabled */ NULL,
- /* updateDepsgraph */ NULL,
+ /* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ dependsOnTime,
/* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index cc6177b9bc8..ac1c0d46d7b 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -743,12 +743,6 @@ ModifierTypeInfo modifierType_CorrectiveSmooth = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -765,4 +759,5 @@ ModifierTypeInfo modifierType_CorrectiveSmooth = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index f3a5e280947..91cedda4f48 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -115,7 +115,7 @@ static void deformVerts(
/* silly that defaxis and curve_deform_verts are off by 1
* but leave for now to save having to call do_versions */
- curve_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, cmd->object), ctx->object,
+ curve_deform_verts(cmd->object, ctx->object,
vertexCos, numVerts, dvert, defgrp_index, cmd->defaxis - 1);
if (!ELEM(mesh_src, NULL, mesh)) {
@@ -152,12 +152,6 @@ ModifierTypeInfo modifierType_Curve = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -174,4 +168,5 @@ ModifierTypeInfo modifierType_Curve = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index 3e461476eac..567af7bae09 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -122,6 +122,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (dtmd->ob_source != NULL) {
CustomData_MeshMasks cddata_masks = {0};
BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types, &cddata_masks);
+ BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(
+ dtmd->vmap_mode, dtmd->emap_mode, dtmd->lmap_mode, dtmd->pmap_mode, &cddata_masks);
DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, "DataTransfer Modifier");
DEG_add_customdata_mask(ctx->node, dtmd->ob_source, &cddata_masks);
@@ -158,7 +160,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* Only used to check wehther we are operating on org data or not... */
Mesh *me = ctx->object->data;
- Object *ob_source = DEG_get_evaluated_object(ctx->depsgraph, dtmd->ob_source);
+ Object *ob_source = dtmd->ob_source;
const bool invert_vgroup = (dtmd->flags & MOD_DATATRANSFER_INVERT_VGROUP) != 0;
@@ -216,12 +218,6 @@ ModifierTypeInfo modifierType_DataTransfer = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -238,4 +234,5 @@ ModifierTypeInfo modifierType_DataTransfer = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index 0ca6111c41a..40968f1173f 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -225,12 +225,6 @@ ModifierTypeInfo modifierType_Decimate = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -247,4 +241,5 @@ ModifierTypeInfo modifierType_Decimate = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 87b25982d81..0060639970c 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -290,7 +290,7 @@ static void displaceModifier_do(
mvert = mesh->mvert;
MOD_get_vgroup(ob, mesh, dmd->defgrp_name, &dvert, &defgrp_index);
- Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &dmd->texture->id);
+ Tex *tex_target = dmd->texture;
if (tex_target != NULL) {
tex_co = MEM_calloc_arrayN((size_t)numVerts, sizeof(*tex_co),
"displaceModifier_do tex_co");
@@ -406,12 +406,6 @@ ModifierTypeInfo modifierType_Displace = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -428,4 +422,5 @@ ModifierTypeInfo modifierType_Displace = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index b84e46e145c..badf3df6b1d 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -58,6 +58,15 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
dynamicPaint_Modifier_copy(pmd, tpmd, flag);
}
+static void freeRuntimeData(void *runtime_data_v)
+{
+ if (runtime_data_v == NULL) {
+ return;
+ }
+ DynamicPaintRuntime *runtime_data = (DynamicPaintRuntime *)runtime_data_v;
+ dynamicPaint_Modifier_free_runtime(runtime_data);
+}
+
static void freeData(ModifierData *md)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md;
@@ -170,12 +179,6 @@ ModifierTypeInfo modifierType_DynamicPaint = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -192,4 +195,5 @@ ModifierTypeInfo modifierType_DynamicPaint = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
+ /* freeRuntimeData */ freeRuntimeData,
};
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index a7b980494b3..751a70916ab 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -146,12 +146,6 @@ ModifierTypeInfo modifierType_EdgeSplit = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -168,4 +162,5 @@ ModifierTypeInfo modifierType_EdgeSplit = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 3a0449a4e52..a8a0b963bd8 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -94,7 +94,7 @@ static void createFacepa(
MFace *fa = NULL, *mface = NULL;
MVert *mvert = NULL;
ParticleData *pa;
- KDTree *tree;
+ KDTree_3d *tree;
RNG *rng;
float center[3], co[3];
int *facepa = NULL, *vertpa = NULL, totvert = 0, totface = 0, totpart = 0;
@@ -138,12 +138,12 @@ static void createFacepa(
}
/* make tree of emitter locations */
- tree = BLI_kdtree_new(totpart);
+ tree = BLI_kdtree_3d_new(totpart);
for (p = 0, pa = psys->particles; p < totpart; p++, pa++) {
psys_particle_on_emitter(psmd, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, NULL, NULL, NULL, NULL);
- BLI_kdtree_insert(tree, p, co);
+ BLI_kdtree_3d_insert(tree, p, co);
}
- BLI_kdtree_balance(tree);
+ BLI_kdtree_3d_balance(tree);
/* set face-particle-indexes to nearest particle to face center */
for (i = 0, fa = mface; i < totface; i++, fa++) {
@@ -157,7 +157,7 @@ static void createFacepa(
mul_v3_fl(center, 1.0f / 3.0f);
}
- p = BLI_kdtree_find_nearest(tree, center, NULL);
+ p = BLI_kdtree_3d_find_nearest(tree, center, NULL);
v1 = vertpa[fa->v1];
v2 = vertpa[fa->v2];
@@ -187,7 +187,7 @@ static void createFacepa(
if (vertpa) {
MEM_freeN(vertpa);
}
- BLI_kdtree_free(tree);
+ BLI_kdtree_3d_free(tree);
BLI_rng_free(rng);
}
@@ -1084,12 +1084,6 @@ ModifierTypeInfo modifierType_Explode = {
/* flags */ eModifierTypeFlag_AcceptsMesh,
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -1106,4 +1100,5 @@ ModifierTypeInfo modifierType_Explode = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c
index d4bac71f677..4377e04db84 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim.c
@@ -138,12 +138,6 @@ ModifierTypeInfo modifierType_Fluidsim = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -160,4 +154,5 @@ ModifierTypeInfo modifierType_Fluidsim = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index e911dbc4b5a..0c15f4caa23 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -248,11 +248,11 @@ static void hook_co_apply(struct HookData_cb *hd, const int j)
}
static void deformVerts_do(
- HookModifierData *hmd, const ModifierEvalContext *ctx,
+ HookModifierData *hmd, const ModifierEvalContext *UNUSED(ctx),
Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
- Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, hmd->object);
+ Object *ob_target = hmd->object;
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_target->pose, hmd->subtarget);
float dmat[4][4];
int i, *index_pt;
@@ -386,12 +386,6 @@ ModifierTypeInfo modifierType_Hook = {
eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -408,4 +402,5 @@ ModifierTypeInfo modifierType_Hook = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index db76b0fd0c2..df0ef4a7404 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -771,12 +771,6 @@ ModifierTypeInfo modifierType_LaplacianDeform = {
/* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -793,4 +787,5 @@ ModifierTypeInfo modifierType_LaplacianDeform = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index a6670f313ce..321dfd5dae1 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -535,12 +535,6 @@ ModifierTypeInfo modifierType_LaplacianSmooth = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -557,4 +551,5 @@ ModifierTypeInfo modifierType_LaplacianSmooth = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 46a9c4f0a47..4715d2ab073 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -94,7 +94,7 @@ static void deformVerts(
MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */
- lattice_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, lmd->object), ctx->object, mesh_src,
+ lattice_deform_verts(lmd->object, ctx->object, mesh_src,
vertexCos, numVerts, lmd->name, lmd->strength);
if (!ELEM(mesh_src, NULL, mesh)) {
@@ -127,12 +127,6 @@ ModifierTypeInfo modifierType_Lattice = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -149,4 +143,5 @@ ModifierTypeInfo modifierType_Lattice = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 6d8317ffe77..efb299773ef 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -127,7 +127,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* if mode is to use selected armature bones, aggregate the bone groups */
if (mmd->mode == MOD_MASK_MODE_ARM) { /* --- using selected bones --- */
- Object *oba = DEG_get_evaluated_object(ctx->depsgraph, mmd->ob_arm);
+ Object *oba = mmd->ob_arm;
bPoseChannel *pchan;
bDeformGroup *def;
bool *bone_select_array;
@@ -357,12 +357,6 @@ ModifierTypeInfo modifierType_Mask = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -379,4 +373,5 @@ ModifierTypeInfo modifierType_Mask = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index 0ecd56372c7..74172927c9d 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -294,12 +294,6 @@ ModifierTypeInfo modifierType_MeshCache = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -316,4 +310,5 @@ ModifierTypeInfo modifierType_MeshCache = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index e59a6ae9add..310b05d4580 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -296,7 +296,7 @@ static void meshdeformModifier_do(
*
* We'll support this case once granular dependency graph is landed.
*/
- Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, mmd->object);
+ Object *ob_target = mmd->object;
cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false);
#if 0 /* This shall not be needed if we always get evaluated target object... */
if (cagemesh == NULL && mmd->bindcagecos == NULL && ob == DEG_get_original_object(ob)) {
@@ -508,12 +508,6 @@ ModifierTypeInfo modifierType_MeshDeform = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -530,4 +524,5 @@ ModifierTypeInfo modifierType_MeshDeform = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index d17f343a1ec..3b092bc7a76 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -189,12 +189,6 @@ ModifierTypeInfo modifierType_MeshSequenceCache = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -211,4 +205,5 @@ ModifierTypeInfo modifierType_MeshSequenceCache = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index c46445471df..5fb4c66471f 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -130,7 +130,7 @@ static Mesh *doBiscetOnMirrorPlane(
static Mesh *doMirrorOnAxis(
MirrorModifierData *mmd,
- const ModifierEvalContext *ctx,
+ const ModifierEvalContext *UNUSED(ctx),
Object *ob,
const Mesh *mesh,
int axis)
@@ -159,7 +159,7 @@ static Mesh *doMirrorOnAxis(
unit_m4(mtx);
mtx[axis][axis] = -1.0f;
- Object *mirror_ob = DEG_get_evaluated_object(ctx->depsgraph, mmd->mirror_ob);
+ Object *mirror_ob = mmd->mirror_ob;
if (mirror_ob != NULL) {
float tmp[4][4];
float itmp[4][4];
@@ -432,12 +432,6 @@ ModifierTypeInfo modifierType_Mirror = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -454,4 +448,5 @@ ModifierTypeInfo modifierType_Mirror = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index 7cd9dfa05aa..af17bd7d53c 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -24,6 +24,8 @@
#include <stddef.h>
+#include "MEM_guardedalloc.h"
+
#include "BLI_utildefines.h"
#include "DNA_mesh_types.h"
@@ -44,6 +46,11 @@
#include "MOD_modifiertypes.h"
+typedef struct MultiresRuntimeData {
+ /* Cached subdivision surface descriptor, with topology and settings. */
+ struct Subdiv *subdiv;
+} MultiresRuntimeData;
+
static void initData(ModifierData *md)
{
MultiresModifierData *mmd = (MultiresModifierData *)md;
@@ -58,19 +65,36 @@ static void initData(ModifierData *md)
static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int flag)
{
- MultiresModifierData *mmd_dst = (MultiresModifierData *)md_dst;
-
modifier_copyData_generic(md_src, md_dst, flag);
+}
- mmd_dst->subdiv = NULL;
+static void freeRuntimeData(void *runtime_data_v)
+{
+ if (runtime_data_v == NULL) {
+ return;
+ }
+ MultiresRuntimeData *runtime_data = (MultiresRuntimeData *)runtime_data_v;
+ if (runtime_data->subdiv != NULL) {
+ BKE_subdiv_free(runtime_data->subdiv);
+ }
+ MEM_freeN(runtime_data);
}
static void freeData(ModifierData *md)
{
MultiresModifierData *mmd = (MultiresModifierData *) md;
- if (mmd->subdiv != NULL) {
- BKE_subdiv_free(mmd->subdiv);
+ freeRuntimeData(mmd->modifier.runtime);
+}
+
+static MultiresRuntimeData *multires_ensure_runtime(MultiresModifierData *mmd)
+{
+ MultiresRuntimeData *runtime_data =
+ (MultiresRuntimeData *)mmd->modifier.runtime;
+ if (runtime_data == NULL) {
+ runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime");
+ mmd->modifier.runtime = runtime_data;
}
+ return runtime_data;
}
/* Main goal of this function is to give usable subdivision surface descriptor
@@ -79,9 +103,11 @@ static Subdiv *subdiv_descriptor_ensure(MultiresModifierData *mmd,
const SubdivSettings *subdiv_settings,
const Mesh *mesh)
{
+ MultiresRuntimeData *runtime_data =
+ (MultiresRuntimeData *)mmd->modifier.runtime;
Subdiv *subdiv = BKE_subdiv_update_from_mesh(
- mmd->subdiv, subdiv_settings, mesh);
- mmd->subdiv = subdiv;
+ runtime_data->subdiv, subdiv_settings, mesh);
+ runtime_data->subdiv = subdiv;
return subdiv;
}
@@ -99,7 +125,7 @@ static Mesh *multires_as_mesh(MultiresModifierData *mmd,
Object *object = ctx->object;
SubdivToMeshSettings mesh_settings;
BKE_multires_subdiv_mesh_settings_init(
- &mesh_settings, scene, object, mmd, use_render_params, ignore_simplify);
+ &mesh_settings, scene, object, mmd, use_render_params, ignore_simplify);
if (mesh_settings.resolution < 3) {
return result;
}
@@ -156,6 +182,7 @@ static Mesh *applyModifier(ModifierData *md,
return result;
}
BKE_subdiv_settings_validate_for_mesh(&subdiv_settings, mesh);
+ MultiresRuntimeData *runtime_data = multires_ensure_runtime(mmd);
Subdiv *subdiv = subdiv_descriptor_ensure(mmd, &subdiv_settings, mesh);
if (subdiv == NULL) {
/* Happens on bad topology, ut also on empty input mesh. */
@@ -180,13 +207,13 @@ static Mesh *applyModifier(ModifierData *md,
/* NOTE: CCG becomes an owner of Subdiv descriptor, so can not share
* this pointer. Not sure if it's needed, but might have a second look
* on the ownership model here. */
- mmd->subdiv = NULL;
+ runtime_data->subdiv = NULL;
// BKE_subdiv_stats_print(&subdiv->stats);
}
else {
result = multires_as_mesh(mmd, ctx, mesh, subdiv);
// BKE_subdiv_stats_print(&subdiv->stats);
- if (subdiv != mmd->subdiv) {
+ if (subdiv != runtime_data->subdiv) {
BKE_subdiv_free(subdiv);
}
}
@@ -204,12 +231,6 @@ ModifierTypeInfo modifierType_Multires = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -226,4 +247,5 @@ ModifierTypeInfo modifierType_Multires = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ freeRuntimeData,
};
diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c
index 781e52fc426..749c329b3b6 100644
--- a/source/blender/modifiers/intern/MOD_none.c
+++ b/source/blender/modifiers/intern/MOD_none.c
@@ -46,12 +46,6 @@ ModifierTypeInfo modifierType_None = {
/* copyData */ NULL,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -68,4 +62,5 @@ ModifierTypeInfo modifierType_None = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index d838d203ed5..2a8bca895be 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -192,7 +192,7 @@ static bool polygons_check_flip(
}
static void normalEditModifier_do_radial(
- NormalEditModifierData *enmd, const ModifierEvalContext *ctx,
+ NormalEditModifierData *enmd, const ModifierEvalContext *UNUSED(ctx),
Object *ob, Mesh *mesh,
short (*clnors)[2], float (*loopnors)[3], float (*polynors)[3],
const short mix_mode, const float mix_factor, const float mix_limit,
@@ -200,7 +200,7 @@ static void normalEditModifier_do_radial(
MVert *mvert, const int num_verts, MEdge *medge, const int num_edges,
MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys)
{
- Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, enmd->target);
+ Object *ob_target = enmd->target;
const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0;
int i;
@@ -296,7 +296,7 @@ static void normalEditModifier_do_radial(
}
static void normalEditModifier_do_directional(
- NormalEditModifierData *enmd, const ModifierEvalContext *ctx,
+ NormalEditModifierData *enmd, const ModifierEvalContext *UNUSED(ctx),
Object *ob, Mesh *mesh,
short (*clnors)[2], float (*loopnors)[3], float (*polynors)[3],
const short mix_mode, const float mix_factor, const float mix_limit,
@@ -304,7 +304,7 @@ static void normalEditModifier_do_directional(
MVert *mvert, const int num_verts, MEdge *medge, const int num_edges,
MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys)
{
- Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, enmd->target);
+ Object *ob_target = enmd->target;
const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0;
const bool use_parallel_normals = (enmd->flag & MOD_NORMALEDIT_USE_DIRECTION_PARALLEL) != 0;
@@ -556,12 +556,6 @@ ModifierTypeInfo modifierType_NormalEdit = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -578,4 +572,5 @@ ModifierTypeInfo modifierType_NormalEdit = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 50ec32bd605..5379321239c 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -176,7 +176,6 @@ typedef struct GenerateOceanGeometryData {
MVert *mverts;
MPoly *mpolys;
MLoop *mloops;
- int *origindex;
MLoopUV *mloopuvs;
int res_x, res_y;
@@ -230,9 +229,6 @@ static void generate_ocean_geometry_polygons(
mp->totloop = 4;
mp->flag |= ME_SMOOTH;
-
- /* generated geometry does not map to original faces */
- gogd->origindex[fi] = ORIGINDEX_NONE;
}
}
@@ -299,8 +295,6 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd)
gogd.mpolys = result->mpoly;
gogd.mloops = result->mloop;
- gogd.origindex = CustomData_get_layer(&result->pdata, CD_ORIGINDEX);
-
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = use_threading;
@@ -503,12 +497,6 @@ ModifierTypeInfo modifierType_Ocean = {
/* copyData */ copyData,
/* deformMatrices_DM */ NULL,
- /* deformVerts_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
- /* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
@@ -524,4 +512,5 @@ ModifierTypeInfo modifierType_Ocean = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index a9d8db493b8..189255a7dd1 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -524,12 +524,6 @@ ModifierTypeInfo modifierType_ParticleInstance = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -546,4 +540,5 @@ ModifierTypeInfo modifierType_ParticleInstance = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 08a19506694..5b3e104072c 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -246,12 +246,6 @@ ModifierTypeInfo modifierType_ParticleSystem = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -268,4 +262,5 @@ ModifierTypeInfo modifierType_ParticleSystem = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c
index 2ff82d863df..345ee6477ac 100644
--- a/source/blender/modifiers/intern/MOD_remesh.c
+++ b/source/blender/modifiers/intern/MOD_remesh.c
@@ -216,12 +216,6 @@ ModifierTypeInfo modifierType_Remesh = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -237,4 +231,5 @@ ModifierTypeInfo modifierType_Remesh = {
/* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 837b4d3d532..8e881fd09f0 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -236,7 +236,7 @@ static Mesh *applyModifier(
MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new;
MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base;
- Object *ob_axis = DEG_get_evaluated_object(ctx->depsgraph, ltmd->ob_axis);
+ Object *ob_axis = ltmd->ob_axis;
ScrewVertConnect *vc, *vc_tmp, *vert_connect = NULL;
@@ -1135,12 +1135,6 @@ ModifierTypeInfo modifierType_Screw = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -1157,4 +1151,5 @@ ModifierTypeInfo modifierType_Screw = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 3530ca21d34..dd5f53c408a 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -121,12 +121,6 @@ ModifierTypeInfo modifierType_ShapeKey = {
/* copyData */ NULL,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ deformMatrices,
/* deformVertsEM */ deformVertsEM,
@@ -143,4 +137,5 @@ ModifierTypeInfo modifierType_ShapeKey = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 7b33df5bf86..73e99738458 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -183,12 +183,6 @@ ModifierTypeInfo modifierType_Shrinkwrap = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -205,4 +199,5 @@ ModifierTypeInfo modifierType_Shrinkwrap = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index cc36cfbf9eb..0ebeb1cd761 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -178,7 +178,7 @@ static void simpleDeform_bend(const float factor, const int axis, const float dc
/* simple deform modifier */
static void SimpleDeformModifier_do(
- SimpleDeformModifierData *smd, const ModifierEvalContext *ctx,
+ SimpleDeformModifierData *smd, const ModifierEvalContext *UNUSED(ctx),
struct Object *ob, struct Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
@@ -222,7 +222,7 @@ static void SimpleDeformModifier_do(
/* Calculate matrixs do convert between coordinate spaces */
if (smd->origin != NULL) {
transf = &tmp_transf;
- BLI_SPACE_TRANSFORM_SETUP(transf, ob, DEG_get_evaluated_object(ctx->depsgraph, smd->origin));
+ BLI_SPACE_TRANSFORM_SETUP(transf, ob, smd->origin);
}
/* Update limits if needed */
@@ -429,12 +429,6 @@ ModifierTypeInfo modifierType_SimpleDeform = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -451,4 +445,5 @@ ModifierTypeInfo modifierType_SimpleDeform = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 7ba7882d0d0..dab2d72133b 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -1940,12 +1940,6 @@ ModifierTypeInfo modifierType_Skin = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -1961,4 +1955,5 @@ ModifierTypeInfo modifierType_Skin = {
/* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index 905e8a18e1b..8a0a8e227ae 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -165,12 +165,6 @@ ModifierTypeInfo modifierType_Smoke = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -187,4 +181,5 @@ ModifierTypeInfo modifierType_Smoke = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 2b9339842fa..685a4837d32 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -244,12 +244,6 @@ ModifierTypeInfo modifierType_Smooth = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -266,4 +260,5 @@ ModifierTypeInfo modifierType_Smooth = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c
index 868b42bc241..2ff50ee3977 100644
--- a/source/blender/modifiers/intern/MOD_softbody.c
+++ b/source/blender/modifiers/intern/MOD_softbody.c
@@ -76,12 +76,6 @@ ModifierTypeInfo modifierType_Softbody = {
/* copyData */ NULL,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -98,4 +92,5 @@ ModifierTypeInfo modifierType_Softbody = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index e449403eb70..e8a7d8217ed 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -768,15 +768,17 @@ static Mesh *applyModifier(
/* add faces & edges */
origindex_edge = CustomData_get_layer(&result->edata, CD_ORIGINDEX);
- BLI_assert((numEdges == 0) || (origindex_edge != NULL));
+ orig_ed = (origindex_edge) ? &origindex_edge[(numEdges * stride) + newEdges] : NULL;
ed = &medge[(numEdges * stride) + newEdges]; /* start after copied edges */
- orig_ed = &origindex_edge[(numEdges * stride) + newEdges];
- for (i = 0; i < rimVerts; i++, ed++, orig_ed++) {
+ for (i = 0; i < rimVerts; i++, ed++) {
ed->v1 = new_vert_arr[i];
ed->v2 = (do_shell ? new_vert_arr[i] : i) + numVerts;
ed->flag |= ME_EDGEDRAW | ME_EDGERENDER;
- *orig_ed = ORIGINDEX_NONE;
+ if (orig_ed) {
+ *orig_ed = ORIGINDEX_NONE;
+ orig_ed++;
+ }
if (crease_rim) {
ed->crease = crease_rim;
@@ -848,8 +850,10 @@ static Mesh *applyModifier(
ml[j++].e = (numEdges * stride) + old_vert_arr[ed->v2] + newEdges;
}
- origindex_edge[ml[j - 3].e] = ORIGINDEX_NONE;
- origindex_edge[ml[j - 1].e] = ORIGINDEX_NONE;
+ if (origindex_edge) {
+ origindex_edge[ml[j - 3].e] = ORIGINDEX_NONE;
+ origindex_edge[ml[j - 1].e] = ORIGINDEX_NONE;
+ }
/* use the next material index if option enabled */
if (mat_ofs_rim) {
@@ -953,12 +957,6 @@ ModifierTypeInfo modifierType_Solidify = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -975,4 +973,5 @@ ModifierTypeInfo modifierType_Solidify = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 1899faa3583..40c9e5c3b1b 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -24,6 +24,8 @@
#include <stddef.h>
+#include "MEM_guardedalloc.h"
+
#include "BLI_utildefines.h"
#include "DNA_object_types.h"
@@ -44,6 +46,11 @@
#include "intern/CCGSubSurf.h"
+typedef struct SubsurfRuntimeData {
+ /* Cached subdivision surface descriptor, with topology and settings. */
+ struct Subdiv *subdiv;
+} SubsurfRuntimeData;
+
static void initData(ModifierData *md)
{
SubsurfModifierData *smd = (SubsurfModifierData *) md;
@@ -64,7 +71,18 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
modifier_copyData_generic(md, target, flag);
tsmd->emCache = tsmd->mCache = NULL;
- tsmd->subdiv = NULL;
+}
+
+static void freeRuntimeData(void *runtime_data_v)
+{
+ if (runtime_data_v == NULL) {
+ return;
+ }
+ SubsurfRuntimeData *runtime_data = (SubsurfRuntimeData *)runtime_data_v;
+ if (runtime_data->subdiv != NULL) {
+ BKE_subdiv_free(runtime_data->subdiv);
+ }
+ MEM_freeN(runtime_data);
}
static void freeData(ModifierData *md)
@@ -79,9 +97,7 @@ static void freeData(ModifierData *md)
ccgSubSurf_free(smd->emCache);
smd->emCache = NULL;
}
- if (smd->subdiv != NULL) {
- BKE_subdiv_free(smd->subdiv);
- }
+ freeRuntimeData(smd->modifier.runtime);
}
static bool isDisabled(const Scene *scene, ModifierData *md, bool useRenderParams)
@@ -121,9 +137,11 @@ static Subdiv *subdiv_descriptor_ensure(SubsurfModifierData *smd,
const SubdivSettings *subdiv_settings,
const Mesh *mesh)
{
+ SubsurfRuntimeData *runtime_data =
+ (SubsurfRuntimeData *)smd->modifier.runtime;
Subdiv *subdiv = BKE_subdiv_update_from_mesh(
- smd->subdiv, subdiv_settings, mesh);
- smd->subdiv = subdiv;
+ runtime_data->subdiv, subdiv_settings, mesh);
+ runtime_data->subdiv = subdiv;
return subdiv;
}
@@ -181,6 +199,17 @@ static Mesh *subdiv_as_ccg(SubsurfModifierData *smd,
return result;
}
+static SubsurfRuntimeData *subsurf_ensure_runtime(SubsurfModifierData *smd)
+{
+ SubsurfRuntimeData *runtime_data =
+ (SubsurfRuntimeData *)smd->modifier.runtime;
+ if (runtime_data == NULL) {
+ runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime");
+ smd->modifier.runtime = runtime_data;
+ }
+ return runtime_data;
+}
+
/* Modifier itself. */
static Mesh *applyModifier(ModifierData *md,
@@ -195,6 +224,7 @@ static Mesh *applyModifier(ModifierData *md,
return result;
}
BKE_subdiv_settings_validate_for_mesh(&subdiv_settings, mesh);
+ SubsurfRuntimeData *runtime_data = subsurf_ensure_runtime(smd);
Subdiv *subdiv = subdiv_descriptor_ensure(smd, &subdiv_settings, mesh);
if (subdiv == NULL) {
/* Happens on bad topology, but also on empty input mesh. */
@@ -209,7 +239,7 @@ static Mesh *applyModifier(ModifierData *md,
result = subdiv_as_ccg(smd, ctx, mesh, subdiv);
}
// BKE_subdiv_stats_print(&subdiv->stats);
- if (subdiv != smd->subdiv) {
+ if (subdiv != runtime_data->subdiv) {
BKE_subdiv_free(subdiv);
}
return result;
@@ -228,12 +258,6 @@ ModifierTypeInfo modifierType_Subsurf = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -250,4 +274,5 @@ ModifierTypeInfo modifierType_Subsurf = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ freeRuntimeData,
};
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index ee3c99bef85..c0fbb4d9ac3 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -195,12 +195,6 @@ ModifierTypeInfo modifierType_Surface = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -217,4 +211,5 @@ ModifierTypeInfo modifierType_Surface = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 554545077fa..44307b4271e 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1124,7 +1124,7 @@ static void deformVert(
static void surfacedeformModifier_do(
ModifierData *md,
- const ModifierEvalContext *ctx,
+ const ModifierEvalContext *UNUSED(ctx),
float (*vertexCos)[3], unsigned int numverts, Object *ob)
{
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
@@ -1147,7 +1147,7 @@ static void surfacedeformModifier_do(
return;
}
- Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, smd->target);
+ Object *ob_target = smd->target;
target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false);
#if 0 /* Should not be needed anymore since we always get that mesh from eval object ? */
if (target == NULL && smd->verts == NULL && ob == DEG_get_original_object(ob)) {
@@ -1256,12 +1256,6 @@ ModifierTypeInfo modifierType_SurfaceDeform = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -1278,4 +1272,5 @@ ModifierTypeInfo modifierType_SurfaceDeform = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 802bde21b5c..0b4de9c8d17 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -34,7 +34,7 @@
#include "MOD_modifiertypes.h"
-static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_method, const int flag)
+static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_method, const int min_vertices, const int flag)
{
Mesh *result;
BMesh *bm;
@@ -59,7 +59,7 @@ static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_
.cd_mask_extra = cddata_masks,
}));
- BM_mesh_triangulate(bm, quad_method, ngon_method, false, NULL, NULL, NULL);
+ BM_mesh_triangulate(bm, quad_method, ngon_method, min_vertices, false, NULL, NULL, NULL);
result = BKE_mesh_from_bmesh_for_eval_nomain(bm, &cddata_masks);
BM_mesh_free(bm);
@@ -98,6 +98,7 @@ static void initData(ModifierData *md)
md->mode |= eModifierMode_Editmode;
tmd->quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE;
tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY;
+ tmd->min_vertices = 4;
}
static Mesh *applyModifier(
@@ -107,7 +108,7 @@ static Mesh *applyModifier(
{
TriangulateModifierData *tmd = (TriangulateModifierData *)md;
Mesh *result;
- if (!(result = triangulate_mesh(mesh, tmd->quad_method, tmd->ngon_method, tmd->flag))) {
+ if (!(result = triangulate_mesh(mesh, tmd->quad_method, tmd->ngon_method, tmd->min_vertices, tmd->flag))) {
return mesh;
}
@@ -127,12 +128,6 @@ ModifierTypeInfo modifierType_Triangulate = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -148,4 +143,5 @@ ModifierTypeInfo modifierType_Triangulate = {
/* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 941fcf6cf9a..2d4a3dc1778 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -59,7 +59,7 @@
void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *ctx)
{
- Tex *tex = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &dmd->texture->id);
+ Tex *tex = dmd->texture;
if (tex == NULL) {
return;
@@ -74,7 +74,7 @@ void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *c
/** \param cos: may be NULL, in which case we use directly mesh vertices' coordinates. */
void MOD_get_texture_coords(
MappingInfoModifierData *dmd,
- const ModifierEvalContext *ctx,
+ const ModifierEvalContext *UNUSED(ctx),
Object *ob,
Mesh *mesh,
float (*cos)[3],
@@ -87,7 +87,7 @@ void MOD_get_texture_coords(
if (texmapping == MOD_DISP_MAP_OBJECT) {
if (dmd->map_object != NULL) {
- Object *map_object = DEG_get_evaluated_object(ctx->depsgraph, dmd->map_object);
+ Object *map_object = dmd->map_object;
invert_m4_m4(mapob_imat, map_object->obmat);
}
else {/* if there is no map object, default to local */
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 26c7ec7ed13..06cd7a80494 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -109,7 +109,7 @@ typedef struct Projector {
static Mesh *uvprojectModifier_do(
UVProjectModifierData *umd,
- const ModifierEvalContext *ctx,
+ const ModifierEvalContext *UNUSED(ctx),
Object *ob, Mesh *mesh)
{
float (*coords)[3], (*co)[3];
@@ -128,7 +128,7 @@ static Mesh *uvprojectModifier_do(
for (i = 0; i < umd->num_projectors; ++i) {
if (umd->projectors[i] != NULL) {
- projectors[num_projectors++].ob = DEG_get_evaluated_object(ctx->depsgraph, umd->projectors[i]);
+ projectors[num_projectors++].ob = umd->projectors[i];
}
}
@@ -323,12 +323,6 @@ ModifierTypeInfo modifierType_UVProject = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -345,4 +339,5 @@ ModifierTypeInfo modifierType_UVProject = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index d4f17b742f1..a850bb34111 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -161,8 +161,8 @@ static Mesh *applyModifier(
}
/* make sure anything moving UVs is available */
- matrix_from_obj_pchan(mat_src, DEG_get_evaluated_object(ctx->depsgraph, umd->object_src), umd->bone_src);
- matrix_from_obj_pchan(mat_dst, DEG_get_evaluated_object(ctx->depsgraph, umd->object_dst), umd->bone_dst);
+ matrix_from_obj_pchan(mat_src, umd->object_src, umd->bone_src);
+ matrix_from_obj_pchan(mat_dst, umd->object_dst, umd->bone_dst);
invert_m4_m4(imat_dst, mat_dst);
mul_m4_m4m4(warp_mat, imat_dst, mat_src);
@@ -255,12 +255,6 @@ ModifierTypeInfo modifierType_UVWarp = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -277,4 +271,5 @@ ModifierTypeInfo modifierType_UVWarp = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index adda5df61ea..30bd391ef84 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -189,8 +189,8 @@ static void warpModifier_do(
invert_m4_m4(obinv, ob->obmat);
- mul_m4_m4m4(mat_from, obinv, DEG_get_evaluated_object(ctx->depsgraph, wmd->object_from)->obmat);
- mul_m4_m4m4(mat_to, obinv, DEG_get_evaluated_object(ctx->depsgraph, wmd->object_to)->obmat);
+ mul_m4_m4m4(mat_from, obinv, wmd->object_from->obmat);
+ mul_m4_m4m4(mat_to, obinv, wmd->object_to->obmat);
invert_m4_m4(tmat, mat_from); // swap?
mul_m4_m4m4(mat_final, tmat, mat_to);
@@ -211,7 +211,7 @@ static void warpModifier_do(
}
weight = strength;
- Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &wmd->texture->id);
+ Tex *tex_target = wmd->texture;
if (mesh != NULL && tex_target != NULL) {
tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "warpModifier_do tex_co");
MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co);
@@ -357,12 +357,6 @@ ModifierTypeInfo modifierType_Warp = {
eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -379,4 +373,5 @@ ModifierTypeInfo modifierType_Warp = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 80ac323c82f..d5c372a2809 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -167,7 +167,7 @@ static void waveModifier_do(
float mat[4][4];
/* get the control object's location in local coordinates */
invert_m4_m4(ob->imat, ob->obmat);
- mul_m4_m4m4(mat, ob->imat, DEG_get_evaluated_object(ctx->depsgraph, wmd->objectcenter)->obmat);
+ mul_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat);
wmd->startx = mat[3][0];
wmd->starty = mat[3][1];
@@ -191,7 +191,7 @@ static void waveModifier_do(
}
}
- Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &wmd->texture->id);
+ Tex *tex_target = wmd->texture;
if (mesh != NULL && tex_target != NULL) {
tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "waveModifier_do tex_co");
MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co);
@@ -357,12 +357,6 @@ ModifierTypeInfo modifierType_Wave = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
@@ -379,4 +373,5 @@ ModifierTypeInfo modifierType_Wave = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 9eda072b7d3..98b2117e5a3 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -537,7 +537,6 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const bool has_clnors = clnors != NULL;
if (!clnors) {
clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops);
- clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
}
MDeformVert *dvert;
@@ -634,12 +633,6 @@ ModifierTypeInfo modifierType_WeightedNormal = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -656,4 +649,5 @@ ModifierTypeInfo modifierType_WeightedNormal = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 85cf3102733..d0631a0c30b 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -127,7 +127,6 @@ void weightvg_do_mask(
/* If we want to mask vgroup weights from a texture. */
if (texture != NULL) {
- texture = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &texture->id);
/* The texture coordinates. */
float (*tex_co)[3];
/* See mapping note below... */
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 32d058e5659..17ccd67dfc9 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -279,12 +279,6 @@ ModifierTypeInfo modifierType_WeightVGEdit = {
/* copyData */ copyData,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -301,4 +295,5 @@ ModifierTypeInfo modifierType_WeightVGEdit = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 495d235b406..0894d30cfc1 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -392,12 +392,6 @@ ModifierTypeInfo modifierType_WeightVGMix = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -414,4 +408,5 @@ ModifierTypeInfo modifierType_WeightVGMix = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 2e2e4fe963d..89ba5395775 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -338,7 +338,9 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md;
if (wmd->proximity_ob_target != NULL) {
DEG_add_object_relation(ctx->node, wmd->proximity_ob_target, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
- DEG_add_object_relation(ctx->node, wmd->proximity_ob_target, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier");
+ if (wmd->proximity_ob_target->data != NULL && wmd->proximity_mode == MOD_WVG_PROXIMITY_GEOMETRY) {
+ DEG_add_object_relation(ctx->node, wmd->proximity_ob_target, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier");
+ }
}
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
@@ -396,7 +398,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
/* Get our target object. */
- obr = DEG_get_evaluated_object(ctx->depsgraph, wmd->proximity_ob_target);
+ obr = wmd->proximity_ob_target;
if (obr == NULL) {
return mesh;
}
@@ -564,12 +566,6 @@ ModifierTypeInfo modifierType_WeightVGProximity = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -586,4 +582,5 @@ ModifierTypeInfo modifierType_WeightVGProximity = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
index 2f70ab16cf8..74ab0ac3d8c 100644
--- a/source/blender/modifiers/intern/MOD_wireframe.c
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -115,12 +115,6 @@ ModifierTypeInfo modifierType_Wireframe = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ NULL,
- /* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ NULL,
- /* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ NULL,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
@@ -137,4 +131,5 @@ ModifierTypeInfo modifierType_Wireframe = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
+ /* freeRuntimeData */ NULL,
};
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index 1e43b5011e6..85f4c81610b 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -136,4 +136,6 @@ void node_cmp_rlayers_outputs(struct bNodeTree *ntree, struct bNode *node);
void node_cmp_rlayers_register_pass(struct bNodeTree *ntree, struct bNode *node, struct Scene *scene, struct ViewLayer *view_layer, const char *name, int type);
const char *node_cmp_rlayers_sock_to_pass(int sock_index);
+void register_node_type_cmp_custom_group(bNodeType *ntype);
+
#endif
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index e88f7a49d30..9e6fa0706d1 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -131,4 +131,6 @@ void register_node_type_sh_tex_checker(void);
void register_node_type_sh_bump(void);
void register_node_type_sh_tex_ies(void);
+void register_node_type_sh_custom_group(bNodeType *ntype);
+
#endif
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index ffa3cf363c9..5ef698c553b 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -195,7 +195,7 @@ void register_node_tree_type_cmp(void)
tt->type = NTREE_COMPOSIT;
strcpy(tt->idname, "CompositorNodeTree");
- strcpy(tt->ui_name, N_("Compositing"));
+ strcpy(tt->ui_name, N_("Compositor"));
tt->ui_icon = 0; /* defined in drawnode.c */
strcpy(tt->ui_description, N_("Compositing nodes"));
diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c
index 9d72335d720..480b9f1e989 100644
--- a/source/blender/nodes/composite/nodes/node_composite_common.c
+++ b/source/blender/nodes/composite/nodes/node_composite_common.c
@@ -56,3 +56,17 @@ void register_node_type_cmp_group(void)
nodeRegisterType(&ntype);
}
+
+void register_node_type_cmp_custom_group(bNodeType *ntype)
+{
+ /* These methods can be overriden but need a default implementation otherwise. */
+ if (ntype->poll == NULL) {
+ ntype->poll = cmp_node_poll_default;
+ }
+ if (ntype->insert_link == NULL) {
+ ntype->insert_link = node_insert_link_default;
+ }
+ if (ntype->update_internal_links == NULL) {
+ ntype->update_internal_links = node_update_internal_links_default;
+ }
+}
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index 08969fe3c0e..97d93ee0fa5 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -39,7 +39,8 @@
/* supported socket types in old nodes */
int node_exec_socket_use_stack(bNodeSocket *sock)
{
- return ELEM(sock->type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_SHADER);
+ /* NOTE: INT supported as FLOAT. Only for EEVEE. */
+ return ELEM(sock->type, SOCK_INT, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_SHADER);
}
/* for a given socket, find the actual stack entry */
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 30cc9d512f7..9f01d2ab254 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -143,7 +143,7 @@ static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree))
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
nodeInternalRelink(localtree, node);
- nodeFreeNode(localtree, node);
+ ntreeFreeLocalNode(localtree, node);
}
}
}
@@ -247,7 +247,7 @@ static bNode *ntree_shader_relink_output_from_group(bNodeTree *ntree,
SH_NODE_OUTPUT_WORLD,
SH_NODE_OUTPUT_LIGHT))
{
- nodeFreeNode(ntree, node);
+ ntreeFreeLocalNode(ntree, node);
}
}
@@ -290,7 +290,7 @@ static bNode *ntree_shader_output_node_from_group(bNodeTree *ntree, int target)
/* Search if node groups do not contain valid output nodes (recursively). */
for (bNode *node = ntree->nodes.first; node; node = node->next) {
- if (!ELEM(node->type, NODE_GROUP)) {
+ if (!ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
continue;
}
if (node->id != NULL) {
@@ -448,11 +448,12 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
bNodeSocketValueVector *src_vector;
bNodeSocketValueRGBA *src_rgba, *dst_rgba;
bNodeSocketValueFloat *src_float, *dst_float;
+ bNodeSocketValueInt *src_int;
bool link_added = false;
for (group_node = localtree->nodes.first; group_node; group_node = group_node->next) {
- if (group_node->type != NODE_GROUP || group_node->id == NULL)
+ if (!(ELEM(group_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) || group_node->id == NULL)
continue;
/* Do it recursively. */
@@ -485,6 +486,15 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
dst_rgba = value_socket->default_value;
copy_v4_v4(dst_rgba->value, src_rgba->value);
break;
+ case SOCK_INT:
+ /* HACK: Support as float. */
+ value_node = nodeAddStaticNode(NULL, localtree, SH_NODE_VALUE);
+ value_socket = ntree_shader_node_find_output(value_node, "Value");
+ BLI_assert(value_socket != NULL);
+ src_int = group_socket->default_value;
+ dst_float = value_socket->default_value;
+ dst_float->value = (float)(src_int->value);
+ break;
case SOCK_FLOAT:
value_node = nodeAddStaticNode(NULL, localtree, SH_NODE_VALUE);
value_socket = ntree_shader_node_find_output(value_node, "Value");
@@ -664,7 +674,7 @@ static void ntree_shader_link_builtin_normal(bNodeTree *ntree,
/* Don't connect node itself! */
continue;
}
- if (node->type == NODE_GROUP && node->id) {
+ if ((ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) && node->id) {
/* Special re-linking for group nodes. */
ntree_shader_link_builtin_group_normal(ntree,
node,
@@ -755,6 +765,7 @@ static bool ntree_tag_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void *user
switch (fromnode->type) {
case NODE_GROUP:
+ case NODE_CUSTOM_GROUP:
/* Recursive */
if (fromnode->id != NULL) {
bNodeTree *ntree = (bNodeTree *)fromnode->id;
@@ -833,7 +844,7 @@ void ntreeGPUMaterialNodes(bNodeTree *localtree, GPUMaterial *mat, bool *has_sur
ntree_shader_tag_nodes(localtree, output, &tags);
exec = ntreeShaderBeginExecTree(localtree);
- ntreeExecGPUNodes(exec, mat, 1);
+ ntreeExecGPUNodes(exec, mat, output);
ntreeShaderEndExecTree(exec);
/* EEVEE: Find which material domain was used (volume, surface ...). */
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index 5488706b87d..19bfd755928 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -102,6 +102,8 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
if (type == SOCK_FLOAT)
gs->type = GPU_FLOAT;
+ else if (type == SOCK_INT)
+ gs->type = GPU_FLOAT; /* HACK: Support as float. */
else if (type == SOCK_VECTOR)
gs->type = GPU_VEC3;
else if (type == SOCK_RGBA)
@@ -199,7 +201,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
return inactivenode;
}
-void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs)
+void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node)
{
bNodeExec *nodeexec;
bNode *node;
@@ -218,7 +220,7 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs)
do_it = false;
/* for groups, only execute outputs for edited group */
if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) {
- if (do_outputs && (node->flag & NODE_DO_OUTPUT))
+ if ((output_node != NULL) && (node == output_node))
do_it = true;
}
else {
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index 1eca3b8721e..e457f2f8b56 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -88,6 +88,6 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, struct bNodeSta
void node_data_from_gpu_stack(struct bNodeStack *ns, struct GPUNodeStack *gs);
void node_shader_gpu_tex_mapping(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out);
-void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs);
+void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, struct bNode *output_node);
#endif
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 ed706ca2ae1..de08f00b0b8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
@@ -37,9 +37,9 @@ static bNodeSocketTemplate sh_node_bsdf_toon_out[] = {
static int node_shader_gpu_bsdf_toon(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
if (!in[3].link)
- in[3].link = GPU_builtin(GPU_VIEW_NORMAL);
- else
- GPU_link(mat, "direction_transform_m4v3", in[3].link, GPU_builtin(GPU_VIEW_MATRIX), &in[3].link);
+ GPU_link(mat, "world_normals_get", &in[3].link);
+
+ GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
return GPU_stack_link(mat, node, "node_bsdf_toon", in, out);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c
index c238a3d946d..b9c9093a065 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -207,7 +207,7 @@ static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execd
return 0;
group_gpu_copy_inputs(node, in, exec->stack);
- ntreeExecGPUNodes(exec, mat, 0);
+ ntreeExecGPUNodes(exec, mat, NULL);
group_gpu_move_outputs(node, out, exec->stack);
return 1;
@@ -239,3 +239,20 @@ void register_node_type_sh_group(void)
nodeRegisterType(&ntype);
}
+
+void register_node_type_sh_custom_group(bNodeType *ntype)
+{
+ /* These methods can be overriden but need a default implementation otherwise. */
+ if (ntype->poll == NULL) {
+ ntype->poll = sh_node_poll_default;
+ }
+ if (ntype->insert_link == NULL) {
+ ntype->insert_link = node_insert_link_default;
+ }
+ if (ntype->update_internal_links == NULL) {
+ ntype->update_internal_links = node_update_internal_links_default;
+ }
+
+ node_type_exec(ntype, group_initexec, group_freeexec, group_execute);
+ node_type_gpu(ntype, gpu_group_execute);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c
index e4c37636347..2b4c3581fc0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_curves.c
+++ b/source/blender/nodes/shader/nodes/node_shader_curves.c
@@ -115,6 +115,7 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UN
{
float *array, layer;
int size;
+ bool use_opti = true;
CurveMapping *cumap = node->storage;
@@ -139,16 +140,38 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UN
ext_rgba[a][1] = 0.0f;
ext_rgba[a][3] = 0.0f;
}
- print_v4_id(ext_rgba[a]);
+
+ /* Check if rgb comps are just linear. */
+ if (a < 3) {
+ if (range_rgba[a] != 1.0f ||
+ ext_rgba[a][1] != 1.0f ||
+ ext_rgba[a][2] != 1.0f ||
+ cm->totpoint != 2 ||
+ cm->curve[0].x != 0.0f ||
+ cm->curve[0].y != 0.0f ||
+ cm->curve[1].x != 1.0f ||
+ cm->curve[1].y != 1.0f)
+ {
+ use_opti = false;
+ }
+ }
}
- return GPU_stack_link(mat, node, "curves_rgb", in, out, tex,
- GPU_constant(&layer),
- GPU_uniform(range_rgba),
- GPU_uniform(ext_rgba[0]),
- GPU_uniform(ext_rgba[1]),
- GPU_uniform(ext_rgba[2]),
- GPU_uniform(ext_rgba[3]));
+ if (use_opti) {
+ return GPU_stack_link(mat, node, "curves_rgb_opti", in, out, tex,
+ GPU_constant(&layer),
+ GPU_uniform(range_rgba),
+ GPU_uniform(ext_rgba[3]));
+ }
+ else {
+ return GPU_stack_link(mat, node, "curves_rgb", in, out, tex,
+ GPU_constant(&layer),
+ GPU_uniform(range_rgba),
+ GPU_uniform(ext_rgba[0]),
+ GPU_uniform(ext_rgba[1]),
+ GPU_uniform(ext_rgba[2]),
+ GPU_uniform(ext_rgba[3]));
+ }
}
void register_node_type_sh_curve_rgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
index fb7d85ce353..24432132a5b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
@@ -59,10 +59,12 @@ static void node_shader_exec_mix_rgb(void *UNUSED(data), int UNUSED(thread), bNo
static int gpu_shader_mix_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- static const char *names[] = {"mix_blend", "mix_add", "mix_mult", "mix_sub",
- "mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light",
- "mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat",
- "mix_val", "mix_color", "mix_soft", "mix_linear"};
+ static const char *names[] = {
+ "mix_blend", "mix_add", "mix_mult", "mix_sub",
+ "mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light",
+ "mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat",
+ "mix_val", "mix_color", "mix_soft", "mix_linear",
+ };
int ret = GPU_stack_link(mat, node, names[node->custom1], in, out);
if (ret && node->custom2 & SHD_MIXRGB_CLAMP) {
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 e0021d44e69..7eb5d2b716c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -82,7 +82,7 @@ static int gpu_shader_normal_map(GPUMaterial *mat, bNode *node, bNodeExecData *U
switch (nm->space) {
case SHD_SPACE_TANGENT:
GPU_link(mat, "color_to_normal_new_shading", realnorm, &realnorm);
- GPU_link(mat, "node_normal_map", GPU_attribute(CD_TANGENT, nm->uv_map), negnorm, realnorm, &realnorm);
+ GPU_link(mat, "node_normal_map", GPU_builtin(GPU_OBJECT_INFO), GPU_attribute(CD_TANGENT, nm->uv_map), negnorm, realnorm, &realnorm);
GPU_link(mat, "vec_math_mix", strength, realnorm, GPU_builtin(GPU_VIEW_NORMAL), &out[0].link);
/* for uniform scale this is sufficient to match Cycles */
GPU_link(mat, "direction_transform_m4v3", out[0].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[0].link);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
index 673cb9d4936..bbb1f60a7e7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tangent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -50,8 +50,9 @@ static int node_shader_gpu_tangent(GPUMaterial *mat, bNode *node, bNodeExecData
else
GPU_link(mat, "tangent_orco_z", orco, &orco);
- return GPU_stack_link(mat, node, "node_tangent", in, out, GPU_builtin(GPU_VIEW_NORMAL), orco,
- GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_INVERSE_VIEW_MATRIX));
+ return GPU_stack_link(
+ mat, node, "node_tangent", in, out, GPU_builtin(GPU_VIEW_NORMAL), orco,
+ GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_INVERSE_VIEW_MATRIX));
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
index fb901ea0774..5a7a81f57bd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
@@ -36,6 +36,14 @@ static bNodeSocketTemplate sh_node_tex_coord_out[] = {
static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
+ Object *ob = (Object *)node->id;
+
+ if (ob != NULL) {
+ invert_m4_m4(ob->imat, ob->obmat);
+ }
+
+ GPUNodeLink *inv_obmat = (ob != NULL) ? GPU_uniform(&ob->imat[0][0]) : GPU_builtin(GPU_INVERSE_OBJECT_MATRIX);
+
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, "");
@@ -43,7 +51,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *node, bNodeExecDat
return GPU_stack_link(mat, node, "node_tex_coord", in, out,
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
+ GPU_builtin(GPU_INVERSE_VIEW_MATRIX), inv_obmat,
GPU_builtin(GPU_CAMERA_TEXCO_FACTORS), orco, mtface);
}
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 ba5d34a445f..3491a28fa8f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -123,12 +123,9 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
case SHD_PROJ_BOX:
- GPU_link(mat, "direction_transform_m4v3", GPU_builtin(GPU_VIEW_NORMAL),
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
- &norm);
- GPU_link(mat, "direction_transform_m4v3", norm,
- GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
- &norm);
+ GPU_link(mat, "mat3_mul", GPU_builtin(GPU_VIEW_NORMAL),
+ GPU_builtin(GPU_INVERSE_NORMAL_MATRIX),
+ &norm);
GPU_link(mat, gpu_node_name, in[0].link,
norm,
GPU_image(ima, iuser, isdata),
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
index cd7a568880f..5d6c1b6cd4f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c
@@ -93,9 +93,11 @@ static void node_shader_exec_vect_math(void *UNUSED(data), int UNUSED(thread), b
static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- static const char *names[] = {"vec_math_add", "vec_math_sub",
+ static const char *names[] = {
+ "vec_math_add", "vec_math_sub",
"vec_math_average", "vec_math_dot", "vec_math_cross",
- "vec_math_normalize"};
+ "vec_math_normalize",
+ };
switch (node->custom1) {
case 0:
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index f876ceb0872..6aeaf8d0179 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -118,7 +118,7 @@ static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree))
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
nodeInternalRelink(localtree, node);
- nodeFreeNode(localtree, node);
+ ntreeFreeLocalNode(localtree, node);
}
}
}
diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index fbd79f28ec7..f35bfb730ad 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -351,11 +351,13 @@ PyObject *BPyInit_bmesh_ops(void)
{
PyObject *submodule;
- if (PyType_Ready(&bmesh_ops_fakemod_Type) < 0)
+ if (PyType_Ready(&bmesh_ops_fakemod_Type) < 0) {
return NULL;
+ }
- if (PyType_Ready(&bmesh_op_Type) < 0)
+ if (PyType_Ready(&bmesh_op_Type) < 0) {
return NULL;
+ }
submodule = PyObject_New(PyObject, &bmesh_ops_fakemod_Type);
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index b371b482ece..366f0b4b3f7 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -67,7 +67,7 @@ PyC_FlagSet bpy_bm_htype_vert_edge_face_flags[] = {
{BM_VERT, "VERT"},
{BM_EDGE, "EDGE"},
{BM_FACE, "FACE"},
- {0, NULL},
+ {0, NULL},
};
PyC_FlagSet bpy_bm_htype_all_flags[] = {
@@ -996,10 +996,10 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
return NULL;
}
else if (use_render) {
- me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, NULL, &data_masks);
+ me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, &data_masks);
}
else {
- me_eval = mesh_create_eval_no_deform(depsgraph, scene_eval, ob, NULL, &data_masks);
+ me_eval = mesh_create_eval_no_deform(depsgraph, scene_eval, ob, &data_masks);
}
}
@@ -1445,8 +1445,9 @@ static PyObject *bpy_bmvert_calc_edge_angle(BPy_BMVert *self, PyObject *args)
BPY_BM_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "|O:calc_edge_angle", &fallback))
+ if (!PyArg_ParseTuple(args, "|O:calc_edge_angle", &fallback)) {
return NULL;
+ }
angle = BM_vert_calc_edge_angle_ex(self->v, angle_invalid);
@@ -1530,8 +1531,9 @@ static PyObject *bpy_bmedge_calc_face_angle(BPy_BMEdge *self, PyObject *args)
BPY_BM_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "|O:calc_face_angle", &fallback))
+ if (!PyArg_ParseTuple(args, "|O:calc_face_angle", &fallback)) {
return NULL;
+ }
angle = BM_edge_calc_face_angle_ex(self->e, angle_invalid);
@@ -1569,8 +1571,9 @@ static PyObject *bpy_bmedge_calc_face_angle_signed(BPy_BMEdge *self, PyObject *a
BPY_BM_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "|O:calc_face_angle_signed", &fallback))
+ if (!PyArg_ParseTuple(args, "|O:calc_face_angle_signed", &fallback)) {
return NULL;
+ }
angle = BM_edge_calc_face_angle_signed_ex(self->e, angle_invalid);
@@ -2161,7 +2164,9 @@ static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
ret = BPy_BMEdge_CreatePyObject(bm, e);
cleanup:
- if (vert_array) PyMem_FREE(vert_array);
+ if (vert_array) {
+ PyMem_FREE(vert_array);
+ }
return ret;
}
}
@@ -2239,7 +2244,9 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
/* pass through */
cleanup:
- if (vert_array) PyMem_FREE(vert_array);
+ if (vert_array) {
+ PyMem_FREE(vert_array);
+ }
return ret;
}
}
@@ -2535,9 +2542,15 @@ static int bpy_bmelemseq_sort_cmp_by_keys_ascending(const void *index1_v, const
const int *index1 = (int *)index1_v;
const int *index2 = (int *)index2_v;
- if (keys[*index1] < keys[*index2]) return -1;
- else if (keys[*index1] > keys[*index2]) return 1;
- else return 0;
+ if (keys[*index1] < keys[*index2]) {
+ return -1;
+ }
+ else if (keys[*index1] > keys[*index2]) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
static int bpy_bmelemseq_sort_cmp_by_keys_descending(const void *index1_v, const void *index2_v, void *keys_v)
@@ -2646,10 +2659,12 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
range_vn_i(elem_idx, n_elem, 0);
/* Sort the index array according to the order of the 'keys' array */
- if (do_reverse)
+ if (do_reverse) {
elem_idx_compare_by_keys = bpy_bmelemseq_sort_cmp_by_keys_descending;
- else
+ }
+ else {
elem_idx_compare_by_keys = bpy_bmelemseq_sort_cmp_by_keys_ascending;
+ }
BLI_qsort_r(elem_idx, n_elem, sizeof(*elem_idx), elem_idx_compare_by_keys, keys);
@@ -2920,7 +2935,10 @@ static PyObject *bpy_bmelemseq_subscript_int(BPy_BMElemSeq *self, int keynum)
{
BPY_BM_CHECK_OBJ(self);
- if (keynum < 0) keynum += bpy_bmelemseq_length(self); /* only get length on negative value, may loop entire seq */
+ if (keynum < 0) {
+ /* only get length on negative value, may loop entire seq */
+ keynum += bpy_bmelemseq_length(self);
+ }
if (keynum >= 0) {
if (self->itype <= BM_FACES_OF_MESH) {
if ((self->bm->elem_table_dirty & bm_iter_itype_htype_map[self->itype]) == 0) {
@@ -3014,8 +3032,9 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
/* don't need error check here */
if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
+ }
return bpy_bmelemseq_subscript_int(self, i);
}
else if (PySlice_Check(key)) {
@@ -3037,14 +3056,22 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+ return NULL;
+ }
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+ return NULL;
+ }
if (start < 0 || stop < 0) {
/* only get the length for negative values */
Py_ssize_t len = bpy_bmelemseq_length(self);
- if (start < 0) start += len;
- if (stop < 0) stop += len;
+ if (start < 0) {
+ start += len;
+ }
+ if (stop < 0) {
+ stop += len;
+ }
}
if (stop - start <= 0) {
@@ -3162,10 +3189,18 @@ static void bpy_bmesh_dealloc(BPy_BMesh *self)
if (bm) {
bm_dealloc_editmode_warn(self);
- if (CustomData_has_layer(&bm->vdata, CD_BM_ELEM_PYPTR)) BM_data_layer_free(bm, &bm->vdata, CD_BM_ELEM_PYPTR);
- if (CustomData_has_layer(&bm->edata, CD_BM_ELEM_PYPTR)) BM_data_layer_free(bm, &bm->edata, CD_BM_ELEM_PYPTR);
- if (CustomData_has_layer(&bm->pdata, CD_BM_ELEM_PYPTR)) BM_data_layer_free(bm, &bm->pdata, CD_BM_ELEM_PYPTR);
- if (CustomData_has_layer(&bm->ldata, CD_BM_ELEM_PYPTR)) BM_data_layer_free(bm, &bm->ldata, CD_BM_ELEM_PYPTR);
+ if (CustomData_has_layer(&bm->vdata, CD_BM_ELEM_PYPTR)) {
+ BM_data_layer_free(bm, &bm->vdata, CD_BM_ELEM_PYPTR);
+ }
+ if (CustomData_has_layer(&bm->edata, CD_BM_ELEM_PYPTR)) {
+ BM_data_layer_free(bm, &bm->edata, CD_BM_ELEM_PYPTR);
+ }
+ if (CustomData_has_layer(&bm->pdata, CD_BM_ELEM_PYPTR)) {
+ BM_data_layer_free(bm, &bm->pdata, CD_BM_ELEM_PYPTR);
+ }
+ if (CustomData_has_layer(&bm->ldata, CD_BM_ELEM_PYPTR)) {
+ BM_data_layer_free(bm, &bm->ldata, CD_BM_ELEM_PYPTR);
+ }
bm->py_handle = NULL;
@@ -3182,8 +3217,9 @@ static void bpy_bmvert_dealloc(BPy_BMElem *self)
BMesh *bm = self->bm;
if (bm) {
void **ptr = CustomData_bmesh_get(&bm->vdata, self->ele->head.data, CD_BM_ELEM_PYPTR);
- if (ptr)
+ if (ptr) {
*ptr = NULL;
+ }
}
PyObject_DEL(self);
}
@@ -3193,8 +3229,9 @@ static void bpy_bmedge_dealloc(BPy_BMElem *self)
BMesh *bm = self->bm;
if (bm) {
void **ptr = CustomData_bmesh_get(&bm->edata, self->ele->head.data, CD_BM_ELEM_PYPTR);
- if (ptr)
+ if (ptr) {
*ptr = NULL;
+ }
}
PyObject_DEL(self);
}
@@ -3204,8 +3241,9 @@ static void bpy_bmface_dealloc(BPy_BMElem *self)
BMesh *bm = self->bm;
if (bm) {
void **ptr = CustomData_bmesh_get(&bm->pdata, self->ele->head.data, CD_BM_ELEM_PYPTR);
- if (ptr)
+ if (ptr) {
*ptr = NULL;
+ }
}
PyObject_DEL(self);
}
@@ -3215,8 +3253,9 @@ static void bpy_bmloop_dealloc(BPy_BMElem *self)
BMesh *bm = self->bm;
if (bm) {
void **ptr = CustomData_bmesh_get(&bm->ldata, self->ele->head.data, CD_BM_ELEM_PYPTR);
- if (ptr)
+ if (ptr) {
*ptr = NULL;
+ }
}
PyObject_DEL(self);
}
@@ -3938,7 +3977,9 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
}
*r_size = seq_len;
- if (r_bm) *r_bm = bm;
+ if (r_bm) {
+ *r_bm = bm;
+ }
return alloc;
err_cleanup:
@@ -4042,10 +4083,10 @@ char *BPy_BMElem_StringFromHType_ex(const char htype, char ret[32])
{
/* zero to ensure string is always NULL terminated */
char *ret_ptr = ret;
- if (htype & BM_VERT) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMVert_Type.tp_name);
- if (htype & BM_EDGE) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMEdge_Type.tp_name);
- if (htype & BM_FACE) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMFace_Type.tp_name);
- if (htype & BM_LOOP) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMLoop_Type.tp_name);
+ if (htype & BM_VERT) { ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMVert_Type.tp_name); }
+ if (htype & BM_EDGE) { ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMEdge_Type.tp_name); }
+ if (htype & BM_FACE) { ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMFace_Type.tp_name); }
+ if (htype & BM_LOOP) { ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMLoop_Type.tp_name); }
ret[0] = '(';
*ret_ptr++ = ')';
*ret_ptr = '\0';
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index c161b974eff..abe146f2581 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -615,7 +615,9 @@ static PyObject *bpy_bmlayercollection_subscript_int(BPy_BMLayerCollection *self
len = bpy_bmlayercollection_length(self);
- if (keynum < 0) keynum += len;
+ if (keynum < 0) {
+ keynum += len;
+ }
if (keynum >= 0) {
if (keynum < len) {
return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, keynum);
@@ -636,8 +638,12 @@ static PyObject *bpy_bmlayercollection_subscript_slice(BPy_BMLayerCollection *se
BPY_BM_CHECK_OBJ(self);
- if (start >= len) start = len - 1;
- if (stop >= len) stop = len - 1;
+ if (start >= len) {
+ start = len - 1;
+ }
+ if (stop >= len) {
+ stop = len - 1;
+ }
tuple = PyTuple_New(stop - start);
@@ -656,8 +662,9 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
}
else if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
+ }
return bpy_bmlayercollection_subscript_int(self, i);
}
else if (PySlice_Check(key)) {
@@ -679,14 +686,22 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+ return NULL;
+ }
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+ return NULL;
+ }
if (start < 0 || stop < 0) {
/* only get the length for negative values */
Py_ssize_t len = bpy_bmlayercollection_length(self);
- if (start < 0) start += len;
- if (stop < 0) stop += len;
+ if (start < 0) {
+ start += len;
+ }
+ if (stop < 0) {
+ stop += len;
+ }
}
if (stop - start <= 0) {
@@ -1085,8 +1100,9 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
ret = -1;
}
else {
- if (tmp_val_len > sizeof(mstring->s))
+ if (tmp_val_len > sizeof(mstring->s)) {
tmp_val_len = sizeof(mstring->s);
+ }
memcpy(mstring->s, tmp_val, tmp_val_len);
mstring->s_len = tmp_val_len;
}
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
index aba54c6c43a..604b55de6e6 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
@@ -306,8 +306,9 @@ static int mathutils_bmloopcol_set(BaseMathObject *bmo, int UNUSED(subtype))
static int mathutils_bmloopcol_get_index(BaseMathObject *bmo, int subtype, int UNUSED(index))
{
/* lazy, avoid repeteing the case statement */
- if (mathutils_bmloopcol_get(bmo, subtype) == -1)
+ if (mathutils_bmloopcol_get(bmo, subtype) == -1) {
return -1;
+ }
return 0;
}
@@ -316,8 +317,9 @@ static int mathutils_bmloopcol_set_index(BaseMathObject *bmo, int subtype, int i
const float f = bmo->data[index];
/* lazy, avoid repeteing the case statement */
- if (mathutils_bmloopcol_get(bmo, subtype) == -1)
+ if (mathutils_bmloopcol_get(bmo, subtype) == -1) {
return -1;
+ }
bmo->data[index] = f;
return mathutils_bmloopcol_set(bmo, subtype);
diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c
index ed631f7105b..e257c1bff4b 100644
--- a/source/blender/python/bmesh/bmesh_py_types_select.c
+++ b/source/blender/python/bmesh/bmesh_py_types_select.c
@@ -255,8 +255,9 @@ static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject *ke
/* don't need error check here */
if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
+ }
return bpy_bmeditselseq_subscript_int(self, i);
}
else if (PySlice_Check(key)) {
@@ -278,14 +279,22 @@ static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject *ke
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+ return NULL;
+ }
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+ return NULL;
+ }
if (start < 0 || stop < 0) {
/* only get the length for negative values */
Py_ssize_t len = bpy_bmeditselseq_length(self);
- if (start < 0) start += len;
- if (stop < 0) stop += len;
+ if (start < 0) {
+ start += len;
+ }
+ if (stop < 0) {
+ stop += len;
+ }
}
if (stop - start <= 0) {
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 08280248649..b52326ed7a4 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -132,9 +132,9 @@
#define GLclampfP_def(number) Buffer *bgl_buffer##number
#endif
-#define GLvoidP_str "O!"
-#define GLvoidP_var(number) (bgl_buffer##number)->buf.asvoid
-#define GLvoidP_ref(number) &BGL_bufferType, &bgl_buffer##number
+#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 GLsizeiP_str "O!"
@@ -476,15 +476,25 @@ static int gl_buffer_type_from_py_buffer(Py_buffer *pybuffer)
Py_ssize_t itemsize = pybuffer->itemsize;
if (PyC_StructFmt_type_is_float_any(format)) {
- if (itemsize == 4) return GL_FLOAT;
- if (itemsize == 8) return GL_DOUBLE;
+ if (itemsize == 4) {
+ return GL_FLOAT;
+ }
+ if (itemsize == 8) {
+ return GL_DOUBLE;
+ }
}
if (PyC_StructFmt_type_is_byte(format) ||
PyC_StructFmt_type_is_int_any(format))
{
- if (itemsize == 1) return GL_BYTE;
- if (itemsize == 2) return GL_SHORT;
- if (itemsize == 4) return GL_INT;
+ if (itemsize == 1) {
+ return GL_BYTE;
+ }
+ if (itemsize == 2) {
+ return GL_SHORT;
+ }
+ if (itemsize == 4) {
+ return GL_INT;
+ }
}
return -1; /* UNKNOWN */
@@ -703,6 +713,22 @@ 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)
+{
+ if (object == Py_None) {
+ *buffer = NULL;
+ return 1;
+ }
+ else if (PyObject_TypeCheck(object, &BGL_bufferType)) {
+ *buffer = (Buffer *)object;
+ return 1;
+ }
+ else {
+ PyErr_SetString(PyExc_TypeError, "expected a bgl.Buffer or None");
+ return 0;
+ }
+}
#define MAX_DIMENSIONS 256
static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
@@ -753,10 +779,12 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject
for (i = 0; i < ndimensions; i++) {
PyObject *ob = PySequence_GetItem(length_ob, i);
- if (!PyLong_Check(ob))
+ if (!PyLong_Check(ob)) {
dimensions[i] = 1;
- else
+ }
+ else {
dimensions[i] = PyLong_AsLong(ob);
+ }
Py_DECREF(ob);
if (dimensions[i] < 1) {
@@ -852,9 +880,15 @@ static PyObject *Buffer_slice(Buffer *self, int begin, int end)
PyObject *list;
int count;
- if (begin < 0) begin = 0;
- if (end > self->dimensions[0]) end = self->dimensions[0];
- if (begin > end) begin = end;
+ if (begin < 0) {
+ begin = 0;
+ }
+ if (end > self->dimensions[0]) {
+ end = self->dimensions[0];
+ }
+ if (begin > end) {
+ begin = end;
+ }
list = PyList_New(end - begin);
@@ -900,9 +934,15 @@ static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq)
PyObject *item;
int count, err = 0;
- if (begin < 0) begin = 0;
- if (end > self->dimensions[0]) end = self->dimensions[0];
- if (begin > end) begin = end;
+ if (begin < 0) {
+ begin = 0;
+ }
+ if (end > self->dimensions[0]) {
+ end = self->dimensions[0];
+ }
+ if (begin > end) {
+ begin = end;
+ }
if (!PySequence_Check(seq)) {
PyErr_Format(PyExc_TypeError,
@@ -941,17 +981,20 @@ static PyObject *Buffer_subscript(Buffer *self, PyObject *item)
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
- if (i < 0)
+ }
+ if (i < 0) {
i += self->dimensions[0];
+ }
return Buffer_item(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0) {
return NULL;
+ }
if (slicelength <= 0) {
return PyTuple_New(0);
@@ -977,20 +1020,24 @@ static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value)
{
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return -1;
- if (i < 0)
+ }
+ if (i < 0) {
i += self->dimensions[0];
+ }
return Buffer_ass_item(self, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0) {
return -1;
+ }
- if (step == 1)
+ if (step == 1) {
return Buffer_ass_slice(self, start, stop, value);
+ }
else {
PyErr_SetString(PyExc_IndexError,
"slice steps not supported with vectors");
@@ -1374,8 +1421,9 @@ PyObject *BPyInit_bgl(void)
submodule = PyModule_Create(&BGL_module_def);
dict = PyModule_GetDict(submodule);
- if (PyType_Ready(&BGL_bufferType) < 0)
+ if (PyType_Ready(&BGL_bufferType) < 0) {
return NULL; /* should never happen */
+ }
PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType);
Py_INCREF((PyObject *)&BGL_bufferType);
@@ -2538,8 +2586,9 @@ static PyObject *Method_ShaderSource(PyObject *UNUSED(self), PyObject *args)
unsigned int shader;
const char *source;
- if (!PyArg_ParseTuple(args, "Is", &shader, &source))
+ if (!PyArg_ParseTuple(args, "Is", &shader, &source)) {
return NULL;
+ }
glShaderSource(shader, 1, (const char **)&source, NULL);
diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c
index 79ffb9aa892..9161e5d979b 100644
--- a/source/blender/python/generic/blf_py_api.c
+++ b/source/blender/python/generic/blf_py_api.c
@@ -50,8 +50,9 @@ static PyObject *py_blf_position(PyObject *UNUSED(self), PyObject *args)
int fontid;
float x, y, z;
- if (!PyArg_ParseTuple(args, "ifff:blf.position", &fontid, &x, &y, &z))
+ if (!PyArg_ParseTuple(args, "ifff:blf.position", &fontid, &x, &y, &z)) {
return NULL;
+ }
BLF_position(fontid, x, y, z);
@@ -75,8 +76,9 @@ static PyObject *py_blf_size(PyObject *UNUSED(self), PyObject *args)
{
int fontid, size, dpi;
- if (!PyArg_ParseTuple(args, "iii:blf.size", &fontid, &size, &dpi))
+ if (!PyArg_ParseTuple(args, "iii:blf.size", &fontid, &size, &dpi)) {
return NULL;
+ }
BLF_size(fontid, size, dpi);
@@ -99,8 +101,9 @@ static PyObject *py_blf_aspect(PyObject *UNUSED(self), PyObject *args)
float aspect;
int fontid;
- if (!PyArg_ParseTuple(args, "if:blf.aspect", &fontid, &aspect))
+ if (!PyArg_ParseTuple(args, "if:blf.aspect", &fontid, &aspect)) {
return NULL;
+ }
BLF_aspect(fontid, aspect, aspect, 1.0);
@@ -157,8 +160,9 @@ static PyObject *py_blf_blur(PyObject *UNUSED(self), PyObject *args)
{
int blur, fontid;
- if (!PyArg_ParseTuple(args, "ii:blf.blur", &fontid, &blur))
+ if (!PyArg_ParseTuple(args, "ii:blf.blur", &fontid, &blur)) {
return NULL;
+ }
BLF_blur(fontid, blur);
@@ -183,8 +187,9 @@ static PyObject *py_blf_draw(PyObject *UNUSED(self), PyObject *args)
int text_length;
int fontid;
- if (!PyArg_ParseTuple(args, "is#:blf.draw", &fontid, &text, &text_length))
+ if (!PyArg_ParseTuple(args, "is#:blf.draw", &fontid, &text, &text_length)) {
return NULL;
+ }
BLF_draw(fontid, text, (unsigned int)text_length);
@@ -210,8 +215,9 @@ static PyObject *py_blf_dimensions(PyObject *UNUSED(self), PyObject *args)
PyObject *ret;
int fontid;
- if (!PyArg_ParseTuple(args, "is:blf.dimensions", &fontid, &text))
+ if (!PyArg_ParseTuple(args, "is:blf.dimensions", &fontid, &text)) {
return NULL;
+ }
BLF_width_and_height(fontid, text, INT_MAX, &r_width, &r_height);
@@ -243,8 +249,9 @@ static PyObject *py_blf_clipping(PyObject *UNUSED(self), PyObject *args)
float xmin, ymin, xmax, ymax;
int fontid;
- if (!PyArg_ParseTuple(args, "iffff:blf.clipping", &fontid, &xmin, &ymin, &xmax, &ymax))
+ if (!PyArg_ParseTuple(args, "iffff:blf.clipping", &fontid, &xmin, &ymin, &xmax, &ymax)) {
return NULL;
+ }
BLF_clipping(fontid, xmin, ymin, xmax, ymax);
@@ -266,8 +273,9 @@ static PyObject *py_blf_word_wrap(PyObject *UNUSED(self), PyObject *args)
int wrap_width;
int fontid;
- if (!PyArg_ParseTuple(args, "ii:blf.word_wrap", &fontid, &wrap_width))
+ if (!PyArg_ParseTuple(args, "ii:blf.word_wrap", &fontid, &wrap_width)) {
return NULL;
+ }
BLF_wordwrap(fontid, wrap_width);
@@ -288,8 +296,9 @@ static PyObject *py_blf_disable(PyObject *UNUSED(self), PyObject *args)
{
int option, fontid;
- if (!PyArg_ParseTuple(args, "ii:blf.disable", &fontid, &option))
+ if (!PyArg_ParseTuple(args, "ii:blf.disable", &fontid, &option)) {
return NULL;
+ }
BLF_disable(fontid, option);
@@ -310,8 +319,9 @@ static PyObject *py_blf_enable(PyObject *UNUSED(self), PyObject *args)
{
int option, fontid;
- if (!PyArg_ParseTuple(args, "ii:blf.enable", &fontid, &option))
+ if (!PyArg_ParseTuple(args, "ii:blf.enable", &fontid, &option)) {
return NULL;
+ }
BLF_enable(fontid, option);
@@ -333,8 +343,9 @@ static PyObject *py_blf_rotation(PyObject *UNUSED(self), PyObject *args)
float angle;
int fontid;
- if (!PyArg_ParseTuple(args, "if:blf.rotation", &fontid, &angle))
+ if (!PyArg_ParseTuple(args, "if:blf.rotation", &fontid, &angle)) {
return NULL;
+ }
BLF_rotation(fontid, angle);
@@ -397,8 +408,9 @@ static PyObject *py_blf_shadow_offset(PyObject *UNUSED(self), PyObject *args)
{
int x, y, fontid;
- if (!PyArg_ParseTuple(args, "iii:blf.shadow_offset", &fontid, &x, &y))
+ if (!PyArg_ParseTuple(args, "iii:blf.shadow_offset", &fontid, &x, &y)) {
return NULL;
+ }
BLF_shadow_offset(fontid, x, y);
@@ -419,8 +431,9 @@ static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
{
const char *filename;
- if (!PyArg_ParseTuple(args, "s:blf.load", &filename))
+ if (!PyArg_ParseTuple(args, "s:blf.load", &filename)) {
return NULL;
+ }
return PyLong_FromLong(BLF_load(filename));
}
@@ -437,8 +450,9 @@ static PyObject *py_blf_unload(PyObject *UNUSED(self), PyObject *args)
{
const char *filename;
- if (!PyArg_ParseTuple(args, "s:blf.unload", &filename))
+ if (!PyArg_ParseTuple(args, "s:blf.unload", &filename)) {
return NULL;
+ }
BLF_unload(filename);
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index 96b5645f0e7..0baa4008f2d 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -180,8 +180,9 @@ PyObject *bpy_text_import_name(const char *name, int *found)
}
/* we know this cant be importable, the name is too long for blender! */
- if (namelen >= (MAX_ID_NAME - 2) - 3)
+ if (namelen >= (MAX_ID_NAME - 2) - 3) {
return NULL;
+ }
memcpy(txtname, name, namelen);
memcpy(&txtname[namelen], ".py", 4);
@@ -200,10 +201,12 @@ PyObject *bpy_text_import_name(const char *name, int *found)
maggie = maggie->next;
}
- if (!text)
+ if (!text) {
return NULL;
- else
+ }
+ else {
*found = 1;
+ }
return bpy_text_import(text);
}
@@ -229,8 +232,9 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
*found = 0;
/* get name, filename from the module itself */
- if ((name = PyModule_GetName(module)) == NULL)
+ if ((name = PyModule_GetName(module)) == NULL) {
return NULL;
+ }
{
PyObject *module_file = PyModule_GetFilenameObject(module);
@@ -248,10 +252,12 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
text = BLI_findstring(&maggie->texts, BLI_path_basename(filepath), offsetof(ID, name) + 2);
/* uh-oh.... didn't find it */
- if (!text)
+ if (!text) {
return NULL;
- else
+ }
+ else {
*found = 1;
+ }
if (bpy_text_compile(text) == false) {
return NULL;
@@ -283,8 +289,9 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject
/* import existing builtin modules or modules that have been imported already */
newmodule = PyImport_ImportModuleLevel(name, globals, locals, fromlist, level);
- if (newmodule)
+ if (newmodule) {
return newmodule;
+ }
PyErr_Fetch(&exception, &err, &tb); /* get the python error in case we cant import as blender text either */
@@ -330,8 +337,9 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
newmodule = PyObject_CallFunctionObjArgs(imp_reload_orig, module, NULL);
- if (newmodule)
+ if (newmodule) {
return newmodule;
+ }
/* no file, try importing from memory */
PyErr_Fetch(&exception, &err, &tb); /*restore for probable later use */
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 6c5177d4759..f18d02a4405 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -419,11 +419,17 @@ static int idp_array_type_from_formatstr_and_size(const char *typestr, Py_ssize_
char format = PyC_StructFmt_type_from_str(typestr);
if (PyC_StructFmt_type_is_float_any(format)) {
- if (itemsize == 4) return IDP_FLOAT;
- if (itemsize == 8) return IDP_DOUBLE;
+ if (itemsize == 4) {
+ return IDP_FLOAT;
+ }
+ if (itemsize == 8) {
+ return IDP_DOUBLE;
+ }
}
if (PyC_StructFmt_type_is_int_any(format)) {
- if (itemsize == 4) return IDP_INT;
+ if (itemsize == 4) {
+ return IDP_INT;
+ }
}
return -1;
@@ -431,9 +437,15 @@ static int idp_array_type_from_formatstr_and_size(const char *typestr, Py_ssize_
static const char *idp_format_from_array_type(int type)
{
- if (type == IDP_INT) return "i";
- if (type == IDP_FLOAT) return "f";
- if (type == IDP_DOUBLE) return "d";
+ if (type == IDP_INT) {
+ return "i";
+ }
+ if (type == IDP_FLOAT) {
+ return "f";
+ }
+ if (type == IDP_DOUBLE) {
+ return "d";
+ }
return NULL;
}
@@ -936,8 +948,9 @@ PyObject *BPy_Wrap_GetKeys(IDProperty *prop)
IDProperty *loop;
int i;
- for (i = 0, loop = prop->data.group.first; loop && (i < prop->len); loop = loop->next, i++)
+ for (i = 0, loop = prop->data.group.first; loop && (i < prop->len); loop = loop->next, i++) {
PyList_SET_ITEM(list, i, PyUnicode_FromString(loop->name));
+ }
/* if the id prop is corrupt, count the remaining */
for ( ; loop; loop = loop->next, i++) {
@@ -1067,7 +1080,9 @@ static PyObject *BPy_IDGroup_update(BPy_IDProperty *self, PyObject *value)
else if (PyDict_Check(value)) {
while (PyDict_Next(value, &i, &pkey, &pval)) {
BPy_IDGroup_Map_SetItem(self, pkey, pval);
- if (PyErr_Occurred()) return NULL;
+ if (PyErr_Occurred()) {
+ return NULL;
+ }
}
}
else {
@@ -1113,14 +1128,16 @@ static PyObject *BPy_IDGroup_get(BPy_IDProperty *self, PyObject *args)
const char *key;
PyObject *def = Py_None;
- if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
+ if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) {
return NULL;
+ }
idprop = IDP_GetPropertyFromGroup(self->prop, key);
if (idprop) {
PyObject *pyobj = BPy_IDGroup_WrapData(self->id, idprop, self->prop);
- if (pyobj)
+ if (pyobj) {
return pyobj;
+ }
}
Py_INCREF(def);
@@ -1376,7 +1393,9 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
int count;
CLAMP(begin, 0, prop->len);
- if (end < 0) end = prop->len + end + 1;
+ if (end < 0) {
+ end = prop->len + end + 1;
+ }
CLAMP(end, 0, prop->len);
begin = MIN2(begin, end);
@@ -1446,17 +1465,20 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item)
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
- if (i < 0)
+ }
+ if (i < 0) {
i += self->prop->len;
+ }
return BPy_IDArray_GetItem(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) {
return NULL;
+ }
if (slicelength <= 0) {
return PyTuple_New(0);
@@ -1481,20 +1503,24 @@ static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject
{
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return -1;
- if (i < 0)
+ }
+ if (i < 0) {
i += self->prop->len;
+ }
return BPy_IDArray_SetItem(self, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) {
return -1;
+ }
- if (step == 1)
+ if (step == 1) {
return BPy_IDArray_ass_slice(self, start, stop, value);
+ }
else {
PyErr_SetString(PyExc_TypeError, "slice steps not supported with vectors");
return -1;
@@ -1516,9 +1542,9 @@ static PyMappingMethods BPy_IDArray_AsMapping = {
static int itemsize_by_idarray_type(int array_type)
{
- if (array_type == IDP_INT) return sizeof(int);
- if (array_type == IDP_FLOAT) return sizeof(float);
- if (array_type == IDP_DOUBLE) return sizeof(double);
+ if (array_type == IDP_INT) { return sizeof(int); }
+ if (array_type == IDP_FLOAT) { return sizeof(float); }
+ if (array_type == IDP_DOUBLE) { return sizeof(double); }
return -1; /* should never happen */
}
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index f18e794ead3..0c10737609c 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -319,8 +319,12 @@ void PyC_FileAndNum(const char **filename, int *lineno)
{
PyFrameObject *frame;
- if (filename) *filename = NULL;
- if (lineno) *lineno = -1;
+ if (filename) {
+ *filename = NULL;
+ }
+ if (lineno) {
+ *lineno = -1;
+ }
if (!(frame = PyThreadState_GET()->frame)) {
return;
@@ -384,10 +388,13 @@ PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...)
attr = va_arg(vargs, char *);
item = PyObject_GetAttrString(item, attr);
- if (item)
+ if (item) {
Py_DECREF(item);
- else /* python will set the error value here */
+ }
+ else {
+ /* python will set the error value here */
break;
+ }
}
va_end(vargs);
@@ -527,8 +534,9 @@ PyObject *PyC_ExceptionBuffer(void)
PyObject *error_type, *error_value, *error_traceback;
- if (!PyErr_Occurred())
+ if (!PyErr_Occurred()) {
return NULL;
+ }
PyErr_Fetch(&error_type, &error_value, &error_traceback);
@@ -593,8 +601,9 @@ PyObject *PyC_ExceptionBuffer_Simple(void)
PyObject *error_type, *error_value, *error_traceback;
- if (!PyErr_Occurred())
+ if (!PyErr_Occurred()) {
return NULL;
+ }
PyErr_Fetch(&error_type, &error_value, &error_traceback);
@@ -775,9 +784,10 @@ void PyC_SetHomePath(const char *py_path_bundle)
#ifdef __APPLE__
/* OSX allow file/directory names to contain : character (represented as / in the Finder)
* but current Python lib (release 3.1.1) doesn't handle these correctly */
- if (strchr(py_path_bundle, ':'))
+ if (strchr(py_path_bundle, ':')) {
printf("Warning : Blender application is located in a path containing : or / chars\
\nThis may make python import function fail\n");
+ }
#endif
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index 4027edbb0f9..cd9e162b1aa 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -52,10 +52,9 @@
#include "gpu_py_offscreen.h" /* own include */
- /* -------------------------------------------------------------------- */
-
- /** \name GPUOffScreen Common Utilities
- * \{ */
+/* -------------------------------------------------------------------- */
+/** \name GPUOffScreen Common Utilities
+ * \{ */
static int bpygpu_offscreen_valid_check(BPyGPUOffScreen *bpygpu_ofs)
{
@@ -260,6 +259,7 @@ static PyObject *bpygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *a
true,
"",
NULL,
+ true,
self->ofs,
NULL);
@@ -299,8 +299,9 @@ static PyObject *bpygpu_offscreen_bind_context_exit(BPyGPUOffScreen *self, PyObj
static void BPyGPUOffScreen__tp_dealloc(BPyGPUOffScreen *self)
{
- if (self->ofs)
+ if (self->ofs) {
GPU_offscreen_free(self->ofs);
+ }
Py_TYPE(self)->tp_free((PyObject *)self);
}
diff --git a/source/blender/python/gpu/gpu_py_types.c b/source/blender/python/gpu/gpu_py_types.c
index 7ed1832eb57..67bdc070168 100644
--- a/source/blender/python/gpu/gpu_py_types.c
+++ b/source/blender/python/gpu/gpu_py_types.c
@@ -45,18 +45,24 @@ PyObject *BPyInit_gpu_types(void)
submodule = PyModule_Create(&BPyGPU_types_module_def);
- if (PyType_Ready(&BPyGPUVertFormat_Type) < 0)
+ if (PyType_Ready(&BPyGPUVertFormat_Type) < 0) {
return NULL;
- if (PyType_Ready(&BPyGPUVertBuf_Type) < 0)
+ }
+ if (PyType_Ready(&BPyGPUVertBuf_Type) < 0) {
return NULL;
- if (PyType_Ready(&BPyGPUIndexBuf_Type) < 0)
+ }
+ if (PyType_Ready(&BPyGPUIndexBuf_Type) < 0) {
return NULL;
- if (PyType_Ready(&BPyGPUBatch_Type) < 0)
+ }
+ if (PyType_Ready(&BPyGPUBatch_Type) < 0) {
return NULL;
- if (PyType_Ready(&BPyGPUOffScreen_Type) < 0)
+ }
+ if (PyType_Ready(&BPyGPUOffScreen_Type) < 0) {
return NULL;
- if (PyType_Ready(&BPyGPUShader_Type) < 0)
+ }
+ if (PyType_Ready(&BPyGPUShader_Type) < 0) {
return NULL;
+ }
#define MODULE_TYPE_ADD(s, t) \
PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t)
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 05b471c4db7..f67ed1a3713 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -126,9 +126,15 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
return NULL;
}
- if (absolute) flag |= BKE_BPATH_TRAVERSE_ABS;
- if (!packed) flag |= BKE_BPATH_TRAVERSE_SKIP_PACKED;
- if (local) flag |= BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
+ if (absolute) {
+ flag |= BKE_BPATH_TRAVERSE_ABS;
+ }
+ if (!packed) {
+ flag |= BKE_BPATH_TRAVERSE_SKIP_PACKED;
+ }
+ if (local) {
+ flag |= BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
+ }
list = PyList_New(0);
@@ -157,20 +163,17 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
}
/* stupid string compare */
- if (STREQ(type, "DATAFILES")) folder_id = BLENDER_USER_DATAFILES;
- else if (STREQ(type, "CONFIG")) folder_id = BLENDER_USER_CONFIG;
- else if (STREQ(type, "SCRIPTS")) folder_id = BLENDER_USER_SCRIPTS;
- else if (STREQ(type, "AUTOSAVE")) folder_id = BLENDER_USER_AUTOSAVE;
+ if (STREQ(type, "DATAFILES")) { folder_id = BLENDER_USER_DATAFILES; }
+ else if (STREQ(type, "CONFIG")) { folder_id = BLENDER_USER_CONFIG; }
+ else if (STREQ(type, "SCRIPTS")) { folder_id = BLENDER_USER_SCRIPTS; }
+ else if (STREQ(type, "AUTOSAVE")) { folder_id = BLENDER_USER_AUTOSAVE; }
else {
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
return NULL;
}
/* same logic as BKE_appdir_folder_id_create(), but best leave it up to the script author to create */
- path = BKE_appdir_folder_id(folder_id, subdir);
-
- if (!path)
- path = BKE_appdir_folder_id_user_notest(folder_id, subdir);
+ path = BKE_appdir_folder_id_user_notest(folder_id, subdir);
return PyC_UnicodeFromByte(path ? path : "");
}
@@ -206,9 +209,9 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
}
/* stupid string compare */
- if (STREQ(type, "USER")) folder_id = BLENDER_RESOURCE_PATH_USER;
- else if (STREQ(type, "LOCAL")) folder_id = BLENDER_RESOURCE_PATH_LOCAL;
- else if (STREQ(type, "SYSTEM")) folder_id = BLENDER_RESOURCE_PATH_SYSTEM;
+ if (STREQ(type, "USER")) { folder_id = BLENDER_RESOURCE_PATH_USER; }
+ else if (STREQ(type, "LOCAL")) { folder_id = BLENDER_RESOURCE_PATH_LOCAL; }
+ else if (STREQ(type, "SYSTEM")) { folder_id = BLENDER_RESOURCE_PATH_SYSTEM; }
else {
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
return NULL;
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 252fd1b3e23..2cd3086dae1 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -253,8 +253,12 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *clos
return -1;
}
- if (param) G.debug |= flag;
- else G.debug &= ~flag;
+ if (param) {
+ G.debug |= flag;
+ }
+ else {
+ G.debug &= ~flag;
+ }
return 0;
}
@@ -278,8 +282,12 @@ static int bpy_app_global_flag_set(PyObject *UNUSED(self), PyObject *value, void
return -1;
}
- if (param) G.f |= flag;
- else G.f &= ~flag;
+ if (param) {
+ G.f |= flag;
+ }
+ else {
+ G.f &= ~flag;
+ }
return 0;
}
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index b6b9f294810..c91c0d69a16 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -90,8 +90,9 @@ static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type), PyO
{
PyObject *value;
- if (!PyArg_ParseTuple(args, "O:bpy.app.handlers.persistent", &value))
+ if (!PyArg_ParseTuple(args, "O:bpy.app.handlers.persistent", &value)) {
return NULL;
+ }
if (PyFunction_Check(value)) {
PyObject **dict_ptr = _PyObject_GetDictPtr(value);
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index 1ed68201a2e..f571caee8ec 100644
--- a/source/blender/python/intern/bpy_app_translations.c
+++ b/source/blender/python/intern/bpy_app_translations.c
@@ -89,8 +89,9 @@ static bool _ghashutil_keycmp(const void *a, const void *b)
const GHashKey *B = b;
/* Note: comparing msgid first, most of the time it will be enough! */
- if (BLI_ghashutil_strcmp(A->msgid, B->msgid) == false)
+ if (BLI_ghashutil_strcmp(A->msgid, B->msgid) == false) {
return BLI_ghashutil_strcmp(A->msgctxt, B->msgctxt);
+ }
return true; /* true means they are not equal! */
}
@@ -249,8 +250,9 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms
const char *tmp;
/* Just in case, should never happen! */
- if (!_translations)
+ if (!_translations) {
return msgid;
+ }
tmp = BLT_lang_get();
if (!STREQ(tmp, locale) || !_translations_cache) {
@@ -458,8 +460,9 @@ static PyObject *app_translations_locales_get(PyObject *UNUSED(self), void *UNUS
if (items) {
/* This is not elegant, but simple! */
for (it = items; it->identifier; it++) {
- if (it->value)
+ if (it->value) {
num_locales++;
+ }
}
}
@@ -467,8 +470,9 @@ static PyObject *app_translations_locales_get(PyObject *UNUSED(self), void *UNUS
if (items) {
for (it = items; it->identifier; it++) {
- if (it->value)
+ if (it->value) {
PyTuple_SET_ITEM(ret, pos++, PyUnicode_FromString(it->description));
+ }
}
}
@@ -801,8 +805,9 @@ PyObject *BPY_app_translations_struct(void)
PyStructSequence_InitType(&BlenderAppTranslationsContextsType, &app_translations_contexts_desc);
}
- if (PyType_Ready(&BlenderAppTranslationsType) < 0)
+ if (PyType_Ready(&BlenderAppTranslationsType) < 0) {
return NULL;
+ }
ret = PyObject_CallObject((PyObject *)&BlenderAppTranslationsType, NULL);
diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.c
index 4c0d220d3d9..549a06f5b28 100644
--- a/source/blender/python/intern/bpy_capi_utils.c
+++ b/source/blender/python/intern/bpy_capi_utils.c
@@ -48,8 +48,9 @@ char *BPy_enum_as_string(const EnumPropertyItem *item)
char *cstring;
for (e = item; item->identifier; item++) {
- if (item->identifier[0])
+ if (item->identifier[0]) {
BLI_dynstr_appendf(dynstr, (e == item) ? "'%s'" : ", '%s'", item->identifier);
+ }
}
cstring = BLI_dynstr_get_cstring(dynstr);
@@ -75,13 +76,27 @@ short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool
return (report_str == NULL) ? 0 : -1;
}
+/**
+ * A version of #BKE_report_write_file_fp that uses Python's stdout.
+ */
+void BPy_reports_write_stdout(const ReportList *reports, const char *header)
+{
+ if (header) {
+ PySys_WriteStdout("%s\n", header);
+ }
+
+ for (const Report *report = reports->list.first; report; report = report->next) {
+ PySys_WriteStdout("%s: %s\n", report->typestr, report->message);
+ }
+}
bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const bool use_location)
{
PyObject *pystring;
- if (!PyErr_Occurred())
+ if (!PyErr_Occurred()) {
return 1;
+ }
/* less hassle if we allow NULL */
if (reports == NULL) {
diff --git a/source/blender/python/intern/bpy_capi_utils.h b/source/blender/python/intern/bpy_capi_utils.h
index 533ff0fb7c2..f8d42b463ac 100644
--- a/source/blender/python/intern/bpy_capi_utils.h
+++ b/source/blender/python/intern/bpy_capi_utils.h
@@ -34,6 +34,7 @@ char *BPy_enum_as_string(const struct EnumPropertyItem *item);
/* error reporting */
short BPy_reports_to_error(struct ReportList *reports, PyObject *exception, const bool clear);
+void BPy_reports_write_stdout(const struct ReportList *reports, const char *header);
bool BPy_errors_to_report_ex(struct ReportList *reports, const bool use_full, const bool use_location);
bool BPy_errors_to_report(struct ReportList *reports);
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index 425a8a29cf9..cb23739ca33 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -31,6 +31,7 @@
#include "BLI_listbase.h"
#include "BLI_math_base.h"
+#include "BLI_string.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
@@ -68,13 +69,17 @@ int bpy_pydriver_create_dict(void)
PyObject *d, *mod;
/* validate namespace for driver evaluation */
- if (bpy_pydriver_Dict) return -1;
+ if (bpy_pydriver_Dict) {
+ return -1;
+ }
d = PyDict_New();
- if (d == NULL)
+ if (d == NULL) {
return -1;
- else
+ }
+ else {
bpy_pydriver_Dict = d;
+ }
/* import some modules: builtins, bpy, math, (Blender.noise)*/
PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins());
@@ -204,8 +209,9 @@ void BPY_driver_reset(void)
PyGILState_STATE gilstate;
bool use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */
PyDict_Clear(bpy_pydriver_Dict);
@@ -226,8 +232,9 @@ void BPY_driver_reset(void)
/* freed when clearing driver dict */
g_pydriver_state_prev.self = NULL;
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
return;
}
@@ -332,7 +339,7 @@ static bool bpy_driver_secure_bytecode_validate(PyObject *expr_code, PyObject *d
}
if (contains_name == false) {
- fprintf(stderr, "\tBPY_driver_eval() - restructed access disallows name '%s', "
+ fprintf(stderr, "\tBPY_driver_eval() - restricted access disallows name '%s', "
"enable auto-execution to support\n", _PyUnicode_AsString(name));
return false;
}
@@ -350,7 +357,7 @@ static bool bpy_driver_secure_bytecode_validate(PyObject *expr_code, PyObject *d
for (Py_ssize_t i = 0; i < code_len; i++) {
const int opcode = _Py_OPCODE(codestr[i]);
if (secure_opcodes[opcode] == 0) {
- fprintf(stderr, "\tBPY_driver_eval() - restructed access disallows opcode '%d', "
+ fprintf(stderr, "\tBPY_driver_eval() - restricted access disallows opcode '%d', "
"enable auto-execution to support\n", opcode);
return false;
}
@@ -398,8 +405,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
/* get the py expression to be evaluated */
expr = driver_orig->expression;
- if (expr[0] == '\0')
+ if (expr[0] == '\0') {
return 0.0f;
+ }
#ifndef USE_BYTECODE_WHITELIST
if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC)) {
@@ -417,8 +425,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
/* needed since drivers are updated directly after undo where 'main' is
* re-allocated [#28807] */
@@ -428,8 +437,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
if (!bpy_pydriver_Dict) {
if (bpy_pydriver_create_dict() != 0) {
fprintf(stderr, "PyDriver error: couldn't create Python dictionary\n");
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
return 0.0f;
}
}
@@ -444,8 +454,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
bpy_pydriver_namespace_clear_self();
}
- if (driver_orig->expr_comp == NULL)
+ if (driver_orig->expr_comp == NULL) {
driver_orig->flag |= DRIVER_FLAG_RECOMPILE;
+ }
/* compile the expression first if it hasn't been compiled or needs to be rebuilt */
if (driver_orig->flag & DRIVER_FLAG_RECOMPILE) {
@@ -552,6 +563,11 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
NULL,}
))
{
+ if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET)) {
+ G.f |= G_FLAG_SCRIPT_AUTOEXEC_FAIL;
+ BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Driver '%s'", expr);
+ }
+
Py_DECREF(expr_code);
expr_code = NULL;
PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 0, NULL);
@@ -565,8 +581,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
retval = PyRun_String(expr, Py_eval_input, bpy_pydriver_Dict, driver_vars);
#else
/* evaluate the compiled expression */
- if (expr_code)
+ if (expr_code) {
retval = PyEval_EvalCode((void *)expr_code, bpy_pydriver_Dict, driver_vars);
+ }
#endif
/* decref the driver vars first... */
@@ -587,8 +604,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, C
Py_DECREF(retval);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (isfinite(result)) {
return (float)result;
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 189fb97f3d2..e07e39642e9 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -98,8 +98,9 @@ void BPY_context_update(bContext *C)
/* don't do this from a non-main (e.g. render) thread, it can cause a race
* condition on C->data.recursion. ideal solution would be to disable
* context entirely from non-main threads, but that's more complicated */
- if (!BLI_thread_is_main())
+ if (!BLI_thread_is_main()) {
return;
+ }
BPy_SetContext(C);
bpy_import_main_set(CTX_data_main(C));
@@ -110,8 +111,9 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
{
py_call_level++;
- if (gilstate)
+ if (gilstate) {
*gilstate = PyGILState_Ensure();
+ }
if (py_call_level == 1) {
BPY_context_update(C);
@@ -135,8 +137,9 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
{
py_call_level--;
- if (gilstate)
+ if (gilstate) {
PyGILState_Release(*gilstate);
+ }
if (py_call_level < 0) {
fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n");
@@ -163,14 +166,16 @@ void BPY_text_free_code(Text *text)
PyGILState_STATE gilstate;
bool use_gil = !PyC_IsInterpreterActive();
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
Py_DECREF((PyObject *)text->compiled);
text->compiled = NULL;
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
}
}
@@ -184,8 +189,9 @@ void BPY_modules_update(bContext *C)
/* refreshes the main struct */
BPY_update_rna_module();
- if (bpy_context_module)
+ if (bpy_context_module) {
bpy_context_module->ptr.data = (void *)C;
+ }
}
void BPY_context_set(bContext *C)
@@ -371,11 +377,13 @@ void BPY_python_end(void)
printf("*bpy stats* - ");
printf("tot exec: %d, ", bpy_timer_count);
printf("tot run: %.4fsec, ", bpy_timer_run_tot);
- if (bpy_timer_count > 0)
+ if (bpy_timer_count > 0) {
printf("average run: %.6fsec, ", (bpy_timer_run_tot / bpy_timer_count));
+ }
- if (bpy_timer > 0.0)
+ if (bpy_timer > 0.0) {
printf("tot usage %.4f%%", (bpy_timer_run_tot / bpy_timer) * 100.0);
+ }
printf("\n");
@@ -750,8 +758,9 @@ void BPY_modules_load_user(bContext *C)
Text *text;
/* can happen on file load */
- if (bmain == NULL)
+ if (bmain == NULL) {
return;
+ }
/* update pointers since this can run from a nested script
* on file load */
@@ -802,8 +811,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
PointerRNA *ptr = NULL;
bool done = false;
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
pyctx = (PyObject *)CTX_py_dict_get(C);
item = PyDict_GetItemString(pyctx, member);
@@ -870,8 +880,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
CLOG_INFO(BPY_LOG_CONTEXT, 2, "'%s' found", member);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
return done;
}
@@ -971,8 +982,9 @@ PyInit_bpy(void)
dealloc_obj_Type.tp_dealloc = dealloc_obj_dealloc;
dealloc_obj_Type.tp_flags = Py_TPFLAGS_DEFAULT;
- if (PyType_Ready(&dealloc_obj_Type) < 0)
+ if (PyType_Ready(&dealloc_obj_Type) < 0) {
return NULL;
+ }
dob = (dealloc_obj *) dealloc_obj_Type.tp_alloc(&dealloc_obj_Type, 0);
dob->mod = bpy_proxy; /* borrow */
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index bf12db0f3a1..77fb6bf1525 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -476,8 +476,9 @@ int BPY_library_load_module(PyObject *mod_par)
/* some compilers don't like accessing this directly, delay assignment */
bpy_lib_Type.tp_getattro = PyObject_GenericGetAttr;
- if (PyType_Ready(&bpy_lib_Type) < 0)
+ if (PyType_Ready(&bpy_lib_Type) < 0) {
return -1;
+ }
return 0;
}
diff --git a/source/blender/python/intern/bpy_library_write.c b/source/blender/python/intern/bpy_library_write.c
index 3b2afb42cdb..7b7457bc4b3 100644
--- a/source/blender/python/intern/bpy_library_write.c
+++ b/source/blender/python/intern/bpy_library_write.c
@@ -57,7 +57,7 @@ PyDoc_STRVAR(bpy_lib_write_doc,
" :type filepath: string\n"
" :arg datablocks: set of data-blocks (:class:`bpy.types.ID` instances).\n"
" :type datablocks: set\n"
-" :arg relative_remap: When True, remap the paths relative to the current blend-file.\n"
+" :arg relative_remap: When True, make paths relative to the current blend-file.\n"
" :type relative_remap: bool\n"
" :arg fake_user: When True, data-blocks will be written with fake-user flag enabled.\n"
" :type fake_user: bool\n"
diff --git a/source/blender/python/intern/bpy_msgbus.c b/source/blender/python/intern/bpy_msgbus.c
index 0fedb379a49..bfcf089fb60 100644
--- a/source/blender/python/intern/bpy_msgbus.c
+++ b/source/blender/python/intern/bpy_msgbus.c
@@ -215,11 +215,16 @@ static void bpy_msgbus_subscribe_value_free_data(
* \{ */
PyDoc_STRVAR(bpy_msgbus_subscribe_rna_doc,
-".. function:: subscribe_rna(data, owner, args, notify)\n"
+".. function:: subscribe_rna(data, owner, args, notify, options=set())\n"
"\n"
BPY_MSGBUS_RNA_MSGKEY_DOC
" :arg owner: Handle for this subscription (compared by identity).\n"
" :type owner: Any type.\n"
+" :arg options: Change the behavior of the subscriber.\n"
+"\n"
+" - ``PERSISTENT`` when set, the subscriber will be kept when remapping ID data.\n"
+"\n"
+" :type options: set of str.\n"
"\n"
" Returns a new vector int property definition.\n"
);
@@ -241,6 +246,13 @@ static PyObject *bpy_msgbus_subscribe_rna(PyObject *UNUSED(self), PyObject *args
};
int options = 0;
+ if (PyTuple_GET_SIZE(args) != 0) {
+ PyErr_Format(
+ PyExc_TypeError,
+ "%s: only keyword arguments are supported",
+ error_prefix);
+ return NULL;
+ }
static const char *_keywords[] = {
"key",
"owner",
@@ -249,7 +261,7 @@ static PyObject *bpy_msgbus_subscribe_rna(PyObject *UNUSED(self), PyObject *args
"options",
NULL,
};
- static _PyArg_Parser _parser = {"$OOO!O|O!:subscribe_rna", _keywords, 0};
+ static _PyArg_Parser _parser = {"OOO!O|O!:subscribe_rna", _keywords, 0};
if (!_PyArg_ParseTupleAndKeywordsFast(
args, kw, &_parser,
&py_sub, &py_owner,
@@ -330,11 +342,18 @@ static PyObject *bpy_msgbus_publish_rna(PyObject *UNUSED(self), PyObject *args,
const char *error_prefix = "publish_rna";
PyObject *py_sub = NULL;
+ if (PyTuple_GET_SIZE(args) != 0) {
+ PyErr_Format(
+ PyExc_TypeError,
+ "%s: only keyword arguments are supported",
+ error_prefix);
+ return NULL;
+ }
static const char *_keywords[] = {
"key",
NULL,
};
- static _PyArg_Parser _parser = {"$O:publish_rna", _keywords, 0};
+ static _PyArg_Parser _parser = {"O:publish_rna", _keywords, 0};
if (!_PyArg_ParseTupleAndKeywordsFast(
args, kw, &_parser,
&py_sub))
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index ecae71d07e3..ff6bd3840e9 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -93,8 +93,9 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
- if (!PyArg_ParseTuple(args, "s|Os:_bpy.ops.poll", &opname, &context_dict, &context_str))
+ if (!PyArg_ParseTuple(args, "s|Os:_bpy.ops.poll", &opname, &context_dict, &context_str)) {
return NULL;
+ }
ot = WM_operatortype_find(opname, true);
@@ -262,10 +263,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
/* operator output is nice to have in the terminal/console too */
if (!BLI_listbase_is_empty(&reports->list)) {
- Report *report;
- for (report = reports->list.first; report; report = report->next) {
- PySys_WriteStdout("%s: %s\n", report->typestr, report->message);
- }
+ BPy_reports_write_stdout(reports, NULL);
}
BKE_reports_clear(reports);
@@ -365,8 +363,9 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
error_val = pyrna_pydict_to_props(&ptr, kw, false, "Converting py args to operator properties: ");
}
- if (error_val == 0)
+ if (error_val == 0) {
buf = WM_operator_pystring_ex(C, NULL, all_args, macro_args, ot, &ptr);
+ }
WM_operator_properties_free(&ptr);
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 6f1450fcbc2..6a130a7c52b 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -162,8 +162,9 @@ PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args)
const char *opname;
const char *macroname;
- if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", &macro, &opname))
+ if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", &macro, &opname)) {
return NULL;
+ }
if (WM_operatortype_find(opname, true) == NULL) {
PyErr_Format(PyExc_ValueError,
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 385b02f231e..18a39f39e70 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -201,10 +201,12 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw)
PyTuple_SET_ITEM(ret, 0, func);
Py_INCREF(func);
- if (kw == NULL)
+ if (kw == NULL) {
kw = PyDict_New();
- else
+ }
+ else {
Py_INCREF(kw);
+ }
PyTuple_SET_ITEM(ret, 1, kw);
@@ -282,8 +284,9 @@ static bool bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -313,8 +316,9 @@ static bool bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -342,8 +346,9 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -369,8 +374,9 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -395,8 +401,9 @@ static bool bpy_prop_poll_cb(struct PointerRNA *self, PointerRNA candidate, stru
py_candidate = pyrna_struct_as_instance(&candidate);
py_func = py_data[BPY_DATA_CB_SLOT_POLL];
- if (!is_write_ok)
+ if (!is_write_ok) {
pyrna_write_set(true);
+ }
args = PyTuple_New(2);
PyTuple_SET_ITEM(args, 0, py_self);
@@ -416,8 +423,9 @@ static bool bpy_prop_poll_cb(struct PointerRNA *self, PointerRNA candidate, stru
}
PyGILState_Release(gilstate);
- if (!is_write_ok)
+ if (!is_write_ok) {
pyrna_write_set(false);
+ }
return result;
}
@@ -442,8 +450,9 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -458,15 +467,17 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
if (ret == NULL) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = false;
+ }
}
else {
if (PyC_AsArray(values, ret, len, &PyBool_Type, false, "BoolVectorProperty get") == -1) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = false;
+ }
/* PyC_AsArray decrements refcount internally on error */
}
@@ -475,8 +486,9 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
}
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -504,8 +516,9 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -532,8 +545,9 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -560,8 +574,9 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -588,8 +603,9 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -617,8 +633,9 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -644,8 +661,9 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -672,8 +690,9 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -688,15 +707,17 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
if (ret == NULL) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = 0;
+ }
}
else {
if (PyC_AsArray(values, ret, len, &PyLong_Type, false, "IntVectorProperty get") == -1) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = 0;
+ }
/* PyC_AsArray decrements refcount internally on error */
}
@@ -705,8 +726,9 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
}
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -734,8 +756,9 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -762,8 +785,9 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -790,8 +814,9 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -818,8 +843,9 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -847,8 +873,9 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -874,8 +901,9 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -902,8 +930,9 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -918,15 +947,17 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
if (ret == NULL) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = 0.0f;
+ }
}
else {
if (PyC_AsArray(values, ret, len, &PyFloat_Type, false, "FloatVectorProperty get") == -1) {
PyC_Err_PrintWithFunc(py_func);
- for (i = 0; i < len; ++i)
+ for (i = 0; i < len; ++i) {
values[i] = 0.0f;
+ }
/* PyC_AsArray decrements refcount internally on error */
}
@@ -935,8 +966,9 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
}
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -964,8 +996,9 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -992,8 +1025,9 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1019,8 +1053,9 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -1051,8 +1086,9 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1079,8 +1115,9 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -1111,8 +1148,9 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1141,8 +1179,9 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -1155,8 +1194,9 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
PyErr_SetString(PyExc_ValueError, "the return value must be a string");
PyC_Err_PrintWithFunc(py_func);
}
- else
+ else {
PyTuple_SET_ITEM(args, 1, py_value);
+ }
ret = PyObject_CallObject(py_func, args);
@@ -1174,8 +1214,9 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1202,8 +1243,9 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_GET];
@@ -1230,8 +1272,9 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1259,8 +1302,9 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
use_gil = true; /* !PyC_IsInterpreterActive(); */
- if (use_gil)
+ if (use_gil) {
gilstate = PyGILState_Ensure();
+ }
py_func = py_data[BPY_DATA_CB_SLOT_SET];
@@ -1286,8 +1330,9 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
Py_DECREF(ret);
}
- if (use_gil)
+ if (use_gil) {
PyGILState_Release(gilstate);
+ }
if (!is_write_ok) {
pyrna_write_set(false);
@@ -1423,8 +1468,9 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *
}
}
- if (tmp_icon)
+ if (tmp_icon) {
tmp.icon = icon_id_from_name(tmp_icon);
+ }
items[i] = tmp;
@@ -2139,8 +2185,9 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
return NULL;
}
- if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, false, "BoolVectorProperty(default=sequence)") == -1)
+ if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, false, "BoolVectorProperty(default=sequence)") == -1) {
return NULL;
+ }
if (bpy_prop_callback_check(update_cb, "update", 2) == -1) {
return NULL;
@@ -2155,7 +2202,9 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
// prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name ? name : id, description);
prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
RNA_def_property_array(prop, size);
- if (pydef) RNA_def_property_boolean_array_default(prop, def);
+ if (pydef) {
+ RNA_def_property_boolean_array_default(prop, def);
+ }
RNA_def_property_ui_text(prop, name ? name : id, description);
if (py_tags) {
@@ -2366,8 +2415,9 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
return NULL;
}
- if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, false, "IntVectorProperty(default=sequence)") == -1)
+ if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, false, "IntVectorProperty(default=sequence)") == -1) {
return NULL;
+ }
if (bpy_prop_callback_check(update_cb, "update", 2) == -1) {
return NULL;
@@ -2381,7 +2431,9 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
prop = RNA_def_property(srna, id, PROP_INT, subtype);
RNA_def_property_array(prop, size);
- if (pydef) RNA_def_property_int_array_default(prop, def);
+ if (pydef) {
+ RNA_def_property_int_array_default(prop, def);
+ }
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
@@ -2618,8 +2670,9 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
return NULL;
}
- if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, false, "FloatVectorProperty(default=sequence)") == -1)
+ if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, false, "FloatVectorProperty(default=sequence)") == -1) {
return NULL;
+ }
if (bpy_prop_callback_check(update_cb, "update", 2) == -1) {
return NULL;
@@ -2633,7 +2686,9 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
prop = RNA_def_property(srna, id, PROP_FLOAT, subtype | unit);
RNA_def_property_array(prop, size);
- if (pydef) RNA_def_property_float_array_default(prop, def);
+ if (pydef) {
+ RNA_def_property_float_array_default(prop, def);
+ }
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
@@ -2728,8 +2783,12 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
}
prop = RNA_def_property(srna, id, PROP_STRING, subtype);
- if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
- if (def && def[0]) RNA_def_property_string_default(prop, def);
+ if (maxlen != 0) {
+ RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
+ }
+ if (def && def[0]) {
+ RNA_def_property_string_default(prop, def);
+ }
RNA_def_property_ui_text(prop, name ? name : id, description);
if (py_tags) {
@@ -2890,8 +2949,12 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
}
}
- if (opts & PROP_ENUM_FLAG) prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description);
- else prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description);
+ if (opts & PROP_ENUM_FLAG) {
+ prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description);
+ }
+ else {
+ prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description);
+ }
if (py_tags) {
RNA_def_property_tags(prop, prop_tags);
@@ -2994,8 +3057,9 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_CHECK(PointerProperty, property_flag_items);
ptype = pointer_type_from_py(type, "PointerProperty(...)");
- if (!ptype)
+ if (!ptype) {
return NULL;
+ }
if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup) && !RNA_struct_is_ID(ptype)) {
PyErr_Format(PyExc_TypeError,
"PointerProperty(...) expected an RNA type derived from %.200s or %.200s",
@@ -3077,8 +3141,9 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items);
ptype = pointer_type_from_py(type, "CollectionProperty(...):");
- if (!ptype)
+ if (!ptype) {
return NULL;
+ }
if (!RNA_struct_is_a(ptype, &RNA_PropertyGroup)) {
PyErr_Format(
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index cb1555f8cc4..f695464ec42 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -314,8 +314,12 @@ static bool rna_id_write_error(PointerRNA *ptr, PyObject *key)
if (!ELEM(idcode, ID_WM, ID_SCR, ID_WS)) { /* may need more added here */
const char *idtype = BKE_idcode_to_name(idcode);
const char *pyname;
- if (key && PyUnicode_Check(key)) pyname = _PyUnicode_AsString(key);
- else pyname = "<UNKNOWN>";
+ if (key && PyUnicode_Check(key)) {
+ pyname = _PyUnicode_AsString(key);
+ }
+ else {
+ pyname = "<UNKNOWN>";
+ }
/* make a nice string error */
BLI_assert(idtype != NULL);
@@ -392,8 +396,9 @@ static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype)
PYRNA_PROP_CHECK_INT(self);
- if (self->prop == NULL)
+ if (self->prop == NULL) {
return -1;
+ }
RNA_property_float_get_array(&self->ptr, self->prop, bmo->data);
@@ -414,8 +419,9 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
PYRNA_PROP_CHECK_INT(self);
- if (self->prop == NULL)
+ if (self->prop == NULL) {
return -1;
+ }
#ifdef USE_PEDANTIC_WRITE
if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
@@ -465,8 +471,9 @@ static int mathutils_rna_vector_get_index(BaseMathObject *bmo, int UNUSED(subtyp
PYRNA_PROP_CHECK_INT(self);
- if (self->prop == NULL)
+ if (self->prop == NULL) {
return -1;
+ }
bmo->data[index] = RNA_property_float_get_index(&self->ptr, self->prop, index);
return 0;
@@ -478,8 +485,9 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
PYRNA_PROP_CHECK_INT(self);
- if (self->prop == NULL)
+ if (self->prop == NULL) {
return -1;
+ }
#ifdef USE_PEDANTIC_WRITE
if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
@@ -522,8 +530,9 @@ static int mathutils_rna_matrix_get(BaseMathObject *bmo, int UNUSED(subtype))
PYRNA_PROP_CHECK_INT(self);
- if (self->prop == NULL)
+ if (self->prop == NULL) {
return -1;
+ }
RNA_property_float_get_array(&self->ptr, self->prop, bmo->data);
return 0;
@@ -535,8 +544,9 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
PYRNA_PROP_CHECK_INT(self);
- if (self->prop == NULL)
+ if (self->prop == NULL) {
return -1;
+ }
#ifdef USE_PEDANTIC_WRITE
if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
@@ -639,8 +649,10 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
totdim = RNA_property_array_dimension(ptr, prop, NULL);
if (totdim == 1 || (totdim == 2 && subtype == PROP_MATRIX)) {
- if (!is_thick)
- ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
+ if (!is_thick) {
+ /* owned by the mathutils PyObject */
+ ret = pyrna_prop_CreatePyObject(ptr, prop);
+ }
switch (subtype) {
case PROP_ALL_VECTOR_SUBTYPES:
@@ -801,8 +813,9 @@ static PyObject *pyrna_struct_richcmp(PyObject *a, PyObject *b, int op)
PyObject *res;
int ok = -1; /* zero is true */
- if (BPy_StructRNA_Check(a) && BPy_StructRNA_Check(b))
+ if (BPy_StructRNA_Check(a) && BPy_StructRNA_Check(b)) {
ok = pyrna_struct_compare((BPy_StructRNA *)a, (BPy_StructRNA *)b);
+ }
switch (op) {
case Py_NE:
@@ -831,8 +844,9 @@ static PyObject *pyrna_prop_richcmp(PyObject *a, PyObject *b, int op)
PyObject *res;
int ok = -1; /* zero is true */
- if (BPy_PropertyRNA_Check(a) && BPy_PropertyRNA_Check(b))
+ if (BPy_PropertyRNA_Check(a) && BPy_PropertyRNA_Check(b)) {
ok = pyrna_prop_compare((BPy_PropertyRNA *)a, (BPy_PropertyRNA *)b);
+ }
switch (op) {
case Py_NE:
@@ -888,8 +902,10 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
PyObject *tmp_str;
PyObject *ret;
- if (id == NULL || !PYRNA_STRUCT_IS_VALID(self))
- return pyrna_struct_str(self); /* fallback */
+ if (id == NULL || !PYRNA_STRUCT_IS_VALID(self)) {
+ /* fallback */
+ return pyrna_struct_str(self);
+ }
tmp_str = PyUnicode_FromString(id->name + 2);
@@ -959,8 +975,9 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
len = pyrna_prop_array_length((BPy_PropertyArrayRNA *)self);
}
- if (len != -1)
+ if (len != -1) {
sprintf(--c, "[%d]", len);
+ }
}
/* if a pointer, try to print name of pointer target too */
@@ -1004,8 +1021,10 @@ static PyObject *pyrna_prop_repr_ex(
PYRNA_PROP_CHECK_OBJ(self);
- if (id == NULL)
- return pyrna_prop_str(self); /* fallback */
+ if (id == NULL) {
+ /* fallback */
+ return pyrna_prop_str(self);
+ }
tmp_str = PyUnicode_FromString(id->name + 2);
@@ -1066,19 +1085,23 @@ static Py_hash_t pyrna_struct_hash(BPy_StructRNA *self)
static long pyrna_prop_hash(BPy_PropertyRNA *self)
{
long x, y;
- if (self->ptr.data == NULL)
+ if (self->ptr.data == NULL) {
x = 0;
+ }
else {
x = _Py_HashPointer(self->ptr.data);
- if (x == -1)
+ if (x == -1) {
return -1;
+ }
}
y = _Py_HashPointer((void *)(self->prop));
- if (y == -1)
+ if (y == -1) {
return -1;
+ }
x ^= y;
- if (x == -1)
+ if (x == -1) {
x = -2;
+ }
return x;
}
@@ -1425,8 +1448,9 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
PyErr_Warn(PyExc_RuntimeWarning, error_str);
#endif
- if (ptr_name)
+ if (ptr_name) {
MEM_freeN((void *)ptr_name);
+ }
}
ret = PyUnicode_FromString("");
@@ -1582,7 +1606,9 @@ int pyrna_pydict_to_props(
while (PyDict_Next(kw, &pos, &key, &value)) {
arg_name = _PyUnicode_AsString(key);
- if (RNA_struct_find_property(ptr, arg_name) == NULL) break;
+ if (RNA_struct_find_property(ptr, arg_name) == NULL) {
+ break;
+ }
arg_name = NULL;
}
@@ -1649,8 +1675,12 @@ static int pyrna_py_to_prop(
return -1;
}
else {
- if (data) *((bool *)data) = param;
- else RNA_property_boolean_set(ptr, prop, param);
+ if (data) {
+ *((bool *)data) = param;
+ }
+ else {
+ RNA_property_boolean_set(ptr, prop, param);
+ }
}
break;
}
@@ -1755,8 +1785,12 @@ static int pyrna_py_to_prop(
return -1;
}
else {
- if (data) *((char **)data) = (char *)param;
- else RNA_property_string_set_bytes(ptr, prop, param, PyBytes_Size(value));
+ if (data) {
+ *((char **)data) = (char *)param;
+ }
+ else {
+ RNA_property_string_set_bytes(ptr, prop, param, PyBytes_Size(value));
+ }
}
}
else {
@@ -1796,8 +1830,12 @@ static int pyrna_py_to_prop(
else {
/* same as bytes */
/* XXX, this is suspect but needed for function calls, need to see if theres a better way */
- if (data) *((char **)data) = (char *)param;
- else RNA_property_string_set(ptr, prop, param);
+ if (data) {
+ *((char **)data) = (char *)param;
+ }
+ else {
+ RNA_property_string_set(ptr, prop, param);
+ }
}
#ifdef USE_STRING_COERCE
Py_XDECREF(value_coerce);
@@ -1823,8 +1861,12 @@ static int pyrna_py_to_prop(
}
}
- if (data) *((int *)data) = val;
- else RNA_property_enum_set(ptr, prop, val);
+ if (data) {
+ *((int *)data) = val;
+ }
+ else {
+ RNA_property_enum_set(ptr, prop, val);
+ }
break;
}
@@ -1922,23 +1964,29 @@ static int pyrna_py_to_prop(
if (flag_parameter & PARM_RNAPTR) {
if (flag & PROP_THICK_WRAP) {
- if (value == Py_None)
+ if (value == Py_None) {
memset(data, 0, sizeof(PointerRNA));
- else if (RNA_struct_is_a(param->ptr.type, ptr_type))
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
*((PointerRNA *)data) = param->ptr;
- else
+ }
+ else {
raise_error = true;
+ }
}
else {
/* for function calls, we sometimes want to pass the 'ptr' directly,
* watch out that it remains valid!, possibly we could support this later if needed */
BLI_assert(value_new == NULL);
- if (value == Py_None)
+ if (value == Py_None) {
*((void **)data) = NULL;
- else if (RNA_struct_is_a(param->ptr.type, ptr_type))
+ }
+ else if (RNA_struct_is_a(param->ptr.type, ptr_type)) {
*((PointerRNA **)data) = &param->ptr;
- else
+ }
+ else {
raise_error = true;
+ }
}
}
else if (value == Py_None) {
@@ -1953,10 +2001,12 @@ static int pyrna_py_to_prop(
}
else {
/* data == NULL, assign to RNA */
- if (value == Py_None || RNA_struct_is_a(param->ptr.type, ptr_type))
+ if (value == Py_None || RNA_struct_is_a(param->ptr.type, ptr_type)) {
RNA_property_pointer_set(ptr, prop, value == Py_None ? PointerRNA_NULL : param->ptr);
- else
+ }
+ else {
raise_error = true;
+ }
}
if (raise_error) {
@@ -2027,8 +2077,9 @@ static int pyrna_py_to_prop(
link->ptr = itemptr;
BLI_addtail(lb, link);
}
- else
+ else {
RNA_property_collection_add(ptr, prop, &itemptr);
+ }
if (pyrna_pydict_to_props(
&itemptr, item, true,
@@ -2152,10 +2203,12 @@ static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self)
{
PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self);
- if (RNA_property_array_dimension(&self->ptr, self->prop, NULL) > 1)
+ if (RNA_property_array_dimension(&self->ptr, self->prop, NULL) > 1) {
return RNA_property_multi_array_length(&self->ptr, self->prop, self->arraydim);
- else
+ }
+ else {
return RNA_property_array_length(&self->ptr, self->prop);
+ }
}
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self)
@@ -2271,10 +2324,13 @@ static PyObject *pyrna_prop_array_subscript_int(BPy_PropertyArrayRNA *self, int
len = pyrna_prop_array_length(self);
- if (keynum < 0) keynum += len;
+ if (keynum < 0) {
+ keynum += len;
+ }
- if (keynum >= 0 && keynum < len)
+ if (keynum >= 0 && keynum < len) {
return pyrna_prop_array_to_py_index(self, keynum);
+ }
PyErr_Format(PyExc_IndexError,
"bpy_prop_array[index]: index %d out of range", keynum);
@@ -2287,8 +2343,9 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons
PYRNA_PROP_CHECK_OBJ(self);
- if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr))
+ if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr)) {
return pyrna_struct_CreatePyObject(&newptr);
+ }
PyErr_Format(PyExc_KeyError, "bpy_prop_collection[key]: key \"%.200s\" not found", keyname);
return NULL;
@@ -2463,8 +2520,9 @@ static PyObject *pyrna_prop_array_subscript_slice(
totdim = RNA_property_array_dimension(ptr, prop, NULL);
if (totdim > 1) {
- for (count = start; count < stop; count++)
+ for (count = start; count < stop; count++) {
PyTuple_SET_ITEM(tuple, count - start, pyrna_prop_array_to_py_index(self, count));
+ }
}
else {
switch (RNA_property_type(prop)) {
@@ -2476,8 +2534,9 @@ static PyObject *pyrna_prop_array_subscript_slice(
else { values = values_stack; }
RNA_property_float_get_array(ptr, prop, values);
- for (count = start; count < stop; count++)
+ for (count = start; count < stop; count++) {
PyTuple_SET_ITEM(tuple, count - start, PyFloat_FromDouble(values[count]));
+ }
if (values != values_stack) {
PyMem_FREE(values);
@@ -2492,8 +2551,9 @@ static PyObject *pyrna_prop_array_subscript_slice(
else { values = values_stack; }
RNA_property_boolean_get_array(ptr, prop, values);
- for (count = start; count < stop; count++)
+ for (count = start; count < stop; count++) {
PyTuple_SET_ITEM(tuple, count - start, PyBool_FromLong(values[count]));
+ }
if (values != values_stack) {
PyMem_FREE(values);
@@ -2508,8 +2568,9 @@ static PyObject *pyrna_prop_array_subscript_slice(
else { values = values_stack; }
RNA_property_int_get_array(ptr, prop, values);
- for (count = start; count < stop; count++)
+ for (count = start; count < stop; count++) {
PyTuple_SET_ITEM(tuple, count - start, PyLong_FromLong(values[count]));
+ }
if (values != values_stack) {
PyMem_FREE(values);
@@ -2537,8 +2598,9 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
}
else if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
+ }
return pyrna_prop_collection_subscript_int(self, i);
}
@@ -2560,14 +2622,22 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+ return NULL;
+ }
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+ return NULL;
+ }
if (start < 0 || stop < 0) {
/* only get the length for negative values */
Py_ssize_t len = (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
- if (start < 0) start += len;
- if (stop < 0) stop += len;
+ if (start < 0) {
+ start += len;
+ }
+ if (stop < 0) {
+ stop += len;
+ }
}
if (stop - start <= 0) {
@@ -2662,8 +2732,9 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self, PyObject *
#endif
if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return -1;
+ }
return pyrna_prop_collection_ass_subscript_int(self, i, value);
}
@@ -2726,8 +2797,9 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
#endif
if (PyIndex_Check(key)) {
Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
+ }
return pyrna_prop_array_subscript_int(self, i);
}
else if (PySlice_Check(key)) {
@@ -2751,8 +2823,9 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
int len = pyrna_prop_array_length(self);
Py_ssize_t start, stop, slicelength;
- if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(key, len, &start, &stop, &step, &slicelength) < 0) {
return NULL;
+ }
if (slicelength <= 0) {
return PyTuple_New(0);
@@ -2963,8 +3036,12 @@ static int prop_subscript_ass_array_slice(
totdim - arraydim, &dimsize[arraydim],
range);
- if (PyErr_Occurred()) ret = -1;
- else RNA_property_float_set_array(ptr, prop, values);
+ if (PyErr_Occurred()) {
+ ret = -1;
+ }
+ else {
+ RNA_property_float_set_array(ptr, prop, values);
+ }
break;
}
case PROP_INT:
@@ -2986,8 +3063,12 @@ static int prop_subscript_ass_array_slice(
totdim - arraydim, &dimsize[arraydim],
range);
- if (PyErr_Occurred()) ret = -1;
- else RNA_property_int_set_array(ptr, prop, values);
+ if (PyErr_Occurred()) {
+ ret = -1;
+ }
+ else {
+ RNA_property_int_set_array(ptr, prop, values);
+ }
break;
}
case PROP_BOOLEAN:
@@ -3006,8 +3087,12 @@ static int prop_subscript_ass_array_slice(
value_items, &values[arrayoffset + (start * span)],
totdim - arraydim, &dimsize[arraydim]);
- if (PyErr_Occurred()) ret = -1;
- else RNA_property_boolean_set_array(ptr, prop, values);
+ if (PyErr_Occurred()) {
+ ret = -1;
+ }
+ else {
+ RNA_property_boolean_set_array(ptr, prop, values);
+ }
break;
}
default:
@@ -3034,10 +3119,13 @@ static int prop_subscript_ass_array_int(BPy_PropertyArrayRNA *self, Py_ssize_t k
len = pyrna_prop_array_length(self);
- if (keynum < 0) keynum += len;
+ if (keynum < 0) {
+ keynum += len;
+ }
- if (keynum >= 0 && keynum < len)
+ if (keynum >= 0 && keynum < len) {
return pyrna_py_to_prop_array_index(self, keynum, value);
+ }
PyErr_SetString(PyExc_IndexError,
"bpy_prop_array[index] = value: index out of range");
@@ -3165,8 +3253,9 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
return -1;
}
- if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr))
+ if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr)) {
return 1;
+ }
return 0;
}
@@ -3191,8 +3280,9 @@ static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
group = RNA_struct_idprops(&self->ptr, 0);
- if (!group)
+ if (!group) {
return 0;
+ }
return IDP_GetPropertyFromGroup(group, name) ? 1 : 0;
}
@@ -3335,8 +3425,9 @@ static PyObject *pyrna_struct_keys(BPy_PropertyRNA *self)
group = RNA_struct_idprops(&self->ptr, 0);
- if (group == NULL)
+ if (group == NULL) {
return PyList_New(0);
+ }
return BPy_Wrap_GetKeys(group);
}
@@ -3363,8 +3454,9 @@ static PyObject *pyrna_struct_items(BPy_PropertyRNA *self)
group = RNA_struct_idprops(&self->ptr, 0);
- if (group == NULL)
+ if (group == NULL) {
return PyList_New(0);
+ }
return BPy_Wrap_GetItems(self->ptr.id.data, group);
}
@@ -3391,8 +3483,9 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self)
group = RNA_struct_idprops(&self->ptr, 0);
- if (group == NULL)
+ if (group == NULL) {
return PyList_New(0);
+ }
return BPy_Wrap_GetValues(self->ptr.id.data, group);
}
@@ -3413,8 +3506,9 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "s:is_property_set", &name))
+ if (!PyArg_ParseTuple(args, "s:is_property_set", &name)) {
return NULL;
+ }
if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) {
PyErr_Format(PyExc_TypeError,
@@ -3438,8 +3532,9 @@ static PyObject *pyrna_struct_property_unset(BPy_StructRNA *self, PyObject *args
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "s:property_unset", &name))
+ if (!PyArg_ParseTuple(args, "s:property_unset", &name)) {
return NULL;
+ }
if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) {
PyErr_Format(PyExc_TypeError,
@@ -3468,8 +3563,9 @@ static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "s:is_property_hidden", &name))
+ if (!PyArg_ParseTuple(args, "s:is_property_hidden", &name)) {
return NULL;
+ }
if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) {
PyErr_Format(PyExc_TypeError,
@@ -3496,8 +3592,9 @@ static PyObject *pyrna_struct_is_property_readonly(BPy_StructRNA *self, PyObject
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "s:is_property_readonly", &name))
+ if (!PyArg_ParseTuple(args, "s:is_property_readonly", &name)) {
return NULL;
+ }
if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) {
PyErr_Format(PyExc_TypeError,
@@ -3592,8 +3689,9 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "s|O!:path_resolve", &path, &PyBool_Type, &coerce))
+ if (!PyArg_ParseTuple(args, "s|O!:path_resolve", &path, &PyBool_Type, &coerce)) {
return NULL;
+ }
if (RNA_path_resolve_full(&self->ptr, path, &r_ptr, &r_prop, &index)) {
if (r_prop) {
@@ -3650,8 +3748,9 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "|s:path_from_id", &name))
+ if (!PyArg_ParseTuple(args, "|s:path_from_id", &name)) {
return NULL;
+ }
if (name) {
prop = RNA_struct_find_property(&self->ptr, name);
@@ -3990,8 +4089,9 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
* */
ret = PyList_New(0);
- if (!BPy_StructRNA_CheckExact(self))
+ if (!BPy_StructRNA_CheckExact(self)) {
pyrna_dir_members_py(ret, (PyObject *)self);
+ }
pyrna_dir_members_rna(ret, &self->ptr);
@@ -4636,8 +4736,9 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
if (nameptr) {
PyTuple_SET_ITEM(item, 0, PyUnicode_FromStringAndSize(nameptr, namelen));
- if (name != nameptr)
+ if (name != nameptr) {
MEM_freeN(nameptr);
+ }
}
else {
/* a bit strange but better then returning an empty list */
@@ -4693,8 +4794,9 @@ static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
+ if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) {
return NULL;
+ }
/* mostly copied from BPy_IDGroup_Map_GetItem */
if (RNA_struct_idprops_check(self->ptr.type) == 0) {
@@ -4737,8 +4839,9 @@ static PyObject *pyrna_struct_pop(BPy_StructRNA *self, PyObject *args)
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
+ if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) {
return NULL;
+ }
/* mostly copied from BPy_IDGroup_Map_GetItem */
if (RNA_struct_idprops_check(self->ptr.type) == 0) {
@@ -4801,14 +4904,16 @@ static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args
PYRNA_PROP_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "O|O:get", &key_ob, &def))
+ if (!PyArg_ParseTuple(args, "O|O:get", &key_ob, &def)) {
return NULL;
+ }
if (PyUnicode_Check(key_ob)) {
const char *key = _PyUnicode_AsString(key_ob);
- if (RNA_property_collection_lookup_string(&self->ptr, self->prop, key, &newptr))
+ if (RNA_property_collection_lookup_string(&self->ptr, self->prop, key, &newptr)) {
return pyrna_struct_CreatePyObject(&newptr);
+ }
}
else if (PyTuple_Check(key_ob)) {
PyObject *ret = pyrna_prop_collection_subscript_str_lib_pair(self, key_ob,
@@ -4942,13 +5047,16 @@ static int foreach_parse_args(
*size = RNA_raw_type_sizeof(*raw_type);
#if 0 /* works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks */
- if ((*attr_tot) < 1)
+ if ((*attr_tot) < 1) {
*attr_tot = 1;
+ }
- if (RNA_property_type(self->prop) == PROP_COLLECTION)
+ if (RNA_property_type(self->prop) == PROP_COLLECTION) {
array_tot = RNA_property_collection_length(&self->ptr, self->prop);
- else
+ }
+ else {
array_tot = RNA_property_array_length(&self->ptr, self->prop);
+ }
target_tot = array_tot * (*attr_tot);
@@ -4978,14 +5086,26 @@ static bool foreach_compat_buffer(RawPropertyType raw_type, int attr_signed, con
switch (raw_type) {
case PROP_RAW_CHAR:
- if (attr_signed) return (f == 'b') ? 1 : 0;
- else return (f == 'B') ? 1 : 0;
+ if (attr_signed) {
+ return (f == 'b') ? 1 : 0;
+ }
+ else {
+ return (f == 'B') ? 1 : 0;
+ }
case PROP_RAW_SHORT:
- if (attr_signed) return (f == 'h') ? 1 : 0;
- else return (f == 'H') ? 1 : 0;
+ if (attr_signed) {
+ return (f == 'h') ? 1 : 0;
+ }
+ else {
+ return (f == 'H') ? 1 : 0;
+ }
case PROP_RAW_INT:
- if (attr_signed) return (f == 'i') ? 1 : 0;
- else return (f == 'I') ? 1 : 0;
+ if (attr_signed) {
+ return (f == 'i') ? 1 : 0;
+ }
+ else {
+ return (f == 'I') ? 1 : 0;
+ }
case PROP_RAW_BOOLEAN:
return (f == '?') ? 1 : 0;
case PROP_RAW_FLOAT:
@@ -5013,11 +5133,13 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
bool attr_signed;
RawPropertyType raw_type;
- if (foreach_parse_args(self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) == -1)
+ if (foreach_parse_args(self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) == -1) {
return NULL;
+ }
- if (tot == 0)
+ if (tot == 0) {
Py_RETURN_NONE;
+ }
@@ -5098,7 +5220,10 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
ok = RNA_property_collection_raw_get(NULL, &self->ptr, self->prop, attr, array, raw_type, tot);
- if (!ok) i = tot; /* skip the loop */
+ if (!ok) {
+ /* skip the loop */
+ i = tot;
+ }
for ( ; i < tot; i++) {
@@ -5135,8 +5260,9 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
}
}
- if (array)
+ if (array) {
PyMem_Free(array);
+ }
if (PyErr_Occurred()) {
/* Maybe we could make our own error */
@@ -5348,8 +5474,9 @@ static PyObject *pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *UN
{
BPy_PropertyRNA *base;
- if (!PyArg_ParseTuple(args, "O!:bpy_prop.__new__", &pyrna_prop_Type, &base))
+ if (!PyArg_ParseTuple(args, "O!:bpy_prop.__new__", &pyrna_prop_Type, &base)) {
return NULL;
+ }
if (type == Py_TYPE(base)) {
return Py_INCREF_RET((PyObject *)base);
@@ -5383,8 +5510,9 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
len = data_alloc->array_tot;
data = data_alloc->array;
}
- else
+ else {
len = RNA_property_array_length(ptr, prop);
+ }
/* resolve the array from a new pytype */
@@ -5393,13 +5521,15 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
switch (type) {
case PROP_BOOLEAN:
ret = PyTuple_New(len);
- for (a = 0; a < len; a++)
+ for (a = 0; a < len; a++) {
PyTuple_SET_ITEM(ret, a, PyBool_FromLong(((bool *)data)[a]));
+ }
break;
case PROP_INT:
ret = PyTuple_New(len);
- for (a = 0; a < len; a++)
+ for (a = 0; a < len; a++) {
PyTuple_SET_ITEM(ret, a, PyLong_FromLong(((int *)data)[a]));
+ }
break;
case PROP_FLOAT:
switch (RNA_property_subtype(prop)) {
@@ -5420,8 +5550,9 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
#endif
default:
ret = PyTuple_New(len);
- for (a = 0; a < len; a++)
+ for (a = 0; a < len; a++) {
PyTuple_SET_ITEM(ret, a, PyFloat_FromDouble(((float *)data)[a]));
+ }
break;
}
break;
@@ -5451,10 +5582,12 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
PyObject *value_coerce = NULL;
const int subtype = RNA_property_subtype(prop);
- if (flag & PROP_THICK_WRAP)
+ if (flag & PROP_THICK_WRAP) {
data_ch = (char *)data;
- else
+ }
+ else {
data_ch = *(char **)data;
+ }
#ifdef USE_STRING_COERCE
if (subtype == PROP_BYTESTRING) {
@@ -5674,8 +5807,9 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
#else
item = small_dict_get_item_string(kw, RNA_property_identifier(parm)); /* borrow ref */
#endif
- if (item)
+ if (item) {
kw_tot++; /* make sure invalid keywords are not given */
+ }
kw_arg = true;
}
@@ -5712,19 +5846,21 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
char error_prefix[512];
PyErr_Clear(); /* re-raise */
- if (kw_arg == true)
+ if (kw_arg == true) {
BLI_snprintf(error_prefix, sizeof(error_prefix),
"%.200s.%.200s(): error with keyword argument \"%.200s\" - ",
RNA_struct_identifier(self_ptr->type),
RNA_function_identifier(self_func),
RNA_property_identifier(parm));
- else
+ }
+ else {
BLI_snprintf(error_prefix, sizeof(error_prefix),
"%.200s.%.200s(): error with argument %d, \"%.200s\" - ",
RNA_struct_identifier(self_ptr->type),
RNA_function_identifier(self_func),
i,
RNA_property_identifier(parm));
+ }
pyrna_py_to_prop(&funcptr, parm, iter.data, item, error_prefix);
@@ -5783,8 +5919,9 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
RNA_parameter_list_begin(&parms, &iter);
for (; iter.valid; RNA_parameter_list_next(&iter)) {
parm = iter.parm;
- if (RNA_parameter_flag(parm) & PARM_OUTPUT)
+ if (RNA_parameter_flag(parm) & PARM_OUTPUT) {
continue;
+ }
BLI_dynstr_appendf(good_args, first ? "%s" : ", %s", RNA_property_identifier(parm));
first = false;
@@ -5831,18 +5968,21 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
for (; iter.valid; RNA_parameter_list_next(&iter)) {
parm = iter.parm;
- if (RNA_parameter_flag(parm) & PARM_OUTPUT)
+ if (RNA_parameter_flag(parm) & PARM_OUTPUT) {
PyTuple_SET_ITEM(ret, i++, pyrna_param_to_py(&funcptr, parm, iter.data));
+ }
}
RNA_parameter_list_end(&iter);
}
- else
+ else {
ret = pyrna_param_to_py(&funcptr, pret_single, retdata_single);
+ }
/* possible there is an error in conversion */
- if (ret == NULL)
+ if (ret == NULL) {
err = -1;
+ }
}
}
}
@@ -5865,11 +6005,13 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
RNA_parameter_list_end(&iter);
RNA_parameter_list_free(&parms);
- if (ret)
+ if (ret) {
return ret;
+ }
- if (err == -1)
+ if (err == -1) {
return NULL;
+ }
Py_RETURN_NONE;
}
@@ -6660,8 +6802,9 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
Py_INCREF(newclass);
- if (RNA_struct_py_type_get(srna))
+ if (RNA_struct_py_type_get(srna)) {
PyC_ObSpit("RNA WAS SET - ", RNA_struct_py_type_get(srna));
+ }
Py_XDECREF(((PyObject *)RNA_struct_py_type_get(srna)));
@@ -7074,30 +7217,38 @@ void BPY_rna_init(void)
#endif
/* metaclass */
- if (PyType_Ready(&pyrna_struct_meta_idprop_Type) < 0)
+ if (PyType_Ready(&pyrna_struct_meta_idprop_Type) < 0) {
return;
+ }
- if (PyType_Ready(&pyrna_struct_Type) < 0)
+ if (PyType_Ready(&pyrna_struct_Type) < 0) {
return;
+ }
- if (PyType_Ready(&pyrna_prop_Type) < 0)
+ if (PyType_Ready(&pyrna_prop_Type) < 0) {
return;
+ }
- if (PyType_Ready(&pyrna_prop_array_Type) < 0)
+ if (PyType_Ready(&pyrna_prop_array_Type) < 0) {
return;
+ }
- if (PyType_Ready(&pyrna_prop_collection_Type) < 0)
+ if (PyType_Ready(&pyrna_prop_collection_Type) < 0) {
return;
+ }
- if (PyType_Ready(&pyrna_prop_collection_idprop_Type) < 0)
+ if (PyType_Ready(&pyrna_prop_collection_idprop_Type) < 0) {
return;
+ }
- if (PyType_Ready(&pyrna_func_Type) < 0)
+ if (PyType_Ready(&pyrna_func_Type) < 0) {
return;
+ }
#ifdef USE_PYRNA_ITER
- if (PyType_Ready(&pyrna_prop_collection_iter_Type) < 0)
+ if (PyType_Ready(&pyrna_prop_collection_iter_Type) < 0) {
return;
+ }
#endif
}
@@ -7239,8 +7390,9 @@ PyObject *BPY_rna_types(void)
pyrna_basetype_Type.tp_flags = Py_TPFLAGS_DEFAULT;
pyrna_basetype_Type.tp_methods = pyrna_basetype_methods;
- if (PyType_Ready(&pyrna_basetype_Type) < 0)
+ if (PyType_Ready(&pyrna_basetype_Type) < 0) {
return NULL;
+ }
}
/* static members for the base class */
@@ -7288,8 +7440,9 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *e
if (parent) {
/* be very careful with this since it will return a parent classes srna.
* modifying this will do confusing stuff! */
- if (py_srna == NULL)
+ if (py_srna == NULL) {
py_srna = (BPy_StructRNA *)PyObject_GetAttr(self, bpy_intern_str_bl_rna);
+ }
}
if (py_srna == NULL) {
@@ -7473,8 +7626,9 @@ static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict)
}
ret = deferred_register_prop(srna, key, item);
- if (ret != 0)
+ if (ret != 0) {
break;
+ }
}
}
@@ -7518,8 +7672,9 @@ int pyrna_deferred_register_class(StructRNA *srna, PyTypeObject *py_class)
{
/* Panels and Menus don't need this
* save some time and skip the checks here */
- if (!RNA_struct_idprops_register_check(srna))
+ if (!RNA_struct_idprops_register_check(srna)) {
return 0;
+ }
return pyrna_deferred_register_class_recursive(srna, py_class);
}
@@ -7541,16 +7696,18 @@ static int rna_function_arg_count(FunctionRNA *func, int *min_count)
if (!(RNA_parameter_flag(parm) & PARM_OUTPUT)) {
if (!done_min_count && (RNA_parameter_flag(parm) & PARM_PYFUNC_OPTIONAL)) {
/* From now on, following parameters are optional in py func */
- if (min_count)
+ if (min_count) {
*min_count = count;
+ }
done_min_count = true;
}
count++;
}
}
- if (!done_min_count && min_count)
+ if (!done_min_count && min_count) {
*min_count = count;
+ }
return count;
}
@@ -7567,8 +7724,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; /* __name__ */
if (srna_base) {
- if (bpy_class_validate_recursive(dummyptr, srna_base, py_data, have_function) != 0)
+ if (bpy_class_validate_recursive(dummyptr, srna_base, py_data, have_function) != 0) {
return -1;
+ }
}
if (base_class) {
@@ -7591,8 +7749,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
* Keep this as-is since its working but we should be using 'FUNC_USE_SELF_TYPE' for many functions. */
const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE);
- if (!(flag & FUNC_REGISTER))
+ if (!(flag & FUNC_REGISTER)) {
continue;
+ }
item = PyObject_GetAttrString(py_class, RNA_function_identifier(func));
@@ -7672,8 +7831,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
PropertyRNA *prop = (PropertyRNA *)link;
const int flag = RNA_property_flag(prop);
- if (!(flag & PROP_REGISTER))
+ if (!(flag & PROP_REGISTER)) {
continue;
+ }
/* TODO(campbell): Use Python3.7x _PyObject_LookupAttr(), also in the macro below. */
identifier = RNA_property_identifier(prop);
@@ -7769,8 +7929,9 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
/* XXX, this is needed because render engine calls without a context
* this should be supported at some point but at the moment its not! */
- if (C == NULL)
+ if (C == NULL) {
C = BPy_GetContext();
+ }
/* annoying!, need to check if the screen gets set to NULL which is a
* hint that the file was actually re-loaded. */
@@ -7792,8 +7953,9 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
}
/* end exception */
- if (py_class_instance == NULL)
+ if (py_class_instance == NULL) {
py_srna = pyrna_struct_CreatePyObject(ptr);
+ }
if (py_class_instance) {
/* special case, instance is cached */
@@ -8055,8 +8217,9 @@ static void bpy_class_free(void *pyob_ptr)
/* remove the rna attribute instead. */
PyDict_DelItem(((PyTypeObject *)self)->tp_dict, bpy_intern_str_bl_rna);
- if (PyErr_Occurred())
+ if (PyErr_Occurred()) {
PyErr_Clear();
+ }
#if 0 /* needs further investigation, too annoying so quiet for now */
if (G.debug & G_DEBUG_PYTHON) {
@@ -8171,6 +8334,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
StructRNA *srna_new;
const char *identifier;
PyObject *py_cls_meth;
+ const char *error_prefix = "register_class(...):";
if (!PyType_Check(py_class)) {
PyErr_Format(PyExc_ValueError,
@@ -8196,8 +8360,9 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
/* warning: gets parent classes srna, only for the register function */
srna = pyrna_struct_as_srna(py_class, true, "register_class(...):");
- if (srna == NULL)
+ if (srna == NULL) {
return NULL;
+ }
/* fails in cases, cant use this check but would like to :| */
#if 0
@@ -8231,13 +8396,22 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
srna_new = reg(CTX_data_main(C), &reports, py_class, identifier,
bpy_class_validate, bpy_class_call, bpy_class_free);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
- return NULL;
+ if (!BLI_listbase_is_empty(&reports.list)) {
+ const bool has_error = BPy_reports_to_error(&reports, PyExc_RuntimeError, false);
+ if (!has_error) {
+ BPy_reports_write_stdout(&reports, error_prefix);
+ }
+ BKE_reports_clear(&reports);
+ if (has_error) {
+ return NULL;
+ }
+ }
/* python errors validating are not converted into reports so the check above will fail.
* the cause for returning NULL will be printed as an error */
- if (srna_new == NULL)
+ if (srna_new == NULL) {
return NULL;
+ }
pyrna_subtype_set_rna(py_class, srna_new); /* takes a ref to py_class */
@@ -8251,8 +8425,9 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
*
* item = PyObject_GetAttrString(py_class, "__dict__");
*/
- if (pyrna_deferred_register_class(srna_new, (PyTypeObject *)py_class) != 0)
+ if (pyrna_deferred_register_class(srna_new, (PyTypeObject *)py_class) != 0) {
return NULL;
+ }
/* call classed register method () */
switch (_PyObject_LookupAttr(py_class, bpy_intern_str_register, &py_cls_meth)) {
@@ -8345,8 +8520,9 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
}
srna = pyrna_struct_as_srna(py_class, false, "unregister_class(...):");
- if (srna == NULL)
+ if (srna == NULL) {
return NULL;
+ }
/* check that we have a unregister callback for this type */
unreg = RNA_struct_unregister(srna);
@@ -8414,8 +8590,9 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
unreg(CTX_data_main(C), srna); /* calls bpy_class_free, this decref's py_class */
PyDict_DelItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna);
- if (PyErr_Occurred())
+ if (PyErr_Occurred()) {
PyErr_Clear(); //return NULL;
+ }
Py_RETURN_NONE;
}
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index faead661f1f..a25906ac9a1 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -339,8 +339,9 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
}
MEM_freeN((void *)path_full);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
+ }
return PyBool_FromLong(result);
}
@@ -356,8 +357,9 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
result = insert_keyframe(G_MAIN, depsgraph, &reports, id, NULL, group_name, path_full, index, cfra, keytype, NULL, options);
MEM_freeN((void *)path_full);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
+ }
return PyBool_FromLong(result);
}
@@ -452,8 +454,9 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
}
MEM_freeN((void *)path_full);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
+ }
return PyBool_FromLong(result);
}
@@ -466,8 +469,9 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
result = delete_keyframe(G.main, &reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
MEM_freeN((void *)path_full);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
+ }
return PyBool_FromLong(result);
}
@@ -493,8 +497,9 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
PYRNA_STRUCT_CHECK_OBJ(self);
- if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index))
+ if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index)) {
return NULL;
+ }
if (pyrna_struct_anim_args_parse(
&self->ptr, "bpy_struct.driver_add():", path,
@@ -512,8 +517,9 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
result = ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index,
CREATEDRIVER_WITH_FMODIFIER, DRIVER_TYPE_PYTHON);
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
+ }
if (result) {
ID *id = self->ptr.id.data;
@@ -592,8 +598,9 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
MEM_freeN((void *)path_full);
}
- if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
+ if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) {
return NULL;
+ }
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index a87da8782bc..4cc3c4c0fae 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -276,8 +276,9 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
*
* arr[2][3][4] = x
* lvalue_dim = 2 */
- for (i = lvalue_dim; i < totdim; i++)
+ for (i = lvalue_dim; i < totdim; i++) {
len *= dimsize[i];
+ }
}
if (tot != len) {
@@ -308,8 +309,9 @@ static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop,
if (MatrixObject_Check(rvalue)) {
MatrixObject *pymat = (MatrixObject *)rvalue;
- if (BaseMath_ReadCallback(pymat) == -1)
+ if (BaseMath_ReadCallback(pymat) == -1) {
return -1;
+ }
if (RNA_property_type(prop) != PROP_FLOAT) {
PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, matrix assign to non float array",
@@ -512,8 +514,9 @@ static int py_to_array_index(
lvalue_dim++;
- for (i = lvalue_dim; i < totdim; i++)
+ for (i = lvalue_dim; i < totdim; i++) {
index *= dimsize[i];
+ }
index += arrayoffset;
@@ -751,8 +754,9 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop
for (i = 0; i < len; i++) {
PyObject *item;
- if (dim + 1 < totdim)
+ if (dim + 1 < totdim) {
item = pyrna_py_from_array_internal(ptr, prop, dim + 1, index);
+ }
else {
item = pyrna_array_index(ptr, prop, *index);
*index = *index + 1;
@@ -802,8 +806,9 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
* x = arr[2][3]
* index = offset + 3 * 5 */
- for (i = arraydim + 1; i < totdim; i++)
+ for (i = arraydim + 1; i < totdim; i++) {
index *= dimsize[i];
+ }
ret->arrayoffset = arrayoffset + index;
}
@@ -822,7 +827,9 @@ PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop)
ret = pyrna_math_object_from_array(ptr, prop);
/* is this a maths object? */
- if (ret) return ret;
+ if (ret) {
+ return ret;
+ }
return pyrna_prop_CreatePyObject(ptr, prop);
}
@@ -834,8 +841,10 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
int type;
int i;
- if (len == 0) /* possible with dynamic arrays */
+ if (len == 0) {
+ /* possible with dynamic arrays */
return 0;
+ }
if (RNA_property_array_dimension(ptr, prop, NULL) > 1) {
PyErr_SetString(PyExc_TypeError, "PropertyRNA - multi dimensional arrays not supported yet");
@@ -871,8 +880,9 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
- if (tmp_arr != tmp)
+ if (tmp_arr != tmp) {
PyMem_FREE(tmp_arr);
+ }
return i < len ? 1 : 0;
}
@@ -904,8 +914,9 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
- if (tmp_arr != tmp)
+ if (tmp_arr != tmp) {
PyMem_FREE(tmp_arr);
+ }
return i < len ? 1 : 0;
}
@@ -937,8 +948,9 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
- if (tmp_arr != tmp)
+ if (tmp_arr != tmp) {
PyMem_FREE(tmp_arr);
+ }
return i < len ? 1 : 0;
}
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index 025ea586fee..30ea657200c 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -136,8 +136,9 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
char *cb_event_str = NULL;
int cb_event;
- if (!PyArg_ParseTuple(args, "OO!|s:bpy_struct.callback_add", &cb_func, &PyTuple_Type, &cb_args, &cb_event_str))
+ if (!PyArg_ParseTuple(args, "OO!|s:bpy_struct.callback_add", &cb_func, &PyTuple_Type, &cb_args, &cb_event_str)) {
return NULL;
+ }
if (!PyCallable_Check(cb_func)) {
PyErr_SetString(PyExc_TypeError, "callback_add(): first argument isn't callable");
@@ -174,8 +175,9 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
void *handle;
void *customdata;
- if (!PyArg_ParseTuple(args, "O!:callback_remove", &PyCapsule_Type, &py_handle))
+ if (!PyArg_ParseTuple(args, "O!:callback_remove", &PyCapsule_Type, &py_handle)) {
return NULL;
+ }
handle = PyCapsule_GetPointer(py_handle, rna_capsual_id);
@@ -205,21 +207,21 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
/* reverse of rna_Space_refine() */
static eSpace_Type rna_Space_refine_reverse(StructRNA *srna)
{
- if (srna == &RNA_SpaceView3D) return SPACE_VIEW3D;
- if (srna == &RNA_SpaceGraphEditor) return SPACE_GRAPH;
- if (srna == &RNA_SpaceOutliner) return SPACE_OUTLINER;
- if (srna == &RNA_SpaceProperties) return SPACE_PROPERTIES;
- if (srna == &RNA_SpaceFileBrowser) return SPACE_FILE;
- if (srna == &RNA_SpaceImageEditor) return SPACE_IMAGE;
- if (srna == &RNA_SpaceInfo) return SPACE_INFO;
- if (srna == &RNA_SpaceSequenceEditor) return SPACE_SEQ;
- if (srna == &RNA_SpaceTextEditor) return SPACE_TEXT;
- if (srna == &RNA_SpaceDopeSheetEditor) return SPACE_ACTION;
- if (srna == &RNA_SpaceNLA) return SPACE_NLA;
- if (srna == &RNA_SpaceNodeEditor) return SPACE_NODE;
- if (srna == &RNA_SpaceConsole) return SPACE_CONSOLE;
- if (srna == &RNA_SpacePreferences) return SPACE_USERPREF;
- if (srna == &RNA_SpaceClipEditor) return SPACE_CLIP;
+ if (srna == &RNA_SpaceView3D) { return SPACE_VIEW3D; }
+ if (srna == &RNA_SpaceGraphEditor) { return SPACE_GRAPH; }
+ if (srna == &RNA_SpaceOutliner) { return SPACE_OUTLINER; }
+ if (srna == &RNA_SpaceProperties) { return SPACE_PROPERTIES; }
+ if (srna == &RNA_SpaceFileBrowser) { return SPACE_FILE; }
+ if (srna == &RNA_SpaceImageEditor) { return SPACE_IMAGE; }
+ if (srna == &RNA_SpaceInfo) { return SPACE_INFO; }
+ if (srna == &RNA_SpaceSequenceEditor) { return SPACE_SEQ; }
+ if (srna == &RNA_SpaceTextEditor) { return SPACE_TEXT; }
+ if (srna == &RNA_SpaceDopeSheetEditor) { return SPACE_ACTION; }
+ if (srna == &RNA_SpaceNLA) { return SPACE_NLA; }
+ if (srna == &RNA_SpaceNodeEditor) { return SPACE_NODE; }
+ if (srna == &RNA_SpaceConsole) { return SPACE_CONSOLE; }
+ if (srna == &RNA_SpacePreferences) { return SPACE_USERPREF; }
+ if (srna == &RNA_SpaceClipEditor) { return SPACE_CLIP; }
return SPACE_EMPTY;
}
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index 31b135fe933..7a5849f818d 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -159,6 +159,7 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
#else
Main *bmain = G_MAIN; /* XXX Ugly, but should work! */
#endif
+ ListBase *lb;
ID *id;
PyObject *subset = NULL;
@@ -223,57 +224,61 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
data_cb.types_bitmap = key_types_bitmap;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
+ FOREACH_MAIN_LISTBASE_BEGIN(bmain, lb)
{
- /* 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)) {
- break; /* Break iter on that type of IDs, continues with next ID type. */
+ 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)) {
+ break;
+ }
}
- }
- /* One-time init, ID is just used as placeholder here, we abuse this in iterator callback
- * to avoid having to rebuild a complete bpyrna object each time for the key searching
- * (where only ID pointer value is used). */
- if (data_cb.py_id_key_lookup_only == NULL) {
- data_cb.py_id_key_lookup_only = pyrna_id_CreatePyObject(id);
- }
+ /* One-time init, ID is just used as placeholder here, we abuse this in iterator callback
+ * to avoid having to rebuild a complete bpyrna object each time for the key searching
+ * (where only ID pointer value is used). */
+ if (data_cb.py_id_key_lookup_only == NULL) {
+ data_cb.py_id_key_lookup_only = pyrna_id_CreatePyObject(id);
+ }
- if (!data_cb.is_subset &&
- /* We do not want to pre-add keys of flitered out types. */
- (key_types_bitmap == NULL || id_check_type(id, key_types_bitmap)) &&
- /* We do not want to pre-add keys when we have filter on value types, but not on key types. */
- (val_types_bitmap == NULL || key_types_bitmap != NULL))
- {
- PyObject *key = data_cb.py_id_key_lookup_only;
- PyObject *set;
-
- RNA_id_pointer_create(id, &((BPy_StructRNA *)key)->ptr);
-
- /* We have to insert the key now, otherwise ID unused would be missing from final dict... */
- if ((set = PyDict_GetItem(data_cb.user_map, key)) == NULL) {
- /* Cannot use our placeholder key here! */
- key = pyrna_id_CreatePyObject(id);
- set = PySet_New(NULL);
- PyDict_SetItem(data_cb.user_map, key, set);
- Py_DECREF(set);
- Py_DECREF(key);
+ if (!data_cb.is_subset &&
+ /* We do not want to pre-add keys of flitered out types. */
+ (key_types_bitmap == NULL || id_check_type(id, key_types_bitmap)) &&
+ /* We do not want to pre-add keys when we have filter on value types, but not on key types. */
+ (val_types_bitmap == NULL || key_types_bitmap != NULL))
+ {
+ PyObject *key = data_cb.py_id_key_lookup_only;
+ PyObject *set;
+
+ RNA_id_pointer_create(id, &((BPy_StructRNA *)key)->ptr);
+
+ /* We have to insert the key now, otherwise ID unused would be missing from final dict... */
+ if ((set = PyDict_GetItem(data_cb.user_map, key)) == NULL) {
+ /* Cannot use our placeholder key here! */
+ key = pyrna_id_CreatePyObject(id);
+ set = PySet_New(NULL);
+ PyDict_SetItem(data_cb.user_map, key, set);
+ Py_DECREF(set);
+ Py_DECREF(key);
+ }
}
- }
- if (val_types_bitmap != NULL && !id_check_type(id, val_types_bitmap)) {
- continue;
- }
+ if (val_types_bitmap != NULL && !id_check_type(id, val_types_bitmap)) {
+ continue;
+ }
- data_cb.id_curr = id;
- BKE_library_foreach_ID_link(NULL, id, foreach_libblock_id_user_map_callback, &data_cb, IDWALK_CB_NOP);
+ data_cb.id_curr = id;
+ BKE_library_foreach_ID_link(NULL, id, foreach_libblock_id_user_map_callback, &data_cb, IDWALK_CB_NOP);
- if (data_cb.py_id_curr) {
- Py_DECREF(data_cb.py_id_curr);
- data_cb.py_id_curr = NULL;
+ if (data_cb.py_id_curr) {
+ Py_DECREF(data_cb.py_id_curr);
+ data_cb.py_id_curr = NULL;
+ }
}
+ FOREACH_MAIN_LISTBASE_ID_END;
}
- FOREACH_MAIN_ID_END;
+ FOREACH_MAIN_LISTBASE_ID_END;
ret = data_cb.user_map;
diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c
index dd4d96cb806..77cd8d8a9b7 100644
--- a/source/blender/python/intern/bpy_traceback.c
+++ b/source/blender/python/intern/bpy_traceback.c
@@ -58,17 +58,20 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
/* new style errors. `err' is an instance */
*message = _PyObject_GetAttrId(err, &PyId_msg);
- if (!*message)
+ if (!*message) {
goto finally;
+ }
v = _PyObject_GetAttrId(err, &PyId_filename);
- if (!v)
+ if (!v) {
goto finally;
+ }
if (v == Py_None) {
Py_DECREF(v);
*filename = _PyUnicode_FromId(&PyId_string);
- if (*filename == NULL)
+ if (*filename == NULL) {
goto finally;
+ }
Py_INCREF(*filename);
}
else {
@@ -76,31 +79,36 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
}
v = _PyObject_GetAttrId(err, &PyId_lineno);
- if (!v)
+ if (!v) {
goto finally;
+ }
hold = PyLong_AsLong(v);
Py_DECREF(v);
- if (hold < 0 && PyErr_Occurred())
+ if (hold < 0 && PyErr_Occurred()) {
goto finally;
+ }
*lineno = (int)hold;
v = _PyObject_GetAttrId(err, &PyId_offset);
- if (!v)
+ if (!v) {
goto finally;
+ }
if (v == Py_None) {
*offset = -1;
Py_DECREF(v);
} else {
hold = PyLong_AsLong(v);
Py_DECREF(v);
- if (hold < 0 && PyErr_Occurred())
+ if (hold < 0 && PyErr_Occurred()) {
goto finally;
+ }
*offset = (int)hold;
}
v = _PyObject_GetAttrId(err, &PyId_text);
- if (!v)
+ if (!v) {
goto finally;
+ }
if (v == Py_None) {
Py_DECREF(v);
*text = NULL;
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 60224d093a1..41738ced41a 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -105,15 +105,17 @@ Py_hash_t mathutils_array_hash(const float *array, size_t array_len)
i = 0;
while (--len >= 0) {
y = _Py_HashDouble((double)(array[i++]));
- if (y == -1)
+ if (y == -1) {
return -1;
+ }
x = (x ^ y) * mult;
/* the cast might truncate len; that doesn't change hash stability */
mult += (Py_hash_t)(82520UL + len + len);
}
x += 97531UL;
- if (x == (Py_uhash_t)-1)
+ if (x == (Py_uhash_t)-1) {
x = -2;
+ }
return x;
}
@@ -392,8 +394,9 @@ int EXPP_VectorsAreEqual(const float *vecA, const float *vecB, int size, int flo
{
int x;
for (x = 0; x < size; x++) {
- if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0)
+ if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0) {
return 0;
+ }
}
return 1;
}
@@ -425,8 +428,10 @@ unsigned char Mathutils_RegisterCallback(Mathutils_Callback *cb)
/* find the first free slot */
for (i = 0; mathutils_callbacks[i]; i++) {
- if (mathutils_callbacks[i] == cb) /* already registered? */
+ if (mathutils_callbacks[i] == cb) {
+ /* already registered? */
return i;
+ }
}
BLI_assert(i + 1 < MATHUTILS_TOT_CB);
@@ -611,18 +616,24 @@ PyMODINIT_FUNC PyInit_mathutils(void)
PyObject *submodule;
PyObject *sys_modules = PyImport_GetModuleDict();
- if (PyType_Ready(&vector_Type) < 0)
+ if (PyType_Ready(&vector_Type) < 0) {
return NULL;
- if (PyType_Ready(&matrix_Type) < 0)
+ }
+ if (PyType_Ready(&matrix_Type) < 0) {
return NULL;
- if (PyType_Ready(&matrix_access_Type) < 0)
+ }
+ if (PyType_Ready(&matrix_access_Type) < 0) {
return NULL;
- if (PyType_Ready(&euler_Type) < 0)
+ }
+ if (PyType_Ready(&euler_Type) < 0) {
return NULL;
- if (PyType_Ready(&quaternion_Type) < 0)
+ }
+ if (PyType_Ready(&quaternion_Type) < 0) {
return NULL;
- if (PyType_Ready(&color_Type) < 0)
+ }
+ if (PyType_Ready(&color_Type) < 0) {
return NULL;
+ }
mod = PyModule_Create(&M_Mathutils_module_def);
@@ -655,7 +666,7 @@ PyMODINIT_FUNC PyInit_mathutils(void)
PyModule_AddObject(mod, "bvhtree", (submodule = PyInit_mathutils_bvhtree()));
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
- /* KDTree submodule */
+ /* KDTree_3d submodule */
PyModule_AddObject(mod, "kdtree", (submodule = PyInit_mathutils_kdtree()));
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
#endif
diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c
index b05b8c81cf9..c97d2720720 100644
--- a/source/blender/python/mathutils/mathutils_Color.c
+++ b/source/blender/python/mathutils/mathutils_Color.c
@@ -52,8 +52,9 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
case 0:
break;
case 1:
- if ((mathutils_array_parse(col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()")) == -1)
+ if ((mathutils_array_parse(col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()")) == -1) {
return NULL;
+ }
break;
default:
PyErr_SetString(PyExc_TypeError,
@@ -101,8 +102,9 @@ PyDoc_STRVAR(Color_copy_doc,
);
static PyObject *Color_copy(ColorObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return Color_CreatePyObject(self->col, Py_TYPE(self));
}
@@ -121,8 +123,9 @@ static PyObject *Color_repr(ColorObject *self)
{
PyObject *ret, *tuple;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
tuple = Color_ToTupleExt(self, -1);
@@ -137,8 +140,9 @@ static PyObject *Color_str(ColorObject *self)
{
DynStr *ds;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
ds = BLI_dynstr_new();
@@ -160,8 +164,9 @@ static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op)
ColorObject *colA = (ColorObject *)a;
ColorObject *colB = (ColorObject *)b;
- if (BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1)
+ if (BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1) {
return NULL;
+ }
ok = EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1;
}
@@ -190,11 +195,13 @@ static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op)
static Py_hash_t Color_hash(ColorObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
+ }
- if (BaseMathObject_Prepare_ForHash(self) == -1)
+ if (BaseMathObject_Prepare_ForHash(self) == -1) {
return -1;
+ }
return mathutils_array_hash(self->col, COLOR_SIZE);
}
@@ -210,7 +217,9 @@ static int Color_len(ColorObject *UNUSED(self))
/* sequence accessor (get) */
static PyObject *Color_item(ColorObject *self, int i)
{
- if (i < 0) i = COLOR_SIZE - i;
+ if (i < 0) {
+ i = COLOR_SIZE - i;
+ }
if (i < 0 || i >= COLOR_SIZE) {
PyErr_SetString(PyExc_IndexError,
@@ -219,8 +228,9 @@ static PyObject *Color_item(ColorObject *self, int i)
return NULL;
}
- if (BaseMath_ReadIndexCallback(self, i) == -1)
+ if (BaseMath_ReadIndexCallback(self, i) == -1) {
return NULL;
+ }
return PyFloat_FromDouble(self->col[i]);
@@ -231,8 +241,9 @@ static int Color_ass_item(ColorObject *self, int i, PyObject *value)
{
float f;
- if (BaseMath_Prepare_ForWrite(self) == -1)
+ if (BaseMath_Prepare_ForWrite(self) == -1) {
return -1;
+ }
f = PyFloat_AsDouble(value);
if (f == -1 && PyErr_Occurred()) { /* parsed item not a number */
@@ -242,7 +253,9 @@ static int Color_ass_item(ColorObject *self, int i, PyObject *value)
return -1;
}
- if (i < 0) i = COLOR_SIZE - i;
+ if (i < 0) {
+ i = COLOR_SIZE - i;
+ }
if (i < 0 || i >= COLOR_SIZE) {
PyErr_SetString(PyExc_IndexError, "color[item] = x: "
@@ -252,8 +265,9 @@ static int Color_ass_item(ColorObject *self, int i, PyObject *value)
self->col[i] = f;
- if (BaseMath_WriteIndexCallback(self, i) == -1)
+ if (BaseMath_WriteIndexCallback(self, i) == -1) {
return -1;
+ }
return 0;
}
@@ -264,11 +278,14 @@ static PyObject *Color_slice(ColorObject *self, int begin, int end)
PyObject *tuple;
int count;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
CLAMP(begin, 0, COLOR_SIZE);
- if (end < 0) end = (COLOR_SIZE + 1) + end;
+ if (end < 0) {
+ end = (COLOR_SIZE + 1) + end;
+ }
CLAMP(end, 0, COLOR_SIZE);
begin = MIN2(begin, end);
@@ -286,16 +303,20 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
int i, size;
float col[COLOR_SIZE];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
CLAMP(begin, 0, COLOR_SIZE);
- if (end < 0) end = (COLOR_SIZE + 1) + end;
+ if (end < 0) {
+ end = (COLOR_SIZE + 1) + end;
+ }
CLAMP(end, 0, COLOR_SIZE);
begin = MIN2(begin, end);
- if ((size = mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1)
+ if ((size = mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1) {
return -1;
+ }
if (size != (end - begin)) {
PyErr_SetString(PyExc_ValueError,
@@ -304,8 +325,9 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
return -1;
}
- for (i = 0; i < COLOR_SIZE; i++)
+ for (i = 0; i < COLOR_SIZE; i++) {
self->col[begin + i] = col[i];
+ }
(void)BaseMath_WriteCallback(self);
return 0;
@@ -316,17 +338,20 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
- if (i < 0)
+ }
+ if (i < 0) {
i += COLOR_SIZE;
+ }
return Color_item(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) {
return NULL;
+ }
if (slicelength <= 0) {
return PyTuple_New(0);
@@ -352,20 +377,24 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu
{
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return -1;
- if (i < 0)
+ }
+ if (i < 0) {
i += COLOR_SIZE;
+ }
return Color_ass_item(self, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) {
return -1;
+ }
- if (step == 1)
+ if (step == 1) {
return Color_ass_slice(self, start, stop, value);
+ }
else {
PyErr_SetString(PyExc_IndexError,
"slice steps not supported with color");
@@ -419,8 +448,9 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2)
color1 = (ColorObject *)v1;
color2 = (ColorObject *)v2;
- if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
+ if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) {
return NULL;
+ }
add_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE);
@@ -442,8 +472,9 @@ static PyObject *Color_iadd(PyObject *v1, PyObject *v2)
color1 = (ColorObject *)v1;
color2 = (ColorObject *)v2;
- if (BaseMath_ReadCallback_ForWrite(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
+ if (BaseMath_ReadCallback_ForWrite(color1) == -1 || BaseMath_ReadCallback(color2) == -1) {
return NULL;
+ }
add_vn_vn(color1->col, color2->col, COLOR_SIZE);
@@ -468,8 +499,9 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2)
color1 = (ColorObject *)v1;
color2 = (ColorObject *)v2;
- if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
+ if (BaseMath_ReadCallback(color1) == -1 || BaseMath_ReadCallback(color2) == -1) {
return NULL;
+ }
sub_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE);
@@ -491,8 +523,9 @@ static PyObject *Color_isub(PyObject *v1, PyObject *v2)
color1 = (ColorObject *)v1;
color2 = (ColorObject *)v2;
- if (BaseMath_ReadCallback_ForWrite(color1) == -1 || BaseMath_ReadCallback(color2) == -1)
+ if (BaseMath_ReadCallback_ForWrite(color1) == -1 || BaseMath_ReadCallback(color2) == -1) {
return NULL;
+ }
sub_vn_vn(color1->col, color2->col, COLOR_SIZE);
@@ -516,13 +549,15 @@ static PyObject *Color_mul(PyObject *v1, PyObject *v2)
if (ColorObject_Check(v1)) {
color1 = (ColorObject *)v1;
- if (BaseMath_ReadCallback(color1) == -1)
+ if (BaseMath_ReadCallback(color1) == -1) {
return NULL;
+ }
}
if (ColorObject_Check(v2)) {
color2 = (ColorObject *)v2;
- if (BaseMath_ReadCallback(color2) == -1)
+ if (BaseMath_ReadCallback(color2) == -1) {
return NULL;
+ }
}
@@ -558,8 +593,9 @@ static PyObject *Color_div(PyObject *v1, PyObject *v2)
if (ColorObject_Check(v1)) {
color1 = (ColorObject *)v1;
- if (BaseMath_ReadCallback(color1) == -1)
+ if (BaseMath_ReadCallback(color1) == -1) {
return NULL;
+ }
}
else {
PyErr_SetString(PyExc_TypeError,
@@ -590,8 +626,9 @@ static PyObject *Color_imul(PyObject *v1, PyObject *v2)
ColorObject *color = (ColorObject *)v1;
float scalar;
- if (BaseMath_ReadCallback_ForWrite(color) == -1)
+ if (BaseMath_ReadCallback_ForWrite(color) == -1) {
return NULL;
+ }
/* only support color *= float */
if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR *= FLOAT */
@@ -616,8 +653,9 @@ static PyObject *Color_idiv(PyObject *v1, PyObject *v2)
ColorObject *color = (ColorObject *)v1;
float scalar;
- if (BaseMath_ReadCallback_ForWrite(color) == -1)
+ if (BaseMath_ReadCallback_ForWrite(color) == -1) {
return NULL;
+ }
/* only support color /= float */
if (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0) { /* COLOR /= FLOAT */
@@ -648,8 +686,9 @@ static PyObject *Color_neg(ColorObject *self)
{
float tcol[COLOR_SIZE];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
negate_vn_vn(tcol, self->col, COLOR_SIZE);
return Color_CreatePyObject(tcol, Py_TYPE(self));
@@ -718,8 +757,9 @@ static PyObject *Color_channel_hsv_get(ColorObject *self, void *type)
float hsv[3];
int i = POINTER_AS_INT(type);
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
@@ -739,16 +779,18 @@ static int Color_channel_hsv_set(ColorObject *self, PyObject *value, void *type)
return -1;
}
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
rgb_to_hsv_v(self->col, hsv);
CLAMP(f, 0.0f, 1.0f);
hsv[i] = f;
hsv_to_rgb_v(hsv, self->col);
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return -1;
+ }
return 0;
}
@@ -760,8 +802,9 @@ static PyObject *Color_hsv_get(ColorObject *self, void *UNUSED(closure))
float hsv[3];
PyObject *ret;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2]));
@@ -777,11 +820,13 @@ static int Color_hsv_set(ColorObject *self, PyObject *value, void *UNUSED(closur
{
float hsv[3];
- if (mathutils_array_parse(hsv, 3, 3, value, "mathutils.Color.hsv = value") == -1)
+ if (mathutils_array_parse(hsv, 3, 3, value, "mathutils.Color.hsv = value") == -1) {
return -1;
+ }
- if (BaseMath_Prepare_ForWrite(self) == -1)
+ if (BaseMath_Prepare_ForWrite(self) == -1) {
return -1;
+ }
CLAMP(hsv[0], 0.0f, 1.0f);
CLAMP(hsv[1], 0.0f, 1.0f);
@@ -789,8 +834,9 @@ static int Color_hsv_set(ColorObject *self, PyObject *value, void *UNUSED(closur
hsv_to_rgb_v(hsv, self->col);
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return -1;
+ }
return 0;
}
@@ -913,10 +959,12 @@ PyObject *Color_CreatePyObject(
self->cb_type = self->cb_subtype = 0;
/* NEW */
- if (col)
+ if (col) {
copy_v3_v3(self->col, col);
- else
+ }
+ else {
zero_v3(self->col);
+ }
self->flag = BASE_MATH_FLAG_DEFAULT;
}
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c
index a3336309574..e928049644b 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -51,19 +51,22 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
- if (!PyArg_ParseTuple(args, "|Os:mathutils.Euler", &seq, &order_str))
+ if (!PyArg_ParseTuple(args, "|Os:mathutils.Euler", &seq, &order_str)) {
return NULL;
+ }
switch (PyTuple_GET_SIZE(args)) {
case 0:
break;
case 2:
- if ((order = euler_order_from_string(order_str, "mathutils.Euler()")) == -1)
+ if ((order = euler_order_from_string(order_str, "mathutils.Euler()")) == -1) {
return NULL;
+ }
ATTR_FALLTHROUGH;
case 1:
- if (mathutils_array_parse(eul, EULER_SIZE, EULER_SIZE, seq, "mathutils.Euler()") == -1)
+ if (mathutils_array_parse(eul, EULER_SIZE, EULER_SIZE, seq, "mathutils.Euler()") == -1) {
return NULL;
+ }
break;
}
return Euler_CreatePyObject(eul, order, type);
@@ -141,8 +144,9 @@ static PyObject *Euler_to_quaternion(EulerObject *self)
{
float quat[4];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
eulO_to_quat(quat, self->eul, self->order);
@@ -162,8 +166,9 @@ static PyObject *Euler_to_matrix(EulerObject *self)
{
float mat[9];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
eulO_to_mat3((float (*)[3])mat, self->eul, self->order);
@@ -177,13 +182,15 @@ PyDoc_STRVAR(Euler_zero_doc,
);
static PyObject *Euler_zero(EulerObject *self)
{
- if (BaseMath_Prepare_ForWrite(self) == -1)
+ if (BaseMath_Prepare_ForWrite(self) == -1) {
return NULL;
+ }
zero_v3(self->eul);
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return NULL;
+ }
Py_RETURN_NONE;
}
@@ -218,8 +225,9 @@ static PyObject *Euler_rotate_axis(EulerObject *self, PyObject *args)
return NULL;
}
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
rotate_eulO(self->eul, self->order, (char)axis, angle);
@@ -241,11 +249,13 @@ static PyObject *Euler_rotate(EulerObject *self, PyObject *value)
{
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
- if (mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1)
+ if (mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1) {
return NULL;
+ }
eulO_to_mat3(self_rmat, self->eul, self->order);
mul_m3_m3m3(rmat, other_rmat, self_rmat);
@@ -268,8 +278,9 @@ static PyObject *Euler_make_compatible(EulerObject *self, PyObject *value)
{
float teul[EULER_SIZE];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value,
"euler.make_compatible(other), invalid 'other' arg") == -1)
@@ -300,8 +311,9 @@ PyDoc_STRVAR(Euler_copy_doc,
);
static PyObject *Euler_copy(EulerObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return Euler_CreatePyObject(self->eul, self->order, Py_TYPE(self));
}
@@ -320,8 +332,9 @@ static PyObject *Euler_repr(EulerObject *self)
{
PyObject *ret, *tuple;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
tuple = Euler_ToTupleExt(self, -1);
@@ -336,8 +349,9 @@ static PyObject *Euler_str(EulerObject *self)
{
DynStr *ds;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
ds = BLI_dynstr_new();
@@ -357,8 +371,9 @@ static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op)
EulerObject *eulA = (EulerObject *)a;
EulerObject *eulB = (EulerObject *)b;
- if (BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1)
+ if (BaseMath_ReadCallback(eulA) == -1 || BaseMath_ReadCallback(eulB) == -1) {
return NULL;
+ }
ok = ((eulA->order == eulB->order) && EXPP_VectorsAreEqual(eulA->eul, eulB->eul, EULER_SIZE, 1)) ? 0 : -1;
}
@@ -387,11 +402,13 @@ static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op)
static Py_hash_t Euler_hash(EulerObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
+ }
- if (BaseMathObject_Prepare_ForHash(self) == -1)
+ if (BaseMathObject_Prepare_ForHash(self) == -1) {
return -1;
+ }
return mathutils_array_hash(self->eul, EULER_SIZE);
}
@@ -407,7 +424,9 @@ static int Euler_len(EulerObject *UNUSED(self))
/* sequence accessor (get) */
static PyObject *Euler_item(EulerObject *self, int i)
{
- if (i < 0) i = EULER_SIZE - i;
+ if (i < 0) {
+ i = EULER_SIZE - i;
+ }
if (i < 0 || i >= EULER_SIZE) {
PyErr_SetString(PyExc_IndexError,
@@ -416,8 +435,9 @@ static PyObject *Euler_item(EulerObject *self, int i)
return NULL;
}
- if (BaseMath_ReadIndexCallback(self, i) == -1)
+ if (BaseMath_ReadIndexCallback(self, i) == -1) {
return NULL;
+ }
return PyFloat_FromDouble(self->eul[i]);
@@ -428,8 +448,9 @@ static int Euler_ass_item(EulerObject *self, int i, PyObject *value)
{
float f;
- if (BaseMath_Prepare_ForWrite(self) == -1)
+ if (BaseMath_Prepare_ForWrite(self) == -1) {
return -1;
+ }
f = PyFloat_AsDouble(value);
if (f == -1 && PyErr_Occurred()) { /* parsed item not a number */
@@ -439,7 +460,9 @@ static int Euler_ass_item(EulerObject *self, int i, PyObject *value)
return -1;
}
- if (i < 0) i = EULER_SIZE - i;
+ if (i < 0) {
+ i = EULER_SIZE - i;
+ }
if (i < 0 || i >= EULER_SIZE) {
PyErr_SetString(PyExc_IndexError,
@@ -450,8 +473,9 @@ static int Euler_ass_item(EulerObject *self, int i, PyObject *value)
self->eul[i] = f;
- if (BaseMath_WriteIndexCallback(self, i) == -1)
+ if (BaseMath_WriteIndexCallback(self, i) == -1) {
return -1;
+ }
return 0;
}
@@ -462,11 +486,14 @@ static PyObject *Euler_slice(EulerObject *self, int begin, int end)
PyObject *tuple;
int count;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
CLAMP(begin, 0, EULER_SIZE);
- if (end < 0) end = (EULER_SIZE + 1) + end;
+ if (end < 0) {
+ end = (EULER_SIZE + 1) + end;
+ }
CLAMP(end, 0, EULER_SIZE);
begin = MIN2(begin, end);
@@ -484,16 +511,20 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
int i, size;
float eul[EULER_SIZE];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
CLAMP(begin, 0, EULER_SIZE);
- if (end < 0) end = (EULER_SIZE + 1) + end;
+ if (end < 0) {
+ end = (EULER_SIZE + 1) + end;
+ }
CLAMP(end, 0, EULER_SIZE);
begin = MIN2(begin, end);
- if ((size = mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1)
+ if ((size = mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1) {
return -1;
+ }
if (size != (end - begin)) {
PyErr_SetString(PyExc_ValueError,
@@ -502,8 +533,9 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
return -1;
}
- for (i = 0; i < EULER_SIZE; i++)
+ for (i = 0; i < EULER_SIZE; i++) {
self->eul[begin + i] = eul[i];
+ }
(void)BaseMath_WriteCallback(self);
return 0;
@@ -514,17 +546,20 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item)
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
- if (i < 0)
+ }
+ if (i < 0) {
i += EULER_SIZE;
+ }
return Euler_item(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) {
return NULL;
+ }
if (slicelength <= 0) {
return PyTuple_New(0);
@@ -551,20 +586,24 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu
{
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return -1;
- if (i < 0)
+ }
+ if (i < 0) {
i += EULER_SIZE;
+ }
return Euler_ass_item(self, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, EULER_SIZE, &start, &stop, &step, &slicelength) < 0) {
return -1;
+ }
- if (step == 1)
+ if (step == 1) {
return Euler_ass_slice(self, start, stop, value);
+ }
else {
PyErr_SetString(PyExc_IndexError,
"slice steps not supported with euler");
@@ -621,8 +660,10 @@ PyDoc_STRVAR(Euler_order_doc,
);
static PyObject *Euler_order_get(EulerObject *self, void *UNUSED(closure))
{
- if (BaseMath_ReadCallback(self) == -1) /* can read order too */
+ if (BaseMath_ReadCallback(self) == -1) {
+ /* can read order too */
return NULL;
+ }
return PyUnicode_FromString(euler_order_str(self));
}
@@ -632,8 +673,9 @@ static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(clos
const char *order_str;
short order;
- if (BaseMath_Prepare_ForWrite(self) == -1)
+ if (BaseMath_Prepare_ForWrite(self) == -1) {
return -1;
+ }
if (((order_str = _PyUnicode_AsString(value)) == NULL) ||
((order = euler_order_from_string(order_str, "euler.order")) == -1))
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 373a6635369..6477493d4a6 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -89,10 +89,12 @@ static int mathutils_matrix_row_get(BaseMathObject *bmo, int row)
MatrixObject *self = (MatrixObject *)bmo->cb_user;
int col;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
- if (!matrix_row_vector_check(self, (VectorObject *)bmo, row))
+ }
+ if (!matrix_row_vector_check(self, (VectorObject *)bmo, row)) {
return -1;
+ }
for (col = 0; col < self->num_col; col++) {
bmo->data[col] = MATRIX_ITEM(self, row, col);
@@ -106,10 +108,12 @@ static int mathutils_matrix_row_set(BaseMathObject *bmo, int row)
MatrixObject *self = (MatrixObject *)bmo->cb_user;
int col;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
- if (!matrix_row_vector_check(self, (VectorObject *)bmo, row))
+ }
+ if (!matrix_row_vector_check(self, (VectorObject *)bmo, row)) {
return -1;
+ }
for (col = 0; col < self->num_col; col++) {
MATRIX_ITEM(self, row, col) = bmo->data[col];
@@ -123,10 +127,12 @@ static int mathutils_matrix_row_get_index(BaseMathObject *bmo, int row, int col)
{
MatrixObject *self = (MatrixObject *)bmo->cb_user;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
- if (!matrix_row_vector_check(self, (VectorObject *)bmo, row))
+ }
+ if (!matrix_row_vector_check(self, (VectorObject *)bmo, row)) {
return -1;
+ }
bmo->data[col] = MATRIX_ITEM(self, row, col);
return 0;
@@ -136,10 +142,12 @@ static int mathutils_matrix_row_set_index(BaseMathObject *bmo, int row, int col)
{
MatrixObject *self = (MatrixObject *)bmo->cb_user;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
- if (!matrix_row_vector_check(self, (VectorObject *)bmo, row))
+ }
+ if (!matrix_row_vector_check(self, (VectorObject *)bmo, row)) {
return -1;
+ }
MATRIX_ITEM(self, row, col) = bmo->data[col];
@@ -174,10 +182,12 @@ static int mathutils_matrix_col_get(BaseMathObject *bmo, int col)
int num_row;
int row;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
- if (!matrix_col_vector_check(self, (VectorObject *)bmo, col))
+ }
+ if (!matrix_col_vector_check(self, (VectorObject *)bmo, col)) {
return -1;
+ }
/* for 'translation' size will always be '3' even on 4x4 vec */
num_row = min_ii(self->num_row, ((VectorObject *)bmo)->size);
@@ -195,10 +205,12 @@ static int mathutils_matrix_col_set(BaseMathObject *bmo, int col)
int num_row;
int row;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
- if (!matrix_col_vector_check(self, (VectorObject *)bmo, col))
+ }
+ if (!matrix_col_vector_check(self, (VectorObject *)bmo, col)) {
return -1;
+ }
/* for 'translation' size will always be '3' even on 4x4 vec */
num_row = min_ii(self->num_row, ((VectorObject *)bmo)->size);
@@ -215,10 +227,12 @@ static int mathutils_matrix_col_get_index(BaseMathObject *bmo, int col, int row)
{
MatrixObject *self = (MatrixObject *)bmo->cb_user;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
- if (!matrix_col_vector_check(self, (VectorObject *)bmo, col))
+ }
+ if (!matrix_col_vector_check(self, (VectorObject *)bmo, col)) {
return -1;
+ }
bmo->data[row] = MATRIX_ITEM(self, row, col);
return 0;
@@ -228,10 +242,12 @@ static int mathutils_matrix_col_set_index(BaseMathObject *bmo, int col, int row)
{
MatrixObject *self = (MatrixObject *)bmo->cb_user;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
- if (!matrix_col_vector_check(self, (VectorObject *)bmo, col))
+ }
+ if (!matrix_col_vector_check(self, (VectorObject *)bmo, col)) {
return -1;
+ }
MATRIX_ITEM(self, row, col) = bmo->data[row];
@@ -266,8 +282,9 @@ static int mathutils_matrix_translation_get(BaseMathObject *bmo, int col)
MatrixObject *self = (MatrixObject *)bmo->cb_user;
int row;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
+ }
for (row = 0; row < 3; row++) {
bmo->data[row] = MATRIX_ITEM(self, row, col);
@@ -281,8 +298,9 @@ static int mathutils_matrix_translation_set(BaseMathObject *bmo, int col)
MatrixObject *self = (MatrixObject *)bmo->cb_user;
int row;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
for (row = 0; row < 3; row++) {
MATRIX_ITEM(self, row, col) = bmo->data[row];
@@ -296,8 +314,9 @@ static int mathutils_matrix_translation_get_index(BaseMathObject *bmo, int col,
{
MatrixObject *self = (MatrixObject *)bmo->cb_user;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
+ }
bmo->data[row] = MATRIX_ITEM(self, row, col);
return 0;
@@ -307,8 +326,9 @@ static int mathutils_matrix_translation_set_index(BaseMathObject *bmo, int col,
{
MatrixObject *self = (MatrixObject *)bmo->cb_user;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
MATRIX_ITEM(self, row, col) = bmo->data[row];
@@ -465,10 +485,12 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
const char *axis = NULL;
int matSize;
double angle; /* use double because of precision problems at high values */
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f};
+ float mat[16] = {
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f,
+ };
if (!PyArg_ParseTuple(args, "di|O:Matrix.Rotation", &angle, &matSize, &vec)) {
return NULL;
@@ -514,8 +536,9 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
if (vec) {
float tvec[3];
- if (mathutils_array_parse(tvec, 3, 3, vec, "Matrix.Rotation(angle, size, axis), invalid 'axis' arg") == -1)
+ if (mathutils_array_parse(tvec, 3, 3, vec, "Matrix.Rotation(angle, size, axis), invalid 'axis' arg") == -1) {
return NULL;
+ }
axis_angle_to_mat3((float (*)[3])mat, tvec, angle);
}
@@ -552,8 +575,9 @@ static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value)
unit_m4(mat);
- if (mathutils_array_parse(mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1)
+ if (mathutils_array_parse(mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1) {
return NULL;
+ }
return Matrix_CreatePyObject(&mat[0][0], 4, 4, (PyTypeObject *)cls);
}
@@ -580,10 +604,12 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
float tvec[3];
float factor;
int matSize;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f};
+ float mat[16] = {
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f,
+ };
if (!PyArg_ParseTuple(args, "fi|O:Matrix.Scale", &factor, &matSize, &vec)) {
return NULL;
@@ -671,10 +697,12 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
int matSize, x;
float norm = 0.0f;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f};
+ float mat[16] = {
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f,
+ };
if (!PyArg_ParseTuple(args, "Oi:Matrix.OrthoProjection", &axis, &matSize)) {
return NULL;
@@ -792,10 +820,12 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
int matSize;
const char *plane;
PyObject *fac;
- float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f};
+ float mat[16] = {
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f,
+ };
if (!PyArg_ParseTuple(args, "siO:Matrix.Shear", &plane, &matSize, &fac)) {
return NULL;
@@ -1071,8 +1101,9 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self)
{
float quat[4];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
/* must be 3-4 cols, 3-4 rows, square matrix */
if ((self->num_row < 3) || (self->num_col < 3) || (self->num_row != self->num_col)) {
@@ -1117,15 +1148,18 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
float mat[3][3];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
- if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
+ if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat)) {
return NULL;
+ }
if (eul_compat) {
- if (BaseMath_ReadCallback(eul_compat) == -1)
+ if (BaseMath_ReadCallback(eul_compat) == -1) {
return NULL;
+ }
copy_v3_v3(eul_compatf, eul_compat->eul);
}
@@ -1147,19 +1181,28 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args)
if (order_str) {
order = euler_order_from_string(order_str, "Matrix.to_euler()");
- if (order == -1)
+ if (order == -1) {
return NULL;
+ }
}
normalize_m3(mat);
if (eul_compat) {
- if (order == 1) mat3_normalized_to_compatible_eul(eul, eul_compatf, mat);
- else mat3_normalized_to_compatible_eulO(eul, eul_compatf, order, mat);
+ if (order == 1) {
+ mat3_normalized_to_compatible_eul(eul, eul_compatf, mat);
+ }
+ else {
+ mat3_normalized_to_compatible_eulO(eul, eul_compatf, order, mat);
+ }
}
else {
- if (order == 1) mat3_normalized_to_eul(eul, mat);
- else mat3_normalized_to_eulO(eul, order, mat);
+ if (order == 1) {
+ mat3_normalized_to_eul(eul, mat);
+ }
+ else {
+ mat3_normalized_to_eulO(eul, order, mat);
+ }
}
return Euler_CreatePyObject(eul, order, NULL);
@@ -1220,8 +1263,9 @@ PyDoc_STRVAR(Matrix_to_4x4_doc,
);
static PyObject *Matrix_to_4x4(MatrixObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (self->num_row == 4 && self->num_col == 4) {
return Matrix_CreatePyObject(self->matrix, 4, 4, Py_TYPE(self));
@@ -1251,8 +1295,9 @@ static PyObject *Matrix_to_3x3(MatrixObject *self)
{
float mat[3][3];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if ((self->num_row < 3) || (self->num_col < 3)) {
PyErr_SetString(PyExc_ValueError,
@@ -1275,8 +1320,9 @@ PyDoc_STRVAR(Matrix_to_translation_doc,
);
static PyObject *Matrix_to_translation(MatrixObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if ((self->num_row < 3) || self->num_col < 4) {
PyErr_SetString(PyExc_ValueError,
@@ -1304,8 +1350,9 @@ static PyObject *Matrix_to_scale(MatrixObject *self)
float mat[3][3];
float size[3];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
/*must be 3-4 cols, 3-4 rows, square matrix */
if ((self->num_row < 3) || (self->num_col < 3)) {
@@ -1393,8 +1440,9 @@ PyDoc_STRVAR(Matrix_invert_doc,
);
static PyObject *Matrix_invert(MatrixObject *self, PyObject *args)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (matrix_invert_is_compat(self) == false) {
return NULL;
@@ -1411,8 +1459,9 @@ static PyObject *Matrix_invert(MatrixObject *self, PyObject *args)
if (PyTuple_GET_SIZE(args) == 1) {
MatrixObject *fallback = (MatrixObject *)PyTuple_GET_ITEM(args, 0);
- if (BaseMath_ReadCallback(fallback) == -1)
+ if (BaseMath_ReadCallback(fallback) == -1) {
return NULL;
+ }
if (self != fallback) {
matrix_copy(self, fallback);
@@ -1443,8 +1492,9 @@ static PyObject *Matrix_inverted(MatrixObject *self, PyObject *args)
{
float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (matrix_invert_args_check(self, args, false) == false) {
return NULL;
@@ -1474,8 +1524,9 @@ static PyObject *Matrix_inverted(MatrixObject *self, PyObject *args)
static PyObject *Matrix_inverted_noargs(MatrixObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (matrix_invert_is_compat(self) == false) {
return NULL;
@@ -1504,8 +1555,9 @@ PyDoc_STRVAR(Matrix_invert_safe_doc,
);
static PyObject *Matrix_invert_safe(MatrixObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (matrix_invert_is_compat(self) == false) {
return NULL;
@@ -1531,8 +1583,9 @@ static PyObject *Matrix_inverted_safe(MatrixObject *self)
{
float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (matrix_invert_is_compat(self) == false) {
return NULL;
@@ -1555,8 +1608,9 @@ PyDoc_STRVAR(Matrix_adjugate_doc,
);
static PyObject *Matrix_adjugate(MatrixObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (self->num_col != self->num_row) {
PyErr_SetString(PyExc_ValueError,
@@ -1610,11 +1664,13 @@ static PyObject *Matrix_rotate(MatrixObject *self, PyObject *value)
{
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
- if (mathutils_any_to_rotmat(other_rmat, value, "matrix.rotate(value)") == -1)
+ if (mathutils_any_to_rotmat(other_rmat, value, "matrix.rotate(value)") == -1) {
return NULL;
+ }
if (self->num_row != 3 || self->num_col != 3) {
PyErr_SetString(PyExc_ValueError,
@@ -1656,8 +1712,9 @@ static PyObject *Matrix_decompose(MatrixObject *self)
return NULL;
}
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
mat4_to_loc_rot_size(loc, rot, size, (float (*)[4])self->matrix);
mat3_to_quat(quat, rot);
@@ -1690,8 +1747,9 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args)
MatrixObject *mat2 = NULL;
float fac, mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
- if (!PyArg_ParseTuple(args, "O!f:lerp", &matrix_Type, &mat2, &fac))
+ if (!PyArg_ParseTuple(args, "O!f:lerp", &matrix_Type, &mat2, &fac)) {
return NULL;
+ }
if (self->num_col != mat2->num_col || self->num_row != mat2->num_row) {
PyErr_SetString(PyExc_ValueError,
@@ -1700,8 +1758,9 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args)
return NULL;
}
- if (BaseMath_ReadCallback(self) == -1 || BaseMath_ReadCallback(mat2) == -1)
+ if (BaseMath_ReadCallback(self) == -1 || BaseMath_ReadCallback(mat2) == -1) {
return NULL;
+ }
/* TODO, different sized matrix */
if (self->num_col == 4 && self->num_row == 4) {
@@ -1741,8 +1800,9 @@ PyDoc_STRVAR(Matrix_determinant_doc,
);
static PyObject *Matrix_determinant(MatrixObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (self->num_col != self->num_row) {
PyErr_SetString(PyExc_ValueError,
@@ -1763,8 +1823,9 @@ PyDoc_STRVAR(Matrix_transpose_doc,
);
static PyObject *Matrix_transpose(MatrixObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (self->num_col != self->num_row) {
PyErr_SetString(PyExc_ValueError,
@@ -1810,8 +1871,9 @@ PyDoc_STRVAR(Matrix_normalize_doc,
);
static PyObject *Matrix_normalize(MatrixObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (self->num_col != self->num_row) {
PyErr_SetString(PyExc_ValueError,
@@ -1859,13 +1921,15 @@ PyDoc_STRVAR(Matrix_zero_doc,
);
static PyObject *Matrix_zero(MatrixObject *self)
{
- if (BaseMath_Prepare_ForWrite(self) == -1)
+ if (BaseMath_Prepare_ForWrite(self) == -1) {
return NULL;
+ }
copy_vn_fl(self->matrix, self->num_col * self->num_row, 0.0f);
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return NULL;
+ }
Py_RETURN_NONE;
@@ -1898,8 +1962,9 @@ PyDoc_STRVAR(Matrix_identity_doc,
);
static PyObject *Matrix_identity(MatrixObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (self->num_col != self->num_row) {
PyErr_SetString(PyExc_ValueError,
@@ -1910,8 +1975,9 @@ static PyObject *Matrix_identity(MatrixObject *self)
matrix_identity_internal(self);
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return NULL;
+ }
Py_RETURN_NONE;
}
@@ -1933,8 +1999,9 @@ PyDoc_STRVAR(Matrix_copy_doc,
);
static PyObject *Matrix_copy(MatrixObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return Matrix_copy_notest(self, self->matrix);
}
@@ -1953,8 +2020,9 @@ static PyObject *Matrix_repr(MatrixObject *self)
int col, row;
PyObject *rows[MATRIX_MAX_DIM] = {NULL};
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
for (row = 0; row < self->num_row; row++) {
rows[row] = PyTuple_New(self->num_col);
@@ -1990,8 +2058,9 @@ static PyObject *Matrix_str(MatrixObject *self)
char dummy_buf[64];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
ds = BLI_dynstr_new();
@@ -2027,8 +2096,9 @@ static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op)
MatrixObject *matA = (MatrixObject *)a;
MatrixObject *matB = (MatrixObject *)b;
- if (BaseMath_ReadCallback(matA) == -1 || BaseMath_ReadCallback(matB) == -1)
+ if (BaseMath_ReadCallback(matA) == -1 || BaseMath_ReadCallback(matB) == -1) {
return NULL;
+ }
ok = ((matA->num_row == matB->num_row) &&
(matA->num_col == matB->num_col) &&
@@ -2062,11 +2132,13 @@ static Py_hash_t Matrix_hash(MatrixObject *self)
{
float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
+ }
- if (BaseMathObject_Prepare_ForHash(self) == -1)
+ if (BaseMathObject_Prepare_ForHash(self) == -1) {
return -1;
+ }
matrix_transpose_internal(mat, self);
@@ -2085,8 +2157,9 @@ static int Matrix_len(MatrixObject *self)
* the wrapped vector gives direct access to the matrix data */
static PyObject *Matrix_item_row(MatrixObject *self, int row)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (row < 0 || row >= self->num_row) {
PyErr_SetString(PyExc_IndexError,
@@ -2099,8 +2172,9 @@ static PyObject *Matrix_item_row(MatrixObject *self, int row)
/* same but column access */
static PyObject *Matrix_item_col(MatrixObject *self, int col)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
if (col < 0 || col >= self->num_col) {
PyErr_SetString(PyExc_IndexError,
@@ -2118,8 +2192,9 @@ static int Matrix_ass_item_row(MatrixObject *self, int row, PyObject *value)
{
int col;
float vec[MATRIX_MAX_DIM];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
if (row >= self->num_row || row < 0) {
PyErr_SetString(PyExc_IndexError,
@@ -2143,8 +2218,9 @@ static int Matrix_ass_item_col(MatrixObject *self, int col, PyObject *value)
{
int row;
float vec[MATRIX_MAX_DIM];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
if (col >= self->num_col || col < 0) {
PyErr_SetString(PyExc_IndexError,
@@ -2174,8 +2250,9 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end)
PyObject *tuple;
int count;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
CLAMP(begin, 0, self->num_row);
CLAMP(end, 0, self->num_row);
@@ -2195,8 +2272,9 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
{
PyObject *value_fast;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
CLAMP(begin, 0, self->num_row);
CLAMP(end, 0, self->num_row);
@@ -2268,8 +2346,9 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2)
return NULL;
}
- if (BaseMath_ReadCallback(mat1) == -1 || BaseMath_ReadCallback(mat2) == -1)
+ if (BaseMath_ReadCallback(mat1) == -1 || BaseMath_ReadCallback(mat2) == -1) {
return NULL;
+ }
if (mat1->num_col != mat2->num_col || mat1->num_row != mat2->num_row) {
PyErr_SetString(PyExc_ValueError,
@@ -2300,8 +2379,9 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2)
return NULL;
}
- if (BaseMath_ReadCallback(mat1) == -1 || BaseMath_ReadCallback(mat2) == -1)
+ if (BaseMath_ReadCallback(mat1) == -1 || BaseMath_ReadCallback(mat2) == -1) {
return NULL;
+ }
if (mat1->num_col != mat2->num_col || mat1->num_row != mat2->num_row) {
PyErr_SetString(PyExc_ValueError,
@@ -2331,13 +2411,15 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
if (MatrixObject_Check(m1)) {
mat1 = (MatrixObject *)m1;
- if (BaseMath_ReadCallback(mat1) == -1)
+ if (BaseMath_ReadCallback(mat1) == -1) {
return NULL;
+ }
}
if (MatrixObject_Check(m2)) {
mat2 = (MatrixObject *)m2;
- if (BaseMath_ReadCallback(mat2) == -1)
+ if (BaseMath_ReadCallback(mat2) == -1) {
return NULL;
+ }
}
if (mat1 && mat2) {
@@ -2386,13 +2468,15 @@ static PyObject *Matrix_imul(PyObject *m1, PyObject *m2)
if (MatrixObject_Check(m1)) {
mat1 = (MatrixObject *)m1;
- if (BaseMath_ReadCallback(mat1) == -1)
+ if (BaseMath_ReadCallback(mat1) == -1) {
return NULL;
+ }
}
if (MatrixObject_Check(m2)) {
mat2 = (MatrixObject *)m2;
- if (BaseMath_ReadCallback(mat2) == -1)
+ if (BaseMath_ReadCallback(mat2) == -1) {
return NULL;
+ }
}
if (mat1 && mat2) {
@@ -2440,13 +2524,15 @@ static PyObject *Matrix_matmul(PyObject *m1, PyObject *m2)
if (MatrixObject_Check(m1)) {
mat1 = (MatrixObject *)m1;
- if (BaseMath_ReadCallback(mat1) == -1)
+ if (BaseMath_ReadCallback(mat1) == -1) {
return NULL;
+ }
}
if (MatrixObject_Check(m2)) {
mat2 = (MatrixObject *)m2;
- if (BaseMath_ReadCallback(mat2) == -1)
+ if (BaseMath_ReadCallback(mat2) == -1) {
return NULL;
+ }
}
if (mat1 && mat2) {
@@ -2479,8 +2565,9 @@ static PyObject *Matrix_matmul(PyObject *m1, PyObject *m2)
if (VectorObject_Check(m2)) {
VectorObject *vec2 = (VectorObject *)m2;
float tvec[MATRIX_MAX_DIM];
- if (BaseMath_ReadCallback(vec2) == -1)
+ if (BaseMath_ReadCallback(vec2) == -1) {
return NULL;
+ }
if (column_vector_multiplication(tvec, vec2, mat1) == -1) {
return NULL;
}
@@ -2510,13 +2597,15 @@ static PyObject *Matrix_imatmul(PyObject *m1, PyObject *m2)
if (MatrixObject_Check(m1)) {
mat1 = (MatrixObject *)m1;
- if (BaseMath_ReadCallback(mat1) == -1)
+ if (BaseMath_ReadCallback(mat1) == -1) {
return NULL;
+ }
}
if (MatrixObject_Check(m2)) {
mat2 = (MatrixObject *)m2;
- if (BaseMath_ReadCallback(mat2) == -1)
+ if (BaseMath_ReadCallback(mat2) == -1) {
return NULL;
+ }
}
if (mat1 && mat2) {
@@ -2579,17 +2668,20 @@ static PyObject *Matrix_subscript(MatrixObject *self, PyObject *item)
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
- if (i < 0)
+ }
+ if (i < 0) {
i += self->num_row;
+ }
return Matrix_item_row(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0) {
return NULL;
+ }
if (slicelength <= 0) {
return PyTuple_New(0);
@@ -2615,20 +2707,24 @@ static int Matrix_ass_subscript(MatrixObject *self, PyObject *item, PyObject *va
{
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return -1;
- if (i < 0)
+ }
+ if (i < 0) {
i += self->num_row;
+ }
return Matrix_ass_item_row(self, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->num_row, &start, &stop, &step, &slicelength) < 0) {
return -1;
+ }
- if (step == 1)
+ if (step == 1) {
return Matrix_ass_slice(self, start, stop, value);
+ }
else {
PyErr_SetString(PyExc_IndexError,
"slice steps not supported with matrices");
@@ -2696,8 +2792,9 @@ static PyObject *Matrix_translation_get(MatrixObject *self, void *UNUSED(closure
{
PyObject *ret;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
/*must be 4x4 square matrix*/
if (self->num_row != 4 || self->num_col != 4) {
@@ -2716,8 +2813,9 @@ static int Matrix_translation_set(MatrixObject *self, PyObject *value, void *UNU
{
float tvec[3];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
/*must be 4x4 square matrix*/
if (self->num_row != 4 || self->num_col != 4) {
@@ -2761,8 +2859,9 @@ static PyObject *Matrix_median_scale_get(MatrixObject *self, void *UNUSED(closur
{
float mat[3][3];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
/*must be 3-4 cols, 3-4 rows, square matrix*/
if ((self->num_row < 3) || (self->num_col < 3)) {
@@ -2782,14 +2881,17 @@ PyDoc_STRVAR(Matrix_is_negative_doc,
);
static PyObject *Matrix_is_negative_get(MatrixObject *self, void *UNUSED(closure))
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
/*must be 3-4 cols, 3-4 rows, square matrix*/
- if (self->num_row == 4 && self->num_col == 4)
+ if (self->num_row == 4 && self->num_col == 4) {
return PyBool_FromLong(is_negative_m4((float (*)[4])self->matrix));
- else if (self->num_row == 3 && self->num_col == 3)
+ }
+ else if (self->num_row == 3 && self->num_col == 3) {
return PyBool_FromLong(is_negative_m3((float (*)[3])self->matrix));
+ }
else {
PyErr_SetString(PyExc_AttributeError,
"Matrix.is_negative: "
@@ -2803,14 +2905,17 @@ PyDoc_STRVAR(Matrix_is_orthogonal_doc,
);
static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closure))
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
/*must be 3-4 cols, 3-4 rows, square matrix*/
- if (self->num_row == 4 && self->num_col == 4)
+ if (self->num_row == 4 && self->num_col == 4) {
return PyBool_FromLong(is_orthonormal_m4((float (*)[4])self->matrix));
- else if (self->num_row == 3 && self->num_col == 3)
+ }
+ else if (self->num_row == 3 && self->num_col == 3) {
return PyBool_FromLong(is_orthonormal_m3((float (*)[3])self->matrix));
+ }
else {
PyErr_SetString(PyExc_AttributeError,
"Matrix.is_orthogonal: "
@@ -2824,14 +2929,17 @@ PyDoc_STRVAR(Matrix_is_orthogonal_axis_vectors_doc,
);
static PyObject *Matrix_is_orthogonal_axis_vectors_get(MatrixObject *self, void *UNUSED(closure))
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
/*must be 3-4 cols, 3-4 rows, square matrix*/
- if (self->num_row == 4 && self->num_col == 4)
+ if (self->num_row == 4 && self->num_col == 4) {
return PyBool_FromLong(is_orthogonal_m4((float (*)[4])self->matrix));
- else if (self->num_row == 3 && self->num_col == 3)
+ }
+ else if (self->num_row == 3 && self->num_col == 3) {
return PyBool_FromLong(is_orthogonal_m3((float (*)[3])self->matrix));
+ }
else {
PyErr_SetString(PyExc_AttributeError,
"Matrix.is_orthogonal_axis_vectors: "
@@ -3200,7 +3308,9 @@ static PyObject *MatrixAccess_slice(MatrixAccessObject *self, int begin, int end
}
CLAMP(begin, 0, matrix_access_len);
- if (end < 0) end = (matrix_access_len + 1) + end;
+ if (end < 0) {
+ end = (matrix_access_len + 1) + end;
+ }
CLAMP(end, 0, matrix_access_len);
begin = MIN2(begin, end);
@@ -3219,24 +3329,28 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
+ }
if (self->type == MAT_ACCESS_ROW) {
- if (i < 0)
+ if (i < 0) {
i += matrix_user->num_row;
+ }
return Matrix_item_row(matrix_user, i);
}
else { /* MAT_ACCESS_ROW */
- if (i < 0)
+ if (i < 0) {
i += matrix_user->num_col;
+ }
return Matrix_item_col(matrix_user, i);
}
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, MatrixAccess_len(self), &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, MatrixAccess_len(self), &start, &stop, &step, &slicelength) < 0) {
return NULL;
+ }
if (slicelength <= 0) {
return PyTuple_New(0);
@@ -3264,17 +3378,20 @@ static int MatrixAccess_ass_subscript(MatrixAccessObject *self, PyObject *item,
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return -1;
+ }
if (self->type == MAT_ACCESS_ROW) {
- if (i < 0)
+ if (i < 0) {
i += matrix_user->num_row;
+ }
return Matrix_ass_item_row(matrix_user, i, value);
}
else { /* MAT_ACCESS_ROW */
- if (i < 0)
+ if (i < 0) {
i += matrix_user->num_col;
+ }
return Matrix_ass_item_col(matrix_user, i, value);
}
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index 5f7ab5fface..422a1ff28fa 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -87,31 +87,43 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args)
short order = EULER_ORDER_XYZ;
EulerObject *eul_compat = NULL;
- if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat))
+ if (!PyArg_ParseTuple(args, "|sO!:to_euler", &order_str, &euler_Type, &eul_compat)) {
return NULL;
+ }
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (order_str) {
order = euler_order_from_string(order_str, "Matrix.to_euler()");
- if (order == -1)
+ if (order == -1) {
return NULL;
+ }
}
normalize_qt_qt(tquat, self->quat);
if (eul_compat) {
- if (BaseMath_ReadCallback(eul_compat) == -1)
+ if (BaseMath_ReadCallback(eul_compat) == -1) {
return NULL;
+ }
- if (order == EULER_ORDER_XYZ) quat_to_compatible_eul(eul, eul_compat->eul, tquat);
- else quat_to_compatible_eulO(eul, eul_compat->eul, order, tquat);
+ if (order == EULER_ORDER_XYZ) {
+ quat_to_compatible_eul(eul, eul_compat->eul, tquat);
+ }
+ else {
+ quat_to_compatible_eulO(eul, eul_compat->eul, order, tquat);
+ }
}
else {
- if (order == EULER_ORDER_XYZ) quat_to_eul(eul, tquat);
- else quat_to_eulO(eul, order, tquat);
+ if (order == EULER_ORDER_XYZ) {
+ quat_to_eul(eul, tquat);
+ }
+ else {
+ quat_to_eulO(eul, order, tquat);
+ }
}
return Euler_CreatePyObject(eul, order, NULL);
@@ -129,8 +141,9 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self)
{
float mat[9]; /* all values are set */
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
quat_to_mat3((float (*)[3])mat, self->quat);
return Matrix_CreatePyObject(mat, 3, 3, NULL);
@@ -153,8 +166,9 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self)
float axis[3];
float angle;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
normalize_qt_qt(tquat, self->quat);
quat_to_axis_angle(axis, &angle, tquat);
@@ -185,8 +199,9 @@ static PyObject *Quaternion_to_exponential_map(QuaternionObject *self)
{
float expmap[3];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
quat_to_expmap(expmap, self->quat);
return Vector_CreatePyObject(expmap, 3, NULL);
@@ -206,8 +221,9 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value)
{
float quat[QUAT_SIZE], tquat[QUAT_SIZE];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value,
"Quaternion.cross(other), invalid 'other' arg") == -1)
@@ -233,8 +249,9 @@ static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value)
{
float tquat[QUAT_SIZE];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value,
"Quaternion.dot(other), invalid 'other' arg") == -1)
@@ -259,8 +276,9 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject
{
float tquat[QUAT_SIZE], quat[QUAT_SIZE];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value,
"Quaternion.difference(other), invalid 'other' arg") == -1)
@@ -297,8 +315,9 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args)
return NULL;
}
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value,
"Quaternion.slerp(other), invalid 'other' arg") == -1)
@@ -331,11 +350,13 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value)
float self_rmat[3][3], other_rmat[3][3], rmat[3][3];
float tquat[4], length;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
- if (mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1)
+ if (mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1) {
return NULL;
+ }
length = normalize_qt_qt(tquat, self->quat);
quat_to_mat3(self_rmat, tquat);
@@ -358,8 +379,9 @@ PyDoc_STRVAR(Quaternion_normalize_doc,
);
static PyObject *Quaternion_normalize(QuaternionObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
normalize_qt(self->quat);
@@ -386,8 +408,9 @@ PyDoc_STRVAR(Quaternion_invert_doc,
);
static PyObject *Quaternion_invert(QuaternionObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
invert_qt(self->quat);
@@ -416,8 +439,9 @@ PyDoc_STRVAR(Quaternion_identity_doc,
);
static PyObject *Quaternion_identity(QuaternionObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
unit_qt(self->quat);
@@ -434,8 +458,9 @@ PyDoc_STRVAR(Quaternion_negate_doc,
);
static PyObject *Quaternion_negate(QuaternionObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
mul_qt_fl(self->quat, -1.0f);
@@ -450,8 +475,9 @@ PyDoc_STRVAR(Quaternion_conjugate_doc,
);
static PyObject *Quaternion_conjugate(QuaternionObject *self)
{
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
conjugate_qt(self->quat);
@@ -484,8 +510,9 @@ PyDoc_STRVAR(Quaternion_copy_doc,
);
static PyObject *Quaternion_copy(QuaternionObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return Quaternion_CreatePyObject(self->quat, Py_TYPE(self));
}
@@ -502,8 +529,9 @@ static PyObject *Quaternion_repr(QuaternionObject *self)
{
PyObject *ret, *tuple;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
tuple = Quaternion_to_tuple_ext(self, -1);
@@ -518,8 +546,9 @@ static PyObject *Quaternion_str(QuaternionObject *self)
{
DynStr *ds;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
ds = BLI_dynstr_new();
@@ -539,8 +568,9 @@ static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
QuaternionObject *quatA = (QuaternionObject *)a;
QuaternionObject *quatB = (QuaternionObject *)b;
- if (BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1)
+ if (BaseMath_ReadCallback(quatA) == -1 || BaseMath_ReadCallback(quatB) == -1) {
return NULL;
+ }
ok = (EXPP_VectorsAreEqual(quatA->quat, quatB->quat, QUAT_SIZE, 1)) ? 0 : -1;
}
@@ -569,11 +599,13 @@ static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
static Py_hash_t Quaternion_hash(QuaternionObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
+ }
- if (BaseMathObject_Prepare_ForHash(self) == -1)
+ if (BaseMathObject_Prepare_ForHash(self) == -1) {
return -1;
+ }
return mathutils_array_hash(self->quat, QUAT_SIZE);
}
@@ -589,7 +621,9 @@ static int Quaternion_len(QuaternionObject *UNUSED(self))
/* sequence accessor (get) */
static PyObject *Quaternion_item(QuaternionObject *self, int i)
{
- if (i < 0) i = QUAT_SIZE - i;
+ if (i < 0) {
+ i = QUAT_SIZE - i;
+ }
if (i < 0 || i >= QUAT_SIZE) {
PyErr_SetString(PyExc_IndexError,
@@ -598,8 +632,9 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i)
return NULL;
}
- if (BaseMath_ReadIndexCallback(self, i) == -1)
+ if (BaseMath_ReadIndexCallback(self, i) == -1) {
return NULL;
+ }
return PyFloat_FromDouble(self->quat[i]);
@@ -610,8 +645,9 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
{
float f;
- if (BaseMath_Prepare_ForWrite(self) == -1)
+ if (BaseMath_Prepare_ForWrite(self) == -1) {
return -1;
+ }
f = (float)PyFloat_AsDouble(ob);
@@ -622,7 +658,9 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
return -1;
}
- if (i < 0) i = QUAT_SIZE - i;
+ if (i < 0) {
+ i = QUAT_SIZE - i;
+ }
if (i < 0 || i >= QUAT_SIZE) {
PyErr_SetString(PyExc_IndexError,
@@ -632,8 +670,9 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob)
}
self->quat[i] = f;
- if (BaseMath_WriteIndexCallback(self, i) == -1)
+ if (BaseMath_WriteIndexCallback(self, i) == -1) {
return -1;
+ }
return 0;
}
@@ -644,11 +683,14 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
PyObject *tuple;
int count;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
CLAMP(begin, 0, QUAT_SIZE);
- if (end < 0) end = (QUAT_SIZE + 1) + end;
+ if (end < 0) {
+ end = (QUAT_SIZE + 1) + end;
+ }
CLAMP(end, 0, QUAT_SIZE);
begin = MIN2(begin, end);
@@ -666,16 +708,20 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
int i, size;
float quat[QUAT_SIZE];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
CLAMP(begin, 0, QUAT_SIZE);
- if (end < 0) end = (QUAT_SIZE + 1) + end;
+ if (end < 0) {
+ end = (QUAT_SIZE + 1) + end;
+ }
CLAMP(end, 0, QUAT_SIZE);
begin = MIN2(begin, end);
- if ((size = mathutils_array_parse(quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1)
+ if ((size = mathutils_array_parse(quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1) {
return -1;
+ }
if (size != (end - begin)) {
PyErr_SetString(PyExc_ValueError,
@@ -685,8 +731,9 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
}
/* parsed well - now set in vector */
- for (i = 0; i < size; i++)
+ for (i = 0; i < size; i++) {
self->quat[begin + i] = quat[i];
+ }
(void)BaseMath_WriteCallback(self);
return 0;
@@ -698,17 +745,20 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
- if (i < 0)
+ }
+ if (i < 0) {
i += QUAT_SIZE;
+ }
return Quaternion_item(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) {
return NULL;
+ }
if (slicelength <= 0) {
return PyTuple_New(0);
@@ -735,20 +785,24 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb
{
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return -1;
- if (i < 0)
+ }
+ if (i < 0) {
i += QUAT_SIZE;
+ }
return Quaternion_ass_item(self, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) {
return -1;
+ }
- if (step == 1)
+ if (step == 1) {
return Quaternion_ass_slice(self, start, stop, value);
+ }
else {
PyErr_SetString(PyExc_IndexError,
"slice steps not supported with quaternion");
@@ -781,8 +835,9 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2)
quat1 = (QuaternionObject *)q1;
quat2 = (QuaternionObject *)q2;
- if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
+ if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1) {
return NULL;
+ }
add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f);
return Quaternion_CreatePyObject(quat, Py_TYPE(q1));
@@ -806,8 +861,9 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2)
quat1 = (QuaternionObject *)q1;
quat2 = (QuaternionObject *)q2;
- if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1)
+ if (BaseMath_ReadCallback(quat1) == -1 || BaseMath_ReadCallback(quat2) == -1) {
return NULL;
+ }
for (x = 0; x < QUAT_SIZE; x++) {
quat[x] = quat1->quat[x] - quat2->quat[x];
@@ -833,13 +889,15 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2)
if (QuaternionObject_Check(q1)) {
quat1 = (QuaternionObject *)q1;
- if (BaseMath_ReadCallback(quat1) == -1)
+ if (BaseMath_ReadCallback(quat1) == -1) {
return NULL;
+ }
}
if (QuaternionObject_Check(q2)) {
quat2 = (QuaternionObject *)q2;
- if (BaseMath_ReadCallback(quat2) == -1)
+ if (BaseMath_ReadCallback(quat2) == -1) {
return NULL;
+ }
}
if (quat1 && quat2) { /* QUAT * QUAT (element-wise product) */
@@ -876,13 +934,15 @@ static PyObject *Quaternion_imul(PyObject *q1, PyObject *q2)
if (QuaternionObject_Check(q1)) {
quat1 = (QuaternionObject *)q1;
- if (BaseMath_ReadCallback(quat1) == -1)
+ if (BaseMath_ReadCallback(quat1) == -1) {
return NULL;
+ }
}
if (QuaternionObject_Check(q2)) {
quat2 = (QuaternionObject *)q2;
- if (BaseMath_ReadCallback(quat2) == -1)
+ if (BaseMath_ReadCallback(quat2) == -1) {
return NULL;
+ }
}
if (quat1 && quat2) { /* QUAT *= QUAT (inplace element-wise product) */
@@ -921,13 +981,15 @@ static PyObject *Quaternion_matmul(PyObject *q1, PyObject *q2)
if (QuaternionObject_Check(q1)) {
quat1 = (QuaternionObject *)q1;
- if (BaseMath_ReadCallback(quat1) == -1)
+ if (BaseMath_ReadCallback(quat1) == -1) {
return NULL;
+ }
}
if (QuaternionObject_Check(q2)) {
quat2 = (QuaternionObject *)q2;
- if (BaseMath_ReadCallback(quat2) == -1)
+ if (BaseMath_ReadCallback(quat2) == -1) {
return NULL;
+ }
}
if (quat1 && quat2) { /* QUAT @ QUAT (cross product) */
@@ -973,13 +1035,15 @@ static PyObject *Quaternion_imatmul(PyObject *q1, PyObject *q2)
if (QuaternionObject_Check(q1)) {
quat1 = (QuaternionObject *)q1;
- if (BaseMath_ReadCallback(quat1) == -1)
+ if (BaseMath_ReadCallback(quat1) == -1) {
return NULL;
+ }
}
if (QuaternionObject_Check(q2)) {
quat2 = (QuaternionObject *)q2;
- if (BaseMath_ReadCallback(quat2) == -1)
+ if (BaseMath_ReadCallback(quat2) == -1) {
return NULL;
+ }
}
if (quat1 && quat2) { /* QUAT @ QUAT (cross product) */
@@ -1005,8 +1069,9 @@ static PyObject *Quaternion_neg(QuaternionObject *self)
{
float tquat[QUAT_SIZE];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
negate_v4_v4(tquat, self->quat);
return Quaternion_CreatePyObject(tquat, Py_TYPE(self));
@@ -1090,8 +1155,9 @@ PyDoc_STRVAR(Quaternion_magnitude_doc,
);
static PyObject *Quaternion_magnitude_get(QuaternionObject *self, void *UNUSED(closure))
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return PyFloat_FromDouble(sqrtf(dot_qtqt(self->quat, self->quat)));
}
@@ -1104,8 +1170,9 @@ static PyObject *Quaternion_angle_get(QuaternionObject *self, void *UNUSED(closu
float tquat[4];
float angle;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
normalize_qt_qt(tquat, self->quat);
@@ -1124,8 +1191,9 @@ static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void *U
float axis[3], angle_dummy;
float angle;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
len = normalize_qt_qt(tquat, self->quat);
quat_to_axis_angle(axis, &angle_dummy, tquat);
@@ -1145,8 +1213,9 @@ static int Quaternion_angle_set(QuaternionObject *self, PyObject *value, void *U
axis_angle_to_quat(self->quat, axis, angle);
mul_qt_fl(self->quat, len);
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return -1;
+ }
return 0;
}
@@ -1161,8 +1230,9 @@ static PyObject *Quaternion_axis_vector_get(QuaternionObject *self, void *UNUSED
float axis[3];
float angle_dummy;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
normalize_qt_qt(tquat, self->quat);
quat_to_axis_angle(axis, &angle_dummy, tquat);
@@ -1180,22 +1250,25 @@ static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, v
float axis[3];
float angle;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
len = normalize_qt_qt(tquat, self->quat);
quat_to_axis_angle(axis, &angle, tquat); /* axis value is unused */
- if (mathutils_array_parse(axis, 3, 3, value, "quat.axis = other") == -1)
+ if (mathutils_array_parse(axis, 3, 3, value, "quat.axis = other") == -1) {
return -1;
+ }
quat__axis_angle_sanitize(axis, &angle);
axis_angle_to_quat(self->quat, axis, angle);
mul_qt_fl(self->quat, len);
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return -1;
+ }
return 0;
}
@@ -1215,8 +1288,9 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
return NULL;
}
- if (!PyArg_ParseTuple(args, "|Od:mathutils.Quaternion", &seq, &angle))
+ if (!PyArg_ParseTuple(args, "|Od:mathutils.Quaternion", &seq, &angle)) {
return NULL;
+ }
switch (PyTuple_GET_SIZE(args)) {
case 0:
@@ -1243,8 +1317,9 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
case 2:
{
float axis[3];
- if (mathutils_array_parse(axis, 3, 3, seq, "mathutils.Quaternion()") == -1)
+ if (mathutils_array_parse(axis, 3, 3, seq, "mathutils.Quaternion()") == -1) {
return NULL;
+ }
angle = angle_wrap_rad(angle); /* clamp because of precision issues */
axis_angle_to_quat(quat, axis, angle);
break;
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 11b8eff85f6..1dd578096f9 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -197,8 +197,9 @@ static PyObject *C_Vector_Range(PyObject *cls, PyObject *args)
size = (stop - start);
- if ((size % step) != 0)
+ if ((size % step) != 0) {
size += step;
+ }
size /= step;
@@ -338,13 +339,15 @@ PyDoc_STRVAR(Vector_zero_doc,
);
static PyObject *Vector_zero(VectorObject *self)
{
- if (BaseMath_Prepare_ForWrite(self) == -1)
+ if (BaseMath_Prepare_ForWrite(self) == -1) {
return NULL;
+ }
copy_vn_fl(self->vec, self->size, 0.0f);
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return NULL;
+ }
Py_RETURN_NONE;
}
@@ -362,8 +365,9 @@ PyDoc_STRVAR(Vector_normalize_doc,
static PyObject *Vector_normalize(VectorObject *self)
{
int size = (self->size == 4 ? 3 : self->size);
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
normalize_vn(self->vec, size);
@@ -533,8 +537,9 @@ static PyObject *Vector_resize_3d(VectorObject *self)
return NULL;
}
- if (self->size == 2)
+ if (self->size == 2) {
self->vec[2] = 0.0f;
+ }
self->size = 3;
Py_RETURN_NONE;
@@ -588,8 +593,9 @@ PyDoc_STRVAR(Vector_to_2d_doc,
);
static PyObject *Vector_to_2d(VectorObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return Vector_CreatePyObject(self->vec, 2, Py_TYPE(self));
}
@@ -605,8 +611,9 @@ static PyObject *Vector_to_3d(VectorObject *self)
{
float tvec[3] = {0.0f};
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 3));
return Vector_CreatePyObject(tvec, 3, Py_TYPE(self));
@@ -623,8 +630,9 @@ static PyObject *Vector_to_4d(VectorObject *self)
{
float tvec[4] = {0.0f, 0.0f, 0.0f, 1.0f};
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 4));
return Vector_CreatePyObject(tvec, 4, Py_TYPE(self));
@@ -666,8 +674,9 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args)
{
int ndigits = 0;
- if (!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits))
+ if (!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits)) {
return NULL;
+ }
if (ndigits > 22 || ndigits < 0) {
PyErr_SetString(PyExc_ValueError,
@@ -676,11 +685,13 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args)
return NULL;
}
- if (PyTuple_GET_SIZE(args) == 0)
+ if (PyTuple_GET_SIZE(args) == 0) {
ndigits = -1;
+ }
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return Vector_to_tuple_ext(self, ndigits);
}
@@ -703,8 +714,9 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args)
const char *strack, *sup;
short track = 2, up = 1;
- if (!PyArg_ParseTuple(args, "|ss:to_track_quat", &strack, &sup))
+ if (!PyArg_ParseTuple(args, "|ss:to_track_quat", &strack, &sup)) {
return NULL;
+ }
if (self->size != 3) {
PyErr_SetString(PyExc_TypeError,
@@ -713,8 +725,9 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args)
return NULL;
}
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (strack) {
const char *axis_err_msg = "only X, -X, Y, -Y, Z or -Z for track axis";
@@ -826,13 +839,16 @@ static PyObject *Vector_orthogonal(VectorObject *self)
return NULL;
}
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
- if (self->size == 3)
+ if (self->size == 3) {
ortho_v3_v3(vec, self->vec);
- else
+ }
+ else {
ortho_v2_v2(vec, self->vec);
+ }
return Vector_CreatePyObject(vec, self->size, Py_TYPE(self));
}
@@ -861,11 +877,13 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value)
float reflect[3] = {0.0f};
float tvec[MAX_DIMENSIONS];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
- if ((value_size = mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1)
+ if ((value_size = mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) {
return NULL;
+ }
if (self->size < 2 || self->size > 4) {
PyErr_SetString(PyExc_ValueError,
@@ -904,8 +922,9 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value)
PyObject *ret;
float tvec[3];
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (self->size > 3) {
PyErr_SetString(PyExc_ValueError,
@@ -913,8 +932,9 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value)
return NULL;
}
- if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1)
+ if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1) {
return NULL;
+ }
if (self->size == 3) {
ret = Vector_CreatePyObject(NULL, 3, Py_TYPE(self));
@@ -942,8 +962,9 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value)
float *tvec;
PyObject *ret;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (mathutils_array_parse_alloc(&tvec, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1) {
return NULL;
@@ -976,16 +997,19 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
int x;
PyObject *fallback = NULL;
- if (!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback))
+ if (!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback)) {
return NULL;
+ }
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
/* don't use clamped size, rule of thumb is vector sizes must match,
* even though n this case 'w' is ignored */
- if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.angle(other), invalid 'other' arg") == -1)
+ if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.angle(other), invalid 'other' arg") == -1) {
return NULL;
+ }
if (self->size > 4) {
PyErr_SetString(PyExc_ValueError,
@@ -1036,14 +1060,17 @@ static PyObject *Vector_angle_signed(VectorObject *self, PyObject *args)
PyObject *value;
PyObject *fallback = NULL;
- if (!PyArg_ParseTuple(args, "O|O:angle_signed", &value, &fallback))
+ if (!PyArg_ParseTuple(args, "O|O:angle_signed", &value, &fallback)) {
return NULL;
+ }
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
- if (mathutils_array_parse(tvec, 2, 2, value, "Vector.angle_signed(other), invalid 'other' arg") == -1)
+ if (mathutils_array_parse(tvec, 2, 2, value, "Vector.angle_signed(other), invalid 'other' arg") == -1) {
return NULL;
+ }
if (self->size != 2) {
PyErr_SetString(PyExc_ValueError,
@@ -1094,11 +1121,13 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value)
return NULL;
}
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
- if (mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1)
+ if (mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1) {
return NULL;
+ }
normalize_v3_v3(vec_a, self->vec);
normalize_v3(vec_b);
@@ -1125,8 +1154,9 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
double dot = 0.0f, dot2 = 0.0f;
int x;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
if (mathutils_array_parse_alloc(&tvec, size, value, "Vector.project(other), invalid 'other' arg") == -1) {
return NULL;
@@ -1164,8 +1194,9 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args)
float fac;
float *tvec;
- if (!PyArg_ParseTuple(args, "Of:lerp", &value, &fac))
+ if (!PyArg_ParseTuple(args, "Of:lerp", &value, &fac)) {
return NULL;
+ }
if (BaseMath_ReadCallback(self) == -1) {
return NULL;
@@ -1205,8 +1236,9 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args)
int x;
PyObject *fallback = NULL;
- if (!PyArg_ParseTuple(args, "Of|O:slerp", &value, &fac, &fallback))
+ if (!PyArg_ParseTuple(args, "Of|O:slerp", &value, &fac, &fallback)) {
return NULL;
+ }
if (BaseMath_ReadCallback(self) == -1) {
return NULL;
@@ -1281,11 +1313,13 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value)
{
float other_rmat[3][3];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return NULL;
+ }
- if (mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1)
+ if (mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1) {
return NULL;
+ }
if (self->size < 3 || self->size > 4) {
PyErr_SetString(PyExc_ValueError,
@@ -1312,8 +1346,9 @@ PyDoc_STRVAR(Vector_copy_doc,
);
static PyObject *Vector_copy(VectorObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return Vector_CreatePyObject(self->vec, self->size, Py_TYPE(self));
}
@@ -1329,8 +1364,9 @@ static PyObject *Vector_repr(VectorObject *self)
{
PyObject *ret, *tuple;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
tuple = Vector_to_tuple_ext(self, -1);
ret = PyUnicode_FromFormat("Vector(%R)", tuple);
@@ -1345,8 +1381,9 @@ static PyObject *Vector_str(VectorObject *self)
DynStr *ds;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
ds = BLI_dynstr_new();
@@ -1371,7 +1408,9 @@ static int Vector_len(VectorObject *self)
/* sequence accessor (get): vector[index] */
static PyObject *vector_item_internal(VectorObject *self, int i, const bool is_attr)
{
- if (i < 0) i = self->size - i;
+ if (i < 0) {
+ i = self->size - i;
+ }
if (i < 0 || i >= self->size) {
if (is_attr) {
@@ -1386,8 +1425,9 @@ static PyObject *vector_item_internal(VectorObject *self, int i, const bool is_a
return NULL;
}
- if (BaseMath_ReadIndexCallback(self, i) == -1)
+ if (BaseMath_ReadIndexCallback(self, i) == -1) {
return NULL;
+ }
return PyFloat_FromDouble(self->vec[i]);
}
@@ -1401,8 +1441,9 @@ static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value,
{
float scalar;
- if (BaseMath_Prepare_ForWrite(self) == -1)
+ if (BaseMath_Prepare_ForWrite(self) == -1) {
return -1;
+ }
if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
@@ -1411,7 +1452,9 @@ static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value,
return -1;
}
- if (i < 0) i = self->size - i;
+ if (i < 0) {
+ i = self->size - i;
+ }
if (i < 0 || i >= self->size) {
if (is_attr) {
@@ -1428,8 +1471,9 @@ static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value,
}
self->vec[i] = scalar;
- if (BaseMath_WriteIndexCallback(self, i) == -1)
+ if (BaseMath_WriteIndexCallback(self, i) == -1) {
return -1;
+ }
return 0;
}
@@ -1444,11 +1488,14 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end)
PyObject *tuple;
int count;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
CLAMP(begin, 0, self->size);
- if (end < 0) end = self->size + end + 1;
+ if (end < 0) {
+ end = self->size + end + 1;
+ }
CLAMP(end, 0, self->size);
begin = MIN2(begin, end);
@@ -1465,8 +1512,9 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
int size = 0;
float *vec = NULL;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
CLAMP(begin, 0, self->size);
CLAMP(end, 0, self->size);
@@ -1489,8 +1537,9 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
PyMem_Free(vec);
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return -1;
+ }
return 0;
}
@@ -1512,8 +1561,9 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2)
vec1 = (VectorObject *)v1;
vec2 = (VectorObject *)v2;
- if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
+ if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) {
return NULL;
+ }
/*VECTOR + VECTOR*/
if (vec1->size != vec2->size) {
@@ -1558,8 +1608,9 @@ static PyObject *Vector_iadd(PyObject *v1, PyObject *v2)
return NULL;
}
- if (BaseMath_ReadCallback_ForWrite(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
+ if (BaseMath_ReadCallback_ForWrite(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) {
return NULL;
+ }
add_vn_vn(vec1->vec, vec2->vec, vec1->size);
@@ -1584,8 +1635,9 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2)
vec1 = (VectorObject *)v1;
vec2 = (VectorObject *)v2;
- if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
+ if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) {
return NULL;
+ }
if (vec1->size != vec2->size) {
PyErr_SetString(PyExc_AttributeError,
@@ -1629,8 +1681,9 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2)
return NULL;
}
- if (BaseMath_ReadCallback_ForWrite(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1)
+ if (BaseMath_ReadCallback_ForWrite(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) {
return NULL;
+ }
sub_vn_vn(vec1->vec, vec2->vec, vec1->size);
@@ -1722,13 +1775,15 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2)
if (VectorObject_Check(v1)) {
vec1 = (VectorObject *)v1;
- if (BaseMath_ReadCallback(vec1) == -1)
+ if (BaseMath_ReadCallback(vec1) == -1) {
return NULL;
+ }
}
if (VectorObject_Check(v2)) {
vec2 = (VectorObject *)v2;
- if (BaseMath_ReadCallback(vec2) == -1)
+ if (BaseMath_ReadCallback(vec2) == -1) {
return NULL;
+ }
}
@@ -1774,17 +1829,20 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2)
if (VectorObject_Check(v1)) {
vec1 = (VectorObject *)v1;
- if (BaseMath_ReadCallback(vec1) == -1)
+ if (BaseMath_ReadCallback(vec1) == -1) {
return NULL;
+ }
}
if (VectorObject_Check(v2)) {
vec2 = (VectorObject *)v2;
- if (BaseMath_ReadCallback(vec2) == -1)
+ if (BaseMath_ReadCallback(vec2) == -1) {
return NULL;
+ }
}
- if (BaseMath_ReadCallback_ForWrite(vec1) == -1)
+ if (BaseMath_ReadCallback_ForWrite(vec1) == -1) {
return NULL;
+ }
/* Intentionally don't support (Quaternion, Matrix) here, uses reverse order instead. */
@@ -1830,13 +1888,15 @@ static PyObject *Vector_matmul(PyObject *v1, PyObject *v2)
if (VectorObject_Check(v1)) {
vec1 = (VectorObject *)v1;
- if (BaseMath_ReadCallback(vec1) == -1)
+ if (BaseMath_ReadCallback(vec1) == -1) {
return NULL;
+ }
}
if (VectorObject_Check(v2)) {
vec2 = (VectorObject *)v2;
- if (BaseMath_ReadCallback(vec2) == -1)
+ if (BaseMath_ReadCallback(vec2) == -1) {
return NULL;
+ }
}
@@ -1859,8 +1919,9 @@ static PyObject *Vector_matmul(PyObject *v1, PyObject *v2)
/* VEC @ MATRIX */
float tvec[MAX_DIMENSIONS];
- if (BaseMath_ReadCallback((MatrixObject *)v2) == -1)
+ if (BaseMath_ReadCallback((MatrixObject *)v2) == -1) {
return NULL;
+ }
if (row_vector_multiplication(tvec, vec1, (MatrixObject *)v2) == -1) {
return NULL;
}
@@ -1906,8 +1967,9 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2)
}
vec1 = (VectorObject *)v1; /* vector */
- if (BaseMath_ReadCallback(vec1) == -1)
+ if (BaseMath_ReadCallback(vec1) == -1) {
return NULL;
+ }
if ((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
@@ -1943,8 +2005,9 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2)
float scalar;
VectorObject *vec1 = (VectorObject *)v1;
- if (BaseMath_ReadCallback_ForWrite(vec1) == -1)
+ if (BaseMath_ReadCallback_ForWrite(vec1) == -1) {
return NULL;
+ }
if ((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
PyErr_SetString(PyExc_TypeError,
@@ -1974,8 +2037,9 @@ static PyObject *Vector_neg(VectorObject *self)
{
float *tvec;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
tvec = PyMem_Malloc(self->size * sizeof(float));
negate_vn_vn(tvec, self->vec, self->size);
@@ -2002,8 +2066,9 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
vecA = (VectorObject *)objectA;
vecB = (VectorObject *)objectB;
- if (BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1)
+ if (BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1) {
return NULL;
+ }
if (vecA->size != vecB->size) {
if (comparison_type == Py_NE) {
@@ -2069,11 +2134,13 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
static Py_hash_t Vector_hash(VectorObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return -1;
+ }
- if (BaseMathObject_Prepare_ForHash(self) == -1)
+ if (BaseMathObject_Prepare_ForHash(self) == -1) {
return -1;
+ }
return mathutils_array_hash(self->vec, self->size);
}
@@ -2097,17 +2164,20 @@ static PyObject *Vector_subscript(VectorObject *self, PyObject *item)
if (PyIndex_Check(item)) {
Py_ssize_t i;
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return NULL;
- if (i < 0)
+ }
+ if (i < 0) {
i += self->size;
+ }
return Vector_item(self, i);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0) {
return NULL;
+ }
if (slicelength <= 0) {
return PyTuple_New(0);
@@ -2133,20 +2203,24 @@ static int Vector_ass_subscript(VectorObject *self, PyObject *item, PyObject *va
{
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
- if (i == -1 && PyErr_Occurred())
+ if (i == -1 && PyErr_Occurred()) {
return -1;
- if (i < 0)
+ }
+ if (i < 0) {
i += self->size;
+ }
return Vector_ass_item(self, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0)
+ if (PySlice_GetIndicesEx(item, self->size, &start, &stop, &step, &slicelength) < 0) {
return -1;
+ }
- if (step == 1)
+ if (step == 1) {
return Vector_ass_slice(self, start, stop, value);
+ }
else {
PyErr_SetString(PyExc_IndexError,
"slice steps not supported with vectors");
@@ -2233,8 +2307,9 @@ PyDoc_STRVAR(Vector_length_doc,
);
static PyObject *Vector_length_get(VectorObject *self, void *UNUSED(closure))
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return PyFloat_FromDouble(sqrt(dot_vn_vn(self->vec, self->vec, self->size)));
}
@@ -2243,8 +2318,9 @@ static int Vector_length_set(VectorObject *self, PyObject *value)
{
double dot = 0.0f, param;
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
if ((param = PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError,
@@ -2264,13 +2340,16 @@ static int Vector_length_set(VectorObject *self, PyObject *value)
dot = dot_vn_vn(self->vec, self->vec, self->size);
- if (!dot) /* cant sqrt zero */
+ if (!dot) {
+ /* cant sqrt zero */
return 0;
+ }
dot = sqrt(dot);
- if (dot == param)
+ if (dot == param) {
return 0;
+ }
dot = dot / param;
@@ -2287,8 +2366,9 @@ PyDoc_STRVAR(Vector_length_squared_doc,
);
static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(closure))
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
return PyFloat_FromDouble(dot_vn_vn(self->vec, self->vec, self->size));
}
@@ -2359,8 +2439,9 @@ static PyObject *Vector_swizzle_get(VectorObject *self, void *closure)
float vec[MAX_DIMENSIONS];
unsigned int swizzleClosure;
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
/* Unpack the axes from the closure into an array. */
axis_to = 0;
@@ -2406,8 +2487,9 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
float tvec[MAX_DIMENSIONS];
float vec_assign[MAX_DIMENSIONS];
- if (BaseMath_ReadCallback_ForWrite(self) == -1)
+ if (BaseMath_ReadCallback_ForWrite(self) == -1) {
return -1;
+ }
/* Check that the closure can be used with this vector: even 2D vectors have
* swizzles defined for axes z and w, but they would be invalid. */
@@ -2469,10 +2551,12 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure
memcpy(self->vec, tvec, self->size * sizeof(float));
/* continue with BaseMathObject_WriteCallback at the end */
- if (BaseMath_WriteCallback(self) == -1)
+ if (BaseMath_WriteCallback(self) == -1) {
return -1;
- else
+ }
+ else {
return 0;
+ }
}
#define _SWIZZLE1(a) ((a) | SWIZZLE_VALID_AXIS)
@@ -2876,8 +2960,9 @@ static int row_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *
}
}
- if (BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1)
+ if (BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1) {
return -1;
+ }
memcpy(vec_cpy, vec->vec, vec_size * sizeof(float));
@@ -2901,8 +2986,9 @@ PyDoc_STRVAR(Vector_negate_doc,
);
static PyObject *Vector_negate(VectorObject *self)
{
- if (BaseMath_ReadCallback(self) == -1)
+ if (BaseMath_ReadCallback(self) == -1) {
return NULL;
+ }
negate_vn(self->vec, self->size);
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index 9b972f5fc91..b99b39ac998 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -924,10 +924,12 @@ static PyObject *C_BVHTree_FromPolygons(PyObject *UNUSED(cls), PyObject *args, P
orig_index, orig_normal);
}
else {
- if (coords)
+ if (coords) {
MEM_freeN(coords);
- if (tris)
+ }
+ if (tris) {
MEM_freeN(tris);
+ }
return NULL;
}
@@ -1064,10 +1066,10 @@ static Mesh *bvh_get_mesh(
}
else if (ob_eval != NULL) {
if (use_cage) {
- return mesh_get_eval_deform(depsgraph, scene, ob_eval, &data_masks); /* ob->derivedDeform */
+ return mesh_get_eval_deform(depsgraph, scene, ob_eval, &data_masks);
}
else {
- return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks); /* ob->derivedFinal */
+ return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks);
}
}
else {
@@ -1086,7 +1088,7 @@ static Mesh *bvh_get_mesh(
}
else {
*r_free_mesh = true;
- return mesh_create_eval_no_deform_render(depsgraph, scene, ob, NULL, &data_masks);
+ return mesh_create_eval_no_deform_render(depsgraph, scene, ob, &data_masks);
}
}
else {
@@ -1097,7 +1099,7 @@ static Mesh *bvh_get_mesh(
}
else {
*r_free_mesh = true;
- return mesh_create_eval_no_deform(depsgraph, scene, ob, NULL, &data_masks);
+ return mesh_create_eval_no_deform(depsgraph, scene, ob, &data_masks);
}
}
}
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 6106b01fd41..05ec57a004a 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -621,12 +621,12 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje
switch (isect_line_sphere_v3(line_a, line_b, sphere_co, sphere_radius, isect_a, isect_b)) {
case 1:
- if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) use_a = false;
+ if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) { use_a = false; }
use_b = false;
break;
case 2:
- if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) use_a = false;
- if (!(!clip || (((lambda = line_point_factor_v3(isect_b, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) use_b = false;
+ if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) { use_a = false; }
+ if (!(!clip || (((lambda = line_point_factor_v3(isect_b, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) { use_b = false; }
break;
default:
use_a = false;
@@ -694,12 +694,12 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO
switch (isect_line_sphere_v2(line_a, line_b, sphere_co, sphere_radius, isect_a, isect_b)) {
case 1:
- if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) use_a = false;
+ if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) { use_a = false; }
use_b = false;
break;
case 2:
- if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) use_a = false;
- if (!(!clip || (((lambda = line_point_factor_v2(isect_b, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) use_b = false;
+ if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) { use_a = false; }
+ if (!(!clip || (((lambda = line_point_factor_v2(isect_b, line_a, line_b)) >= 0.0f) && (lambda <= 1.0f)))) { use_b = false; }
break;
default:
use_a = false;
@@ -1225,15 +1225,19 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject
polyVec = PySequence_GetItem(polyLine, index);
if (VectorObject_Check(polyVec)) {
- if (BaseMath_ReadCallback((VectorObject *)polyVec) == -1)
+ if (BaseMath_ReadCallback((VectorObject *)polyVec) == -1) {
ls_error = 1;
+ }
fp[0] = ((VectorObject *)polyVec)->vec[0];
fp[1] = ((VectorObject *)polyVec)->vec[1];
- if (((VectorObject *)polyVec)->size > 2)
+ if (((VectorObject *)polyVec)->size > 2) {
fp[2] = ((VectorObject *)polyVec)->vec[2];
- else
- fp[2] = 0.0f; /* if its a 2d vector then set the z to be zero */
+ }
+ else {
+ /* if its a 2d vector then set the z to be zero */
+ fp[2] = 0.0f;
+ }
}
else {
ls_error = 1;
diff --git a/source/blender/python/mathutils/mathutils_interpolate.c b/source/blender/python/mathutils/mathutils_interpolate.c
index da2ed0ced7e..792f8b1f065 100644
--- a/source/blender/python/mathutils/mathutils_interpolate.c
+++ b/source/blender/python/mathutils/mathutils_interpolate.c
@@ -66,15 +66,19 @@ static PyObject *M_Interpolate_poly_3d_calc(PyObject *UNUSED(self), PyObject *ar
return NULL;
}
- if (BaseMath_ReadCallback((VectorObject *)point) == -1)
+ if (BaseMath_ReadCallback((VectorObject *)point) == -1) {
return NULL;
+ }
fp[0] = ((VectorObject *)point)->vec[0];
fp[1] = ((VectorObject *)point)->vec[1];
- if (((VectorObject *)point)->size > 2)
+ if (((VectorObject *)point)->size > 2) {
fp[2] = ((VectorObject *)point)->vec[2];
- else
- fp[2] = 0.0f; /* if its a 2d vector then set the z to be zero */
+ }
+ else {
+ /* if its a 2d vector then set the z to be zero */
+ fp[2] = 0.0f;
+ }
len = mathutils_array_parse_alloc_v(((float **)&vecs), 3, veclist, __func__);
if (len == -1) {
diff --git a/source/blender/python/mathutils/mathutils_kdtree.c b/source/blender/python/mathutils/mathutils_kdtree.c
index 43aaae6ad99..7228ac41bd6 100644
--- a/source/blender/python/mathutils/mathutils_kdtree.c
+++ b/source/blender/python/mathutils/mathutils_kdtree.c
@@ -38,7 +38,7 @@
typedef struct {
PyObject_HEAD
- KDTree *obj;
+ KDTree_3d *obj;
unsigned int maxsize;
unsigned int count;
unsigned int count_balance; /* size when we last balanced */
@@ -48,7 +48,7 @@ typedef struct {
/* -------------------------------------------------------------------- */
/* Utility helper functions */
-static void kdtree_nearest_to_py_tuple(const KDTreeNearest *nearest, PyObject *py_retval)
+static void kdtree_nearest_to_py_tuple(const KDTreeNearest_3d *nearest, PyObject *py_retval)
{
BLI_assert(nearest->index >= 0);
BLI_assert(PyTuple_GET_SIZE(py_retval) == 3);
@@ -59,7 +59,7 @@ static void kdtree_nearest_to_py_tuple(const KDTreeNearest *nearest, PyObject *p
PyFloat_FromDouble(nearest->dist));
}
-static PyObject *kdtree_nearest_to_py(const KDTreeNearest *nearest)
+static PyObject *kdtree_nearest_to_py(const KDTreeNearest_3d *nearest)
{
PyObject *py_retval;
@@ -70,7 +70,7 @@ static PyObject *kdtree_nearest_to_py(const KDTreeNearest *nearest)
return py_retval;
}
-static PyObject *kdtree_nearest_to_py_and_check(const KDTreeNearest *nearest)
+static PyObject *kdtree_nearest_to_py_and_check(const KDTreeNearest_3d *nearest)
{
PyObject *py_retval;
@@ -110,7 +110,7 @@ static int PyKDTree__tp_init(PyKDTree *self, PyObject *args, PyObject *kwargs)
return -1;
}
- self->obj = BLI_kdtree_new(maxsize);
+ self->obj = BLI_kdtree_3d_new(maxsize);
self->maxsize = maxsize;
self->count = 0;
self->count_balance = 0;
@@ -120,7 +120,7 @@ static int PyKDTree__tp_init(PyKDTree *self, PyObject *args, PyObject *kwargs)
static void PyKDTree__tp_dealloc(PyKDTree *self)
{
- BLI_kdtree_free(self->obj);
+ BLI_kdtree_3d_free(self->obj);
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -148,8 +148,9 @@ static PyObject *py_kdtree_insert(PyKDTree *self, PyObject *args, PyObject *kwar
return NULL;
}
- if (mathutils_array_parse(co, 3, 3, py_co, "insert: invalid 'co' arg") == -1)
+ if (mathutils_array_parse(co, 3, 3, py_co, "insert: invalid 'co' arg") == -1) {
return NULL;
+ }
if (index < 0) {
PyErr_SetString(PyExc_ValueError, "negative index given");
@@ -161,7 +162,7 @@ static PyObject *py_kdtree_insert(PyKDTree *self, PyObject *args, PyObject *kwar
return NULL;
}
- BLI_kdtree_insert(self->obj, index, co);
+ BLI_kdtree_3d_insert(self->obj, index, co);
self->count++;
Py_RETURN_NONE;
@@ -178,7 +179,7 @@ PyDoc_STRVAR(py_kdtree_balance_doc,
);
static PyObject *py_kdtree_balance(PyKDTree *self)
{
- BLI_kdtree_balance(self->obj);
+ BLI_kdtree_3d_balance(self->obj);
self->count_balance = self->count;
Py_RETURN_NONE;
}
@@ -228,7 +229,7 @@ static PyObject *py_kdtree_find(PyKDTree *self, PyObject *args, PyObject *kwargs
{
PyObject *py_co, *py_filter = NULL;
float co[3];
- KDTreeNearest nearest;
+ KDTreeNearest_3d nearest;
const char *keywords[] = {"co", "filter", NULL};
if (!PyArg_ParseTupleAndKeywords(
@@ -238,8 +239,9 @@ static PyObject *py_kdtree_find(PyKDTree *self, PyObject *args, PyObject *kwargs
return NULL;
}
- if (mathutils_array_parse(co, 3, 3, py_co, "find: invalid 'co' arg") == -1)
+ if (mathutils_array_parse(co, 3, 3, py_co, "find: invalid 'co' arg") == -1) {
return NULL;
+ }
if (self->count != self->count_balance) {
PyErr_SetString(PyExc_RuntimeError, "KDTree must be balanced before calling find()");
@@ -249,7 +251,7 @@ static PyObject *py_kdtree_find(PyKDTree *self, PyObject *args, PyObject *kwargs
nearest.index = -1;
if (py_filter == NULL) {
- BLI_kdtree_find_nearest(self->obj, co, &nearest);
+ BLI_kdtree_3d_find_nearest(self->obj, co, &nearest);
}
else {
struct PyKDTree_NearestData data = {0};
@@ -257,7 +259,7 @@ static PyObject *py_kdtree_find(PyKDTree *self, PyObject *args, PyObject *kwargs
data.py_filter = py_filter;
data.is_error = false;
- BLI_kdtree_find_nearest_cb(
+ BLI_kdtree_3d_find_nearest_cb(
self->obj, co,
py_find_nearest_cb, &data,
&nearest);
@@ -287,7 +289,7 @@ static PyObject *py_kdtree_find_n(PyKDTree *self, PyObject *args, PyObject *kwar
PyObject *py_list;
PyObject *py_co;
float co[3];
- KDTreeNearest *nearest;
+ KDTreeNearest_3d *nearest;
unsigned int n;
int i, found;
const char *keywords[] = {"co", "n", NULL};
@@ -299,8 +301,9 @@ static PyObject *py_kdtree_find_n(PyKDTree *self, PyObject *args, PyObject *kwar
return NULL;
}
- if (mathutils_array_parse(co, 3, 3, py_co, "find_n: invalid 'co' arg") == -1)
+ if (mathutils_array_parse(co, 3, 3, py_co, "find_n: invalid 'co' arg") == -1) {
return NULL;
+ }
if (UINT_IS_NEG(n)) {
PyErr_SetString(PyExc_RuntimeError, "negative 'n' given");
@@ -312,9 +315,9 @@ static PyObject *py_kdtree_find_n(PyKDTree *self, PyObject *args, PyObject *kwar
return NULL;
}
- nearest = MEM_mallocN(sizeof(KDTreeNearest) * n, __func__);
+ nearest = MEM_mallocN(sizeof(KDTreeNearest_3d) * n, __func__);
- found = BLI_kdtree_find_nearest_n(self->obj, co, nearest, n);
+ found = BLI_kdtree_3d_find_nearest_n(self->obj, co, nearest, n);
py_list = PyList_New(found);
@@ -344,7 +347,7 @@ static PyObject *py_kdtree_find_range(PyKDTree *self, PyObject *args, PyObject *
PyObject *py_list;
PyObject *py_co;
float co[3];
- KDTreeNearest *nearest = NULL;
+ KDTreeNearest_3d *nearest = NULL;
float radius;
int i, found;
@@ -357,8 +360,9 @@ static PyObject *py_kdtree_find_range(PyKDTree *self, PyObject *args, PyObject *
return NULL;
}
- if (mathutils_array_parse(co, 3, 3, py_co, "find_range: invalid 'co' arg") == -1)
+ if (mathutils_array_parse(co, 3, 3, py_co, "find_range: invalid 'co' arg") == -1) {
return NULL;
+ }
if (radius < 0.0f) {
PyErr_SetString(PyExc_RuntimeError, "negative radius given");
@@ -370,7 +374,7 @@ static PyObject *py_kdtree_find_range(PyKDTree *self, PyObject *args, PyObject *
return NULL;
}
- found = BLI_kdtree_range_search(self->obj, co, &nearest, radius);
+ found = BLI_kdtree_3d_range_search(self->obj, co, &nearest, radius);
py_list = PyList_New(found);
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index 364690c43eb..04cadb9b592 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -136,17 +136,20 @@ static void next_state(void)
/* if init_genrand() has not been called, */
/* a default initial seed is used */
- if (initf == 0)
+ if (initf == 0) {
init_genrand(5489UL);
+ }
left = N;
next = state;
- for (j = N - M + 1; --j; p++)
+ for (j = N - M + 1; --j; p++) {
*p = p[M] ^ TWIST(p[0], p[1]);
+ }
- for (j = M; --j; p++)
+ for (j = M; --j; p++) {
*p = p[M - N] ^ TWIST(p[0], p[1]);
+ }
*p = p[M - N] ^ TWIST(p[0], state[0]);
}
@@ -155,10 +158,12 @@ static void next_state(void)
static void setRndSeed(int seed)
{
- if (seed == 0)
+ if (seed == 0) {
init_genrand(time(NULL));
- else
+ }
+ else {
init_genrand(seed);
+ }
}
/* float number in range [0, 1) using the mersenne twister rng */
@@ -166,8 +171,9 @@ static float frand(void)
{
unsigned long y;
- if (--left == 0)
+ if (--left == 0) {
next_state();
+ }
y = *next++;
/* Tempering */
@@ -253,16 +259,18 @@ static float turb(
int i;
amp = 1.f;
out = (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f);
- if (hard)
+ if (hard) {
out = fabsf(out);
+ }
for (i = 1; i < oct; i++) {
amp *= ampscale;
x *= freqscale;
y *= freqscale;
z *= freqscale;
t = (float)(amp * (2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f));
- if (hard)
+ if (hard) {
t = fabsf(t);
+ }
out += t;
}
return out;
@@ -406,8 +414,9 @@ PyDoc_STRVAR(M_Noise_seed_set_doc,
static PyObject *M_Noise_seed_set(PyObject *UNUSED(self), PyObject *args)
{
int s;
- if (!PyArg_ParseTuple(args, "i:seed_set", &s))
+ if (!PyArg_ParseTuple(args, "i:seed_set", &s)) {
return NULL;
+ }
setRndSeed(s);
Py_RETURN_NONE;
}
@@ -447,8 +456,9 @@ static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args, PyObject
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "noise: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "noise: invalid 'position' arg") == -1) {
return NULL;
+ }
return PyFloat_FromDouble((2.0f * BLI_gNoise(1.0f, vec[0], vec[1], vec[2], 0, noise_basis_enum) - 1.0f));
}
@@ -488,8 +498,9 @@ static PyObject *M_Noise_noise_vector(PyObject *UNUSED(self), PyObject *args, Py
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "noise_vector: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "noise_vector: invalid 'position' arg") == -1) {
return NULL;
+ }
noise_vector(vec[0], vec[1], vec[2], noise_basis_enum, r_vec);
@@ -540,8 +551,9 @@ static PyObject *M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args, PyOb
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "turbulence: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "turbulence: invalid 'position' arg") == -1) {
return NULL;
+ }
return PyFloat_FromDouble(turb(vec[0], vec[1], vec[2], oct, hd, noise_basis_enum, as, fs));
}
@@ -590,8 +602,9 @@ static PyObject *M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *arg
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "turbulence_vector: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "turbulence_vector: invalid 'position' arg") == -1) {
return NULL;
+ }
vTurb(vec[0], vec[1], vec[2], oct, hd, noise_basis_enum, as, fs, r_vec);
@@ -641,8 +654,9 @@ static PyObject *M_Noise_fractal(PyObject *UNUSED(self), PyObject *args, PyObjec
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "fractal: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "fractal: invalid 'position' arg") == -1) {
return NULL;
+ }
return PyFloat_FromDouble(mg_fBm(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
}
@@ -689,8 +703,9 @@ static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args, P
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "multi_fractal: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "multi_fractal: invalid 'position' arg") == -1) {
return NULL;
+ }
return PyFloat_FromDouble(mg_MultiFractal(vec[0], vec[1], vec[2], H, lac, oct, noise_basis_enum));
}
@@ -749,8 +764,9 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "variable_lacunarity: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "variable_lacunarity: invalid 'position' arg") == -1) {
return NULL;
+ }
return PyFloat_FromDouble(mg_VLNoise(vec[0], vec[1], vec[2], d, noise_type1_enum, noise_type2_enum));
}
@@ -799,8 +815,9 @@ static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args,
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "hetero_terrain: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "hetero_terrain: invalid 'position' arg") == -1) {
return NULL;
+ }
return PyFloat_FromDouble(mg_HeteroTerrain(vec[0], vec[1], vec[2], H, lac, oct, ofs, noise_basis_enum));
}
@@ -851,8 +868,9 @@ static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject *
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "hybrid_multi_fractal: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "hybrid_multi_fractal: invalid 'position' arg") == -1) {
return NULL;
+ }
return PyFloat_FromDouble(mg_HybridMultiFractal(vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
}
@@ -903,8 +921,9 @@ static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject *
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "ridged_multi_fractal: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "ridged_multi_fractal: invalid 'position' arg") == -1) {
return NULL;
+ }
return PyFloat_FromDouble(mg_RidgedMultiFractal(vec[0], vec[1], vec[2], H, lac, oct, ofs, gn, noise_basis_enum));
}
@@ -952,8 +971,9 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args, PyObjec
return NULL;
}
- if (mathutils_array_parse(vec, 3, 3, value, "voronoi: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "voronoi: invalid 'position' arg") == -1) {
return NULL;
+ }
list = PyList_New(4);
@@ -984,11 +1004,13 @@ static PyObject *M_Noise_cell(PyObject *UNUSED(self), PyObject *args)
PyObject *value;
float vec[3];
- if (!PyArg_ParseTuple(args, "O:cell", &value))
+ if (!PyArg_ParseTuple(args, "O:cell", &value)) {
return NULL;
+ }
- if (mathutils_array_parse(vec, 3, 3, value, "cell: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "cell: invalid 'position' arg") == -1) {
return NULL;
+ }
return PyFloat_FromDouble(cellNoise(vec[0], vec[1], vec[2]));
}
@@ -1008,11 +1030,13 @@ static PyObject *M_Noise_cell_vector(PyObject *UNUSED(self), PyObject *args)
PyObject *value;
float vec[3], r_vec[3];
- if (!PyArg_ParseTuple(args, "O:cell_vector", &value))
+ if (!PyArg_ParseTuple(args, "O:cell_vector", &value)) {
return NULL;
+ }
- if (mathutils_array_parse(vec, 3, 3, value, "cell_vector: invalid 'position' arg") == -1)
+ if (mathutils_array_parse(vec, 3, 3, value, "cell_vector: invalid 'position' arg") == -1) {
return NULL;
+ }
cellNoiseV(vec[0], vec[1], vec[2], r_vec);
return Vector_CreatePyObject(r_vec, 3, NULL);
diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h
index cdd696e56bb..780894f419d 100644
--- a/source/blender/render/extern/include/RE_engine.h
+++ b/source/blender/render/extern/include/RE_engine.h
@@ -183,7 +183,7 @@ bool RE_engine_is_opengl(RenderEngineType *render_type);
RenderEngineType *RE_engines_find(const char *idname);
-rcti* RE_engine_get_current_tiles(struct Render *re, int *r_total_tiles, bool *r_needs_free);
+rcti *RE_engine_get_current_tiles(struct Render *re, int *r_total_tiles, bool *r_needs_free);
struct RenderData *RE_engine_get_render_data(struct Render *re);
void RE_bake_engine_set_engine_parameters(
struct Render *re, struct Main *bmain, struct Scene *scene);
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c
index 346d57e17cf..5e63f76ca80 100644
--- a/source/blender/render/intern/source/bake_api.c
+++ b/source/blender/render/intern/source/bake_api.c
@@ -362,18 +362,18 @@ static bool cast_ray_highpoly(
/* transfer position differentials */
float tmp[3];
- mul_v3_v3fl(tmp, dir_high, 1.0f/dot_v3v3(dir_high, triangle_high->normal));
+ mul_v3_v3fl(tmp, dir_high, 1.0f / dot_v3v3(dir_high, triangle_high->normal));
madd_v3_v3fl(dxco, tmp, -dot_v3v3(dxco, triangle_high->normal));
madd_v3_v3fl(dyco, tmp, -dot_v3v3(dyco, triangle_high->normal));
/* compute barycentric differentials from position differentials */
barycentric_differentials_from_position(
- hits[hit_mesh].co, triangle_high->mverts[0]->co,
- triangle_high->mverts[1]->co, triangle_high->mverts[2]->co,
- dxco, dyco, triangle_high->normal, true,
- &pixel_high->uv[0], &pixel_high->uv[1],
- &pixel_high->du_dx, &pixel_high->dv_dx,
- &pixel_high->du_dy, &pixel_high->dv_dy);
+ hits[hit_mesh].co, triangle_high->mverts[0]->co,
+ triangle_high->mverts[1]->co, triangle_high->mverts[2]->co,
+ dxco, dyco, triangle_high->normal, true,
+ &pixel_high->uv[0], &pixel_high->uv[1],
+ &pixel_high->du_dx, &pixel_high->dv_dx,
+ &pixel_high->du_dy, &pixel_high->dv_dy);
/* verify we have valid uvs */
BLI_assert(pixel_high->uv[0] >= -1e-3f &&
@@ -421,10 +421,10 @@ static TriTessFace *mesh_calc_tri_tessface(
}
BKE_mesh_recalc_looptri(
- me->mloop, me->mpoly,
- me->mvert,
- me->totloop, me->totpoly,
- looptri);
+ me->mloop, me->mpoly,
+ me->mvert,
+ me->totloop, me->totpoly,
+ looptri);
const float *precomputed_normals = CustomData_get_layer(&me->pdata, CD_NORMAL);
const bool calculate_normal = precomputed_normals ? false : true;
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index 153d41627c9..a9bf80a6aa0 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -273,7 +273,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result, bool cance
RenderPart *pa = get_part_from_result(re, result);
if (pa) {
- pa->status = (!cancel && merge_results)? PART_STATUS_MERGED: PART_STATUS_RENDERED;
+ pa->status = (!cancel && merge_results) ? PART_STATUS_MERGED : PART_STATUS_RENDERED;
}
else if (re->result->do_exr_tile) {
/* if written result does not match any tile and we are using save
@@ -432,7 +432,7 @@ bool RE_engine_get_spherical_stereo(RenderEngine *engine, Object *camera)
return BKE_camera_multiview_spherical_stereo(re ? &re->r : NULL, camera) ? 1 : 0;
}
-rcti* RE_engine_get_current_tiles(Render *re, int *r_total_tiles, bool *r_needs_free)
+rcti *RE_engine_get_current_tiles(Render *re, int *r_total_tiles, bool *r_needs_free)
{
static rcti tiles_static[BLENDER_MAX_THREADS];
const int allocation_step = BLENDER_MAX_THREADS;
@@ -505,7 +505,7 @@ static void engine_depsgraph_free(RenderEngine *engine)
void RE_engine_frame_set(RenderEngine *engine, int frame, float subframe)
{
- if(!engine->depsgraph) {
+ if (!engine->depsgraph) {
return;
}
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index afddbcfbd4c..e67a07e791e 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -63,27 +63,27 @@ static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y)
int ofs = y * ibuf->x + x;
if (ibuf->rect_float) {
- if (ibuf->channels==4) {
- const float *fp= ibuf->rect_float + 4*ofs;
+ if (ibuf->channels == 4) {
+ const float *fp = ibuf->rect_float + 4 * ofs;
copy_v4_v4(col, fp);
}
- else if (ibuf->channels==3) {
- const float *fp= ibuf->rect_float + 3*ofs;
+ else if (ibuf->channels == 3) {
+ const float *fp = ibuf->rect_float + 3 * ofs;
copy_v3_v3(col, fp);
- col[3]= 1.0f;
+ col[3] = 1.0f;
}
else {
- const float *fp= ibuf->rect_float + ofs;
- col[0]= col[1]= col[2]= col[3]= *fp;
+ const float *fp = ibuf->rect_float + ofs;
+ col[0] = col[1] = col[2] = col[3] = *fp;
}
}
else {
- const char *rect = (char *)( ibuf->rect+ ofs);
+ const char *rect = (char *)(ibuf->rect + ofs);
- col[0] = ((float)rect[0])*(1.0f/255.0f);
- col[1] = ((float)rect[1])*(1.0f/255.0f);
- col[2] = ((float)rect[2])*(1.0f/255.0f);
- col[3] = ((float)rect[3])*(1.0f/255.0f);
+ col[0] = ((float)rect[0]) * (1.0f / 255.0f);
+ col[1] = ((float)rect[1]) * (1.0f / 255.0f);
+ col[2] = ((float)rect[2]) * (1.0f / 255.0f);
+ col[3] = ((float)rect[3]) * (1.0f / 255.0f);
/* bytes are internally straight, however render pipeline seems to expect premul */
col[0] *= col[3];
@@ -98,13 +98,13 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
int x, y, retval;
int xi, yi; /* original values */
- texres->tin= texres->ta= texres->tr= texres->tg= texres->tb= 0.0f;
+ texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f;
/* we need to set retval OK, otherwise texture code generates normals itself... */
- retval= texres->nor ? 3 : 1;
+ retval = texres->nor ? 3 : 1;
/* quick tests */
- if (ibuf==NULL && ima==NULL)
+ if (ibuf == NULL && ima == NULL)
return retval;
if (ima) {
@@ -114,9 +114,9 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool);
- ima->flag|= IMA_USED_FOR_RENDER;
+ ima->flag |= IMA_USED_FOR_RENDER;
}
- if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) {
+ if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
if (ima)
BKE_image_pool_release_ibuf(ima, ibuf, pool);
return retval;
@@ -124,21 +124,21 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
/* setup mapping */
if (tex->imaflag & TEX_IMAROT) {
- fy= texvec[0];
- fx= texvec[1];
+ fy = texvec[0];
+ fx = texvec[1];
}
else {
- fx= texvec[0];
- fy= texvec[1];
+ fx = texvec[0];
+ fy = texvec[1];
}
if (tex->extend == TEX_CHECKER) {
int xs, ys;
- xs= (int)floor(fx);
- ys= (int)floor(fy);
- fx-= xs;
- fy-= ys;
+ xs = (int)floor(fx);
+ ys = (int)floor(fy);
+ fx -= xs;
+ fy -= ys;
if ( (tex->flag & TEX_CHECKER_ODD) == 0) {
if ((xs + ys) & 1) {
@@ -150,53 +150,53 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
return retval;
}
}
- if ( (tex->flag & TEX_CHECKER_EVEN)==0) {
- if ((xs+ys) & 1) {
+ if ( (tex->flag & TEX_CHECKER_EVEN) == 0) {
+ if ((xs + ys) & 1) {
if (ima)
BKE_image_pool_release_ibuf(ima, ibuf, pool);
return retval;
}
}
/* scale around center, (0.5, 0.5) */
- if (tex->checkerdist<1.0f) {
- fx= (fx-0.5f)/(1.0f-tex->checkerdist) +0.5f;
- fy= (fy-0.5f)/(1.0f-tex->checkerdist) +0.5f;
+ if (tex->checkerdist < 1.0f) {
+ fx = (fx - 0.5f) / (1.0f - tex->checkerdist) + 0.5f;
+ fy = (fy - 0.5f) / (1.0f - tex->checkerdist) + 0.5f;
}
}
- x= xi= (int)floorf(fx*ibuf->x);
- y= yi= (int)floorf(fy*ibuf->y);
+ x = xi = (int)floorf(fx * ibuf->x);
+ y = yi = (int)floorf(fy * ibuf->y);
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 (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y || texvec[2] < -1.0f || texvec[2] > 1.0f) {
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) {
+ else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
+ if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
if (ima)
BKE_image_pool_release_ibuf(ima, ibuf, pool);
return retval;
}
}
else {
- if (tex->extend==TEX_EXTEND) {
- if (x>=ibuf->x) x = ibuf->x-1;
- else if (x<0) x= 0;
+ if (tex->extend == TEX_EXTEND) {
+ if (x >= ibuf->x) x = ibuf->x - 1;
+ else if (x < 0) x = 0;
}
else {
- x= x % ibuf->x;
- if (x<0) x+= ibuf->x;
+ x = x % ibuf->x;
+ if (x < 0) x += ibuf->x;
}
- if (tex->extend==TEX_EXTEND) {
- if (y>=ibuf->y) y = ibuf->y-1;
- else if (y<0) y= 0;
+ if (tex->extend == TEX_EXTEND) {
+ if (y >= ibuf->y) y = ibuf->y - 1;
+ else if (y < 0) y = 0;
}
else {
- y= y % ibuf->y;
- if (y<0) y+= ibuf->y;
+ y = y % ibuf->y;
+ if (y < 0) y += ibuf->y;
}
}
@@ -221,7 +221,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
fx -= (float)(xi - x) / (float)ibuf->x;
fy -= (float)(yi - y) / (float)ibuf->y;
- boxsample(ibuf, fx-filterx, fy-filtery, fx+filterx, fy+filtery, texres, (tex->extend==TEX_REPEAT), (tex->extend==TEX_EXTEND));
+ boxsample(ibuf, fx - filterx, fy - filtery, fx + filterx, fy + filtery, texres, (tex->extend == TEX_REPEAT), (tex->extend == TEX_EXTEND));
}
else { /* no filtering */
ibuf_get_color(&texres->tr, ibuf, x, y);
@@ -236,35 +236,35 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
- texres->nor[0] = -2.f*(texres->tr - 0.5f);
- texres->nor[1] = 2.f*(texres->tg - 0.5f);
- texres->nor[2] = 2.f*(texres->tb - 0.5f);
+ texres->nor[0] = -2.f * (texres->tr - 0.5f);
+ texres->nor[1] = 2.f * (texres->tg - 0.5f);
+ texres->nor[2] = 2.f * (texres->tb - 0.5f);
}
else {
/* bump: take three samples */
- val1= texres->tr+texres->tg+texres->tb;
+ val1 = texres->tr + texres->tg + texres->tb;
- if (x<ibuf->x-1) {
+ if (x < ibuf->x - 1) {
float col[4];
- ibuf_get_color(col, ibuf, x+1, y);
- val2= (col[0]+col[1]+col[2]);
+ ibuf_get_color(col, ibuf, x + 1, y);
+ val2 = (col[0] + col[1] + col[2]);
}
else {
- val2= val1;
+ val2 = val1;
}
- if (y<ibuf->y-1) {
+ if (y < ibuf->y - 1) {
float col[4];
- ibuf_get_color(col, ibuf, x, y+1);
- val3 = (col[0]+col[1]+col[2]);
+ ibuf_get_color(col, ibuf, x, y + 1);
+ val3 = (col[0] + col[1] + col[2]);
}
else {
val3 = val1;
}
/* do not mix up x and y here! */
- texres->nor[0]= (val1-val2);
- texres->nor[1]= (val1-val3);
+ texres->nor[0] = (val1 - val2);
+ texres->nor[1] = (val1 - val3);
}
}
@@ -284,11 +284,11 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
/* de-premul, this is being premulled in shade_input_do_shade()
* do not de-premul for generated alpha, it is already in straight */
- if (texres->ta!=1.0f && texres->ta>1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
- fx= 1.0f/texres->ta;
- texres->tr*= fx;
- texres->tg*= fx;
- texres->tb*= fx;
+ if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
+ fx = 1.0f / texres->ta;
+ texres->tr *= fx;
+ texres->tg *= fx;
+ texres->tb *= fx;
}
if (ima)
@@ -304,45 +304,45 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
rctf *rf, *newrct;
short a;
- a= *count;
- rf= stack;
- for (;a>0;a--) {
- if (rf->xmin<x1) {
- if (rf->xmax<x1) {
- rf->xmin+= (x2-x1);
- rf->xmax+= (x2-x1);
+ a = *count;
+ rf = stack;
+ for (; a > 0; a--) {
+ if (rf->xmin < x1) {
+ if (rf->xmax < x1) {
+ rf->xmin += (x2 - x1);
+ rf->xmax += (x2 - x1);
}
else {
- if (rf->xmax>x2) rf->xmax = x2;
- newrct= stack+ *count;
+ if (rf->xmax > x2) rf->xmax = x2;
+ newrct = stack + *count;
(*count)++;
newrct->xmax = x2;
- newrct->xmin = rf->xmin+(x2-x1);
+ newrct->xmin = rf->xmin + (x2 - x1);
newrct->ymin = rf->ymin;
newrct->ymax = rf->ymax;
- if (newrct->xmin ==newrct->xmax) (*count)--;
+ if (newrct->xmin == newrct->xmax) (*count)--;
rf->xmin = x1;
}
}
- else if (rf->xmax>x2) {
- if (rf->xmin>x2) {
- rf->xmin-= (x2-x1);
- rf->xmax-= (x2-x1);
+ else if (rf->xmax > x2) {
+ if (rf->xmin > x2) {
+ rf->xmin -= (x2 - x1);
+ rf->xmax -= (x2 - x1);
}
else {
- if (rf->xmin<x1) rf->xmin = x1;
- newrct= stack+ *count;
+ if (rf->xmin < x1) rf->xmin = x1;
+ newrct = stack + *count;
(*count)++;
newrct->xmin = x1;
- newrct->xmax = rf->xmax-(x2-x1);
+ newrct->xmax = rf->xmax - (x2 - x1);
newrct->ymin = rf->ymin;
newrct->ymax = rf->ymax;
- if (newrct->xmin ==newrct->xmax) (*count)--;
+ if (newrct->xmin == newrct->xmax) (*count)--;
rf->xmax = x2;
}
@@ -357,45 +357,45 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
rctf *rf, *newrct;
short a;
- a= *count;
- rf= stack;
- for (;a>0;a--) {
- if (rf->ymin<y1) {
- if (rf->ymax<y1) {
- rf->ymin+= (y2-y1);
- rf->ymax+= (y2-y1);
+ a = *count;
+ rf = stack;
+ for (; a > 0; a--) {
+ if (rf->ymin < y1) {
+ if (rf->ymax < y1) {
+ rf->ymin += (y2 - y1);
+ rf->ymax += (y2 - y1);
}
else {
- if (rf->ymax>y2) rf->ymax = y2;
- newrct= stack+ *count;
+ if (rf->ymax > y2) rf->ymax = y2;
+ newrct = stack + *count;
(*count)++;
newrct->ymax = y2;
- newrct->ymin = rf->ymin+(y2-y1);
+ newrct->ymin = rf->ymin + (y2 - y1);
newrct->xmin = rf->xmin;
newrct->xmax = rf->xmax;
- if (newrct->ymin==newrct->ymax) (*count)--;
+ if (newrct->ymin == newrct->ymax) (*count)--;
rf->ymin = y1;
}
}
- else if (rf->ymax>y2) {
- if (rf->ymin>y2) {
- rf->ymin-= (y2-y1);
- rf->ymax-= (y2-y1);
+ else if (rf->ymax > y2) {
+ if (rf->ymin > y2) {
+ rf->ymin -= (y2 - y1);
+ rf->ymax -= (y2 - y1);
}
else {
- if (rf->ymin<y1) rf->ymin = y1;
- newrct= stack+ *count;
+ if (rf->ymin < y1) rf->ymin = y1;
+ newrct = stack + *count;
(*count)++;
newrct->ymin = y1;
- newrct->ymax = rf->ymax-(y2-y1);
+ newrct->ymax = rf->ymax - (y2 - y1);
newrct->xmin = rf->xmin;
newrct->xmax = rf->xmax;
- if (newrct->ymin==newrct->ymax) (*count)--;
+ if (newrct->ymin == newrct->ymax) (*count)--;
rf->ymax = y2;
}
@@ -419,10 +419,10 @@ static float clipx_rctf(rctf *rf, float x1, float x2)
size = BLI_rctf_size_x(rf);
- if (rf->xmin<x1) {
+ if (rf->xmin < x1) {
rf->xmin = x1;
}
- if (rf->xmax>x2) {
+ if (rf->xmax > x2) {
rf->xmax = x2;
}
if (rf->xmin > rf->xmax) {
@@ -441,10 +441,10 @@ static float clipy_rctf(rctf *rf, float y1, float y2)
size = BLI_rctf_size_y(rf);
- if (rf->ymin<y1) {
+ if (rf->ymin < y1) {
rf->ymin = y1;
}
- if (rf->ymax>y2) {
+ if (rf->ymax > y2) {
rf->ymax = y2;
}
@@ -467,79 +467,79 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
float muly, mulx, div, col[4];
int x, y, startx, endx, starty, endy;
- startx= (int)floor(rf->xmin);
- endx= (int)floor(rf->xmax);
- starty= (int)floor(rf->ymin);
- endy= (int)floor(rf->ymax);
+ startx = (int)floor(rf->xmin);
+ endx = (int)floor(rf->xmax);
+ starty = (int)floor(rf->ymin);
+ endy = (int)floor(rf->ymax);
- if (startx < 0) startx= 0;
- if (starty < 0) starty= 0;
- if (endx>=ibuf->x) endx= ibuf->x-1;
- if (endy>=ibuf->y) endy= ibuf->y-1;
+ if (startx < 0) startx = 0;
+ if (starty < 0) starty = 0;
+ if (endx >= ibuf->x) endx = ibuf->x - 1;
+ if (endy >= ibuf->y) endy = ibuf->y - 1;
- if (starty==endy && startx==endx) {
+ if (starty == endy && startx == endx) {
ibuf_get_color(&texres->tr, ibuf, startx, starty);
}
else {
- div= texres->tr= texres->tg= texres->tb= texres->ta= 0.0;
- for (y=starty; y<=endy; y++) {
+ div = texres->tr = texres->tg = texres->tb = texres->ta = 0.0;
+ for (y = starty; y <= endy; y++) {
- muly= 1.0;
+ muly = 1.0;
- if (starty==endy) {
+ if (starty == endy) {
/* pass */
}
else {
- if (y==starty) muly= 1.0f-(rf->ymin - y);
- if (y==endy) muly= (rf->ymax - y);
+ if (y == starty) muly = 1.0f - (rf->ymin - y);
+ if (y == endy) muly = (rf->ymax - y);
}
- if (startx==endx) {
- mulx= muly;
+ if (startx == endx) {
+ mulx = muly;
ibuf_get_color(col, ibuf, startx, y);
- texres->ta+= mulx*col[3];
- texres->tr+= mulx*col[0];
- texres->tg+= mulx*col[1];
- texres->tb+= mulx*col[2];
- div+= mulx;
+ texres->ta += mulx * col[3];
+ texres->tr += mulx * col[0];
+ texres->tg += mulx * col[1];
+ texres->tb += mulx * col[2];
+ div += mulx;
}
else {
- for (x=startx; x<=endx; x++) {
- mulx= muly;
- if (x==startx) mulx*= 1.0f-(rf->xmin - x);
- if (x==endx) mulx*= (rf->xmax - x);
+ for (x = startx; x <= endx; x++) {
+ mulx = muly;
+ if (x == startx) mulx *= 1.0f - (rf->xmin - x);
+ if (x == endx) mulx *= (rf->xmax - x);
ibuf_get_color(col, ibuf, x, y);
- if (mulx==1.0f) {
- texres->ta+= col[3];
- texres->tr+= col[0];
- texres->tg+= col[1];
- texres->tb+= col[2];
- div+= 1.0f;
+ if (mulx == 1.0f) {
+ texres->ta += col[3];
+ texres->tr += col[0];
+ texres->tg += col[1];
+ texres->tb += col[2];
+ div += 1.0f;
}
else {
- texres->ta+= mulx*col[3];
- texres->tr+= mulx*col[0];
- texres->tg+= mulx*col[1];
- texres->tb+= mulx*col[2];
- div+= mulx;
+ texres->ta += mulx * col[3];
+ texres->tr += mulx * col[0];
+ texres->tg += mulx * col[1];
+ texres->tb += mulx * col[2];
+ div += mulx;
}
}
}
}
- if (div!=0.0f) {
- div= 1.0f/div;
- texres->tb*= div;
- texres->tg*= div;
- texres->tr*= div;
- texres->ta*= div;
+ if (div != 0.0f) {
+ div = 1.0f / div;
+ texres->tb *= div;
+ texres->tg *= div;
+ texres->tr *= div;
+ texres->ta *= div;
}
else {
- texres->tr= texres->tg= texres->tb= texres->ta= 0.0f;
+ texres->tr = texres->tg = texres->tb = texres->ta = 0.0f;
}
}
}
@@ -557,79 +557,79 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
* the point which min/max is derived from is assumed to be wrapped */
TexResult texr;
rctf *rf, stack[8];
- float opp, tot, alphaclip= 1.0;
- short count=1;
+ float opp, tot, alphaclip = 1.0;
+ short count = 1;
- rf= stack;
- rf->xmin = minx*(ibuf->x);
- rf->xmax = maxx*(ibuf->x);
- rf->ymin = miny*(ibuf->y);
- rf->ymax = maxy*(ibuf->y);
+ rf = stack;
+ rf->xmin = minx * (ibuf->x);
+ rf->xmax = maxx * (ibuf->x);
+ rf->ymin = miny * (ibuf->y);
+ rf->ymax = maxy * (ibuf->y);
- texr.talpha= texres->talpha; /* is read by boxsample_clip */
+ texr.talpha = texres->talpha; /* is read by boxsample_clip */
if (imapextend) {
- CLAMP(rf->xmin, 0.0f, ibuf->x-1);
- CLAMP(rf->xmax, 0.0f, ibuf->x-1);
+ CLAMP(rf->xmin, 0.0f, ibuf->x - 1);
+ CLAMP(rf->xmax, 0.0f, ibuf->x - 1);
}
else if (imaprepeat)
clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x));
else {
- alphaclip= clipx_rctf(rf, 0.0, (float)(ibuf->x));
+ alphaclip = clipx_rctf(rf, 0.0, (float)(ibuf->x));
- if (alphaclip<=0.0f) {
- texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
+ if (alphaclip <= 0.0f) {
+ texres->tr = texres->tb = texres->tg = texres->ta = 0.0;
return;
}
}
if (imapextend) {
- CLAMP(rf->ymin, 0.0f, ibuf->y-1);
- CLAMP(rf->ymax, 0.0f, ibuf->y-1);
+ CLAMP(rf->ymin, 0.0f, ibuf->y - 1);
+ CLAMP(rf->ymax, 0.0f, ibuf->y - 1);
}
else if (imaprepeat)
clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y));
else {
- alphaclip*= clipy_rctf(rf, 0.0, (float)(ibuf->y));
+ alphaclip *= clipy_rctf(rf, 0.0, (float)(ibuf->y));
- if (alphaclip<=0.0f) {
- texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
+ if (alphaclip <= 0.0f) {
+ texres->tr = texres->tb = texres->tg = texres->ta = 0.0;
return;
}
}
- if (count>1) {
- tot= texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
+ if (count > 1) {
+ tot = texres->tr = texres->tb = texres->tg = texres->ta = 0.0;
while (count--) {
boxsampleclip(ibuf, rf, &texr);
- opp= square_rctf(rf);
- tot+= opp;
+ opp = square_rctf(rf);
+ tot += opp;
- texres->tr+= opp*texr.tr;
- texres->tg+= opp*texr.tg;
- texres->tb+= opp*texr.tb;
- if (texres->talpha) texres->ta+= opp*texr.ta;
+ texres->tr += opp * texr.tr;
+ texres->tg += opp * texr.tg;
+ texres->tb += opp * texr.tb;
+ 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) texres->ta/= tot;
+ if (tot != 0.0f) {
+ texres->tr /= tot;
+ texres->tg /= tot;
+ texres->tb /= tot;
+ if (texres->talpha) texres->ta /= tot;
}
}
else
boxsampleclip(ibuf, rf, texres);
- if (texres->talpha==0) texres->ta= 1.0;
+ if (texres->talpha == 0) texres->ta = 1.0;
- if (alphaclip!=1.0f) {
+ if (alphaclip != 1.0f) {
/* premul it all */
- texres->tr*= alphaclip;
- texres->tg*= alphaclip;
- texres->tb*= alphaclip;
- texres->ta*= alphaclip;
+ texres->tr *= alphaclip;
+ texres->tg *= alphaclip;
+ texres->tb *= alphaclip;
+ texres->ta *= alphaclip;
}
}
@@ -655,19 +655,19 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
{
int clip = 0;
switch (extflag) {
- case TXC_XMIR: /* y rep */
- x %= 2*ibuf->x;
- x += x < 0 ? 2*ibuf->x : 0;
- x = x >= ibuf->x ? 2*ibuf->x - x - 1 : x;
+ case TXC_XMIR: /* y rep */
+ x %= 2 * ibuf->x;
+ x += x < 0 ? 2 * ibuf->x : 0;
+ x = x >= ibuf->x ? 2 * ibuf->x - x - 1 : x;
y %= ibuf->y;
y += y < 0 ? ibuf->y : 0;
break;
- case TXC_YMIR: /* x rep */
+ case TXC_YMIR: /* x rep */
x %= ibuf->x;
x += x < 0 ? ibuf->x : 0;
- y %= 2*ibuf->y;
- y += y < 0 ? 2*ibuf->y : 0;
- y = y >= ibuf->y ? 2*ibuf->y - y - 1 : y;
+ y %= 2 * ibuf->y;
+ y += y < 0 ? 2 * ibuf->y : 0;
+ y = y >= ibuf->y ? 2 * ibuf->y - y - 1 : y;
break;
case TXC_EXTD:
x = (x < 0) ? 0 : ((x >= ibuf->x) ? (ibuf->x - 1) : x);
@@ -680,7 +680,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
y += (y < 0) ? ibuf->y : 0;
break;
default:
- { /* as extend, if clipped, set alpha to 0.0 */
+ { /* as extend, if clipped, set alpha to 0.0 */
if (x < 0) { x = 0; } /* TXF alpha: clip = 1; } */
if (x >= ibuf->x) { x = ibuf->x - 1; } /* TXF alpha: clip = 1; } */
if (y < 0) { y = 0; } /* TXF alpha: clip = 1; } */
@@ -689,7 +689,7 @@ 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;
+ const float *fp = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
if (ibuf->channels == 1)
col[0] = col[1] = col[2] = col[3] = *fp;
else {
@@ -700,12 +700,12 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
}
}
else {
- const char *rect = (char *)(ibuf->rect + x + y*ibuf->x);
+ const char *rect = (char *)(ibuf->rect + x + y * ibuf->x);
float inv_alpha_fac = (1.0f / 255.0f) * rect[3] * (1.0f / 255.0f);
col[0] = rect[0] * inv_alpha_fac;
col[1] = rect[1] * inv_alpha_fac;
col[2] = rect[2] * inv_alpha_fac;
- col[3] = clip ? 0.f : rect[3]*(1.f/255.f);
+ col[3] = clip ? 0.f : rect[3] * (1.f / 255.f);
}
return clip;
}
@@ -717,16 +717,16 @@ static int ibuf_get_color_clip_bilerp(float col[4], ImBuf *ibuf, float u, float
float c00[4], c01[4], c10[4], c11[4];
const float ufl = floorf(u -= 0.5f), vfl = floorf(v -= 0.5f);
const float uf = u - ufl, vf = v - vfl;
- const float w00=(1.f-uf)*(1.f-vf), w10=uf*(1.f-vf), w01=(1.f-uf)*vf, w11=uf*vf;
+ const float w00 = (1.f - uf) * (1.f - vf), w10 = uf * (1.f - vf), w01 = (1.f - uf) * vf, w11 = uf * vf;
const int x1 = (int)ufl, y1 = (int)vfl, x2 = x1 + 1, y2 = y1 + 1;
int clip = ibuf_get_color_clip(c00, ibuf, x1, y1, extflag);
clip |= ibuf_get_color_clip(c10, ibuf, x2, y1, extflag);
clip |= ibuf_get_color_clip(c01, ibuf, x1, y2, extflag);
clip |= ibuf_get_color_clip(c11, ibuf, x2, y2, extflag);
- col[0] = w00*c00[0] + w10*c10[0] + w01*c01[0] + w11*c11[0];
- col[1] = w00*c00[1] + w10*c10[1] + w01*c01[1] + w11*c11[1];
- col[2] = w00*c00[2] + w10*c10[2] + w01*c01[2] + w11*c11[2];
- col[3] = clip ? 0.f : w00*c00[3] + w10*c10[3] + w01*c01[3] + w11*c11[3];
+ col[0] = w00 * c00[0] + w10 * c10[0] + w01 * c01[0] + w11 * c11[0];
+ col[1] = w00 * c00[1] + w10 * c10[1] + w01 * c01[1] + w11 * c11[1];
+ col[2] = w00 * c00[2] + w10 * c10[2] + w01 * c01[2] + w11 * c11[2];
+ col[3] = clip ? 0.f : w00 * c00[3] + w10 * c10[3] + w01 * c01[3] + w11 * c11[3];
return clip;
}
return ibuf_get_color_clip(col, ibuf, (int)u, (int)v, extflag);
@@ -736,23 +736,23 @@ static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
{
int xs, ys, clip = 0;
float tc[4], xsd, ysd, cw = 0.f;
- const float ux = ibuf->x*AFD->dxt[0], uy = ibuf->y*AFD->dxt[1];
- const float vx = ibuf->x*AFD->dyt[0], vy = ibuf->y*AFD->dyt[1];
- int xsam = (int)(0.5f*sqrtf(ux*ux + uy*uy) + 0.5f);
- int ysam = (int)(0.5f*sqrtf(vx*vx + vy*vy) + 0.5f);
+ const float ux = ibuf->x * AFD->dxt[0], uy = ibuf->y * AFD->dxt[1];
+ const float vx = ibuf->x * AFD->dyt[0], vy = ibuf->y * AFD->dyt[1];
+ int xsam = (int)(0.5f * sqrtf(ux * ux + uy * uy) + 0.5f);
+ int ysam = (int)(0.5f * sqrtf(vx * vx + vy * vy) + 0.5f);
const int minsam = AFD->intpol ? 2 : 4;
- xsam = CLAMPIS(xsam, minsam, ibuf->x*2);
- ysam = CLAMPIS(ysam, minsam, ibuf->y*2);
+ xsam = CLAMPIS(xsam, minsam, ibuf->x * 2);
+ ysam = CLAMPIS(ysam, minsam, ibuf->y * 2);
xsd = 1.f / xsam;
ysd = 1.f / ysam;
texr->tr = texr->tg = texr->tb = texr->ta = 0.f;
- for (ys=0; ys<ysam; ++ys) {
- for (xs=0; xs<xsam; ++xs) {
- const float su = (xs + ((ys & 1) + 0.5f)*0.5f)*xsd - 0.5f;
- const float sv = (ys + ((xs & 1) + 0.5f)*0.5f)*ysd - 0.5f;
- const float pu = fx + su*AFD->dxt[0] + sv*AFD->dyt[0];
- const float pv = fy + su*AFD->dxt[1] + sv*AFD->dyt[1];
- const int out = ibuf_get_color_clip_bilerp(tc, ibuf, pu*ibuf->x, pv*ibuf->y, AFD->intpol, AFD->extflag);
+ for (ys = 0; ys < ysam; ++ys) {
+ for (xs = 0; xs < xsam; ++xs) {
+ const float su = (xs + ((ys & 1) + 0.5f) * 0.5f) * xsd - 0.5f;
+ const float sv = (ys + ((xs & 1) + 0.5f) * 0.5f) * ysd - 0.5f;
+ const float pu = fx + su * AFD->dxt[0] + sv * AFD->dyt[0];
+ const float pv = fy + su * AFD->dxt[1] + sv * AFD->dyt[1];
+ const int out = ibuf_get_color_clip_bilerp(tc, ibuf, pu * ibuf->x, pv * ibuf->y, AFD->intpol, AFD->extflag);
clip |= out;
cw += out ? 0.f : 1.f;
texr->tr += tc[0];
@@ -766,7 +766,7 @@ static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
texr->tg *= xsd;
texr->tb *= xsd;
/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
- texr->ta = texr->talpha ? texr->ta*xsd : (clip ? cw*xsd : 1.f);
+ texr->ta = texr->talpha ? texr->ta * xsd : (clip ? cw * xsd : 1.f);
}
typedef struct ReadEWAData {
@@ -776,7 +776,7 @@ typedef struct ReadEWAData {
static void ewa_read_pixel_cb(void *userdata, int x, int y, float result[4])
{
- ReadEWAData *data = (ReadEWAData *) userdata;
+ ReadEWAData *data = (ReadEWAData *)userdata;
ibuf_get_color_clip(result, data->ibuf, x, y, data->AFD->extflag);
}
@@ -799,40 +799,40 @@ static void ewa_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t
static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD)
{
const int maxn = AFD->iProbes - 1;
- const float ll = ((AFD->majrad == AFD->minrad) ? 2.f*AFD->majrad : 2.f*(AFD->majrad - AFD->minrad)) / (maxn ? (float)maxn : 1.f);
- float du = maxn ? cosf(AFD->theta)*ll : 0.f;
- float dv = maxn ? sinf(AFD->theta)*ll : 0.f;
+ const float ll = ((AFD->majrad == AFD->minrad) ? 2.f * AFD->majrad : 2.f * (AFD->majrad - AFD->minrad)) / (maxn ? (float)maxn : 1.f);
+ float du = maxn ? cosf(AFD->theta) * ll : 0.f;
+ float dv = maxn ? sinf(AFD->theta) * ll : 0.f;
/* const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); */
- const float D = (EWA_MAXIDX + 1)*0.25f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad);
+ const float D = (EWA_MAXIDX + 1) * 0.25f * (du * du + dv * dv) / (AFD->majrad * AFD->majrad);
float d; /* TXF alpha: cw = 0.f; */
int n; /* TXF alpha: clip = 0; */
/* have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) */
du *= AFD->dusc;
dv *= AFD->dvsc;
d = texr->tr = texr->tb = texr->tg = texr->ta = 0.f;
- for (n=-maxn; n<=maxn; n+=2) {
+ for (n = -maxn; n <= maxn; n += 2) {
float tc[4];
- const float hn = n*0.5f;
- const float u = fx + hn*du, v = fy + hn*dv;
+ const float hn = n * 0.5f;
+ const float u = fx + hn * du, v = fy + hn * dv;
/*const float wt = expf(n*n*D);
- * can use ewa table here too */
- const float wt = EWA_WTS[(int)(n*n*D)];
- /*const int out =*/ ibuf_get_color_clip_bilerp(tc, ibuf, ibuf->x*u, ibuf->y*v, AFD->intpol, AFD->extflag);
+ * can use ewa table here too */
+ const float wt = EWA_WTS[(int)(n * n * D)];
+ /*const int out =*/ ibuf_get_color_clip_bilerp(tc, ibuf, ibuf->x * u, ibuf->y * v, AFD->intpol, AFD->extflag);
/* TXF alpha: clip |= out;
* TXF alpha: cw += out ? 0.f : wt; */
- texr->tr += tc[0]*wt;
- texr->tg += tc[1]*wt;
- texr->tb += tc[2]*wt;
- texr->ta += texr->talpha ? tc[3]*wt : 0.f;
+ texr->tr += tc[0] * wt;
+ texr->tg += tc[1] * wt;
+ texr->tb += tc[2] * wt;
+ texr->ta += texr->talpha ? tc[3] * wt : 0.f;
d += wt;
}
- d = 1.f/d;
+ d = 1.f / d;
texr->tr *= d;
texr->tg *= d;
texr->tb *= d;
/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
- texr->ta = texr->talpha ? texr->ta*d : 1.f; // TXF alpha: (clip ? cw*d : 1.f);
+ texr->ta = texr->talpha ? texr->ta * d : 1.f; // TXF alpha: (clip ? cw*d : 1.f);
}
#undef EWA_MAXIDX
@@ -845,21 +845,21 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl
* if this is actually correct for the all the filtering algorithms .. */
if (!(extflag == TXC_REPT || extflag == TXC_EXTD)) {
- rf.xmin = minx*(ibuf->x);
- rf.xmax = maxx*(ibuf->x);
- rf.ymin = miny*(ibuf->y);
- rf.ymax = maxy*(ibuf->y);
+ rf.xmin = minx * (ibuf->x);
+ rf.xmax = maxx * (ibuf->x);
+ rf.ymin = miny * (ibuf->y);
+ rf.ymax = maxy * (ibuf->y);
alphaclip = clipx_rctf(&rf, 0.0, (float)(ibuf->x));
alphaclip *= clipy_rctf(&rf, 0.0, (float)(ibuf->y));
alphaclip = max_ff(alphaclip, 0.0f);
- if (alphaclip!=1.0f) {
+ if (alphaclip != 1.0f) {
/* premul it all */
- texres->tr*= alphaclip;
- texres->tg*= alphaclip;
- texres->tb*= alphaclip;
- texres->ta*= alphaclip;
+ texres->tr *= alphaclip;
+ texres->tg *= alphaclip;
+ texres->tb *= alphaclip;
+ texres->ta *= alphaclip;
}
}
}
@@ -896,7 +896,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
int curmap, retval, intpol, extflag = 0;
afdata_t AFD;
- void (*filterfunc)(TexResult*, ImBuf*, float, float, afdata_t*);
+ void (*filterfunc)(TexResult *, ImBuf *, float, float, afdata_t *);
switch (tex->texfilter) {
case TXF_EWA:
filterfunc = ewa_eval;
@@ -915,9 +915,9 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
retval = texres->nor ? 3 : 1;
/* quick tests */
- if (ibuf==NULL && ima==NULL) return retval;
+ if (ibuf == NULL && ima == NULL) return retval;
- if (ima) { /* hack for icon render */
+ if (ima) { /* hack for icon render */
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
return retval;
}
@@ -962,8 +962,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
maxy = max_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
/* tex_sharper has been removed */
- minx = (maxx - minx)*0.5f;
- miny = (maxy - miny)*0.5f;
+ minx = (maxx - minx) * 0.5f;
+ 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) */
@@ -1060,8 +1060,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
/* scale around center, (0.5, 0.5) */
if (tex->checkerdist < 1.f) {
const float omcd = 1.f / (1.f - tex->checkerdist);
- fx = (fx - 0.5f)*omcd + 0.5f;
- fy = (fy - 0.5f)*omcd + 0.5f;
+ fx = (fx - 0.5f) * omcd + 0.5f;
+ fy = (fy - 0.5f) * omcd + 0.5f;
minx *= omcd;
miny *= omcd;
}
@@ -1103,10 +1103,10 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float 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)
- 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)
- mul_v2_fl(AFD.dyt, 2.0f/len_v2(AFD.dyt));
+ 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)
+ mul_v2_fl(AFD.dyt, 2.0f / len_v2(AFD.dyt));
/* choice: */
if (tex->imaflag & TEX_MIPMAP) {
@@ -1118,12 +1118,12 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
/* modify ellipse minor axis if too eccentric, use for area sampling as well
* scaling dxt/dyt as done in pbrt is not the same
* (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision) */
- const float ff = sqrtf(ibuf->x), q = ibuf->y/ff;
- const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q;
- const float A = Vx*Vx + Vy*Vy;
- const float B = -2.f*(Ux*Vx + Uy*Vy);
- const float C = Ux*Ux + Uy*Uy;
- const float F = A*C - B*B*0.25f;
+ const float ff = sqrtf(ibuf->x), q = ibuf->y / ff;
+ const float Ux = dxt[0] * ff, Vx = dxt[1] * q, Uy = dyt[0] * ff, Vy = dyt[1] * q;
+ const float A = Vx * Vx + Vy * Vy;
+ const float B = -2.f * (Ux * Vx + Uy * Vy);
+ const float C = Ux * Ux + Uy * Uy;
+ const float F = A * C - B * B * 0.25f;
float a, b, th, ecc;
BLI_ewa_imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
if (tex->texfilter == TXF_FELINE) {
@@ -1132,18 +1132,18 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
b *= ff;
a = max_ff(a, 1.0f);
b = max_ff(b, 1.0f);
- fProbes = 2.f*(a / b) - 1.f;
+ 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)
- b = 2.f*a / (float)(AFD.iProbes + 1);
- AFD.majrad = a/ff;
- AFD.minrad = b/ff;
+ b = 2.f * a / (float)(AFD.iProbes + 1);
+ AFD.majrad = a / ff;
+ AFD.minrad = b / ff;
AFD.theta = th;
- AFD.dusc = 1.f/ff;
+ AFD.dusc = 1.f / ff;
AFD.dvsc = ff / (float)ibuf->y;
}
- else { /* EWA & area */
+ else { /* EWA & area */
if (ecc > (float)tex->afmax) b = a / (float)tex->afmax;
b *= ff;
}
@@ -1192,16 +1192,16 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
if (previbuf != curibuf) { /* interpolate */
filterfunc(&texr, previbuf, fx, fy, &AFD);
/* rgb */
- texres->tr += levf*(texr.tr - texres->tr);
- texres->tg += levf*(texr.tg - texres->tg);
- texres->tb += levf*(texr.tb - texres->tb);
- texres->ta += levf*(texr.ta - texres->ta);
+ texres->tr += levf * (texr.tr - texres->tr);
+ texres->tg += levf * (texr.tg - texres->tg);
+ texres->tb += levf * (texr.tb - texres->tb);
+ texres->ta += levf * (texr.ta - texres->ta);
/* normal */
- val1 += levf*((texr.tr + texr.tg + texr.tb) - val1);
+ val1 += levf * ((texr.tr + texr.tg + texr.tb) - val1);
filterfunc(&texr, previbuf, fx + dxt[0], fy + dxt[1], &AFD);
- val2 += levf*((texr.tr + texr.tg + texr.tb) - val2);
+ val2 += levf * ((texr.tr + texr.tg + texr.tb) - val2);
filterfunc(&texr, previbuf, fx + dyt[0], fy + dyt[1], &AFD);
- val3 += levf*((texr.tr + texr.tg + texr.tb) - val3);
+ val3 += levf * ((texr.tr + texr.tg + texr.tb) - val3);
texres->nor[0] = val1 - val2; /* vals have been interpolated above! */
texres->nor[1] = val1 - val3;
}
@@ -1210,40 +1210,40 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
filterfunc(texres, curibuf, fx, fy, &AFD);
if (previbuf != curibuf) { /* interpolate */
filterfunc(&texr, previbuf, fx, fy, &AFD);
- texres->tr += levf*(texr.tr - texres->tr);
- texres->tg += levf*(texr.tg - texres->tg);
- texres->tb += levf*(texr.tb - texres->tb);
- texres->ta += levf*(texr.ta - texres->ta);
+ texres->tr += levf * (texr.tr - texres->tr);
+ texres->tg += levf * (texr.tg - texres->tg);
+ texres->tb += levf * (texr.tb - texres->tb);
+ texres->ta += levf * (texr.ta - texres->ta);
}
if (tex->texfilter != TXF_EWA) {
- alpha_clip_aniso(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, extflag, texres);
+ alpha_clip_aniso(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, extflag, texres);
}
}
}
- else { /* no mipmap */
+ else { /* no mipmap */
/* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */
if (tex->texfilter == TXF_FELINE) {
- const float ff = sqrtf(ibuf->x), q = ibuf->y/ff;
- const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q;
- const float A = Vx*Vx + Vy*Vy;
- const float B = -2.f*(Ux*Vx + Uy*Vy);
- const float C = Ux*Ux + Uy*Uy;
- const float F = A*C - B*B*0.25f;
+ const float ff = sqrtf(ibuf->x), q = ibuf->y / ff;
+ const float Ux = dxt[0] * ff, Vx = dxt[1] * q, Uy = dyt[0] * ff, Vy = dyt[1] * q;
+ const float A = Vx * Vx + Vy * Vy;
+ const float B = -2.f * (Ux * Vx + Uy * Vy);
+ const float C = Ux * Ux + Uy * Uy;
+ const float F = A * C - B * B * 0.25f;
float a, b, th, ecc, fProbes;
BLI_ewa_imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
a *= ff;
b *= ff;
a = max_ff(a, 1.0f);
b = max_ff(b, 1.0f);
- fProbes = 2.f*(a / b) - 1.f;
+ 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) b = 2.f*a / (float)(AFD.iProbes + 1);
- AFD.majrad = a/ff;
- AFD.minrad = b/ff;
+ if (AFD.iProbes < fProbes) b = 2.f * a / (float)(AFD.iProbes + 1);
+ AFD.majrad = a / ff;
+ AFD.minrad = b / ff;
AFD.theta = th;
- AFD.dusc = 1.f/ff;
+ AFD.dusc = 1.f / ff;
AFD.dvsc = ff / (float)ibuf->y;
}
if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) {
@@ -1261,7 +1261,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
else {
filterfunc(texres, ibuf, fx, fy, &AFD);
if (tex->texfilter != TXF_EWA) {
- alpha_clip_aniso(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, extflag, texres);
+ alpha_clip_aniso(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, extflag, texres);
}
}
}
@@ -1272,16 +1272,16 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
texres->tin = texres->ta;
if (tex->flag & TEX_NEGALPHA) texres->ta = 1.f - texres->ta;
- if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */
+ if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */
/* The invert of the red channel is to make
* the normal map compliant with the outside world.
* It needs to be done because in Blender
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
- texres->nor[0] = -2.f*(texres->tr - 0.5f);
- texres->nor[1] = 2.f*(texres->tg - 0.5f);
- texres->nor[2] = 2.f*(texres->tb - 0.5f);
+ texres->nor[0] = -2.f * (texres->tr - 0.5f);
+ texres->nor[1] = 2.f * (texres->tg - 0.5f);
+ texres->nor[2] = 2.f * (texres->tb - 0.5f);
}
/* de-premul, this is being premulled in shade_input_do_shade()
@@ -1291,8 +1291,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
/* brecht: tried to fix this, see "TXF alpha" comments */
/* do not de-premul for generated alpha, it is already in straight */
- if (texres->ta!=1.0f && texres->ta>1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
- fx = 1.f/texres->ta;
+ if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
+ fx = 1.f / texres->ta;
texres->tr *= fx;
texres->tg *= fx;
texres->tb *= fx;
@@ -1323,13 +1323,13 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
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;
+ texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f;
/* we need to set retval OK, otherwise texture code generates normals itself... */
retval = texres->nor ? 3 : 1;
/* quick tests */
- if (ibuf==NULL && ima==NULL)
+ if (ibuf == NULL && ima == NULL)
return retval;
if (ima) {
@@ -1339,9 +1339,9 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool);
- ima->flag|= IMA_USED_FOR_RENDER;
+ ima->flag |= IMA_USED_FOR_RENDER;
}
- if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) {
+ if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
if (ima)
BKE_image_pool_release_ibuf(ima, ibuf, pool);
return retval;
@@ -1358,15 +1358,15 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
}
}
- texr.talpha= texres->talpha;
+ texr.talpha = texres->talpha;
if (tex->imaflag & TEX_IMAROT) {
- fy= texvec[0];
- fx= texvec[1];
+ fy = texvec[0];
+ fx = texvec[1];
}
else {
- fx= texvec[0];
- fy= texvec[1];
+ fx = texvec[0];
+ fy = texvec[1];
}
/* pixel coordinates */
@@ -1377,57 +1377,57 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
maxy = max_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
/* tex_sharper has been removed */
- minx= (maxx-minx)/2.0f;
- miny= (maxy-miny)/2.0f;
+ minx = (maxx - minx) / 2.0f;
+ 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) */
- float addval= (0.5f * tex->filtersize) / (float) MIN2(ibuf->x, ibuf->y);
+ float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y);
if (addval > minx)
- minx= addval;
+ minx = addval;
if (addval > miny)
- miny= addval;
+ miny = addval;
}
- else if (tex->filtersize!=1.0f) {
- minx*= tex->filtersize;
- miny*= tex->filtersize;
+ else if (tex->filtersize != 1.0f) {
+ minx *= tex->filtersize;
+ miny *= tex->filtersize;
- dxt[0]*= tex->filtersize;
- dxt[1]*= tex->filtersize;
- dyt[0]*= tex->filtersize;
- dyt[1]*= tex->filtersize;
+ dxt[0] *= tex->filtersize;
+ dxt[1] *= tex->filtersize;
+ dyt[0] *= tex->filtersize;
+ dyt[1] *= tex->filtersize;
}
if (tex->imaflag & TEX_IMAROT) SWAP(float, minx, miny);
- if (minx>0.25f) minx= 0.25f;
- else if (minx<0.00001f) minx= 0.00001f; /* side faces of unit-cube */
- if (miny>0.25f) miny= 0.25f;
- else if (miny<0.00001f) miny= 0.00001f;
+ if (minx > 0.25f) minx = 0.25f;
+ else if (minx < 0.00001f) minx = 0.00001f; /* side faces of unit-cube */
+ if (miny > 0.25f) miny = 0.25f;
+ else if (miny < 0.00001f) miny = 0.00001f;
/* repeat and clip */
- imaprepeat= (tex->extend==TEX_REPEAT);
- imapextend= (tex->extend==TEX_EXTEND);
+ imaprepeat = (tex->extend == TEX_REPEAT);
+ imapextend = (tex->extend == TEX_EXTEND);
if (tex->extend == TEX_REPEAT) {
- if (tex->flag & (TEX_REPEAT_XMIR|TEX_REPEAT_YMIR)) {
- imaprepeat= 0;
- imapextend= 1;
+ if (tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) {
+ imaprepeat = 0;
+ imapextend = 1;
}
}
if (tex->extend == TEX_CHECKER) {
int xs, ys, xs1, ys1, xs2, ys2, boundary;
- xs= (int)floor(fx);
- ys= (int)floor(fy);
+ xs = (int)floor(fx);
+ ys = (int)floor(fy);
/* both checkers available, no boundary exceptions, checkerdist will eat aliasing */
if ( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) {
- fx-= xs;
- fy-= ys;
+ fx -= xs;
+ fy -= ys;
}
else if ((tex->flag & TEX_CHECKER_ODD) == 0 &&
(tex->flag & TEX_CHECKER_EVEN) == 0)
@@ -1438,14 +1438,14 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
}
else {
- xs1= (int)floor(fx-minx);
- ys1= (int)floor(fy-miny);
- xs2= (int)floor(fx+minx);
- ys2= (int)floor(fy+miny);
- boundary= (xs1!=xs2) || (ys1!=ys2);
+ xs1 = (int)floor(fx - minx);
+ ys1 = (int)floor(fy - miny);
+ xs2 = (int)floor(fx + minx);
+ ys2 = (int)floor(fy + miny);
+ boundary = (xs1 != xs2) || (ys1 != ys2);
- if (boundary==0) {
- if ( (tex->flag & TEX_CHECKER_ODD)==0) {
+ if (boundary == 0) {
+ if ( (tex->flag & TEX_CHECKER_ODD) == 0) {
if ((xs + ys) & 1) {
/* pass */
}
@@ -1455,52 +1455,52 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
return retval;
}
}
- if ( (tex->flag & TEX_CHECKER_EVEN)==0) {
+ if ( (tex->flag & TEX_CHECKER_EVEN) == 0) {
if ((xs + ys) & 1) {
if (ima)
BKE_image_pool_release_ibuf(ima, ibuf, pool);
return retval;
}
}
- fx-= xs;
- fy-= ys;
+ fx -= xs;
+ fy -= ys;
}
else {
if (tex->flag & TEX_CHECKER_ODD) {
- if ((xs1+ys) & 1) fx-= xs2;
- else fx-= xs1;
+ if ((xs1 + ys) & 1) fx -= xs2;
+ else fx -= xs1;
- if ((ys1+xs) & 1) fy-= ys2;
- else fy-= ys1;
+ if ((ys1 + xs) & 1) fy -= ys2;
+ else fy -= ys1;
}
if (tex->flag & TEX_CHECKER_EVEN) {
- if ((xs1+ys) & 1) fx-= xs1;
- else fx-= xs2;
+ if ((xs1 + ys) & 1) fx -= xs1;
+ else fx -= xs2;
- if ((ys1+xs) & 1) fy-= ys1;
- else fy-= ys2;
+ if ((ys1 + xs) & 1) fy -= ys1;
+ else fy -= ys2;
}
}
}
/* scale around center, (0.5, 0.5) */
- if (tex->checkerdist<1.0f) {
- fx= (fx-0.5f)/(1.0f-tex->checkerdist) +0.5f;
- fy= (fy-0.5f)/(1.0f-tex->checkerdist) +0.5f;
- minx/= (1.0f-tex->checkerdist);
- miny/= (1.0f-tex->checkerdist);
+ if (tex->checkerdist < 1.0f) {
+ fx = (fx - 0.5f) / (1.0f - tex->checkerdist) + 0.5f;
+ fy = (fy - 0.5f) / (1.0f - tex->checkerdist) + 0.5f;
+ minx /= (1.0f - tex->checkerdist);
+ miny /= (1.0f - tex->checkerdist);
}
}
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 (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)
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) {
+ 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)
BKE_image_pool_release_ibuf(ima, ibuf, pool);
return retval;
@@ -1508,21 +1508,21 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
}
else {
if (imapextend) {
- if (fx>1.0f) fx = 1.0f;
- else if (fx<0.0f) fx= 0.0f;
+ if (fx > 1.0f) fx = 1.0f;
+ else if (fx < 0.0f) fx = 0.0f;
}
else {
- if (fx>1.0f) fx -= (int)(fx);
- else if (fx<0.0f) fx+= 1-(int)(fx);
+ if (fx > 1.0f) fx -= (int)(fx);
+ else if (fx < 0.0f) fx += 1 - (int)(fx);
}
if (imapextend) {
- if (fy>1.0f) fy = 1.0f;
- else if (fy<0.0f) fy= 0.0f;
+ if (fy > 1.0f) fy = 1.0f;
+ else if (fy < 0.0f) fy = 0.0f;
}
else {
- if (fy>1.0f) fy -= (int)(fy);
- else if (fy<0.0f) fy+= 1-(int)(fy);
+ if (fy > 1.0f) fy -= (int)(fy);
+ else if (fy < 0.0f) fy += 1 - (int)(fy);
}
}
@@ -1536,105 +1536,105 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
maxd = max_ff(dx, dy);
if (maxd > 0.5f) maxd = 0.5f;
- pixsize = 1.0f / (float) MIN2(ibuf->x, ibuf->y);
+ pixsize = 1.0f / (float)MIN2(ibuf->x, ibuf->y);
- bumpscale= pixsize/maxd;
- if (bumpscale>1.0f) bumpscale= 1.0f;
- else bumpscale*=bumpscale;
+ bumpscale = pixsize / maxd;
+ if (bumpscale > 1.0f) bumpscale = 1.0f;
+ else bumpscale *= bumpscale;
- curmap= 0;
- previbuf= curibuf= ibuf;
+ curmap = 0;
+ previbuf = curibuf = ibuf;
while (curmap < IMB_MIPMAP_LEVELS && ibuf->mipmap[curmap]) {
if (maxd < pixsize) break;
- previbuf= curibuf;
- curibuf= ibuf->mipmap[curmap];
- pixsize= 1.0f / (float)MIN2(curibuf->x, curibuf->y);
+ previbuf = curibuf;
+ curibuf = ibuf->mipmap[curmap];
+ pixsize = 1.0f / (float)MIN2(curibuf->x, curibuf->y);
curmap++;
}
- if (previbuf!=curibuf || (tex->imaflag & TEX_INTERPOL)) {
+ if (previbuf != curibuf || (tex->imaflag & TEX_INTERPOL)) {
/* sample at least 1 pixel */
if (minx < 0.5f / ibuf->x) minx = 0.5f / ibuf->x;
if (miny < 0.5f / ibuf->y) miny = 0.5f / ibuf->y;
}
- if (texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
+ if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) {
/* a bit extra filter */
//minx*= 1.35f;
//miny*= 1.35f;
- boxsample(curibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres, imaprepeat, imapextend);
- val1= texres->tr+texres->tg+texres->tb;
- boxsample(curibuf, fx-minx+dxt[0], fy-miny+dxt[1], fx+minx+dxt[0], fy+miny+dxt[1], &texr, imaprepeat, imapextend);
- val2= texr.tr + texr.tg + texr.tb;
- boxsample(curibuf, fx-minx+dyt[0], fy-miny+dyt[1], fx+minx+dyt[0], fy+miny+dyt[1], &texr, imaprepeat, imapextend);
- val3= texr.tr + texr.tg + texr.tb;
+ boxsample(curibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
+ val1 = texres->tr + texres->tg + texres->tb;
+ boxsample(curibuf, fx - minx + dxt[0], fy - miny + dxt[1], fx + minx + dxt[0], fy + miny + dxt[1], &texr, imaprepeat, imapextend);
+ val2 = texr.tr + texr.tg + texr.tb;
+ boxsample(curibuf, fx - minx + dyt[0], fy - miny + dyt[1], fx + minx + dyt[0], fy + miny + dyt[1], &texr, imaprepeat, imapextend);
+ val3 = texr.tr + texr.tg + texr.tb;
/* don't switch x or y! */
- texres->nor[0]= (val1-val2);
- texres->nor[1]= (val1-val3);
+ texres->nor[0] = (val1 - val2);
+ texres->nor[1] = (val1 - val3);
- if (previbuf!=curibuf) { /* interpolate */
+ if (previbuf != curibuf) { /* interpolate */
- boxsample(previbuf, fx-minx, fy-miny, fx+minx, fy+miny, &texr, imaprepeat, imapextend);
+ boxsample(previbuf, fx - minx, fy - miny, fx + minx, fy + miny, &texr, imaprepeat, imapextend);
/* calc rgb */
- dx= 2.0f*(pixsize-maxd)/pixsize;
- if (dx>=1.0f) {
- texres->ta= texr.ta; texres->tb= texr.tb;
- texres->tg= texr.tg; texres->tr= texr.tr;
+ dx = 2.0f * (pixsize - maxd) / pixsize;
+ if (dx >= 1.0f) {
+ texres->ta = texr.ta; texres->tb = texr.tb;
+ texres->tg = texr.tg; texres->tr = texr.tr;
}
else {
- dy= 1.0f-dx;
- texres->tb= dy*texres->tb+ dx*texr.tb;
- texres->tg= dy*texres->tg+ dx*texr.tg;
- texres->tr= dy*texres->tr+ dx*texr.tr;
- texres->ta= dy*texres->ta+ dx*texr.ta;
+ dy = 1.0f - dx;
+ texres->tb = dy * texres->tb + dx * texr.tb;
+ texres->tg = dy * texres->tg + dx * texr.tg;
+ texres->tr = dy * texres->tr + dx * texr.tr;
+ texres->ta = dy * texres->ta + dx * texr.ta;
}
- val1= dy*val1+ dx*(texr.tr + texr.tg + texr.tb);
- boxsample(previbuf, fx-minx+dxt[0], fy-miny+dxt[1], fx+minx+dxt[0], fy+miny+dxt[1], &texr, imaprepeat, imapextend);
- val2= dy*val2+ dx*(texr.tr + texr.tg + texr.tb);
- boxsample(previbuf, fx-minx+dyt[0], fy-miny+dyt[1], fx+minx+dyt[0], fy+miny+dyt[1], &texr, imaprepeat, imapextend);
- val3= dy*val3+ dx*(texr.tr + texr.tg + texr.tb);
-
- texres->nor[0]= (val1-val2); /* vals have been interpolated above! */
- texres->nor[1]= (val1-val3);
-
- if (dx<1.0f) {
- dy= 1.0f-dx;
- texres->tb= dy*texres->tb+ dx*texr.tb;
- texres->tg= dy*texres->tg+ dx*texr.tg;
- texres->tr= dy*texres->tr+ dx*texr.tr;
- texres->ta= dy*texres->ta+ dx*texr.ta;
+ val1 = dy * val1 + dx * (texr.tr + texr.tg + texr.tb);
+ boxsample(previbuf, fx - minx + dxt[0], fy - miny + dxt[1], fx + minx + dxt[0], fy + miny + dxt[1], &texr, imaprepeat, imapextend);
+ val2 = dy * val2 + dx * (texr.tr + texr.tg + texr.tb);
+ boxsample(previbuf, fx - minx + dyt[0], fy - miny + dyt[1], fx + minx + dyt[0], fy + miny + dyt[1], &texr, imaprepeat, imapextend);
+ val3 = dy * val3 + dx * (texr.tr + texr.tg + texr.tb);
+
+ texres->nor[0] = (val1 - val2); /* vals have been interpolated above! */
+ texres->nor[1] = (val1 - val3);
+
+ if (dx < 1.0f) {
+ dy = 1.0f - dx;
+ texres->tb = dy * texres->tb + dx * texr.tb;
+ texres->tg = dy * texres->tg + dx * texr.tg;
+ texres->tr = dy * texres->tr + dx * texr.tr;
+ texres->ta = dy * texres->ta + dx * texr.ta;
}
}
- texres->nor[0]*= bumpscale;
- texres->nor[1]*= bumpscale;
+ texres->nor[0] *= bumpscale;
+ texres->nor[1] *= bumpscale;
}
else {
- maxx= fx+minx;
- minx= fx-minx;
- maxy= fy+miny;
- miny= fy-miny;
+ maxx = fx + minx;
+ minx = fx - minx;
+ maxy = fy + miny;
+ miny = fy - miny;
boxsample(curibuf, minx, miny, maxx, maxy, texres, imaprepeat, imapextend);
- if (previbuf!=curibuf) { /* interpolate */
+ if (previbuf != curibuf) { /* interpolate */
boxsample(previbuf, minx, miny, maxx, maxy, &texr, imaprepeat, imapextend);
- fx= 2.0f*(pixsize-maxd)/pixsize;
+ fx = 2.0f * (pixsize - maxd) / pixsize;
- if (fx>=1.0f) {
- texres->ta= texr.ta; texres->tb= texr.tb;
- texres->tg= texr.tg; texres->tr= texr.tr;
+ if (fx >= 1.0f) {
+ texres->ta = texr.ta; texres->tb = texr.tb;
+ texres->tg = texr.tg; texres->tr = texr.tr;
}
else {
- fy= 1.0f-fx;
- texres->tb= fy*texres->tb+ fx*texr.tb;
- texres->tg= fy*texres->tg+ fx*texr.tg;
- texres->tr= fy*texres->tr+ fx*texr.tr;
- texres->ta= fy*texres->ta+ fx*texr.ta;
+ fy = 1.0f - fx;
+ texres->tb = fy * texres->tb + fx * texr.tb;
+ texres->tg = fy * texres->tg + fx * texr.tg;
+ texres->tr = fy * texres->tr + fx * texr.tr;
+ texres->ta = fy * texres->ta + fx * texr.ta;
}
}
}
@@ -1647,20 +1647,20 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
if (miny < 0.5f / ibuf->y) miny = 0.5f / ibuf->y;
}
- if (texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
- boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres, imaprepeat, imapextend);
- val1= texres->tr+texres->tg+texres->tb;
- boxsample(ibuf, fx-minx+dxt[0], fy-miny+dxt[1], fx+minx+dxt[0], fy+miny+dxt[1], &texr, imaprepeat, imapextend);
- val2= texr.tr + texr.tg + texr.tb;
- boxsample(ibuf, fx-minx+dyt[0], fy-miny+dyt[1], fx+minx+dyt[0], fy+miny+dyt[1], &texr, imaprepeat, imapextend);
- val3= texr.tr + texr.tg + texr.tb;
+ if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) {
+ boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
+ val1 = texres->tr + texres->tg + texres->tb;
+ boxsample(ibuf, fx - minx + dxt[0], fy - miny + dxt[1], fx + minx + dxt[0], fy + miny + dxt[1], &texr, imaprepeat, imapextend);
+ val2 = texr.tr + texr.tg + texr.tb;
+ boxsample(ibuf, fx - minx + dyt[0], fy - miny + dyt[1], fx + minx + dyt[0], fy + miny + dyt[1], &texr, imaprepeat, imapextend);
+ val3 = texr.tr + texr.tg + texr.tb;
/* don't switch x or y! */
- texres->nor[0]= (val1-val2);
- texres->nor[1]= (val1-val3);
+ texres->nor[0] = (val1 - val2);
+ texres->nor[1] = (val1 - val3);
}
else
- boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres, imaprepeat, imapextend);
+ boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
}
if (tex->imaflag & TEX_CALCALPHA) {
@@ -1670,7 +1670,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
texres->tin = texres->ta;
}
- if (tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta;
+ if (tex->flag & TEX_NEGALPHA) texres->ta = 1.0f - texres->ta;
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) {
/* qdn: normal from color
@@ -1680,14 +1680,14 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
- texres->nor[0] = -2.f*(texres->tr - 0.5f);
- texres->nor[1] = 2.f*(texres->tg - 0.5f);
- texres->nor[2] = 2.f*(texres->tb - 0.5f);
+ texres->nor[0] = -2.f * (texres->tr - 0.5f);
+ texres->nor[1] = 2.f * (texres->tg - 0.5f);
+ texres->nor[2] = 2.f * (texres->tb - 0.5f);
}
/* de-premul, this is being premulled in shade_input_do_shade() */
/* do not de-premul for generated alpha, it is already in straight */
- if (texres->ta!=1.0f && texres->ta>1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
+ if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
mul_v3_fl(&texres->tr, 1.0f / texres->ta);
}
@@ -1713,7 +1713,7 @@ void image_sample(Image *ima, float fx, float fy, float dx, float dy, float resu
boxsample(ibuf, fx, fy, fx + dx, fy + dy, &texres, 0, 1);
copy_v4_v4(result, &texres.tr);
- ima->flag|= IMA_USED_FOR_RENDER;
+ ima->flag |= IMA_USED_FOR_RENDER;
BKE_image_pool_release_ibuf(ima, ibuf, pool);
}
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 7b0b1bed0ef..ff0d2867426 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -118,7 +118,7 @@ float RE_filter_value(int type, float x)
{
const float two_gaussfac2 = 2.0f * gaussfac * gaussfac;
x *= 3.0f * gaussfac;
- return 1.0f / sqrtf((float)M_PI * two_gaussfac2) * expf(-x*x / two_gaussfac2);
+ return 1.0f / sqrtf((float)M_PI * two_gaussfac2) * expf(-x * x / two_gaussfac2);
}
case R_FILTER_MITCH:
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c
index f20434969db..632c501c54c 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/source/multires_bake.c
@@ -103,7 +103,7 @@ typedef struct {
const int *orig_index_mp_to_orig;
} MNormalBakeData;
-static void multiresbake_get_normal(const MResolvePixelData *data, float norm[],const int tri_num, const int vert_index)
+static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], const int tri_num, const int vert_index)
{
const int poly_index = data->mlooptri[tri_num].poly;
const MPoly *mp = &data->mpoly[poly_index];
@@ -129,7 +129,7 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[],
static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResolvePixelData *data,
MFlushPixel flush_pixel, short *do_update)
{
- BakeImBufuserData *userdata = (BakeImBufuserData *) ibuf->userdata;
+ BakeImBufuserData *userdata = (BakeImBufuserData *)ibuf->userdata;
memset(bake_rast, 0, sizeof(MBakeRast));
@@ -281,9 +281,9 @@ static void bake_rasterize(const MBakeRast *bake_rast, const float st0_in[2], co
/* check if mid point is to the left or to the right of the lo-hi edge */
is_mid_right = (-(shi - slo) * (tmi - thi) + (thi - tlo) * (smi - shi)) > 0 ? 1 : 0;
- ylo = (int) ceilf(tlo);
- yhi_beg = (int) ceilf(tmi);
- yhi = (int) ceilf(thi);
+ ylo = (int)ceilf(tlo);
+ yhi_beg = (int)ceilf(tmi);
+ yhi = (int)ceilf(thi);
/*if (fTmi>ceilf(fTlo))*/
rasterize_half(bake_rast, slo, tlo, smi, tmi, slo, tlo, shi, thi, ylo, yhi_beg, is_mid_right);
@@ -343,7 +343,7 @@ static int multires_bake_queue_next_tri(MultiresBakeQueue *queue)
static void *do_multires_bake_thread(void *data_v)
{
- MultiresBakeThread *handle = (MultiresBakeThread *) data_v;
+ MultiresBakeThread *handle = (MultiresBakeThread *)data_v;
MResolvePixelData *data = &handle->data;
MBakeRast *bake_rast = &handle->bake_rast;
MultiresBakeRender *bkr = handle->bkr;
@@ -403,9 +403,9 @@ static void init_ccgdm_arrays(DerivedMesh *dm)
grid_offset = dm->getGridOffset(dm);
dm->getGridKey(dm, &key);
- (void) grid_size;
- (void) grid_data;
- (void) grid_offset;
+ (void)grid_size;
+ (void)grid_data;
+ (void)grid_offset;
}
static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, bool require_tangent, MPassKnownData passKnownData,
@@ -525,10 +525,10 @@ static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float
float u, v;
float data[4][3];
- x0 = (int) crn_x;
+ x0 = (int)crn_x;
x1 = x0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (x0 + 1);
- y0 = (int) crn_y;
+ y0 = (int)crn_y;
y1 = y0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (y0 + 1);
u = crn_x - x0;
@@ -717,7 +717,7 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
MPoly *mpoly = lores_dm->getPolyArray(lores_dm) + lt->poly;
MLoopUV *mloopuv = lores_dm->getLoopDataArray(lores_dm, CD_MLOOPUV);
MHeightBakeData *height_data = (MHeightBakeData *)bake_data;
- MultiresBakeThread *thread_data = (MultiresBakeThread *) thread_data_v;
+ MultiresBakeThread *thread_data = (MultiresBakeThread *)thread_data_v;
float uv[2], *st0, *st1, *st2, *st3;
int pixel = ibuf->x * y + x;
float vec[3], p0[3], p1[3], n[3], len;
@@ -941,7 +941,7 @@ static void create_ao_raytree(MultiresBakeRender *bkr, MAOBakeData *ao_data)
num_faces = num_grids * (grid_size - 1) * (grid_size - 1);
raytree = ao_data->raytree = RE_rayobject_create(bkr->raytrace_structure, num_faces, bkr->octree_resolution);
- face = ao_data->rayfaces = (RayFace *) MEM_callocN(num_faces * sizeof(RayFace), "ObjectRen faces");
+ face = ao_data->rayfaces = (RayFace *)MEM_callocN(num_faces * sizeof(RayFace), "ObjectRen faces");
for (i = 0; i < num_grids; i++) {
int x, y;
@@ -999,7 +999,7 @@ static void *init_ao_data(MultiresBakeRender *bkr, Image *UNUSED(ima))
static void free_ao_data(void *bake_data)
{
- MAOBakeData *ao_data = (MAOBakeData *) bake_data;
+ MAOBakeData *ao_data = (MAOBakeData *)bake_data;
RE_rayobject_free(ao_data->raytree);
MEM_freeN(ao_data->rayfaces);
@@ -1056,7 +1056,7 @@ static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void
const MLoopTri *lt = lores_dm->getLoopTriArray(lores_dm) + tri_index;
MPoly *mpoly = lores_dm->getPolyArray(lores_dm) + lt->poly;
MLoopUV *mloopuv = lores_dm->getLoopDataArray(lores_dm, CD_MLOOPUV);
- MAOBakeData *ao_data = (MAOBakeData *) bake_data;
+ MAOBakeData *ao_data = (MAOBakeData *)bake_data;
int i, k, perm_offs;
float pos[3], nrm[3];
@@ -1113,8 +1113,8 @@ static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void
const unsigned short I = ao_data->permutation_table_1[(i + perm_offs) % ao_data->number_of_rays];
const unsigned short J = ao_data->permutation_table_2[i];
- const float JitPh = (get_ao_random2(I + perm_offs) & (MAX_NUMBER_OF_AO_RAYS-1))/((float) MAX_NUMBER_OF_AO_RAYS);
- const float JitTh = (get_ao_random1(J + perm_offs) & (MAX_NUMBER_OF_AO_RAYS-1))/((float) MAX_NUMBER_OF_AO_RAYS);
+ const float JitPh = (get_ao_random2(I + perm_offs) & (MAX_NUMBER_OF_AO_RAYS - 1)) / ((float)MAX_NUMBER_OF_AO_RAYS);
+ const float JitTh = (get_ao_random1(J + perm_offs) & (MAX_NUMBER_OF_AO_RAYS - 1)) / ((float)MAX_NUMBER_OF_AO_RAYS);
const float SiSqPhi = (I + JitPh) / ao_data->number_of_rays;
const float Theta = (float)(2 * M_PI) * ((J + JitTh) / ao_data->number_of_rays);
@@ -1149,7 +1149,7 @@ static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void
rrgbf[3] = 1.0f;
}
else {
- unsigned char *rrgb = (unsigned char *) ibuf->rect + pixel * 4;
+ unsigned char *rrgb = (unsigned char *)ibuf->rect + pixel * 4;
rrgb[0] = rrgb[1] = rrgb[2] = unit_float_to_uchar_clamp(value);
rrgb[3] = 255;
}
@@ -1206,7 +1206,7 @@ static void bake_ibuf_normalize_displacement(ImBuf *ibuf, float *displacement, c
}
if (ibuf->rect) {
- unsigned char *cp = (unsigned char *) (ibuf->rect + i);
+ unsigned char *cp = (unsigned char *)(ibuf->rect + i);
cp[0] = cp[1] = cp[2] = unit_float_to_uchar_clamp(normalized_displacement);
cp[3] = 255;
}
@@ -1294,14 +1294,14 @@ static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
for (link = bkr->image.first; link; link = link->next) {
Image *ima = (Image *)link->data;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
- BakeImBufuserData *userdata = (BakeImBufuserData *) ibuf->userdata;
+ BakeImBufuserData *userdata = (BakeImBufuserData *)ibuf->userdata;
if (ibuf->x <= 0 || ibuf->y <= 0)
continue;
if (use_displacement_buffer) {
bake_ibuf_normalize_displacement(ibuf, userdata->displacement_buffer, userdata->mask_buffer,
- result->height_min, result->height_max);
+ result->height_min, result->height_max);
}
bake_ibuf_filter(ibuf, userdata->mask_buffer, bkr->bake_filter);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index bd8d390b23b..021abe89105 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -354,7 +354,7 @@ Scene *RE_GetScene(Render *re)
return NULL;
}
-void RE_SetScene(Render *re, Scene* sce)
+void RE_SetScene(Render *re, Scene *sce)
{
if (re) {
re->scene = sce;
@@ -863,8 +863,8 @@ static void render_result_rescale(Render *re)
}
}
- scale_x = (float) result->rectx / re->result->rectx;
- scale_y = (float) result->recty / re->result->recty;
+ scale_x = (float)result->rectx / re->result->rectx;
+ scale_y = (float)result->recty / re->result->recty;
for (x = 0; x < re->result->rectx; ++x) {
for (y = 0; y < re->result->recty; ++y) {
int src_x = x * scale_x;
@@ -1261,7 +1261,7 @@ static void ntree_render_scenes(Render *re)
/* bad call... need to think over proper method still */
static void render_composit_stats(void *arg, const char *str)
{
- Render *re = (Render*)arg;
+ Render *re = (Render *)arg;
RenderStats i;
memcpy(&i, &re->i, sizeof(i));
@@ -1319,7 +1319,7 @@ static void free_all_freestyle_renders(void)
Render *re1;
LinkData *link;
- for (re1= RenderGlobal.renderlist.first; re1; re1= re1->next) {
+ for (re1 = RenderGlobal.renderlist.first; re1; re1 = re1->next) {
for (link = (LinkData *)re1->freestyle_renders.first; link; link = link->next) {
Render *freestyle_render = (Render *)link->data;
@@ -1445,7 +1445,7 @@ static void renderresult_stampinfo(Render *re)
/* this is the basic trick to get the displayed float or char rect from render result */
nr = 0;
- for (rv = re->result->views.first;rv;rv = rv->next, nr++) {
+ for (rv = re->result->views.first; rv; rv = rv->next, nr++) {
RE_SetActiveRenderView(re, rv->name);
RE_AcquireResultImage(re, &rres, nr);
BKE_image_stamp_buf(re->scene,
@@ -1769,7 +1769,7 @@ static bool node_tree_has_composite_output(bNodeTree *ntree)
if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) {
return true;
}
- else if (node->type == NODE_GROUP) {
+ else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
if (node->id) {
if (node_tree_has_composite_output((bNodeTree *)node->id)) {
return true;
@@ -2019,7 +2019,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, ViewLayer *single_la
#ifdef WITH_FREESTYLE
void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, int render)
{
- re->result_ok= 0;
+ re->result_ok = 0;
if (render_initialize_from_main(re, &scene->r, bmain, scene, NULL, NULL, 0, 0)) {
if (render)
do_render_3d(re);
@@ -2181,7 +2181,7 @@ bool RE_WriteRenderViewsMovie(
&scene->display_settings, &scene->r.im_format);
ok &= mh->append_movie(movie_ctx_arr[view_id], rd, preview ? scene->r.psfra : scene->r.sfra, scene->r.cfra,
- (int *) ibuf->rect, ibuf->x, ibuf->y, suffix, reports);
+ (int *)ibuf->rect, ibuf->x, ibuf->y, suffix, reports);
/* imbuf knows which rects are not part of ibuf */
IMB_freeImBuf(ibuf);
@@ -2205,7 +2205,7 @@ bool RE_WriteRenderViewsMovie(
ibuf_arr[2] = IMB_stereo3d_ImBuf(&scene->r.im_format, ibuf_arr[0], ibuf_arr[1]);
- ok = mh->append_movie(movie_ctx_arr[0], rd, preview ? scene->r.psfra : scene->r.sfra, scene->r.cfra, (int *) ibuf_arr[2]->rect,
+ ok = mh->append_movie(movie_ctx_arr[0], rd, preview ? scene->r.psfra : scene->r.sfra, scene->r.cfra, (int *)ibuf_arr[2]->rect,
ibuf_arr[2]->x, ibuf_arr[2]->y, "", reports);
for (i = 0; i < 3; i++) {
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 06d51fb161d..d3e6b6c6c51 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -251,9 +251,9 @@ static void pointdensity_cache_psys(Depsgraph *depsgraph, Scene *scene,
BLI_bvhtree_insert(pd->point_tree, i, partco, 1);
if (data_vel) {
- data_vel[i*3 + 0] = state.vel[0];
- data_vel[i*3 + 1] = state.vel[1];
- data_vel[i*3 + 2] = state.vel[2];
+ data_vel[i * 3 + 0] = state.vel[0];
+ data_vel[i * 3 + 1] = state.vel[1];
+ data_vel[i * 3 + 2] = state.vel[2];
}
if (data_life) {
data_life[i] = state.time;
@@ -309,7 +309,7 @@ static void pointdensity_cache_vertex_color(PointDensity *pd, Object *UNUSED(ob)
*/
for (i = 0; i < pd->totpoints; i++) {
if (mcorners[i] > 0)
- mul_v3_fl(&data_color[i*3], 1.0f / mcorners[i]);
+ mul_v3_fl(&data_color[i * 3], 1.0f / mcorners[i]);
}
MEM_freeN(mcorners);
@@ -566,8 +566,9 @@ static void accum_density(void *userdata, int index, const float co[3], float sq
}
-static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData *pdr,
- float *density, float *vec, float *age, float *col, struct CurveMapping *density_curve, float velscale)
+static void init_pointdensityrangedata(
+ PointDensity *pd, PointDensityRangeData *pdr,
+ float *density, float *vec, float *age, float *col, struct CurveMapping *density_curve, float velscale)
{
pdr->squared_radius = pd->radius * pd->radius;
pdr->density = density;
@@ -600,9 +601,9 @@ static int pointdensity(PointDensity *pd,
texres->tin = 0.0f;
init_pointdensityrangedata(pd, &pdr, &density, vec, &age, col,
- (pd->flag & TEX_PD_FALLOFF_CURVE ? pd->falloff_curve : NULL),
- pd->falloff_speed_scale * 0.001f);
- noise_fac = pd->noise_fac * 0.5f; /* better default */
+ (pd->flag & TEX_PD_FALLOFF_CURVE ? pd->falloff_curve : NULL),
+ pd->falloff_speed_scale * 0.001f);
+ noise_fac = pd->noise_fac * 0.5f; /* better default */
copy_v3_v3(co, texvec);
@@ -626,7 +627,7 @@ static int pointdensity(PointDensity *pd,
turb = BLI_gTurbulence(pd->noise_size, texvec[0] + vec[0], texvec[1] + vec[1], texvec[2] + vec[2],
pd->noise_depth, 0, pd->noise_basis);
- turb -= 0.5f; /* re-center 0.0-1.0 range around 0 to prevent offsetting result */
+ turb -= 0.5f; /* re-center 0.0-1.0 range around 0 to prevent offsetting result */
/* now we have an offset coordinate to use for the density lookup */
co[0] = texvec[0] + noise_fac * turb;
@@ -894,8 +895,8 @@ static void point_density_sample_func(
pointdensity(pd, texvec, &texres, vec, &age, col);
pointdensity_color(pd, &texres, age, vec, col);
- copy_v3_v3(&values[index*4 + 0], &texres.tr);
- values[index*4 + 3] = texres.tin;
+ copy_v3_v3(&values[index * 4 + 0], &texres.tr);
+ values[index * 4 + 3] = texres.tin;
}
}
}
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 6e0eaa68b82..c00fc48bcd0 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -169,7 +169,7 @@ void render_result_views_shallowdelete(RenderResult *rr)
}
-static char* set_pass_name(char *outname, const char *name, int channel, const char *chan_id)
+static char *set_pass_name(char *outname, const char *name, int channel, const char *chan_id)
{
BLI_strncpy(outname, name, EXR_PASS_MAXNAME);
if (channel >= 0) {
@@ -325,12 +325,12 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
IMB_exr_add_view(rl->exrhandle, view);
#define RENDER_LAYER_ADD_PASS_SAFE(rr, rl, channels, name, viewname, chan_id) \
- do { \
- if (render_layer_add_pass(rr, rl, channels, name, viewname, chan_id) == NULL) { \
- render_result_free(rr); \
- return NULL; \
- } \
- } while (false)
+ do { \
+ if (render_layer_add_pass(rr, rl, channels, name, viewname, chan_id) == NULL) { \
+ render_result_free(rr); \
+ return NULL; \
+ } \
+ } while (false)
/* a renderlayer should always have a Combined pass*/
render_layer_add_pass(rr, rl, 4, "Combined", view, "RGBA");
@@ -598,8 +598,8 @@ static void *ml_addview_cb(void *base, const char *str)
static int order_render_passes(const void *a, const void *b)
{
// 1 if a is after b
- RenderPass *rpa = (RenderPass *) a;
- RenderPass *rpb = (RenderPass *) b;
+ RenderPass *rpa = (RenderPass *)a;
+ RenderPass *rpb = (RenderPass *)b;
unsigned int passtype_a = passtype_from_name(rpa->name);
unsigned int passtype_b = passtype_from_name(rpb->name);
@@ -838,7 +838,7 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil
}
if (write_z && rview->rectz) {
- const char *layname = (multi_layer)? "Composite": "";
+ const char *layname = (multi_layer) ? "Composite" : "";
IMB_exr_add_channel(exrhandle, layname, "Z", viewname,
1, rr->rectx, rview->rectz, false);
}
@@ -846,7 +846,7 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil
}
/* Other render layers. */
- int nr = (rr->have_combined)? 1: 0;
+ int nr = (rr->have_combined) ? 1 : 0;
for (RenderLayer *rl = rr->layers.first; rl; rl = rl->next, nr++) {
/* Skip other render layers if requested. */
if (!multi_layer && nr != layer) {
@@ -1304,7 +1304,7 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd, const int vi
RenderView *rv = RE_RenderViewGetById(rr, view_id);
/* if not exists, BKE_imbuf_write makes one */
- ibuf->rect = (unsigned int *) rv->rect32;
+ ibuf->rect = (unsigned int *)rv->rect32;
ibuf->rect_float = rv->rectf;
ibuf->zbuf_float = rv->rectz;
@@ -1392,7 +1392,7 @@ void render_result_rect_get_pixels(RenderResult *rr, unsigned int *rect, int rec
if (rv->rect32)
memcpy(rect, rv->rect32, sizeof(int) * rr->rectx * rr->recty);
else if (rv->rectf)
- IMB_display_buffer_transform_apply((unsigned char *) rect, rv->rectf, rr->rectx, rr->recty, 4,
+ IMB_display_buffer_transform_apply((unsigned char *)rect, rv->rectf, rr->rectx, rr->recty, 4,
view_settings, display_settings, true);
else
/* else fill with black */
@@ -1431,11 +1431,13 @@ bool RE_HasFloatPixels(RenderResult *res)
bool RE_RenderResult_is_stereo(RenderResult *res)
{
- if (! BLI_findstring(&res->views, STEREO_LEFT_NAME, offsetof(RenderView, name)))
+ if (!BLI_findstring(&res->views, STEREO_LEFT_NAME, offsetof(RenderView, name))) {
return false;
+ }
- if (! BLI_findstring(&res->views, STEREO_RIGHT_NAME, offsetof(RenderView, name)))
+ if (!BLI_findstring(&res->views, STEREO_RIGHT_NAME, offsetof(RenderView, name))) {
return false;
+ }
return true;
}
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 4e38f8d569a..7678e69caad 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -87,24 +87,24 @@ static void tex_normal_derivate(Tex *tex, TexResult *texres)
if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) {
float fac0, fac1, fac2, fac3;
- fac0= (col[0]+col[1]+col[2]);
+ fac0 = (col[0] + col[1] + col[2]);
BKE_colorband_evaluate(tex->coba, texres->nor[0], col);
- fac1= (col[0]+col[1]+col[2]);
+ fac1 = (col[0] + col[1] + col[2]);
BKE_colorband_evaluate(tex->coba, texres->nor[1], col);
- fac2= (col[0]+col[1]+col[2]);
+ fac2 = (col[0] + col[1] + col[2]);
BKE_colorband_evaluate(tex->coba, texres->nor[2], col);
- fac3= (col[0]+col[1]+col[2]);
+ fac3 = (col[0] + col[1] + col[2]);
- texres->nor[0]= (fac0 - fac1) / 3.0f;
- texres->nor[1]= (fac0 - fac2) / 3.0f;
- texres->nor[2]= (fac0 - fac3) / 3.0f;
+ texres->nor[0] = (fac0 - fac1) / 3.0f;
+ texres->nor[1] = (fac0 - fac2) / 3.0f;
+ texres->nor[2] = (fac0 - fac3) / 3.0f;
return;
}
}
- texres->nor[0]= texres->tin - texres->nor[0];
- texres->nor[1]= texres->tin - texres->nor[1];
- texres->nor[2]= texres->tin - texres->nor[2];
+ texres->nor[0] = texres->tin - texres->nor[0];
+ texres->nor[1] = texres->tin - texres->nor[1];
+ texres->nor[2] = texres->tin - texres->nor[2];
}
@@ -114,41 +114,41 @@ static int blend(Tex *tex, const float texvec[3], TexResult *texres)
float x, y, t;
if (tex->flag & TEX_FLIPBLEND) {
- x= texvec[1];
- y= texvec[0];
+ x = texvec[1];
+ y = texvec[0];
}
else {
- x= texvec[0];
- y= texvec[1];
+ x = texvec[0];
+ y = texvec[1];
}
- if (tex->stype==TEX_LIN) { /* lin */
- texres->tin= (1.0f+x)/2.0f;
+ if (tex->stype == TEX_LIN) { /* lin */
+ texres->tin = (1.0f + x) / 2.0f;
}
- else if (tex->stype==TEX_QUAD) { /* quad */
- texres->tin= (1.0f+x)/2.0f;
- if (texres->tin<0.0f) texres->tin= 0.0f;
- else texres->tin*= texres->tin;
+ else if (tex->stype == TEX_QUAD) { /* quad */
+ texres->tin = (1.0f + x) / 2.0f;
+ if (texres->tin < 0.0f) texres->tin = 0.0f;
+ else texres->tin *= texres->tin;
}
- else if (tex->stype==TEX_EASE) { /* ease */
- texres->tin= (1.0f+x)/2.0f;
- if (texres->tin<=0.0f) texres->tin= 0.0f;
- else if (texres->tin>=1.0f) texres->tin= 1.0f;
+ else if (tex->stype == TEX_EASE) { /* ease */
+ texres->tin = (1.0f + x) / 2.0f;
+ if (texres->tin <= 0.0f) texres->tin = 0.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);
+ t = texres->tin * texres->tin;
+ texres->tin = (3.0f * t - 2.0f * t * texres->tin);
}
}
- else if (tex->stype==TEX_DIAG) { /* diag */
- texres->tin= (2.0f+x+y)/4.0f;
+ else if (tex->stype == TEX_DIAG) { /* diag */
+ texres->tin = (2.0f + x + y) / 4.0f;
}
- else if (tex->stype==TEX_RAD) { /* radial */
+ else if (tex->stype == TEX_RAD) { /* radial */
texres->tin = (atan2f(y, x) / (float)(2 * M_PI) + 0.5f);
}
else { /* sphere TEX_SPHERE */
texres->tin = 1.0f - sqrtf(x * x + y * y + texvec[2] * texvec[2]);
- if (texres->tin<0.0f) texres->tin= 0.0f;
- if (tex->stype==TEX_HALO) texres->tin*= texres->tin; /* halo */
+ if (texres->tin < 0.0f) texres->tin = 0.0f;
+ if (tex->stype == TEX_HALO) texres->tin *= texres->tin; /* halo */
}
BRICONT;
@@ -165,24 +165,24 @@ static int clouds(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
- texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+ texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
- if (texres->nor!=NULL) {
+ if (texres->nor != NULL) {
/* calculate bumpnormal */
- texres->nor[0] = BLI_gTurbulence(tex->noisesize, texvec[0] + tex->nabla, texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
- texres->nor[1] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1] + tex->nabla, texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
- texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + tex->nabla, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+ texres->nor[0] = BLI_gTurbulence(tex->noisesize, texvec[0] + tex->nabla, texvec[1], texvec[2], tex->noisedepth, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
+ texres->nor[1] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1] + tex->nabla, texvec[2], tex->noisedepth, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
+ texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + tex->nabla, tex->noisedepth, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
}
- if (tex->stype==TEX_COLOR) {
+ if (tex->stype == TEX_COLOR) {
/* in this case, int. value should really be computed from color,
* and bumpnormal from that, would be too slow, looks ok as is */
texres->tr = texres->tin;
- texres->tg = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[0], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
- texres->tb = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[2], texvec[0], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+ texres->tg = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[0], texvec[2], tex->noisedepth, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
+ texres->tb = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[2], texvec[0], tex->noisedepth, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
BRICONTRGB;
texres->ta = 1.0;
return (rv | TEX_RGB);
@@ -205,10 +205,10 @@ static float tex_sin(float a)
/* creates a saw wave */
static float tex_saw(float a)
{
- const float b = 2*M_PI;
+ const float b = 2 * M_PI;
int n = (int)(a / b);
- a -= n*b;
+ a -= n * b;
if (a < 0) a += b;
return a / b;
}
@@ -216,10 +216,10 @@ static float tex_saw(float a)
/* creates a triangle wave */
static float tex_tri(float a)
{
- const float b = 2*M_PI;
+ const float b = 2 * M_PI;
const float rmax = 1.0;
- a = rmax - 2.0f*fabsf(floorf((a*(1.0f/b))+0.5f) - (a*(1.0f/b)));
+ a = rmax - 2.0f * fabsf(floorf((a * (1.0f / b)) + 0.5f) - (a * (1.0f / b)));
return a;
}
@@ -228,29 +228,29 @@ static float tex_tri(float a)
static float wood_int(Tex *tex, float x, float y, float z)
{
float wi = 0;
- short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
- short wt = tex->stype; /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
+ short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
+ short wt = tex->stype; /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
- float (*waveform[3])(float); /* create array of pointers to waveform functions */
- waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
+ float (*waveform[3])(float); /* create array of pointers to waveform functions */
+ waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
waveform[1] = tex_saw;
waveform[2] = tex_tri;
- if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 is initialized ahead of time */
+ 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);
+ if (wt == TEX_BAND) {
+ wi = waveform[wf]((x + y + z) * 10.0f);
}
- else if (wt==TEX_RING) {
- wi = waveform[wf](sqrtf(x*x + y*y + z*z)*20.0f);
+ else if (wt == TEX_RING) {
+ wi = waveform[wf](sqrtf(x * x + y * y + z * z) * 20.0f);
}
- else if (wt==TEX_BANDNOISE) {
- wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
- wi = waveform[wf]((x + y + z)*10.0f + wi);
+ else if (wt == TEX_BANDNOISE) {
+ wi = tex->turbul * BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
+ wi = waveform[wf]((x + y + z) * 10.0f + wi);
}
- else if (wt==TEX_RINGNOISE) {
- wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
- wi = waveform[wf](sqrtf(x*x + y*y + z*z)*20.0f + wi);
+ else if (wt == TEX_RINGNOISE) {
+ wi = tex->turbul * BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
+ wi = waveform[wf](sqrtf(x * x + y * y + z * z) * 20.0f + wi);
}
return wi;
@@ -258,10 +258,10 @@ static float wood_int(Tex *tex, float x, float y, float z)
static int wood(Tex *tex, const float texvec[3], TexResult *texres)
{
- int rv=TEX_INT;
+ int rv = TEX_INT;
texres->tin = wood_int(tex, texvec[0], texvec[1], texvec[2]);
- if (texres->nor!=NULL) {
+ if (texres->nor != NULL) {
/* calculate bumpnormal */
texres->nor[0] = wood_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]);
texres->nor[1] = wood_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]);
@@ -280,26 +280,26 @@ static int wood(Tex *tex, const float texvec[3], TexResult *texres)
static float marble_int(Tex *tex, float x, float y, float z)
{
float n, mi;
- short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
- short mt = tex->stype; /* marble type: TEX_SOFT=0, TEX_SHARP=1, TEX_SHAPER=2 */
+ short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
+ short mt = tex->stype; /* marble type: TEX_SOFT=0, TEX_SHARP=1, TEX_SHAPER=2 */
- float (*waveform[3])(float); /* create array of pointers to waveform functions */
- waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
+ float (*waveform[3])(float); /* create array of pointers to waveform functions */
+ waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
waveform[1] = tex_saw;
waveform[2] = tex_tri;
- if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 isn't initialized ahead of time */
+ 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);
- mi = n + tex->turbul * BLI_gTurbulence(tex->noisesize, x, y, z, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+ mi = n + tex->turbul * BLI_gTurbulence(tex->noisesize, x, y, z, tex->noisedepth, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
- if (mt>=TEX_SOFT) { /* TEX_SOFT always true */
+ if (mt >= TEX_SOFT) { /* TEX_SOFT always true */
mi = waveform[wf](mi);
- if (mt==TEX_SHARP) {
+ if (mt == TEX_SHARP) {
mi = sqrtf(mi);
}
- else if (mt==TEX_SHARPER) {
+ else if (mt == TEX_SHARPER) {
mi = sqrtf(sqrtf(mi));
}
}
@@ -309,11 +309,11 @@ static float marble_int(Tex *tex, float x, float y, float z)
static int marble(Tex *tex, const float texvec[3], TexResult *texres)
{
- int rv=TEX_INT;
+ int rv = TEX_INT;
texres->tin = marble_int(tex, texvec[0], texvec[1], texvec[2]);
- if (texres->nor!=NULL) {
+ if (texres->nor != NULL) {
/* calculate bumpnormal */
texres->nor[0] = marble_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]);
texres->nor[1] = marble_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]);
@@ -336,45 +336,45 @@ static int magic(Tex *tex, const float texvec[3], TexResult *texres)
float x, y, z, turb;
int n;
- n= tex->noisedepth;
- turb= tex->turbul/5.0f;
+ n = tex->noisedepth;
+ turb = tex->turbul / 5.0f;
- x = sinf(( texvec[0] + texvec[1] + texvec[2]) * 5.0f);
+ x = sinf((texvec[0] + texvec[1] + texvec[2]) * 5.0f);
y = cosf((-texvec[0] + texvec[1] - texvec[2]) * 5.0f);
z = -cosf((-texvec[0] - texvec[1] + texvec[2]) * 5.0f);
- if (n>0) {
- x*= turb;
- y*= turb;
- z*= turb;
- y= -cosf(x-y+z);
- y*= turb;
- if (n>1) {
- x= cosf(x-y-z);
- x*= turb;
- if (n>2) {
- z= sinf(-x-y-z);
- z*= turb;
- if (n>3) {
- x= -cosf(-x+y-z);
- x*= turb;
- if (n>4) {
- y= -sinf(-x+y+z);
- y*= turb;
- if (n>5) {
- y= -cosf(-x+y+z);
- y*= turb;
- if (n>6) {
- x= cosf(x+y+z);
- x*= turb;
- if (n>7) {
- z= sinf(x+y-z);
- z*= turb;
- if (n>8) {
- x= -cosf(-x-y+z);
- x*= turb;
- if (n>9) {
- y= -sinf(x-y+z);
- y*= turb;
+ if (n > 0) {
+ x *= turb;
+ y *= turb;
+ z *= turb;
+ y = -cosf(x - y + z);
+ y *= turb;
+ if (n > 1) {
+ x = cosf(x - y - z);
+ x *= turb;
+ if (n > 2) {
+ z = sinf(-x - y - z);
+ z *= turb;
+ if (n > 3) {
+ x = -cosf(-x + y - z);
+ x *= turb;
+ if (n > 4) {
+ y = -sinf(-x + y + z);
+ y *= turb;
+ if (n > 5) {
+ y = -cosf(-x + y + z);
+ y *= turb;
+ if (n > 6) {
+ x = cosf(x + y + z);
+ x *= turb;
+ if (n > 7) {
+ z = sinf(x + y - z);
+ z *= turb;
+ if (n > 8) {
+ x = -cosf(-x - y + z);
+ x *= turb;
+ if (n > 9) {
+ y = -sinf(x - y + z);
+ y *= turb;
}
}
}
@@ -386,17 +386,17 @@ static int magic(Tex *tex, const float texvec[3], TexResult *texres)
}
}
- if (turb!=0.0f) {
- turb*= 2.0f;
- x/= turb;
- y/= turb;
- z/= turb;
+ if (turb != 0.0f) {
+ turb *= 2.0f;
+ x /= turb;
+ y /= turb;
+ z /= turb;
}
texres->tr = 0.5f - x;
texres->tg = 0.5f - y;
texres->tb = 0.5f - z;
- texres->tin= (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
+ texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
BRICONTRGB;
texres->ta = 1.0f;
@@ -410,38 +410,38 @@ static int magic(Tex *tex, const float texvec[3], TexResult *texres)
static int stucci(Tex *tex, const float texvec[3], TexResult *texres)
{
float nor[3], b2, ofs;
- int retval= TEX_INT;
+ int retval = TEX_INT;
- b2= BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+ b2 = BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2], (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
- ofs= tex->turbul/200.0f;
+ ofs = tex->turbul / 200.0f;
- if (tex->stype) ofs*=(b2*b2);
- nor[0] = BLI_gNoise(tex->noisesize, texvec[0]+ofs, texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
- nor[1] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1]+ofs, texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
- nor[2] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2]+ofs, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+ if (tex->stype) ofs *= (b2 * b2);
+ nor[0] = BLI_gNoise(tex->noisesize, texvec[0] + ofs, texvec[1], texvec[2], (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
+ nor[1] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1] + ofs, texvec[2], (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
+ nor[2] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2] + ofs, (tex->noisetype != TEX_NOISESOFT), tex->noisebasis);
- texres->tin= nor[2];
+ texres->tin = nor[2];
if (texres->nor) {
copy_v3_v3(texres->nor, nor);
tex_normal_derivate(tex, texres);
- if (tex->stype==TEX_WALLOUT) {
- texres->nor[0]= -texres->nor[0];
- texres->nor[1]= -texres->nor[1];
- texres->nor[2]= -texres->nor[2];
+ if (tex->stype == TEX_WALLOUT) {
+ texres->nor[0] = -texres->nor[0];
+ texres->nor[1] = -texres->nor[1];
+ texres->nor[2] = -texres->nor[2];
}
retval |= TEX_NOR;
}
- if (tex->stype==TEX_WALLOUT)
- texres->tin= 1.0f-texres->tin;
+ if (tex->stype == TEX_WALLOUT)
+ texres->tin = 1.0f - texres->tin;
- if (texres->tin<0.0f)
- texres->tin= 0.0f;
+ if (texres->tin < 0.0f)
+ texres->tin = 0.0f;
return retval;
}
@@ -454,20 +454,20 @@ 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
mgravefunc = mg_fBm;
- texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
+ texres->tin = tex->ns_outscale * mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
- if (texres->nor!=NULL) {
- float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
+ if (texres->nor != NULL) {
+ float offs = tex->nabla / tex->noisesize; /* also scaling of texvec */
/* calculate bumpnormal */
- texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
- texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
- texres->nor[2] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
+ texres->nor[0] = tex->ns_outscale * mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
+ texres->nor[1] = tex->ns_outscale * mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
+ texres->nor[2] = tex->ns_outscale * mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
@@ -484,20 +484,20 @@ 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
mgravefunc = mg_HybridMultiFractal;
- texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
+ texres->tin = tex->ns_outscale * mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
- if (texres->nor!=NULL) {
- float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
+ if (texres->nor != NULL) {
+ float offs = tex->nabla / tex->noisesize; /* also scaling of texvec */
/* calculate bumpnormal */
- texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
- texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
- texres->nor[2] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
+ texres->nor[0] = tex->ns_outscale * mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
+ texres->nor[1] = tex->ns_outscale * mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
+ texres->nor[2] = tex->ns_outscale * mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
@@ -514,15 +514,15 @@ static float mg_HTerrainTex(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
- texres->tin = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
+ texres->tin = tex->ns_outscale * mg_HeteroTerrain(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
- if (texres->nor!=NULL) {
- float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
+ if (texres->nor != NULL) {
+ float offs = tex->nabla / tex->noisesize; /* also scaling of texvec */
/* calculate bumpnormal */
- texres->nor[0] = tex->ns_outscale*mg_HeteroTerrain(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
- texres->nor[1] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
- texres->nor[2] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
+ texres->nor[0] = tex->ns_outscale * mg_HeteroTerrain(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
+ texres->nor[1] = tex->ns_outscale * mg_HeteroTerrain(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
+ texres->nor[2] = tex->ns_outscale * mg_HeteroTerrain(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
@@ -541,8 +541,8 @@ static float mg_distNoiseTex(Tex *tex, const float texvec[3], TexResult *texres)
texres->tin = mg_VLNoise(texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
- if (texres->nor!=NULL) {
- float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
+ if (texres->nor != NULL) {
+ float offs = tex->nabla / tex->noisesize; /* also scaling of texvec */
/* calculate bumpnormal */
texres->nor[0] = mg_VLNoise(texvec[0] + offs, texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
@@ -567,39 +567,39 @@ static float mg_distNoiseTex(Tex *tex, const float texvec[3], TexResult *texres)
static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
{
int rv = TEX_INT;
- float da[4], pa[12]; /* distance and point coordinate arrays of 4 nearest neighbors */
+ float da[4], pa[12]; /* distance and point coordinate arrays of 4 nearest neighbors */
float aw1 = fabsf(tex->vn_w1);
float aw2 = fabsf(tex->vn_w2);
float aw3 = fabsf(tex->vn_w3);
float aw4 = fabsf(tex->vn_w4);
float sc = (aw1 + aw2 + aw3 + aw4);
- if (sc!=0.f) sc = tex->ns_outscale/sc;
+ 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] + tex->vn_w4*da[3]);
+ texres->tin = sc * fabsf(tex->vn_w1 * da[0] + tex->vn_w2 * da[1] + tex->vn_w3 * da[2] + tex->vn_w4 * da[3]);
if (tex->vn_coltype) {
- float ca[3]; /* cell color */
+ float ca[3]; /* cell color */
cellNoiseV(pa[0], pa[1], pa[2], ca);
- texres->tr = aw1*ca[0];
- texres->tg = aw1*ca[1];
- texres->tb = aw1*ca[2];
+ texres->tr = aw1 * ca[0];
+ texres->tg = aw1 * ca[1];
+ texres->tb = aw1 * ca[2];
cellNoiseV(pa[3], pa[4], pa[5], ca);
- texres->tr += aw2*ca[0];
- texres->tg += aw2*ca[1];
- texres->tb += aw2*ca[2];
+ texres->tr += aw2 * ca[0];
+ texres->tg += aw2 * ca[1];
+ texres->tb += aw2 * ca[2];
cellNoiseV(pa[6], pa[7], pa[8], ca);
- texres->tr += aw3*ca[0];
- texres->tg += aw3*ca[1];
- texres->tb += aw3*ca[2];
+ texres->tr += aw3 * ca[0];
+ texres->tg += aw3 * ca[1];
+ texres->tb += aw3 * ca[2];
cellNoiseV(pa[9], pa[10], pa[11], ca);
- texres->tr += aw4*ca[0];
- texres->tg += aw4*ca[1];
- texres->tb += aw4*ca[2];
- if (tex->vn_coltype>=2) {
- float t1 = (da[1]-da[0])*10;
- if (t1>1) t1=1;
- if (tex->vn_coltype==3) t1*=texres->tin; else t1*=sc;
+ texres->tr += aw4 * ca[0];
+ texres->tg += aw4 * ca[1];
+ texres->tb += aw4 * ca[2];
+ if (tex->vn_coltype >= 2) {
+ float t1 = (da[1] - da[0]) * 10;
+ if (t1 > 1) t1 = 1;
+ if (tex->vn_coltype == 3) t1 *= texres->tin; else t1 *= sc;
texres->tr *= t1;
texres->tg *= t1;
texres->tb *= t1;
@@ -611,16 +611,16 @@ static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
}
}
- if (texres->nor!=NULL) {
- float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
+ if (texres->nor != NULL) {
+ float offs = tex->nabla / tex->noisesize; /* also scaling of texvec */
/* calculate bumpnormal */
voronoi(texvec[0] + offs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
- texres->nor[0] = sc * fabsf(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
+ texres->nor[0] = sc * fabsf(tex->vn_w1 * da[0] + tex->vn_w2 * da[1] + tex->vn_w3 * da[2] + tex->vn_w4 * da[3]);
voronoi(texvec[0], texvec[1] + offs, texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
- texres->nor[1] = sc * fabsf(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
+ texres->nor[1] = sc * fabsf(tex->vn_w1 * da[0] + tex->vn_w2 * da[1] + tex->vn_w3 * da[2] + tex->vn_w4 * da[3]);
voronoi(texvec[0], texvec[1], texvec[2] + offs, da, pa, tex->vn_mexp, tex->vn_distm);
- texres->nor[2] = sc * fabsf(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
+ texres->nor[2] = sc * fabsf(tex->vn_w1 * da[0] + tex->vn_w2 * da[1] + tex->vn_w3 * da[2] + tex->vn_w4 * da[3]);
tex_normal_derivate(tex, texres);
rv |= TEX_NOR;
@@ -642,15 +642,15 @@ static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
static int texnoise(Tex *tex, TexResult *texres, int thread)
{
- float div=3.0;
+ float div = 3.0;
int val, ran, loop, shift = 29;
- ran= BLI_rng_thread_rand(random_tex_array, thread);
+ ran = BLI_rng_thread_rand(random_tex_array, thread);
- loop= tex->noisedepth;
+ loop = tex->noisedepth;
/* start from top bits since they have more variance */
- val= ((ran >> shift) & 3);
+ val = ((ran >> shift) & 3);
while (loop--) {
shift -= 2;
@@ -658,7 +658,7 @@ static int texnoise(Tex *tex, TexResult *texres, int thread)
div *= 3.0f;
}
- texres->tin= ((float)val)/div;
+ texres->tin = ((float)val) / div;
BRICONT;
return TEX_INT;
@@ -671,8 +671,8 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
float x1, y1, z1, nor[3];
int ret;
- if (n==NULL) {
- nor[0]= x; nor[1]= y; nor[2]= z; /* use local render coord */
+ if (n == NULL) {
+ nor[0] = x; nor[1] = y; nor[2] = z; /* use local render coord */
}
else {
copy_v3_v3(nor, n);
@@ -682,20 +682,20 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
y1 = fabsf(nor[1]);
z1 = fabsf(nor[2]);
- if (z1>=x1 && z1>=y1) {
+ if (z1 >= x1 && z1 >= y1) {
*adr1 = (x + 1.0f) / 2.0f;
*adr2 = (y + 1.0f) / 2.0f;
- ret= 0;
+ ret = 0;
}
- else if (y1>=x1 && y1>=z1) {
+ else if (y1 >= x1 && y1 >= z1) {
*adr1 = (x + 1.0f) / 2.0f;
*adr2 = (z + 1.0f) / 2.0f;
- ret= 1;
+ ret = 1;
}
else {
*adr1 = (y + 1.0f) / 2.0f;
*adr2 = (z + 1.0f) / 2.0f;
- ret= 2;
+ ret = 2;
}
return ret;
}
@@ -705,90 +705,90 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
/* ------------------------------------------------------------------------- */
static void do_2d_mapping(
- const MTex *mtex, float texvec[3], const float n[3], float dxt[3], float dyt[3])
+ const MTex *mtex, float texvec[3], const float n[3], float dxt[3], float dyt[3])
{
Tex *tex;
float fx, fy, fac1, area[8];
- int ok, proj, areaflag= 0, wrap;
+ int ok, proj, areaflag = 0, wrap;
/* mtex variables localized, only cubemap doesn't cooperate yet... */
- wrap= mtex->mapping;
- tex= mtex->tex;
+ wrap = mtex->mapping;
+ tex = mtex->tex;
if (!(dxt && dyt)) {
- if (wrap==MTEX_FLAT) {
+ if (wrap == MTEX_FLAT) {
fx = (texvec[0] + 1.0f) / 2.0f;
fy = (texvec[1] + 1.0f) / 2.0f;
}
- else if (wrap == MTEX_TUBE) map_to_tube( &fx, &fy, texvec[0], texvec[1], texvec[2]);
+ else if (wrap == MTEX_TUBE) map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
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);
}
/* repeat */
- if (tex->extend==TEX_REPEAT) {
- if (tex->xrepeat>1) {
- float origf= fx *= tex->xrepeat;
+ if (tex->extend == TEX_REPEAT) {
+ if (tex->xrepeat > 1) {
+ float origf = fx *= tex->xrepeat;
- if (fx>1.0f) fx -= (int)(fx);
- else if (fx<0.0f) fx+= 1-(int)(fx);
+ if (fx > 1.0f) fx -= (int)(fx);
+ else if (fx < 0.0f) fx += 1 - (int)(fx);
if (tex->flag & TEX_REPEAT_XMIR) {
- int orig= (int)floor(origf);
+ int orig = (int)floor(origf);
if (orig & 1)
- fx= 1.0f-fx;
+ fx = 1.0f - fx;
}
}
- if (tex->yrepeat>1) {
- float origf= fy *= tex->yrepeat;
+ if (tex->yrepeat > 1) {
+ float origf = fy *= tex->yrepeat;
- if (fy>1.0f) fy -= (int)(fy);
- else if (fy<0.0f) fy+= 1-(int)(fy);
+ if (fy > 1.0f) fy -= (int)(fy);
+ else if (fy < 0.0f) fy += 1 - (int)(fy);
if (tex->flag & TEX_REPEAT_YMIR) {
- int orig= (int)floor(origf);
+ int orig = (int)floor(origf);
if (orig & 1)
- fy= 1.0f-fy;
+ fy = 1.0f - fy;
}
}
}
/* crop */
- if (tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) {
- fac1= tex->cropxmax - tex->cropxmin;
- fx= tex->cropxmin+ fx*fac1;
+ if (tex->cropxmin != 0.0f || tex->cropxmax != 1.0f) {
+ fac1 = tex->cropxmax - tex->cropxmin;
+ fx = tex->cropxmin + fx * fac1;
}
- if (tex->cropymin!=0.0f || tex->cropymax!=1.0f) {
- fac1= tex->cropymax - tex->cropymin;
- fy= tex->cropymin+ fy*fac1;
+ if (tex->cropymin != 0.0f || tex->cropymax != 1.0f) {
+ fac1 = tex->cropymax - tex->cropymin;
+ fy = tex->cropymin + fy * fac1;
}
- texvec[0]= fx;
- texvec[1]= fy;
+ texvec[0] = fx;
+ texvec[1] = fy;
}
else {
- if (wrap==MTEX_FLAT) {
- fx= (texvec[0] + 1.0f) / 2.0f;
- fy= (texvec[1] + 1.0f) / 2.0f;
- dxt[0]/= 2.0f;
- dxt[1]/= 2.0f;
- dxt[2]/= 2.0f;
- dyt[0]/= 2.0f;
- dyt[1]/= 2.0f;
- dyt[2]/= 2.0f;
+ if (wrap == MTEX_FLAT) {
+ fx = (texvec[0] + 1.0f) / 2.0f;
+ fy = (texvec[1] + 1.0f) / 2.0f;
+ dxt[0] /= 2.0f;
+ dxt[1] /= 2.0f;
+ dxt[2] /= 2.0f;
+ dyt[0] /= 2.0f;
+ dyt[1] /= 2.0f;
+ dyt[2] /= 2.0f;
}
else if (ELEM(wrap, MTEX_TUBE, MTEX_SPHERE)) {
/* exception: the seam behind (y<0.0) */
- ok= 1;
- if (texvec[1]<=0.0f) {
- fx= texvec[0]+dxt[0];
- fy= texvec[0]+dyt[0];
- if (fx>=0.0f && fy>=0.0f && texvec[0]>=0.0f) {
+ ok = 1;
+ if (texvec[1] <= 0.0f) {
+ fx = texvec[0] + dxt[0];
+ fy = texvec[0] + dyt[0];
+ if (fx >= 0.0f && fy >= 0.0f && texvec[0] >= 0.0f) {
/* pass */
}
- else if (fx<=0.0f && fy<=0.0f && texvec[0]<=0.0f) {
+ else if (fx <= 0.0f && fy <= 0.0f && texvec[0] <= 0.0f) {
/* pass */
}
else {
@@ -797,43 +797,43 @@ static void do_2d_mapping(
}
if (ok) {
- if (wrap==MTEX_TUBE) {
- map_to_tube(area, area+1, texvec[0], texvec[1], texvec[2]);
+ if (wrap == MTEX_TUBE) {
+ map_to_tube(area, area + 1, texvec[0], texvec[1], texvec[2]);
map_to_tube(area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]);
map_to_tube(area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]);
}
else {
- map_to_sphere(area, area+1, texvec[0], texvec[1], texvec[2]);
+ map_to_sphere(area, area + 1, texvec[0], texvec[1], texvec[2]);
map_to_sphere(area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]);
map_to_sphere(area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]);
}
- areaflag= 1;
+ areaflag = 1;
}
else {
- if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy, texvec[0], texvec[1], texvec[2]);
+ if (wrap == MTEX_TUBE) map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
else map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
- dxt[0]/= 2.0f;
- dxt[1]/= 2.0f;
- dyt[0]/= 2.0f;
- dyt[1]/= 2.0f;
+ dxt[0] /= 2.0f;
+ dxt[1] /= 2.0f;
+ dyt[0] /= 2.0f;
+ dyt[1] /= 2.0f;
}
}
else {
proj = cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
- if (proj==1) {
+ if (proj == 1) {
SWAP(float, dxt[1], dxt[2]);
SWAP(float, dyt[1], dyt[2]);
}
- else if (proj==2) {
- float f1= dxt[0], f2= dyt[0];
- dxt[0]= dxt[1];
- dyt[0]= dyt[1];
- dxt[1]= dxt[2];
- dyt[1]= dyt[2];
- dxt[2]= f1;
- dyt[2]= f2;
+ else if (proj == 2) {
+ float f1 = dxt[0], f2 = dyt[0];
+ dxt[0] = dxt[1];
+ dyt[0] = dyt[1];
+ dxt[1] = dxt[2];
+ dyt[1] = dyt[2];
+ dxt[2] = f1;
+ dyt[2] = f2;
}
dxt[0] *= 0.5f;
@@ -848,80 +848,80 @@ static void do_2d_mapping(
/* if area, then reacalculate dxt[] and dyt[] */
if (areaflag) {
- fx= area[0];
- fy= area[1];
- dxt[0]= area[2]-fx;
- dxt[1]= area[3]-fy;
- dyt[0]= area[4]-fx;
- dyt[1]= area[5]-fy;
+ fx = area[0];
+ fy = area[1];
+ dxt[0] = area[2] - fx;
+ dxt[1] = area[3] - fy;
+ dyt[0] = area[4] - fx;
+ dyt[1] = area[5] - fy;
}
/* repeat */
- if (tex->extend==TEX_REPEAT) {
- float max= 1.0f;
- if (tex->xrepeat>1) {
- float origf= fx *= tex->xrepeat;
+ if (tex->extend == TEX_REPEAT) {
+ float max = 1.0f;
+ if (tex->xrepeat > 1) {
+ float origf = fx *= tex->xrepeat;
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
if (tex->texfilter == TXF_BOX) {
- if (fx>1.0f) fx -= (int)(fx);
- else if (fx<0.0f) fx+= 1-(int)(fx);
+ if (fx > 1.0f) fx -= (int)(fx);
+ else if (fx < 0.0f) fx += 1 - (int)(fx);
if (tex->flag & TEX_REPEAT_XMIR) {
- int orig= (int)floor(origf);
+ int orig = (int)floor(origf);
if (orig & 1)
- fx= 1.0f-fx;
+ fx = 1.0f - fx;
}
}
- max= tex->xrepeat;
+ max = tex->xrepeat;
- dxt[0]*= tex->xrepeat;
- dyt[0]*= tex->xrepeat;
+ dxt[0] *= tex->xrepeat;
+ dyt[0] *= tex->xrepeat;
}
- if (tex->yrepeat>1) {
- float origf= fy *= tex->yrepeat;
+ if (tex->yrepeat > 1) {
+ float origf = fy *= tex->yrepeat;
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
if (tex->texfilter == TXF_BOX) {
- if (fy>1.0f) fy -= (int)(fy);
- else if (fy<0.0f) fy+= 1-(int)(fy);
+ if (fy > 1.0f) fy -= (int)(fy);
+ else if (fy < 0.0f) fy += 1 - (int)(fy);
if (tex->flag & TEX_REPEAT_YMIR) {
- int orig= (int)floor(origf);
+ int orig = (int)floor(origf);
if (orig & 1)
- fy= 1.0f-fy;
+ fy = 1.0f - fy;
}
}
- if (max<tex->yrepeat)
- max= tex->yrepeat;
+ if (max < tex->yrepeat)
+ max = tex->yrepeat;
- dxt[1]*= tex->yrepeat;
- dyt[1]*= tex->yrepeat;
+ dxt[1] *= tex->yrepeat;
+ dyt[1] *= tex->yrepeat;
}
- if (max!=1.0f) {
- dxt[2]*= max;
- dyt[2]*= max;
+ if (max != 1.0f) {
+ dxt[2] *= max;
+ dyt[2] *= max;
}
}
/* crop */
- if (tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) {
- fac1= tex->cropxmax - tex->cropxmin;
- fx= tex->cropxmin+ fx*fac1;
- dxt[0]*= fac1;
- dyt[0]*= fac1;
+ if (tex->cropxmin != 0.0f || tex->cropxmax != 1.0f) {
+ fac1 = tex->cropxmax - tex->cropxmin;
+ fx = tex->cropxmin + fx * fac1;
+ dxt[0] *= fac1;
+ dyt[0] *= fac1;
}
- if (tex->cropymin!=0.0f || tex->cropymax!=1.0f) {
- fac1= tex->cropymax - tex->cropymin;
- fy= tex->cropymin+ fy*fac1;
- dxt[1]*= fac1;
- dyt[1]*= fac1;
+ if (tex->cropymin != 0.0f || tex->cropymax != 1.0f) {
+ fac1 = tex->cropymax - tex->cropymin;
+ fy = tex->cropymin + fy * fac1;
+ dxt[1] *= fac1;
+ dyt[1] *= fac1;
}
- texvec[0]= fx;
- texvec[1]= fy;
+ texvec[0] = fx;
+ texvec[1] = fy;
}
}
@@ -953,7 +953,7 @@ static int multitex(Tex *tex,
else {
switch (tex->type) {
case 0:
- texres->tin= 0.0f;
+ texres->tin = 0.0f;
return 0;
case TEX_CLOUDS:
retval = clouds(tex, texvec, texres);
@@ -978,7 +978,7 @@ static int multitex(Tex *tex,
break;
case TEX_IMAGE:
if (osatex) retval = imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres, pool, skip_load_image);
- else retval = imagewrap(tex, tex->ima, NULL, texvec, texres, pool, skip_load_image);
+ else retval = imagewrap(tex, tex->ima, NULL, texvec, texres, pool, skip_load_image);
if (tex->ima) {
BKE_image_tag_time(tex->ima);
}
@@ -1006,7 +1006,7 @@ static int multitex(Tex *tex,
break;
}
break;
- /* newnoise: voronoi type */
+ /* newnoise: voronoi type */
case TEX_VORONOI:
/* ton: added this, for Blender convention reason.
* artificer: added the use of tmpvec to avoid scaling texvec
@@ -1032,10 +1032,10 @@ static int multitex(Tex *tex,
float col[4];
if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) {
texres->talpha = true;
- texres->tr= col[0];
- texres->tg= col[1];
- texres->tb= col[2];
- texres->ta= col[3];
+ texres->tr = col[0];
+ texres->tg = col[1];
+ texres->tb = col[2];
+ texres->ta = col[3];
retval |= TEX_RGB;
}
}
@@ -1056,15 +1056,15 @@ static int multitex_nodes_intern(Tex *tex,
const bool texnode_preview,
const bool use_nodes)
{
- if (tex==NULL) {
+ if (tex == NULL) {
memset(texres, 0, sizeof(TexResult));
return 0;
}
if (mtex)
- which_output= mtex->which_output;
+ which_output = mtex->which_output;
- if (tex->type==TEX_IMAGE) {
+ if (tex->type == TEX_IMAGE) {
int rgbnor;
if (mtex) {
@@ -1102,10 +1102,10 @@ static int multitex_nodes_intern(Tex *tex,
MTex localmtex;
float texvec_l[3], dxt_l[3], dyt_l[3];
- localmtex.mapping= MTEX_FLAT;
- localmtex.tex= tex;
- localmtex.object= NULL;
- localmtex.texco= TEXCO_ORCO;
+ localmtex.mapping = MTEX_FLAT;
+ localmtex.tex = tex;
+ localmtex.object = NULL;
+ localmtex.texco = TEXCO_ORCO;
copy_v3_v3(texvec_l, texvec);
if (dxt && dyt) {
@@ -1238,90 +1238,90 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
switch (blendtype) {
case MTEX_BLEND:
- fact*= facg;
- facm= 1.0f-fact;
+ fact *= facg;
+ facm = 1.0f - fact;
- in[0]= (fact*tex[0] + facm*out[0]);
- in[1]= (fact*tex[1] + facm*out[1]);
- in[2]= (fact*tex[2] + facm*out[2]);
+ in[0] = (fact * tex[0] + facm * out[0]);
+ in[1] = (fact * tex[1] + facm * out[1]);
+ in[2] = (fact * tex[2] + facm * out[2]);
break;
case MTEX_MUL:
- fact*= facg;
- facm= 1.0f-fact;
- in[0]= (facm+fact*tex[0])*out[0];
- in[1]= (facm+fact*tex[1])*out[1];
- in[2]= (facm+fact*tex[2])*out[2];
+ fact *= facg;
+ facm = 1.0f - fact;
+ in[0] = (facm + fact * tex[0]) * out[0];
+ in[1] = (facm + fact * tex[1]) * out[1];
+ in[2] = (facm + fact * tex[2]) * out[2];
break;
case MTEX_SCREEN:
- fact*= facg;
- facm= 1.0f-fact;
- in[0]= 1.0f - (facm+fact*(1.0f-tex[0])) * (1.0f-out[0]);
- in[1]= 1.0f - (facm+fact*(1.0f-tex[1])) * (1.0f-out[1]);
- in[2]= 1.0f - (facm+fact*(1.0f-tex[2])) * (1.0f-out[2]);
+ fact *= facg;
+ facm = 1.0f - fact;
+ in[0] = 1.0f - (facm + fact * (1.0f - tex[0])) * (1.0f - out[0]);
+ in[1] = 1.0f - (facm + fact * (1.0f - tex[1])) * (1.0f - out[1]);
+ in[2] = 1.0f - (facm + fact * (1.0f - tex[2])) * (1.0f - out[2]);
break;
case MTEX_OVERLAY:
- fact*= facg;
- facm= 1.0f-fact;
+ fact *= facg;
+ facm = 1.0f - fact;
if (out[0] < 0.5f)
- in[0] = out[0] * (facm + 2.0f*fact*tex[0]);
+ in[0] = out[0] * (facm + 2.0f * fact * tex[0]);
else
- in[0] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[0])) * (1.0f - out[0]);
+ in[0] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[0])) * (1.0f - out[0]);
if (out[1] < 0.5f)
- in[1] = out[1] * (facm + 2.0f*fact*tex[1]);
+ in[1] = out[1] * (facm + 2.0f * fact * tex[1]);
else
- in[1] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[1])) * (1.0f - out[1]);
+ in[1] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[1])) * (1.0f - out[1]);
if (out[2] < 0.5f)
- in[2] = out[2] * (facm + 2.0f*fact*tex[2]);
+ in[2] = out[2] * (facm + 2.0f * fact * tex[2]);
else
- in[2] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[2])) * (1.0f - out[2]);
+ in[2] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[2])) * (1.0f - out[2]);
break;
case MTEX_SUB:
- fact= -fact;
+ fact = -fact;
ATTR_FALLTHROUGH;
case MTEX_ADD:
- fact*= facg;
- in[0]= (fact*tex[0] + out[0]);
- in[1]= (fact*tex[1] + out[1]);
- in[2]= (fact*tex[2] + out[2]);
+ fact *= facg;
+ in[0] = (fact * tex[0] + out[0]);
+ in[1] = (fact * tex[1] + out[1]);
+ in[2] = (fact * tex[2] + out[2]);
break;
case MTEX_DIV:
- fact*= facg;
- facm= 1.0f-fact;
+ fact *= facg;
+ facm = 1.0f - fact;
- if (tex[0]!=0.0f)
- in[0]= facm*out[0] + fact*out[0]/tex[0];
- if (tex[1]!=0.0f)
- in[1]= facm*out[1] + fact*out[1]/tex[1];
- if (tex[2]!=0.0f)
- in[2]= facm*out[2] + fact*out[2]/tex[2];
+ if (tex[0] != 0.0f)
+ in[0] = facm * out[0] + fact * out[0] / tex[0];
+ if (tex[1] != 0.0f)
+ in[1] = facm * out[1] + fact * out[1] / tex[1];
+ if (tex[2] != 0.0f)
+ in[2] = facm * out[2] + fact * out[2] / tex[2];
break;
case MTEX_DIFF:
- fact*= facg;
- facm= 1.0f-fact;
- in[0]= facm*out[0] + fact*fabsf(tex[0]-out[0]);
- in[1]= facm*out[1] + fact*fabsf(tex[1]-out[1]);
- in[2]= facm*out[2] + fact*fabsf(tex[2]-out[2]);
+ fact *= facg;
+ facm = 1.0f - fact;
+ in[0] = facm * out[0] + fact * fabsf(tex[0] - out[0]);
+ in[1] = facm * out[1] + fact * fabsf(tex[1] - out[1]);
+ in[2] = facm * out[2] + fact * fabsf(tex[2] - out[2]);
break;
case MTEX_DARK:
- fact*= facg;
- facm= 1.0f-fact;
+ fact *= facg;
+ facm = 1.0f - fact;
- in[0] = min_ff(out[0], tex[0])*fact + out[0]*facm;
- in[1] = min_ff(out[1], tex[1])*fact + out[1]*facm;
- in[2] = min_ff(out[2], tex[2])*fact + out[2]*facm;
+ in[0] = min_ff(out[0], tex[0]) * fact + out[0] * facm;
+ in[1] = min_ff(out[1], tex[1]) * fact + out[1] * facm;
+ in[2] = min_ff(out[2], tex[2]) * fact + out[2] * facm;
break;
case MTEX_LIGHT:
- fact*= facg;
+ fact *= facg;
in[0] = max_ff(fact * tex[0], out[0]);
in[1] = max_ff(fact * tex[1], out[1]);
@@ -1329,32 +1329,32 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
break;
case MTEX_BLEND_HUE:
- fact*= facg;
+ fact *= facg;
copy_v3_v3(in, out);
ramp_blend(MA_RAMP_HUE, in, fact, tex);
break;
case MTEX_BLEND_SAT:
- fact*= facg;
+ fact *= facg;
copy_v3_v3(in, out);
ramp_blend(MA_RAMP_SAT, in, fact, tex);
break;
case MTEX_BLEND_VAL:
- fact*= facg;
+ fact *= facg;
copy_v3_v3(in, out);
ramp_blend(MA_RAMP_VAL, in, fact, tex);
break;
case MTEX_BLEND_COLOR:
- fact*= facg;
+ fact *= facg;
copy_v3_v3(in, out);
ramp_blend(MA_RAMP_COLOR, in, fact, tex);
break;
case MTEX_SOFT_LIGHT:
- fact*= facg;
+ fact *= facg;
copy_v3_v3(in, out);
ramp_blend(MA_RAMP_SOFT, in, fact, tex);
break;
case MTEX_LIN_LIGHT:
- fact*= facg;
+ fact *= facg;
copy_v3_v3(in, out);
ramp_blend(MA_RAMP_LINEAR, in, fact, tex);
break;
@@ -1363,73 +1363,73 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
float texture_value_blend(float tex, float out, float fact, float facg, int blendtype)
{
- float in=0.0, facm, col, scf;
- int flip= (facg < 0.0f);
+ float in = 0.0, facm, col, scf;
+ int flip = (facg < 0.0f);
- facg= fabsf(facg);
+ facg = fabsf(facg);
- fact*= facg;
- facm= 1.0f-fact;
+ fact *= facg;
+ facm = 1.0f - fact;
if (flip) SWAP(float, fact, facm);
switch (blendtype) {
case MTEX_BLEND:
- in= fact*tex + facm*out;
+ in = fact * tex + facm * out;
break;
case MTEX_MUL:
- facm= 1.0f-facg;
- in= (facm+fact*tex)*out;
+ facm = 1.0f - facg;
+ in = (facm + fact * tex) * out;
break;
case MTEX_SCREEN:
- facm= 1.0f-facg;
- in= 1.0f-(facm+fact*(1.0f-tex))*(1.0f-out);
+ facm = 1.0f - facg;
+ in = 1.0f - (facm + fact * (1.0f - tex)) * (1.0f - out);
break;
case MTEX_OVERLAY:
- facm= 1.0f-facg;
+ facm = 1.0f - facg;
if (out < 0.5f)
- in = out * (facm + 2.0f*fact*tex);
+ in = out * (facm + 2.0f * fact * tex);
else
- in = 1.0f - (facm + 2.0f*fact*(1.0f - tex)) * (1.0f - out);
+ in = 1.0f - (facm + 2.0f * fact * (1.0f - tex)) * (1.0f - out);
break;
case MTEX_SUB:
- fact= -fact;
+ fact = -fact;
ATTR_FALLTHROUGH;
case MTEX_ADD:
- in= fact*tex + out;
+ in = fact * tex + out;
break;
case MTEX_DIV:
- if (tex!=0.0f)
- in= facm*out + fact*out/tex;
+ if (tex != 0.0f)
+ in = facm * out + fact * out / tex;
break;
case MTEX_DIFF:
- in= facm*out + fact*fabsf(tex-out);
+ in = facm * out + fact * fabsf(tex - out);
break;
case MTEX_DARK:
- in = min_ff(out, tex)*fact + out*facm;
+ in = min_ff(out, tex) * fact + out * facm;
break;
case MTEX_LIGHT:
- col= fact*tex;
- if (col > out) in= col; else in= out;
+ col = fact * tex;
+ if (col > out) in = col; else in = out;
break;
case MTEX_SOFT_LIGHT:
- scf=1.0f - (1.0f - tex) * (1.0f - out);
- in= facm*out + fact * ((1.0f - out) * tex * out) + (out * scf);
+ scf = 1.0f - (1.0f - tex) * (1.0f - out);
+ in = facm * out + fact * ((1.0f - out) * tex * out) + (out * scf);
break;
case MTEX_LIN_LIGHT:
if (tex > 0.5f)
- in = out + fact*(2.0f*(tex - 0.5f));
+ in = out + fact * (2.0f * (tex - 0.5f));
else
- in = out + fact*(2.0f*tex - 1.0f);
+ in = out + fact * (2.0f * tex - 1.0f);
break;
}
@@ -1451,22 +1451,22 @@ int externtex(const MTex *mtex,
float dxt[3], dyt[3], texvec[3];
int rgb;
- tex= mtex->tex;
- if (tex==NULL) return 0;
- texr.nor= NULL;
+ tex = mtex->tex;
+ if (tex == NULL) return 0;
+ texr.nor = NULL;
/* placement */
- if (mtex->projx) texvec[0]= mtex->size[0]*(vec[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
+ if (mtex->projx) texvec[0] = mtex->size[0] * (vec[mtex->projx - 1] + mtex->ofs[0]);
+ else texvec[0] = mtex->size[0] * (mtex->ofs[0]);
- if (mtex->projy) texvec[1]= mtex->size[1]*(vec[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
+ if (mtex->projy) texvec[1] = mtex->size[1] * (vec[mtex->projy - 1] + mtex->ofs[1]);
+ else texvec[1] = mtex->size[1] * (mtex->ofs[1]);
- if (mtex->projz) texvec[2]= mtex->size[2]*(vec[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
+ if (mtex->projz) texvec[2] = mtex->size[2] * (vec[mtex->projz - 1] + mtex->ofs[2]);
+ else texvec[2] = mtex->size[2] * (mtex->ofs[2]);
/* texture */
- if (tex->type==TEX_IMAGE) {
+ if (tex->type == TEX_IMAGE) {
do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
}
@@ -1485,16 +1485,16 @@ int externtex(const MTex *mtex,
texr.tin = IMB_colormanagement_get_luminance(&texr.tr);
}
else {
- texr.tr= mtex->r;
- texr.tg= mtex->g;
- texr.tb= mtex->b;
+ texr.tr = mtex->r;
+ texr.tg = mtex->g;
+ texr.tb = mtex->b;
}
- *tin= texr.tin;
- *tr= texr.tr;
- *tg= texr.tg;
- *tb= texr.tb;
- *ta= texr.ta;
+ *tin = texr.tin;
+ *tr = texr.tr;
+ *tg = texr.tg;
+ *tb = texr.tb;
+ *ta = texr.ta;
return (rgb != 0);
}
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index 51104714a99..05944df770a 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -48,11 +48,11 @@ void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty)
{
memset(zspan, 0, sizeof(ZSpan));
- zspan->rectx= rectx;
- zspan->recty= recty;
+ zspan->rectx = rectx;
+ zspan->recty = recty;
- zspan->span1= MEM_mallocN(recty*sizeof(float), "zspan");
- zspan->span2= MEM_mallocN(recty*sizeof(float), "zspan");
+ zspan->span1 = MEM_mallocN(recty * sizeof(float), "zspan");
+ zspan->span2 = MEM_mallocN(recty * sizeof(float), "zspan");
}
void zbuf_free_span(ZSpan *zspan)
@@ -60,16 +60,16 @@ void zbuf_free_span(ZSpan *zspan)
if (zspan) {
if (zspan->span1) MEM_freeN(zspan->span1);
if (zspan->span2) MEM_freeN(zspan->span2);
- zspan->span1= zspan->span2= NULL;
+ zspan->span1 = zspan->span2 = NULL;
}
}
/* reset range for clipping */
static void zbuf_init_span(ZSpan *zspan)
{
- zspan->miny1= zspan->miny2= zspan->recty+1;
- zspan->maxy1= zspan->maxy2= -1;
- zspan->minp1= zspan->maxp1= zspan->minp2= zspan->maxp2= NULL;
+ zspan->miny1 = zspan->miny2 = zspan->recty + 1;
+ zspan->maxy1 = zspan->maxy2 = -1;
+ zspan->minp1 = zspan->maxp1 = zspan->minp2 = zspan->maxp2 = NULL;
}
static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
@@ -79,30 +79,30 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
float xx1, dx0, xs0;
int y, my0, my2;
- if (v1[1]<v2[1]) {
- minv= v1; maxv= v2;
+ if (v1[1] < v2[1]) {
+ minv = v1; maxv = v2;
}
else {
- minv= v2; maxv= v1;
+ minv = v2; maxv = v1;
}
- my0= ceil(minv[1]);
- my2= floor(maxv[1]);
+ my0 = ceil(minv[1]);
+ my2 = floor(maxv[1]);
- if (my2<0 || my0>= zspan->recty) return;
+ if (my2 < 0 || my0 >= zspan->recty) return;
/* clip top */
- if (my2>=zspan->recty) my2= zspan->recty-1;
+ if (my2 >= zspan->recty) my2 = zspan->recty - 1;
/* clip bottom */
- if (my0<0) my0= 0;
+ if (my0 < 0) my0 = 0;
- if (my0>my2) return;
+ if (my0 > my2) return;
/* if (my0>my2) should still fill in, that way we get spans that skip nicely */
- xx1= maxv[1]-minv[1];
- if (xx1>FLT_EPSILON) {
- dx0= (minv[0]-maxv[0])/xx1;
- xs0= dx0*(minv[1]-my2) + minv[0];
+ xx1 = maxv[1] - minv[1];
+ if (xx1 > FLT_EPSILON) {
+ dx0 = (minv[0] - maxv[0]) / xx1;
+ xs0 = dx0 * (minv[1] - my2) + minv[0];
}
else {
dx0 = 0.0f;
@@ -111,43 +111,43 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
/* empty span */
if (zspan->maxp1 == NULL) {
- span= zspan->span1;
+ span = zspan->span1;
}
- else { /* does it complete left span? */
- if ( maxv == zspan->minp1 || minv==zspan->maxp1) {
- span= zspan->span1;
+ else { /* does it complete left span? */
+ if (maxv == zspan->minp1 || minv == zspan->maxp1) {
+ span = zspan->span1;
}
else {
- span= zspan->span2;
+ span = zspan->span2;
}
}
- if (span==zspan->span1) {
+ if (span == zspan->span1) {
// printf("left span my0 %d my2 %d\n", my0, my2);
- if (zspan->minp1==NULL || zspan->minp1[1] > minv[1] ) {
- zspan->minp1= minv;
+ if (zspan->minp1 == NULL || zspan->minp1[1] > minv[1]) {
+ zspan->minp1 = minv;
}
- if (zspan->maxp1==NULL || zspan->maxp1[1] < maxv[1] ) {
- zspan->maxp1= maxv;
+ if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) {
+ zspan->maxp1 = maxv;
}
- if (my0<zspan->miny1) zspan->miny1= my0;
- if (my2>zspan->maxy1) zspan->maxy1= my2;
+ if (my0 < zspan->miny1) zspan->miny1 = my0;
+ if (my2 > zspan->maxy1) zspan->maxy1 = my2;
}
else {
// printf("right span my0 %d my2 %d\n", my0, my2);
- if (zspan->minp2==NULL || zspan->minp2[1] > minv[1] ) {
- zspan->minp2= minv;
+ if (zspan->minp2 == NULL || zspan->minp2[1] > minv[1]) {
+ zspan->minp2 = minv;
}
- if (zspan->maxp2==NULL || zspan->maxp2[1] < maxv[1] ) {
- zspan->maxp2= maxv;
+ if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) {
+ zspan->maxp2 = maxv;
}
- if (my0<zspan->miny2) zspan->miny2= my0;
- if (my2>zspan->maxy2) zspan->maxy2= my2;
+ if (my0 < zspan->miny2) zspan->miny2 = my0;
+ if (my2 > zspan->maxy2) zspan->maxy2 = my2;
}
- for (y=my2; y>=my0; y--, xs0+= dx0) {
+ for (y = my2; y >= my0; y--, xs0 += dx0) {
/* xs0 is the xcoord! */
- span[y]= xs0;
+ span[y] = xs0;
}
}
@@ -173,57 +173,57 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float *
zbuf_add_to_span(zspan, v3, v1);
/* clipped */
- if (zspan->minp2==NULL || zspan->maxp2==NULL) return;
+ 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) return;
+ if (my2 < my0) return;
/* ZBUF DX DY, in floats still */
- x1= v1[0]- v2[0];
- x2= v2[0]- v3[0];
- y1= v1[1]- v2[1];
- y2= v2[1]- v3[1];
+ x1 = v1[0] - v2[0];
+ x2 = v2[0] - v3[0];
+ y1 = v1[1] - v2[1];
+ y2 = v2[1] - v3[1];
- z1= 1.0f; /* (u1 - u2) */
- z2= 0.0f; /* (u2 - u3) */
+ z1 = 1.0f; /* (u1 - u2) */
+ z2 = 0.0f; /* (u2 - u3) */
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
- z0= x1*y2-y1*x2;
+ x0 = y1 * z2 - z1 * y2;
+ y0 = z1 * x2 - x1 * z2;
+ z0 = x1 * y2 - y1 * x2;
- if (z0==0.0f) return;
+ if (z0 == 0.0f) return;
- xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f;
- uxd= -(double)x0/(double)z0;
- uyd= -(double)y0/(double)z0;
- uy0= ((double)my2)*uyd + (double)xx1;
+ xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + 1.0f;
+ uxd = -(double)x0 / (double)z0;
+ uyd = -(double)y0 / (double)z0;
+ uy0 = ((double)my2) * uyd + (double)xx1;
- z1= -1.0f; /* (v1 - v2) */
- z2= 1.0f; /* (v2 - v3) */
+ z1 = -1.0f; /* (v1 - v2) */
+ z2 = 1.0f; /* (v2 - v3) */
- x0= y1*z2-z1*y2;
- y0= z1*x2-x1*z2;
+ x0 = y1 * z2 - z1 * y2;
+ y0 = z1 * x2 - x1 * z2;
- xx1= (x0*v1[0] + y0*v1[1])/z0;
- vxd= -(double)x0/(double)z0;
- vyd= -(double)y0/(double)z0;
- vy0= ((double)my2)*vyd + (double)xx1;
+ xx1 = (x0 * v1[0] + y0 * v1[1]) / z0;
+ vxd = -(double)x0 / (double)z0;
+ vyd = -(double)y0 / (double)z0;
+ vy0 = ((double)my2) * vyd + (double)xx1;
/* correct span */
- span1= zspan->span1+my2;
- span2= zspan->span2+my2;
+ span1 = zspan->span1 + my2;
+ span2 = zspan->span2 + my2;
for (i = 0, y = my2; y >= my0; i++, y--, span1--, span2--) {
- sn1= floor(min_ff(*span1, *span2));
- sn2= floor(max_ff(*span1, *span2));
+ sn1 = floor(min_ff(*span1, *span2));
+ sn2 = floor(max_ff(*span1, *span2));
sn1++;
- if (sn2>=rectx) sn2= rectx-1;
- if (sn1<0) sn1= 0;
+ if (sn2 >= rectx) sn2 = rectx - 1;
+ if (sn1 < 0) sn1 = 0;
u = (((double)sn1 * uxd) + uy0) - (i * uyd);
v = (((double)sn1 * vxd) + vy0) - (i * vyd);
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h
index 7f9b17dbe17..762c25b3f18 100644
--- a/source/blender/windowmanager/WM_toolsystem.h
+++ b/source/blender/windowmanager/WM_toolsystem.h
@@ -54,7 +54,7 @@ struct bToolRef *WM_toolsystem_ref_find(struct WorkSpace *workspace, const bTool
bool WM_toolsystem_ref_ensure(
struct WorkSpace *workspace, const bToolKey *tkey,
struct bToolRef **r_tref);
-struct bToolRef *WM_toolsystem_ref_set_by_name(
+struct bToolRef *WM_toolsystem_ref_set_by_id(
struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey,
const char *name, bool cycle);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 0f799448561..9e18a655903 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -490,6 +490,20 @@ typedef struct wmEvent {
} wmEvent;
+/**
+ * Values below are considered a click, above are considered a drag.
+ */
+#define WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD (U.tweak_threshold * U.dpi_fac)
+
+/**
+ * Values below are ignored when detecting if the user interntionally moved the cursor.
+ * Keep this very small since it's used for selection cycling for eg,
+ * where we want intended adjustments to pass this threshold and select new items.
+ *
+ * Always check for <= this value since it may be zero.
+ */
+#define WM_EVENT_CURSOR_MOTION_THRESHOLD ((float)U.move_threshold * U.dpi_fac)
+
/* ************** custom wmEvent data ************** */
typedef struct wmTabletData {
int Active; /* 0=EVT_TABLET_NONE, 1=EVT_TABLET_STYLUS, 2=EVT_TABLET_ERASER */
@@ -597,8 +611,13 @@ typedef struct wmOperatorType {
/* previous settings - for initializing on re-use */
struct IDProperty *last_properties;
- /* Default rna property to use for generic invoke functions.
- * menus, enum search... etc. Example: Enum 'type' for a Delete menu */
+ /**
+ * Default rna property to use for generic invoke functions.
+ * menus, enum search... etc. Example: Enum 'type' for a Delete menu.
+ *
+ * When assigned a string/number property,
+ * immediately edit the value when used in a popup. see: #UI_BUT_ACTIVATE_ON_INIT.
+ */
PropertyRNA *prop;
/* struct wmOperatorTypeMacro */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index e1eb735f074..42dd5e8f293 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -61,7 +61,6 @@
/* Allow gizmo part's to be single click only,
* dragging falls back to activating their 'drag_part' action. */
#define USE_DRAG_DETECT
-#define DRAG_THRESHOLD (U.tweak_threshold * U.dpi_fac)
/* -------------------------------------------------------------------- */
/** \name wmGizmoGroup
@@ -440,7 +439,7 @@ static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmGizmoMap *gzmap = mtweak->gzmap;
if (mtweak->drag_state == DRAG_DETECT) {
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
- if (len_manhattan_v2v2_int(&event->x, gzmap->gzmap_context.event_xy) >= DRAG_THRESHOLD) {
+ if (len_manhattan_v2v2_int(&event->x, gzmap->gzmap_context.event_xy) >= WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD) {
mtweak->drag_state = DRAG_IDLE;
gz->highlight_part = gz->drag_part;
}
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 194bd2b5449..df9f38824b0 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -39,6 +39,7 @@
#include "GPU_glew.h"
#include "GPU_matrix.h"
#include "GPU_select.h"
+#include "GPU_state.h"
#include "MEM_guardedalloc.h"
@@ -429,29 +430,29 @@ static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBas
}
else {
if (is_depth) {
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
else {
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
}
is_depth_prev = is_depth;
}
/* XXX force AntiAlias Gizmos. */
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_POLYGON_SMOOTH);
+ GPU_line_smooth(true);
+ GPU_polygon_smooth(true);
gz->type->draw(C, gz);
- glDisable(GL_LINE_SMOOTH);
- glDisable(GL_POLYGON_SMOOTH);
+ GPU_line_smooth(false);
+ GPU_polygon_smooth(false);
/* free/remove gizmo link after drawing */
BLI_freelinkN(draw_gizmos, link);
}
if (is_depth_prev) {
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
}
}
@@ -496,10 +497,10 @@ static void gizmo_draw_select_3D_loop(
}
else {
if (is_depth) {
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
else {
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
}
is_depth_prev = is_depth;
}
@@ -518,7 +519,7 @@ static void gizmo_draw_select_3D_loop(
}
if (is_depth_prev) {
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
}
if (is_depth_skip_prev) {
glDepthMask(true);
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index fcfc9c8b0ae..11e803c4b82 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -41,6 +41,7 @@
#include "BKE_idcode.h"
#include "GPU_shader.h"
+#include "GPU_state.h"
#include "IMB_imbuf_types.h"
@@ -388,7 +389,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
}
/* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */
- glEnable(GL_BLEND);
+ GPU_blend(true);
for (drag = wm->drags.first; drag; drag = drag->next) {
const char text_col[] = {255, 255, 255, 255};
int iconsize = UI_DPI_ICON_SIZE;
@@ -466,5 +467,5 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
}
}
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index c2488ed0992..4f299201bdf 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -59,6 +59,7 @@
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_matrix.h"
+#include "GPU_state.h"
#include "GPU_texture.h"
#include "GPU_viewport.h"
@@ -125,44 +126,59 @@ static bool wm_draw_region_stereo_set(Main *bmain, ScrArea *sa, ARegion *ar, eSt
{
/* We could detect better when stereo is actually needed, by inspecting the
* image in the image editor and sequencer. */
- if (ar->regiontype != RGN_TYPE_WINDOW) {
+ if (!ELEM(ar->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_PREVIEW)) {
return false;
}
switch (sa->spacetype) {
case SPACE_IMAGE:
{
- SpaceImage *sima = sa->spacedata.first;
- sima->iuser.multiview_eye = sview;
- return true;
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ SpaceImage *sima = sa->spacedata.first;
+ sima->iuser.multiview_eye = sview;
+ return true;
+ }
+ break;
}
case SPACE_VIEW3D:
{
- View3D *v3d = sa->spacedata.first;
- if (v3d->camera && v3d->camera->type == OB_CAMERA) {
- Camera *cam = v3d->camera->data;
- CameraBGImage *bgpic = cam->bg_images.first;
- v3d->multiview_eye = sview;
- if (bgpic) bgpic->iuser.multiview_eye = sview;
- return true;
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ View3D *v3d = sa->spacedata.first;
+ if (v3d->camera && v3d->camera->type == OB_CAMERA) {
+ Camera *cam = v3d->camera->data;
+ CameraBGImage *bgpic = cam->bg_images.first;
+ v3d->multiview_eye = sview;
+ if (bgpic) {
+ bgpic->iuser.multiview_eye = sview;
+ }
+ return true;
+ }
}
- return false;
+ break;
}
case SPACE_NODE:
{
- SpaceNode *snode = sa->spacedata.first;
- if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) {
- Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
- ima->eye = sview;
- return true;
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ SpaceNode *snode = sa->spacedata.first;
+ if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) {
+ Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima->eye = sview;
+ return true;
+ }
}
- return false;
+ break;
}
case SPACE_SEQ:
{
SpaceSeq *sseq = sa->spacedata.first;
sseq->multiview_eye = sview;
- return true;
+
+ if (ar->regiontype == RGN_TYPE_PREVIEW) {
+ return true;
+ }
+ else if (ar->regiontype == RGN_TYPE_WINDOW) {
+ return (sseq->draw_flag & SEQ_DRAW_BACKDROP) != 0;
+ }
}
}
@@ -448,7 +464,7 @@ void wm_draw_region_blend(ARegion *ar, int view, bool blend)
if (blend) {
/* GL_ONE because regions drawn offscreen have premultiplied alpha. */
- glEnable(GL_BLEND);
+ GPU_blend(true);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
@@ -492,7 +508,7 @@ void wm_draw_region_blend(ARegion *ar, int view, bool blend)
if (blend) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 1ae3f7ffb79..70c2470e764 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2729,8 +2729,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if (wm_action_not_handled(action)) {
if (event->check_drag) {
wmWindow *win = CTX_wm_window(C);
- if ((abs(event->x - win->eventstate->prevclickx)) >= WM_EVENT_CLICK_TWEAK_THRESHOLD ||
- (abs(event->y - win->eventstate->prevclicky)) >= WM_EVENT_CLICK_TWEAK_THRESHOLD)
+ if ((abs(event->x - win->eventstate->prevclickx)) >= WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD ||
+ (abs(event->y - win->eventstate->prevclicky)) >= WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD)
{
int x = event->x;
int y = event->y;
@@ -3365,7 +3365,8 @@ void WM_event_modal_handler_region_replace(wmWindow *win, const ARegion *old_reg
LISTBASE_FOREACH (wmEventHandler *, handler_base, &win->modalhandlers) {
if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
- if (handler->context.region == old_region) {
+ /* 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;
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index acc680014f4..7357a4c3b57 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2299,7 +2299,7 @@ void WM_OT_save_as_mainfile(wmOperatorType *ot)
WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
RNA_def_boolean(ot->srna, "compress", false, "Compress", "Write compressed .blend file");
RNA_def_boolean(ot->srna, "relative_remap", true, "Remap Relative",
- "Remap relative paths when saving in a different directory");
+ "Make paths relative when saving to a different directory");
prop = RNA_def_boolean(ot->srna, "copy", false, "Save Copy",
"Save a copy of the actual working state but does not make saved file active");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -2358,7 +2358,7 @@ void WM_OT_save_mainfile(wmOperatorType *ot)
WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
RNA_def_boolean(ot->srna, "compress", false, "Compress", "Write compressed .blend file");
RNA_def_boolean(ot->srna, "relative_remap", false, "Remap Relative",
- "Remap relative paths when saving in a different directory");
+ "Make paths relative when saving to a different directory");
prop = RNA_def_boolean(ot->srna, "exit", false, "Exit", "Exit Blender after saving");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index c9853776902..013ee029200 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -197,7 +197,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
- glEnable(GL_BLEND);
+ GPU_blend(true);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.05f);
@@ -206,7 +206,7 @@ static void wm_gesture_draw_rect(wmGesture *gt)
immUnbindProgram();
- glDisable(GL_BLEND);
+ GPU_blend(false);
shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -231,7 +231,7 @@ static void wm_gesture_draw_circle(wmGesture *gt)
{
rcti *rect = (rcti *)gt->customdata;
- glEnable(GL_BLEND);
+ GPU_blend(true);
const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -242,7 +242,7 @@ static void wm_gesture_draw_circle(wmGesture *gt)
immUnbindProgram();
- glDisable(GL_BLEND);
+ GPU_blend(false);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
@@ -304,7 +304,7 @@ static void draw_filled_lasso(wmGesture *gt)
draw_filled_lasso_px_cb, &lasso_fill_data);
/* Additive Blending */
- glEnable(GL_BLEND);
+ GPU_blend(true);
glBlendFunc(GL_ONE, GL_ONE);
GLint unpack_alignment;
@@ -324,7 +324,7 @@ static void draw_filled_lasso(wmGesture *gt)
MEM_freeN(pixel_buf);
- glDisable(GL_BLEND);
+ GPU_blend(false);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 946e7c4a856..136d4e00d91 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -165,7 +165,7 @@ void WM_init_state_start_with_console_set(bool value)
* scripts) we deferre the ghost initialization the most as possible
* so that it does not break anything that can run in headless mode (as in
* without display server attached).
- **/
+ */
static bool opengl_is_init = false;
void WM_init_opengl(Main *bmain)
@@ -497,6 +497,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
BKE_tracking_clipboard_free();
BKE_mask_clipboard_free();
BKE_vfont_clipboard_free();
+ BKE_node_clipboard_free();
#ifdef WITH_COMPOSITOR
COM_deinitialize();
@@ -518,7 +519,6 @@ void WM_exit_ext(bContext *C, const bool do_python)
ANIM_fmodifiers_copybuf_free();
ED_gpencil_anim_copybuf_free();
ED_gpencil_strokes_copybuf_free();
- BKE_node_clipboard_clear();
/* free gizmo-maps after freeing blender, so no deleted data get accessed during cleaning up of areas */
wm_gizmomaptypes_free();
diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c
index b387cd0cfa8..1c3e09dac29 100644
--- a/source/blender/windowmanager/intern/wm_keymap_utils.c
+++ b/source/blender/windowmanager/intern/wm_keymap_utils.c
@@ -69,7 +69,7 @@ wmKeyMapItem *WM_keymap_add_panel(wmKeyMap *keymap, const char *idname, int type
/* tool wrapper for WM_keymap_add_item */
wmKeyMapItem *WM_keymap_add_tool(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
{
- wmKeyMapItem *kmi = WM_keymap_add_item(keymap, "WM_OT_tool_set_by_name", type, val, modifier, keymodifier);
+ wmKeyMapItem *kmi = WM_keymap_add_item(keymap, "WM_OT_tool_set_by_id", type, val, modifier, keymodifier);
RNA_string_set(kmi->ptr, "name", idname);
return kmi;
}
@@ -169,7 +169,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
if (STRPREFIX(opname, "WM_OT") ||
STRPREFIX(opname, "ED_OT_undo"))
{
- if (STREQ(opname, "WM_OT_tool_set_by_name")) {
+ if (STREQ(opname, "WM_OT_tool_set_by_id")) {
km = WM_keymap_guess_from_context(C);
}
@@ -252,12 +252,14 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
}
else if (STRPREFIX(opname, "SCULPT_OT")) {
switch (CTX_data_mode_enum(C)) {
- case OB_MODE_SCULPT:
+ case CTX_MODE_SCULPT:
km = WM_keymap_find_all(C, "Sculpt", 0, 0);
break;
- case OB_MODE_EDIT:
+ case CTX_MODE_EDIT_MESH:
km = WM_keymap_find_all(C, "UV Sculpt", 0, 0);
break;
+ default:
+ break;
}
}
else if (STRPREFIX(opname, "MBALL_OT")) {
@@ -284,15 +286,20 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
else if (STRPREFIX(opname, "PAINT_OT")) {
/* check for relevant mode */
switch (CTX_data_mode_enum(C)) {
- case OB_MODE_WEIGHT_PAINT:
+ case CTX_MODE_PAINT_WEIGHT:
km = WM_keymap_find_all(C, "Weight Paint", 0, 0);
break;
- case OB_MODE_VERTEX_PAINT:
+ case CTX_MODE_PAINT_VERTEX:
km = WM_keymap_find_all(C, "Vertex Paint", 0, 0);
break;
- case OB_MODE_TEXTURE_PAINT:
+ case CTX_MODE_PAINT_TEXTURE:
km = WM_keymap_find_all(C, "Image Paint", 0, 0);
break;
+ case CTX_MODE_SCULPT:
+ km = WM_keymap_find_all(C, "Sculpt", 0, 0);
+ break;
+ default:
+ break;
}
}
/* Image Editor */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index a6e0c86b5fd..6e5f83eba47 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -85,6 +85,7 @@
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
+#include "GPU_state.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -789,7 +790,9 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg)
/* fake button, it holds space for search items */
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), width, height, NULL, 0, 0, 0, 0, NULL);
- UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
+ /* Move it downwards, mouse over button. */
+ UI_block_bounds_set_popup(block, 6, (const int[2]){0, -UI_UNIT_Y});
+
UI_but_focus_on_enter_event(win, but);
return block;
@@ -1062,7 +1065,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
}
- UI_block_bounds_set_popup(block, 4, 0, 0);
+ UI_block_bounds_set_popup(block, 4, NULL);
return block;
}
@@ -1146,11 +1149,14 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData)
col_block = uiLayoutGetBlock(col);
/* Create OK button, the callback of which will execute op */
btn = uiDefBut(col_block, UI_BTYPE_BUT, 0, IFACE_("OK"), 0, -30, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ UI_but_flag_enable(btn, UI_BUT_ACTIVE_DEFAULT);
UI_but_func_set(btn, dialog_exec_cb, data, col_block);
}
/* center around the mouse */
- UI_block_bounds_set_popup(block, 4, data->width / -2, data->height / 2);
+ UI_block_bounds_set_popup(block, 4, (const int[2]){data->width / -2, data->height / 2});
+
+ UI_block_active_only_flagged_buttons(C, ar, block);
return block;
}
@@ -1175,7 +1181,9 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData)
UI_block_func_set(block, NULL, NULL, NULL);
- UI_block_bounds_set_popup(block, 4, 0, 0);
+ UI_block_bounds_set_popup(block, 4, NULL);
+
+ UI_block_active_only_flagged_buttons(C, ar, block);
return block;
}
@@ -1419,11 +1427,11 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
#ifndef WITH_HEADLESS
if (U.dpi_fac > 1.0) {
- ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_2x_png,
+ ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_splash_2x_png,
datatoc_splash_2x_png_size, IB_rect, NULL, "<splash screen>");
}
else {
- ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_png,
+ ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_splash_png,
datatoc_splash_png_size, IB_rect, NULL, "<splash screen>");
}
@@ -1581,8 +1589,6 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *userdata)
{
const struct SearchPopupInit_Data *init_data = userdata;
static char search[256] = "";
- wmEvent event;
- wmWindow *win = CTX_wm_window(C);
uiBlock *block;
uiBut *but;
@@ -1592,19 +1598,14 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *userdata)
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, init_data->size[0], UI_UNIT_Y, 0, 0, "");
UI_but_func_operator_search(but);
+ UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
/* fake button, it holds space for search items */
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - init_data->size[1],
init_data->size[0], init_data->size[1], NULL, 0, 0, 0, 0, NULL);
- UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
-
- wm_event_init_from_window(win, &event);
- event.type = EVT_BUT_OPEN;
- event.val = KM_PRESS;
- event.customdata = but;
- event.customdatafree = false;
- wm_event_add(win, &event);
+ /* Move it downwards, mouse over button. */
+ UI_block_bounds_set_popup(block, 6, (const int[2]){0, -UI_UNIT_Y});
return block;
}
@@ -2059,11 +2060,6 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
GLint swizzleMask[] = {GL_ZERO, GL_ZERO, GL_ZERO, GL_RED};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
- immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_MASK_UNIFORM_COLOR);
-
- immUniformColor3fvAlpha(col, alpha);
- immUniform1i("image", 0);
-
/* set up rotation if available */
if (rc->rot_prop) {
rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop);
@@ -2071,6 +2067,11 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
GPU_matrix_rotate_2d(RAD2DEGF(rot));
}
+ immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_MASK_UNIFORM_COLOR);
+
+ immUniformColor3fvAlpha(col, alpha);
+ immUniform1i("image", 0);
+
/* draw textured quad */
immBegin(GPU_PRIM_TRI_FAN, 4);
@@ -2159,8 +2160,8 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
y = rc->initial_mouse[1];
GPU_matrix_translate_2f((float)x, (float)y);
- glEnable(GL_BLEND);
- glEnable(GL_LINE_SMOOTH);
+ GPU_blend(true);
+ GPU_line_smooth(true);
/* apply zoom if available */
if (rc->zoom_prop) {
@@ -2220,8 +2221,8 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
BLF_disable(fontid, BLF_SHADOW);
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
+ GPU_blend(false);
+ GPU_line_smooth(false);
}
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index a8d75ac8fdb..0a1ec29c01c 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -57,11 +57,12 @@
#include "BIF_glutil.h"
+#include "GPU_context.h"
#include "GPU_matrix.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
-#include "GPU_context.h"
#include "GPU_init_exit.h"
+#include "GPU_state.h"
#include "DNA_scene_types.h"
#include "ED_datafiles.h" /* for fonts */
@@ -228,7 +229,7 @@ static void playanim_event_qual_update(void)
typedef struct PlayAnimPict {
struct PlayAnimPict *next, *prev;
- char *mem;
+ uchar *mem;
int size;
const char *name;
struct ImBuf *ibuf;
@@ -311,7 +312,7 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
/* checkerboard for case alpha */
if (ibuf->planes == 32) {
- glEnable(GL_BLEND);
+ GPU_blend(true);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
imm_draw_box_checker_2d(offs_x, offs_y, offs_x + span_x, offs_y + span_y);
@@ -329,7 +330,7 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
((ps->draw_flip[1] ? -1.0f : 1.0f)) * (ps->zoom / (float)ps->win_y),
NULL);
- glDisable(GL_BLEND);
+ GPU_blend(false);
pupdate_time();
@@ -380,7 +381,8 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
static void build_pict_list_ex(PlayState *ps, const char *first, int totframes, int fstep, int fontid)
{
- char *mem, filepath[FILE_MAX];
+ char filepath[FILE_MAX];
+ uchar *mem;
// short val;
PlayAnimPict *picture = NULL;
struct ImBuf *ibuf = NULL;
@@ -465,7 +467,7 @@ static void build_pict_list_ex(PlayState *ps, const char *first, int totframes,
picture->IB_flags = IB_rect;
if (fromdisk == false) {
- mem = (char *)MEM_mallocN(size, "build pic list");
+ mem = MEM_mallocN(size, "build pic list");
if (mem == NULL) {
printf("Couldn't get memory\n");
close(file);
@@ -497,7 +499,7 @@ static void build_pict_list_ex(PlayState *ps, const char *first, int totframes,
if (ptottime > 1.0) {
/* OCIO_TODO: support different input color space */
if (picture->mem) {
- ibuf = IMB_ibImageFromMemory((unsigned char *)picture->mem, picture->size,
+ ibuf = IMB_ibImageFromMemory(picture->mem, picture->size,
picture->IB_flags, NULL, picture->name);
}
else {
@@ -1377,7 +1379,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
}
else if (ps.picture->mem) {
/* use correct colorspace here */
- ibuf = IMB_ibImageFromMemory((unsigned char *) ps.picture->mem, ps.picture->size,
+ ibuf = IMB_ibImageFromMemory(ps.picture->mem, ps.picture->size,
ps.picture->IB_flags, NULL, ps.picture->name);
}
else {
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index 1c8bea19952..806bd028295 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -475,7 +475,7 @@ void WM_toolsystem_ref_sync_from_context(
const EnumPropertyItem *item = &items[i];
if (!STREQ(tref_rt->data_block, item->identifier)) {
STRNCPY(tref_rt->data_block, item->identifier);
- STRNCPY(tref->idname, item->name);
+ SNPRINTF(tref->idname, "builtin_brush.%s", item->name);
}
}
}
@@ -488,7 +488,7 @@ void WM_toolsystem_ref_sync_from_context(
const EnumPropertyItem *item = &items[i];
if (!STREQ(tref_rt->data_block, item->identifier)) {
STRNCPY(tref_rt->data_block, item->identifier);
- STRNCPY(tref->idname, item->name);
+ SNPRINTF(tref->idname, "builtin_brush.%s", item->name);
}
}
}
@@ -501,7 +501,7 @@ void WM_toolsystem_ref_sync_from_context(
const EnumPropertyItem *item = &items[i];
if (!STREQ(tref_rt->data_block, item->identifier)) {
STRNCPY(tref_rt->data_block, item->identifier);
- STRNCPY(tref->idname, item->name);
+ SNPRINTF(tref->idname, "builtin_brush.%s", item->name);
}
}
}
@@ -514,7 +514,7 @@ void WM_toolsystem_ref_sync_from_context(
const EnumPropertyItem *item = &items[i];
if (!STREQ(tref_rt->data_block, item->identifier)) {
STRNCPY(tref_rt->data_block, item->identifier);
- STRNCPY(tref->idname, item->name);
+ SNPRINTF(tref->idname, "builtin_brush.%s", item->name);
}
}
}
@@ -532,7 +532,7 @@ void WM_toolsystem_ref_sync_from_context(
const char *identifier = items[i].identifier;
if (!STREQ(tref_rt->data_block, identifier)) {
STRNCPY(tref_rt->data_block, identifier);
- STRNCPY(tref->idname, name);
+ SNPRINTF(tref->idname, "builtin_brush.%s", name);
}
}
}
@@ -728,11 +728,11 @@ static void toolsystem_refresh_screen_from_active_tool(
}
}
-bToolRef *WM_toolsystem_ref_set_by_name(
+bToolRef *WM_toolsystem_ref_set_by_id(
bContext *C, WorkSpace *workspace, const bToolKey *tkey,
const char *name, bool cycle)
{
- wmOperatorType *ot = WM_operatortype_find("WM_OT_tool_set_by_name", false);
+ wmOperatorType *ot = WM_operatortype_find("WM_OT_tool_set_by_id", false);
/* On startup, Python operatores are not yet loaded. */
if (ot == NULL) {
return NULL;
@@ -775,7 +775,7 @@ static void toolsystem_reinit_with_toolref(
.space_type = tref->space_type,
.mode = tref->mode,
};
- WM_toolsystem_ref_set_by_name(C, workspace, &tkey, tref->idname, false);
+ WM_toolsystem_ref_set_by_id(C, workspace, &tkey, tref->idname, false);
}
static const char *toolsystem_default_tool(const bToolKey *tkey)
@@ -790,31 +790,31 @@ static const char *toolsystem_default_tool(const bToolKey *tkey)
case CTX_MODE_WEIGHT_GPENCIL:
case CTX_MODE_PAINT_TEXTURE:
case CTX_MODE_PAINT_GPENCIL:
- return "Draw";
+ return "builtin_brush.Draw";
case CTX_MODE_SCULPT_GPENCIL:
- return "Push";
+ return "builtin_brush.Push";
/* end temporary hack. */
case CTX_MODE_PARTICLE:
- return "Comb";
+ return "builtin_brush.Comb";
case CTX_MODE_EDIT_TEXT:
- return "Cursor";
+ return "builtin.cursor";
}
break;
case SPACE_IMAGE:
switch (tkey->mode) {
case SI_MODE_PAINT:
- return "Draw";
+ return "builtin_brush.draw";
}
break;
case SPACE_NODE:
{
/* 'Select Box' interferes with cut-links which is handy. */
- return "Select";
+ return "builtin.select";
}
}
- return "Select Box";
+ return "builtin.select_box";
}
/**
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 89b7e53a93a..a4c953fd958 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -65,6 +65,7 @@
#include "wm_event_system.h"
#include "ED_anim_api.h"
+#include "ED_render.h"
#include "ED_scene.h"
#include "ED_screen.h"
#include "ED_fileselect.h"
@@ -432,6 +433,7 @@ static uiBlock *block_create_confirm_quit(struct bContext *C, struct ARegion *ar
block, UI_BTYPE_BUT, 0, ICON_FILE_TICK, IFACE_("Save & Quit"), 0, 0, 50, UI_UNIT_Y,
NULL, 0, 0, 0, 0, TIP_("Save and quit"));
UI_but_func_set(but, wm_block_confirm_quit_save, block, NULL);
+ UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT);
UI_block_bounds_set_centered(block, 10);
@@ -2210,16 +2212,17 @@ ViewLayer *WM_window_get_active_view_layer(const wmWindow *win)
void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
{
BLI_assert(BKE_view_layer_find(WM_window_get_active_scene(win), view_layer->name) != NULL);
+ Main *bmain = G_MAIN;
- wmWindowManager *wm = G_MAIN->wm.first;
+ wmWindowManager *wm = bmain->wm.first;
wmWindow *win_parent = (win->parent) ? win->parent : win;
- /* Set view layer in parent and child windows. */
- STRNCPY(win_parent->view_layer_name, view_layer->name);
-
- for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) {
- if (win_child->parent == win_parent) {
- STRNCPY(win_child->view_layer_name, view_layer->name);
+ /* Set view layer in parent and child windows. */
+ for (wmWindow *win_iter = wm->windows.first; win_iter; win_iter = win_iter->next) {
+ if ((win_iter == win_parent) || (win_iter->parent == win_parent)) {
+ STRNCPY(win_iter->view_layer_name, view_layer->name);
+ bScreen *screen = BKE_workspace_active_screen_get(win_iter->workspace_hook);
+ ED_render_view_layer_changed(bmain, screen);
}
}
}